StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StJetMaker.cxx
1 // $Id: StJetMaker.cxx,v 1.75 2010/06/05 03:13:13 pibero Exp $
2 
3 // ROOT
4 #include "TTree.h"
5 
6 // STAR
7 #include "StJetFinder/StProtoJet.h"
8 #include "StSpinPool/StJets/StJets.h"
9 #include "StSpinPool/StJetEvent/StJetEvent.h"
10 
11 // Local
12 #include "StjeParticleCollector.h"
13 #include "StjeJetFinderRunner.h"
14 #include "StjeJetCuts.h"
15 #include "StjeTreeWriter.h"
16 #include "StjeDefaultJetTreeWriter.h"
17 #include "StppJetAnalyzer.h"
18 #include "StJetMaker.h"
19 
20 ClassImp(StJetMaker);
21 
22 StJetMaker::StJetMaker(const char* name, StMuDstMaker* uDstMaker, const char* outputName)
23  : StMaker(name)
24  , _defaultTreeWriter(new StjeDefaultJetTreeWriter(*uDstMaker, outputName))
25  , _treeWriter(_defaultTreeWriter)
26 {
27 }
28 
29 StJetMaker::~StJetMaker()
30 {
31  delete _defaultTreeWriter;
32 }
33 
34 StJetMaker::StJetBranch::StJetBranch(const StppAnaPars* anapars, StJetPars* jetpars, StFourPMaker* fourPMaker, const char* name)
35  : name(name)
36  , particleCollector(new StjeParticleCollector(anapars,fourPMaker,this->particles))
37  , jetFinder(new StjeJetFinderRunner(jetpars,this->particles,this->protojets))
38  , jetCuts(new StjeJetCuts(anapars,this->protojets))
39 {
40 }
41 
42 void StJetMaker::addAnalyzer(const StppAnaPars* anapars, StJetPars* jetpars, StFourPMaker* fourPMaker, const char* name)
43 {
44  StJetBranch* jetBranch = new StJetBranch(anapars,jetpars,fourPMaker,name);
45  mJetBranches.push_back(jetBranch);
46  _treeWriter->addJetFinder(fourPMaker,&jetBranch->particles,&jetBranch->protojets,name,new StJets);
47 }
48 
49 void StJetMaker::SetTreeWriter(StjeTreeWriter* treeWriter)
50 {
51  _treeWriter = treeWriter;
52 }
53 
54 Int_t StJetMaker::Init()
55 {
56  for (size_t iBranch = 0; iBranch < mJetBranches.size(); ++iBranch)
57  mJetBranches[iBranch]->jetFinder->Init();
58 
59  _treeWriter->Init();
60 
61  return kStOk;
62 }
63 
65 {
66  for (size_t iBranch = 0; iBranch < mJetBranches.size(); ++iBranch) {
67  StJetBranch* jetBranch = mJetBranches[iBranch];
68  _treeWriter->fillJetTreeHeader(iBranch);
69  for (size_t iVertex = 0; iVertex < jetBranch->particleCollector->numberOfVertices(); ++iVertex) {
70  jetBranch->particleCollector->Do(iVertex);
71  jetBranch->jetFinder->Run();
72  jetBranch->jetCuts->Apply();
73  _treeWriter->fillJetTree(iBranch,iVertex);
74  }
75  }
76 
77  _treeWriter->jetTree()->Fill();
78 
79  return kStOk;
80 }
81 
83 {
84  _treeWriter->Finish();
85 
86  return kStOK;
87 }
88 
89 TTree* StJetMaker::tree() const
90 {
91  return _treeWriter->jetTree();
92 }
93 
94 StJets* StJetMaker::getStJets(const char* branchName) const
95 {
96  TTree* jetTree = _treeWriter->jetTree();
97  if (jetTree) {
98  TBranch* branch = jetTree->GetBranch(branchName);
99  if (branch) return *(StJets**)branch->GetAddress();
100  }
101  return 0;
102 }
103 
104 StJetEvent* StJetMaker::getStJetEvent(const char* branchName) const
105 {
106  TTree* jetTree = _treeWriter->jetTree();
107  if (jetTree) {
108  TBranch* branch = jetTree->GetBranch(branchName);
109  if (branch) return *(StJetEvent**)branch->GetAddress();
110  }
111  return 0;
112 }
Int_t Finish()
Definition: StJetMaker.cxx:82
Definition: StJets.h:24
Definition: Stypes.h:40
Int_t Make()
Definition: StJetMaker.cxx:64
Definition: Stypes.h:41