StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHbtTagWriterTest.C
1 // example how to access memberfunctions from a correlation function
2 // ((QinvEbyECorrFctn*)((StHbtAnalysis*)((StHbtMaker*) chain->GetMaker("HBT"))->HbtManager()->Analysis(0))->CorrFctn(0))->Ratio()->Draw()
3 
4 // NOTE - chain needs to be declared global so for StHbtEventReader
5 class StChain;
6 StChain *chain=0;
7 
8 // keep pointers to Analysis global, so you can have access to themm ...
9 class StHbtAnalysis;
10 StHbtAnalysis* anal;
11 
12 // File-scope stuff needed by setFiles, nextFile. Someone ambitious
13 // can clean this up by putting it all into a nice clean class.
14 Int_t usePath = 0;
15 Int_t nFile = 0;
16 TString thePath;
17 TString theFileName;
18 TString originalPath;
19 //class StChain;
20 //StChain *chain=0;
21 
22 void wait(int n=1) {
23  for ( int i=0; i<n*1e6; i++) { /*no-op*/ }
24 }
25 void mess(const char* c="alive") {
26  for ( int i=0; i<10; i++) { cout << c << endl; }
27 }
28 
29 
30 void StHbtExampleQQ(const Int_t nevents, const Char_t **fileList, const char*);
31 
32 
33 //==========================================================================================
34 //==========================================================================================
35 void StHbtTagWriterTest(const Int_t nevents=9999, const Char_t *path, const Char_t *file)
36 {
37  const char *fileListQQ[]={0,0};
38  if (path[0]=='-') {
39  fileListQQ[0]=file;
40  } else {
41  fileListQQ[0] = gSystem->ConcatFileName(path,file);
42  }
43  StHbtExampleQQ(nevents,fileListQQ);
44 }
45 //==========================================================================================
46 //==========================================================================================
47 void StHbtExampleQQ(const Int_t nevents, const Char_t **fileList)
48 {
49 
50 // Dynamically link needed shared libs
51 gSystem->Load("St_base");
52 gSystem->Load("StChain");
53 gSystem->Load("St_Tables");
54 gSystem->Load("StMagF");
55 gSystem->Load("StUtilities"); // new addition 22jul99
56 gSystem->Load("StTreeMaker");
57 gSystem->Load("StIOMaker");
58 gSystem->Load("StarClassLibrary");
59 gSystem->Load("StEvent");
60 gSystem->Load("StEventMaker");
61 
62 gSystem->Load("StHbtMaker");
63 //gSystem->Load("StHbtTagMaker");
64 
65 cout << " loading done " << endl;
66 
67 chain = new StChain("StChain");
68 chain->SetDebug();
69 
70 
71 StFile *setFiles= new StFile();
72 for (int ifil=0; fileList[ifil]; ifil++)
73 setFiles->AddFile(fileList[ifil]);
74 
75 
76 // ********************************
77 // Now we add Makers to the chain...
78 // ********************************
79 
80 // *************
81 // file handling
82 // *************
83 StIOMaker* ioMaker = new StIOMaker("IO","r",setFiles,"bfcTree");
84 ioMaker->SetDebug();
85 ioMaker->SetIOMode("r");
86 ioMaker->SetDebug();
87 ioMaker->SetBranch("*",0,"r"); //deactivate all branches
88 // ***********
89 // Event Maker
90 // ***********
91 StEventMaker* eventMaker = new StEventMaker("events","title");
92 cout << "Just instantiated StEventMaker... lets go StHbtMaker!" << endl;
93 // *********
94 // Hbt Maker
95 // *********
96 StHbtMaker* hbtMaker = new StHbtMaker("HBT","title");
97  cout << "StHbtMaker instantiated"<<endl;
98  StHbtTagMaker* hbtTagMaker = new StHbtTagMaker("HBTTAG");
99  hbtTagMaker->SetShowTags(1);
100  cout << "StHbtTagMaker instantiated"<<endl;
101 
102 // -------------- set up of hbt stuff ----- //
103 cout << "StHbtMaker::Init - setting up Reader and Analyses..." << endl;
104 StHbtManager* TheManager = hbtMaker->HbtManager();
105 // ***********************
106 // setup HBT event readers
107 // ***********************
108 // *****************************************
109 // set up StHbtMcEventReader as Event Reader
110 // *****************************************
112 Reader->SetTheEventMaker(eventMaker); // gotta tell the reader where it should read from
113 TheManager->SetEventReader(Reader);
114 cout << "READER SET UP.... " << endl;
115 
116 // define example particle cut and cut monitors to use in the analyses
117 // example particle cut
118  franksTrackCut* aTrackCut = new franksTrackCut; // use "frank's" particle cut object
119  aTrackCut->SetNSigmaPion(-3.0,3.0); // number of Sigma in TPC dEdx away from nominal pion dEdx
120  aTrackCut->SetNSigmaKaon(-1000.,1000.); // number of Sigma in TPC dEdx away from nominal kaon dEdx
121  aTrackCut->SetNSigmaProton(-1000.,1000.0); // number of Sigma in TPC dEdx away from nominal proton dEdx
122  aTrackCut->SetNHits(10,50); // range on number of TPC hits on the track
123  aTrackCut->SetP(0.,0.8); // range in P
124  aTrackCut->SetPt(0.,2.); // range in Pt
125  aTrackCut->SetRapidity(-1.5,1.5); // range in rapidity
126  aTrackCut->SetDCA(0.0,2.); // range in Distance of Closest Approach to primary vertex
127  aTrackCut->SetCharge(+1); // want positive kaons
128  aTrackCut->SetMass(0.139); // kaon mass
129 // now, we define the analysis
130 
131  // ********************************************* //
132  // * franks piPlus analysis - by Frank Laue, OSU //
133  // ********************************************* //
134  // 0) now define an analysis...
135  StHbtAnalysis* piPlusAnal = new StHbtAnalysis;
136  // 1) set the Event cuts for the analysis
137  mikesEventCut* evcut = new mikesEventCut; // use "mike's" event cut object
138  evcut->SetEventMult(0,100000); // selected multiplicity range
139  evcut->SetVertZPos(-35.0,35.0); // selected range of vertex z-position
140  piPlusAnal->SetEventCut(evcut); // this is the event cut object for this analsys
141  // 2) set the Track (particle) cuts for the analysis
142  franksTrackCut* piPlusTrkcut = new franksTrackCut( *aTrackCut ); // copy from example
143  piPlusAnal->SetFirstParticleCut(piPlusTrkcut); // this is the track cut for the "first" particle
144  piPlusAnal->SetSecondParticleCut(piPlusTrkcut); // this is the track cut for the "second" particle
145  // 3) set the Pair cuts for the analysis
146  mikesPairCut* pairCut = new mikesPairCut; // use "frank's" pair cut object
147  piPlusAnal->SetPairCut(pairCut); // this is the pair cut for this analysis
148  // 4) set the number of events to mix (per event)
149  piPlusAnal->SetNumEventsToMix(5);
150  // ********************************************************************
151  // 5) now set up the correlation functions that this analysis will make
152  // ********************************************************************
153  // define example Minv correlation function
154  QinvEbyECorrFctn* QinvEbyECF = new QinvEbyECorrFctn("QinvEbyE",20,0.,.2);
155  QinvEbyECF->SetTagMeans("positivePionsMeans");
156  QinvEbyECF->SetTagSigmas("positivePionsSigmas");
157  piPlusAnal->AddCorrFctn(QinvEbyECF); // adds the just-defined correlation function to the analysis
158  // now add as many more correlation functions to the Analysis as you like..
159  // 6) add the Analysis to the AnalysisCollection
160  TheManager->AddAnalysis(piPlusAnal);
161 
162  // ********************************************* //
163  // * franks piPlus analysis - by Frank Laue, OSU //
164  // ********************************************* //
165  // // 0) now define an analysis...
166  StHbtAnalysis* kaonPlusAnal = new StHbtAnalysis;
167  // 1) set the Event cuts for the analysis
168  mikesEventCut* evcut = new mikesEventCut; // use "mike's" event cut object
169  evcut->SetEventMult(0,100000); // selected multiplicity range
170  evcut->SetVertZPos(-35.0,35.0); // selected range of vertex z-position
171  kaonPlusAnal->SetEventCut(evcut); // this is the event cut object for this analsys
172  // 2) set the Track (particle) cuts for the analysis
173  franksTrackCut* kaonPlusTrkcut = new franksTrackCut( *aTrackCut ); // copy from example
174  kaonPlusTrkcut->SetNSigmaPion(3.0,1000.0); // number of Sigma in TPC dEdx away from nominal pion dEdx
175  kaonPlusTrkcut->SetNSigmaKaon(-3.,3.); // number of Sigma in TPC dEdx away from nominal kaon dEdx
176  kaonPlusTrkcut->SetNSigmaProton(-1000.0,-3.0); // number of Sigma in TPC dEdx away from nominal proton dEdx
177  kaonPlusTrkcut->SetMass(0.494);
178  kaonPlusAnal->SetFirstParticleCut(kaonPlusTrkcut); // this is the track cut for the "first" particle
179  kaonPlusAnal->SetSecondParticleCut(kaonPlusTrkcut); // this is the track cut for the "second" particle
180  // 3) set the Pair cuts for the analysis
181  mikesPairCut* pairCut = new mikesPairCut; // use "frank's" pair cut object
182  kaonPlusAnal->SetPairCut(pairCut); // this is the pair cut for this analysis
183  // 4) set the number of events to mix (per event)
184  kaonPlusAnal->SetNumEventsToMix(5);
185  // ********************************************************************
186  // 5) now set up the correlation functions that this analysis will make
187  // ********************************************************************
188  // define example Minv correlation function
189  QinvEbyECorrFctn* QinvEbyECFKaons = new QinvEbyECorrFctn("QinvEbyEKaons",20,0.,.2);
190  QinvEbyECFKaons->SetTagMeans("positiveKaonsMeans");
191  QinvEbyECFKaons->SetTagSigmas("positiveKaonsSigmas");
192  kaonPlusAnal->AddCorrFctn(QinvEbyECFKaons); // adds the just-defined correlation function to the analysis
193  // now add as many more correlation functions to the Analysis as you like..
194  // 6) add the Analysis to the AnalysisCollection
195  TheManager->AddAnalysis(kaonPlusAnal);
196 
197 
198 
199  // ------------------ end of setting up hbt stuff ------------------ //
200 
201  chain->Init(); // This should call the Init() method in ALL makers
202  chain->PrintInfo();
203 
204  // exit();
205  for (Int_t iev=0;iev<nevents; iev++) {
206  cout << "StHbtExample -- Working on eventNumber " << iev << endl;
207  chain->Clear();
208  int iret = chain->Make(iev); // This should call the Make() method in ALL makers
209  if (iret) {
210  cout << "Bad return code!" << endl;
211  break;
212  }
213  } // Event Loop
214  chain->Finish(); // This should call the Finish() method in ALL makers
215 
216 }
217 
218 
219 
Definition: StTree.h:125
virtual void SetIOMode(Option_t *iomode="w")
number of transactions
Definition: StIOInterFace.h:35
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
virtual Int_t Finish()
Definition: StChain.cxx:85
virtual Int_t Make()
Definition: StChain.cxx:110