StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StHbtExample.C
1 // $Id: StHbtExample.C,v 1.11 2006/08/15 21:43:03 jeromel Exp $
2 // $Log: StHbtExample.C,v $
3 // Revision 1.11 2006/08/15 21:43:03 jeromel
4 // Fix rhic -> rhic.bnl.gov
5 //
6 // Revision 1.10 2005/08/31 15:05:08 fisyak
7 // Add dependence StMagF vs StarMagField
8 //
9 // Revision 1.9 2000/04/13 21:46:22 kathy
10 // remove loading of libtpc_Tables since l3Track table is now dst_track type from global
11 //
12 // Revision 1.8 2000/04/12 17:39:02 kathy
13 // change to only load table libraries needed: lib*_Tables instead of all tables: St_Tables
14 //
15 // Revision 1.7 2000/03/20 17:50:40 kathy
16 // fix all macros so that they set all branches on that are needed - otherwise won't work with soft links
17 //
18 // Revision 1.6 2000/01/19 15:52:46 kathy
19 // change default input file to be the one in /afs/rhic.bnl.gov/star/data/samples
20 //
21 // Revision 1.5 1999/09/24 00:00:34 lisa
22 // HBT example macro updated to use TrackCuts not ParticleCuts
23 //
24 // Revision 1.4 1999/07/27 21:09:18 lisa
25 // do event loop with goto because Cint pukes on for loop
26 //
27 // Revision 1.3 1999/07/13 02:31:39 lisa
28 // Update StHbtExample macro for new StHbtMaker
29 //
30 // Revision 1.2 1999/07/13 01:13:02 kathy
31 // moved rch.C to obsolete, put in id,log,owner into HbtExample, removed loading of StRootEvent and changed default input file in bfcread.C and Example_readdst_qa_tables.C
32 //
33 
34 //======================================================================
35 // owner: Mike Lisa
36 // what it does:
37 // runs the StHbt framework. Runs two simultaneous correlation
38 // analyses. The first one is pi-pi HBT, building two simultaneous
39 // correlation functions. The second in K+K-, building an invariant
40 // mass spectrum with background subtraction
41 //=======================================================================
42 
43 class StChain;
44 StChain *chain=0;
45 
46 // keep pointers to Correlation Functions global, so you can have access to them...
47 class QinvCorrFctn;
48 QinvCorrFctn* QinvCF;
49 class QvecCorrFctn;
50 QvecCorrFctn* QvecCF;
51 class MinvCorrFctn;
52 MinvCorrFctn* MinvCF;
53 
54 void StHbtExample(Int_t nevents=1,
55  const char *MainFile=
56 "/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root")
57 {
58 
59  // Dynamically link needed shared libs
60  gSystem->Load("St_base");
61  gSystem->Load("StChain");
62  gSystem->Load("libglobal_Tables");
63  gSystem->Load("libsim_Tables");
64  gSystem->Load("libgen_Tables");
65  gSystem->Load("StUtilities"); // new addition 22jul99
66  gSystem->Load("StAnalysisUtilities"); // needed by V0dstMaker
67  gSystem->Load("StarMagField");
68  gSystem->Load("StMagF");
69  gSystem->Load("StIOMaker");
70  gSystem->Load("StarClassLibrary");
71  gSystem->Load("StEvent");
72  gSystem->Load("StEventMaker");
73  gSystem->Load("StHbtMaker");
74  gSystem->Load("StV0MiniDstMaker");
75 
76  cout << "Dynamic loading done" << endl;
77 
78  chain = new StChain("StChain");
79  chain->SetDebug();
80 
81 
82  // Now we add Makers to the chain...
83 
84  StIOMaker* ioMaker = new StIOMaker("IO","r",MainFile,"bfcTree");
85  ioMaker->SetDebug();
86 
87  ioMaker->SetIOMode("r");
88  ioMaker->SetDebug();
89  ioMaker->SetBranch("*",0,"0"); //deactivate all branches
90  ioMaker->SetBranch("dstBranch",0,"r"); //activate EventBranch
91  ioMaker->SetBranch("runcoBranch",0,"r"); //activate runcoBranch
92 
93 
94  StEventMaker* eventMaker = new StEventMaker("events","title");
95  cout << "Just instantiated StEventMaker... lets go StHbtMaker!" << endl;
96 
97  // UNCOMMENT THIS NEXT PART OUT IF YOU WANT V0's
98  //StV0MiniDstMaker* v0dst = new StV0MiniDstMaker("v0dst");
99  //cout << "Just instantiated StV0MiniDstMaker... lets go StHbt!" << endl;
100  //v0dst.SetV0VertexType(); //Set v0MiniDstMaker to find v0s not Xis
101  //v0dst.SetOutputFile("muv0dst.root"); // Set V0MiniDStMaker output file
102 
103 
104 
105  StHbtMaker* hbtMaker = new StHbtMaker("HBT","title");
106  cout << "StHbtMaker instantiated"<<endl;
107 
108 
109 
110  /* -------------- set up of hbt stuff ----- */
111  cout << "StHbtMaker::Init - setting up Reader and Analyses..." << endl;
112 
113  StHbtManager* TheManager = hbtMaker->HbtManager();
114 
115  // here, we instantiate the appropriate StHbtEventReader
116  // for STAR analyses in root4star, we instantiate StStandardHbtEventReader
118  Reader->SetTheEventMaker(eventMaker); // gotta tell the reader where it should read from
119 
120  // UNCOMMENT THIS NEXT LINE OUT IF YOU WANT V0's
121  // Reader->SetTheV0Maker(v0dst); //Gotta tell the reader where to read the v0 stuff from
122 
123  // here would be the palce to plug in any "front-loaded" Event or Particle Cuts...
124  TheManager->SetEventReader(Reader);
125 
126  cout << "READER SET UP.... " << endl;
127 
128  // Hey kids! Let's make a microDST!
129  // in StHbt we do this by instantiating and plugging in a StHbtEventReader as a writer!
130  // the particular StHbtEventReader that we will use will write (and read) ASCII files
131  //
132  // StHbtAsciiReader* Writer = new StHbtAsciiReader;
133  // Writer->SetFileName("FirstMicroDst.asc");
134  // TheManager->SetEventWriter(Writer);
135  // cout << "WRITER SET UP.... " << endl;
136 
137  // 0) now define an analysis...
138  StHbtAnalysis* anal = new StHbtAnalysis;
139  // 1) set the Event cuts for the analysis
140  mikesEventCut* evcut = new mikesEventCut; // use "mike's" event cut object
141  evcut->SetEventMult(0,10000); // selected multiplicity range
142  evcut->SetVertZPos(-35.0,35.0); // selected range of vertex z-position
143  anal->SetEventCut(evcut); // this is the event cut object for this analsys
144  // 2) set the Track (particle) cuts for the analysis
145  mikesTrackCut* trkcut = new mikesTrackCut; // use "mike's" particle cut object
146  trkcut->SetNSigmaPion(-1.5,1.5); // number of Sigma in TPC dEdx away from nominal pion dEdx
147  trkcut->SetNSigmaKaon(-1000.0,1000.0); // number of Sigma in TPC dEdx away from nominal kaon dEdx
148  trkcut->SetNSigmaProton(-1000.0,1000.0); // number of Sigma in TPC dEdx away from nominal proton dEdx
149  trkcut->SetNHits(5,50); // range on number of TPC hits on the track
150  trkcut->SetPt(0.1,1.0); // range in Pt
151  trkcut->SetRapidity(-1.0,1.0); // range in rapidity
152  trkcut->SetDCA(0.0,0.5); // range in Distance of Closest Approach to primary vertex
153  trkcut->SetCharge(-1); // want negative pions
154  trkcut->SetMass(0.139); // pion mass
155  anal->SetFirstParticleCut(trkcut); // this is the track cut for the "first" particle
156  anal->SetSecondParticleCut(trkcut); // NOTE - it is also for the "second" particle -- i.e. identical particle HBT
157  // 3) set the Pair cuts for the analysis
158  mikesPairCut* paircut = new mikesPairCut; // use "mike's" pair cut object
159  anal->SetPairCut(paircut); // this is the pair cut for this analysis
160  // 4) set the number of events to mix (per event)
161  anal->SetNumEventsToMix(5);
162  // 5) now set up the correlation functions that this analysis will make
163  // this particular analysis will have two: the first is a Q-invariant correlation function
164  QinvCF = new QinvCorrFctn("mikesQinvCF",50,0.0,0.2); // defines a Qinv correlation function
165  anal->AddCorrFctn(QinvCF); // adds the just-defined correlation function to the analysis
166  // for this analysis, we will also (simultaneously) build a Q-vector correlation function
167  QvecCF = new QvecCorrFctn("randysQvecCF",50,0.0,0.2);
168  anal->AddCorrFctn(QvecCF); // adds the just-defined correlation function to the analysis
169 
170  // now add as many more correlation functions to the Analysis as you like..
171 
172  // 6) add the Analysis to the AnalysisCollection
173  TheManager->AddAnalysis(anal);
174 
175  // now, we define another analysis that runs simultaneously with the previous one.
176  // this one looks at K+K- correlations (so NONidentical particles) in invariant mass
177 
178  /* ****************************************** */
179  /* * franks phi analysis - by Frank Laue, OSU */
180  /* ****************************************** */
181  // 0) now define an analysis...
182  StHbtAnalysis* phiAnal = new StHbtAnalysis;
183  // 1) set the Event cuts for the analysis
184  mikesEventCut* phiEvcut = new mikesEventCut; // use "mike's" event cut object
185  phiEvcut->SetEventMult(0,10000); // selected multiplicity range
186  phiEvcut->SetVertZPos(-35.0,35.0); // selected range of vertex z-position
187  phiAnal->SetEventCut(phiEvcut); // this is the event cut object for this analsys
188  // 2) set the Track (particle) cuts for the analysis
189  mikesTrackCut* kaonTrkcut = new mikesTrackCut; // use "mike's" particle cut object
190  kaonTrkcut->SetNSigmaPion(3,1000.0); // number of Sigma in TPC dEdx away from nominal pion dEdx
191  kaonTrkcut->SetNSigmaKaon(-3.0,3.0); // number of Sigma in TPC dEdx away from nominal kaon dEdx
192  kaonTrkcut->SetNSigmaProton(-1000.,-1.0); // number of Sigma in TPC dEdx away from nominal proton dEdx
193  kaonTrkcut->SetNHits(0,50); // range on number of TPC hits on the track
194  kaonTrkcut->SetPt(0.1,2.0); // range in Pt
195  kaonTrkcut->SetRapidity(-2.0,2.0); // range in rapidity
196  kaonTrkcut->SetDCA(0.0,0.5); // range in Distance of Closest Approach to primary vertex
197  kaonTrkcut->SetCharge(+1); // want positive kaons
198  kaonTrkcut->SetMass(0.494); // kaon mass
199  phiAnal->SetFirstParticleCut(kaonTrkcut); // this is the track cut for the "first" particle
200  mikesTrackCut* antikaonTrkcut = new mikesTrackCut; // use "mike's" particle cut object
201  antikaonTrkcut->SetNSigmaPion(3.0,1000.0); // number of Sigma in TPC dEdx away from nominal pion dEdx
202  antikaonTrkcut->SetNSigmaKaon(-3.0,3.0); // number of Sigma in TPC dEdx away from nominal kaon dEdx
203  antikaonTrkcut->SetNSigmaProton(-1000.0,-1.0); // number of Sigma in TPC dEdx away from nominal proton dEdx
204  antikaonTrkcut->SetNHits(0,50); // range on number of TPC hits on the track
205  antikaonTrkcut->SetPt(0.1,2.0); // range in Pt
206  antikaonTrkcut->SetRapidity(-2.0,2.0); // range in rapidity
207  antikaonTrkcut->SetDCA(0.0,0.5); // range in Distance of Closest Approach to primary vertex
208  antikaonTrkcut->SetCharge(-1); // want negative kaons
209  antikaonTrkcut->SetMass(0.494); // kaon mass
210  phiAnal->SetSecondParticleCut(antikaonTrkcut); // this is the track cut for the "second" particle
211  // 3) set the Pair cuts for the analysis
212  mikesPairCut* phiPaircut = new mikesPairCut; // use "mike's" pair cut object
213  phiAnal->SetPairCut(phiPaircut); // this is the pair cut for this analysis
214  // 4) set the number of events to mix (per event)
215  phiAnal->SetNumEventsToMix(5);
216  // 5) now set up the correlation functions that this analysis will make
217  MinvCF = new MinvCorrFctn("franksMinvCF",100,0.98,1.18); // defines a Minv correlation function
218  phiAnal->AddCorrFctn(MinvCF); // adds the just-defined correlation function to the analysis
219  // now add as many more correlation functions to the Analysis as you like..
220  // 6) add the Analysis to the AnalysisCollection
221  TheManager->AddAnalysis(phiAnal);
222 
223 
224 
225  /* ------------------ end of setting up hbt stuff ------------------ */
226 
227 
228  // now execute the chain member functions
229 
230  if (chain->Init()){ // This should call the Init() method in ALL makers
231  cout << "Initialization failed \n";
232  goto TheEnd;
233  }
234  chain->PrintInfo();
235 
236 
237  // Event loop
238  int istat=0,iev=1;
239  EventLoop: if (iev <= nevents && !istat) {
240  cout << "StHbtExample -- Working on eventNumber " << iev << " of " << nevents << endl;
241  chain->Clear();
242  istat = chain->Make(iev);
243  if (istat) {cout << "Last event processed. Status = " << istat << endl;}
244  iev++; goto EventLoop;
245  }
246 
247 // good old Cint can't even handle a for-loop
248 // for (Int_t iev=1;iev<=nevents; iev++) {
249 // chain->Clear();
250 // int iret = chain->Make(iev); // This should call the Make() method in ALL makers
251 // if (iret) {
252 // cout << "StHbtExample.C -- chain returned nonzero value " << iret
253 // << " on event " << iev << endl;
254 // break;
255 // }
256 // } // Event Loop
257 
258 
259 
260  cout << "StHbtExample -- Done with event loop" << endl;
261 
262  chain->Finish(); // This should call the Finish() method in ALL makers
263  TheEnd:
264 }
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