StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doFlowEvents.C
1 //
3 // $Id: doFlowEvents.C,v 1.3 2006/08/15 21:42:07 jeromel Exp $
4 //
5 // Description:
6 // Chain to read events from files into StFlowEvent and analyze.
7 // what it does: reads dst.root or pico files to fill StFlowEvent
8 //
9 // Environment:
10 // Software developed for the STAR Detector at Brookhaven National Laboratory
11 //
12 // Ways to run:
13 // If you specify a path, all DST files below that path will be
14 // found, and 'nevents' events will be analyzed.
15 // The type of DST files searched for is taken from the 'file' parameter.
16 // If 'file' ends in '.dst.root', ROOT DSTs are searched for.
17 // If 'file' ends in '.event.root' a StEvent file is used.
18 // If 'file' ends in 'flowpicoevent.root' a StFlowPicoEvent file is used.
19 //
20 // inputs:
21 // nevents = # events to process
22 // path = a. directory you want files from
23 // b. "-" to get just the one file you want
24 // file = a. file names in directory (takes all files)
25 // b. the 1 particular full file name (with directory) you want
26 // qaflag = "off" - doesn't do anything now
27 // wrStEOut = flag to turn on=1, off=0 writing of output test.event.root
28 // file --- set to off by default
29 //
30 // Usage:
31 // doFlowEvents.C(nevents, "-", "some_directory/some_dst_file.root")
32 // doFlowEvents.C(nevents, "some_directory", "*.dst.root/*.event.root")
33 // doFlowEvents.C(nevents)
34 // doFlowEvents.C() // 2 events
35 //
36 // A parameter, RunType, may be passed from the calling LSF shell script
37 // (see pdsf:: ~posk/doFlowEvents.csh):
38 // root4star -b << eof >& $LOG
39 // Int_t RunType = $runNo ;
40 // .L $doFile
41 // doFlowEvents.C
42 // .q
43 //eof
44 //
45 // Author List: Torre Wenaus, BNL 2/99
46 // Victor Perevoztchikov
47 // Art Poskanzer
48 //
50 gROOT->Reset();
51 
52 
53 
54 class StChain;
55 StChain *chain = 0;
56 TBrowser *b = 0;
57 Int_t RunType;
58 
59 const char *dstFile = 0;
60 const char *fileList[] = {dstFile, 0};
61 
62 void doFlowEvents(Int_t, const Char_t **, const char *qaflag = "",
63  const Int_t wrStEOut = 0);
64 void doFlowEvents(Int_t, const Char_t *, const Char_t *,
65  const char *qaflag = "off", const Int_t wrStEOut = 0);
66 void doFlowEvents(Int_t nevents = 2);
67 
68 
69 // ------------------ Here is the actual method ----------------------------------
70 void doFlowEvents(Int_t nevents, const Char_t **fileList, const char *qaflag,
71  const Int_t wrStEOut)
72 {
73  cout << endl << endl <<" doFlowEvents - input # events = " << nevents << endl;
74  Int_t ilist = 0;
75  while (fileList[ilist]){
76  cout << " doFlowEvents - input fileList = " << fileList[ilist] << endl;
77  ilist++;
78  }
79  cout << " doFlowEvents - input qaflag = " << qaflag << endl;
80  cout << " doFlowEvents - input wrStEOut = " << wrStEOut << endl << endl << endl;
81 
82  //
83  // First load some shared libraries we need
84  // (Do it in this order)
85  //
86  gSystem->Load("St_base");
87  gSystem->Load("StChain");
88 
89  gSystem->Load("libgen_Tables");
90  gSystem->Load("libsim_Tables");
91  gSystem->Load("libglobal_Tables");
92 
93  gSystem->Load("StUtilities");
94  gSystem->Load("StIOMaker");
95  gSystem->Load("StTreeMaker");
96  gSystem->Load("StarClassLibrary");
97  gSystem->Load("StEvent");
98  gSystem->Load("StEventUtilities");
99  gSystem->Load("StMagF");
100 
101  gSystem->Load("StFlowMaker");
102  gSystem->Load("PIDFitter");
103 
104  gSystem->Load("StStrangeMuDstMaker");
105  gSystem->Load("StMuDSTMaker");
106 
107  // Make a chain with a file list
108  chain = new StChain("StChain");
109  //chain->SetDebug();
110 
111  StFileI *setFiles = 0;
112  if (fileList) { //Normal case
113  setFiles = new StFile(fileList);
114  } else { //Grand Challenge
115  gSystem->Load("StChallenger");
116  setFiles = StChallenger::Challenge();
117  setFiles->SetDebug();
118  const char *Argv[]= {
119  "-s","dst runco", // list of components needed
120  "-q","n_trk_tpc[0]>1000 && n_trk_tpc[1]>1000", // example of user query
121  "-c","/afs/rhic.bnl.gov/star/incoming/GCA/daq/stacs.rc" // GC servers for daq
122  };
123  Int_t Argc=sizeof(Argv)/4;
124  setFiles->Init(Argc,Argv);
125  }
126 
127  //
128  // Make Selection objects and instantiate FlowMaker
129  //
130  char makerName[30];
131  //StFlowSelection flowSelect;
132  // particles: pi+, pi-, pi, k+, k-, e-, e+, pbar, proton, d and dbar
133  //flowSelect->SetPidPart("pi"); // for parts. wrt plane
134  //flowSelect->SetPtPart(0.1, 1.); // for parts. wrt plane
135  //flowSelect->SetPPart(0.15, 5.); // for parts. wrt plane
136  //flowSelect->SetEtaPart(0., 0.); // for parts. wrt plane
137  //flowSelect->SetFitPtsPart(20, 50); // for parts. wrt plane
138  //flowSelect->SetFitOverMaxPtsPart(0.52, 1.); // for parts. wrt plane
139  //flowSelect->SetChiSqPart(0.1, 1.3); // for parts. wrt plane
140  //flowSelect->SetDcaPart(0., 0.8); // for parts. wrt plane
141  //flowSelect->SetDcaGlobalPart(0., 0.8); // for parts. wrt plane
142  //flowSelect->SetYPart(-0.5, 0.5); // for parts. wrt plane
143 
144  // uncomment next line if you make a selection object
145  //sprintf(makerName, "Flow");
146 
147  if (strstr(fileList[0], ".dst.root")) {
148  // Read raw events and make StEvent
149  //cout << "dst file" << endl;
150  gSystem->Load("StEventMaker");
151  TString mainBranch;
152  if (fileList && fileList[0] && strstr(fileList[0],".root")) {
153  mainBranch = fileList[0];
154  mainBranch.ReplaceAll(".root","");
155  int idot = strrchr((char*)mainBranch,'.') - mainBranch.Data();
156  mainBranch.Replace(0,idot+1,"");
157  mainBranch+="Branch";
158  }
159  StIOMaker *IOMk = new StIOMaker("IO", "r", setFiles, "bfcTree");
160  IOMk->SetIOMode("r");
161  IOMk->SetBranch("*", 0, "0"); //deactivate all branches
162  if (!mainBranch.IsNull()) IOMk->SetBranch(mainBranch,0,"r");
163  //IOMk->SetBranch("dstBranch", 0, "r");
164  //IOMk->SetBranch("runcoBranch", 0, "r");
165  //IOMk->SetDebug();
166  StEventMaker *readerMaker = new StEventMaker("events", "title");
167  if (makerName[0]=='\0') { StFlowMaker* flowMaker = new StFlowMaker();
168  } else {
169  StFlowMaker* flowMaker = new StFlowMaker(makerName, flowSelect);
170  }
171  if (wrStEOut) {
172  // Write out StEvent
173  cout << "doFlowEvents - will write out .event.root file" << endl << endl;
174  StTreeMaker *outMk = new StTreeMaker("EvOut", "", "bfcTree");
175  outMk->SetIOMode("w");
176  outMk->SetBranch("eventBranch", "test.event.root", "w");
177  outMk->IntoBranch("eventBranch", "StEvent");
178  }
179 
180  } else if (strstr(fileList[0], "picoevent.root")) {
181  //Read pico-DST
182  //cout << "pico file" << endl;
183  if (makerName[0]=='\0') { StFlowMaker* flowMaker = new StFlowMaker();
184  } else {
185  StFlowMaker* flowMaker = new StFlowMaker(makerName, flowSelect);
186  }
187  flowMaker->PicoEventRead(kTRUE);
188  flowMaker->SetPicoEventFileName(setFiles);
189 
190  } else if (strstr(fileList[0], "MuDst.root")) {
191  //Read mu-DST
192  //cout << "##### doFlowEvents: MuDST file" << endl;
193  if (makerName[0]=='\0') {
194  StFlowMaker* flowMaker = new StFlowMaker();
195  } else {
196  StFlowMaker* flowMaker = new StFlowMaker(makerName, flowSelect);
197  }
198  flowMaker->MuEventRead(kTRUE);
199  flowMaker->SetMuEventFileName(setFiles);
200 
201 
202  } else if (strstr(fileList[0], ".event.root")) {
203  // Read StEvent files
204  //cout << "StEvent file" << endl;
205  StIOMaker *IOMk = new StIOMaker("IO", "r", setFiles, "bfcTree");
206  IOMk->SetIOMode("r");
207  IOMk->SetBranch("*", 0, "0"); //deactivate all branches
208  IOMk->SetBranch("eventBranch", 0, "r");
209  //IOMk->SetBranch("runcoBranch", 0, "r");
210  //IOMk->SetDebug();
211  if (makerName[0]=='\0') { StFlowMaker* flowMaker = new StFlowMaker();
212  } else {
213  StFlowMaker* flowMaker = new StFlowMaker(makerName, flowSelect);
214  }
215 
216  } else {
217  cout << " doFlowEvents - unknown file name = " << fileList[0] << endl;
218  }
219 
221  // Flow Makers
222  // Use of the TagMaker is optional.
223  // The AnalysisMaker may be used with a selection object.
224 
225  //StFlowTagMaker* flowTagMaker = new StFlowTagMaker();
226 
227 
228 
229  if (makerName[0]=='\0') {
230  StPidAmpMaker* pidAmpMaker = new StPidAmpMaker();
231  } else {
232  sprintf(makerName, "PidAmp");
233  StPidAmpMaker* pidAmpMaker = new StPidAmpMaker(makerName, flowSelect);
234  }
235 
236  pidAmpMaker->SetMultBinNumber(0);
237 
238 
239 
240  //
241  // Initialize chain
242  //
243  Int_t iInit = chain->Init();
244  if (iInit) chain->Fatal(iInit, "on init");
245  chain->PrintInfo();
246  if (iInit) goto END;
247 
248  //
249  // Set the parameters
250  //
251 
252  // Get centrality from RunType
253 
254  /*
255  if (RunType) {
256  Int_t centrality = RunType % 10 ;
257  StFlowCutEvent::SetCent(centrality, centrality);
258  }
259  */
260 
261  // Set the event cuts // 1-26% <=>1-4, 26%-10% <=> 5-6, >10% <=> 7-8
262  // StFlowCutEvent::SetCent(5, 6);
263 
264  //for year 2, I changed the StFlowCutEvent so that it cuts on Nch instead of OrigMult.
265  //year 2 data, 1-26% <=> 10<Nch<250, 26%-10% <=> 250<Nch<409, >10% <=> Nch>409
266 
267  StFlowCutEvent::SetMult(10, 250);
268 
269 
270 
271 
272 
273 
274 // StFlowCutEvent::SetVertexX(0., 0.);
275 // StFlowCutEvent::SetVertexY(0., 0.);
276 // StFlowCutEvent::SetVertexZ(0., 0.);
277 // StFlowCutEvent::SetEtaSym(0., 0.);
278 
279  // Set the track cuts
280  StFlowCutTrack::SetFitPtsTpc(0, 0);
281  StFlowCutTrack::SetFitPtsFtpc(0, 0);
282  StFlowCutTrack::SetFitOverMaxPts(0., 0.);
283  StFlowCutTrack::SetChiSqTpc(0., 0.);
284 // StFlowCutTrack::SetChiSqFtpc(0., 0.);
285 // StFlowCutTrack::SetDcaTpc(0., 0.);
286 // StFlowCutTrack::SetDcaFtpc(0., 0.);
287 // StFlowCutTrack::SetPtTpc(0., 0.);
288 // StFlowCutTrack::SetPtFtpc(0., 0.);
289 // StFlowCutTrack::SetEtaTpc(0., 0.);
290 // StFlowCutTrack::SetEtaFtpc(0., 0., 0., 0.);
291 
292 
293  // Set the event plane selections
294  //StFlowEvent::SetEtaTpcCut(0.05, 1., 0, 0); // harmonic 1, selection 1
295  //StFlowEvent::SetEtaTpcCut(0.05, 1., 1, 0); // harmonic 2, selection 1
296  //StFlowEvent::SetEtaTpcCut(0.05, 1., 2, 0); // harmonic 3, selection 1
297  //StFlowEvent::SetEtaTpcCut(0.05, 1., 1, 1); // harmonic 2, selection 2
298  //StFlowEvent::SetEtaFtpcCut(0.05, 1., 1, 1); // harmonic 2, selection 2
299  //StFlowEvent::SetPtTpcCut(0.0, 1., 1, 1); // harmonic 2, selection 2
300  //StFlowEvent::SetPtFtpcCut(0.0, 1., 1, 1); // harmonic 2, selection 2
301 
302  //StFlowEvent::SetDcaGlobalCut(0., 1.); // for event plane
303 
304  // particles: pi+, pi-, pi, k+, k-, e-, e+, pbar, proton, d and dbar
305  //StFlowEvent::SetPid("pi"); // for event plane
306 
307  // Make Eta subevents
308 // StFlowEvent::SetEtaSubs();
309 
310  // Use a Pt weight in the event plane calcualtion
311  // StFlowEvent::SetPtWgt(kTRUE);
312 
313  // Use Aihong's probability PID method
314  // StFlowEvent::SetProbPid();
315 
316  // Set the PID deviant windows
317 // StFlowEvent::SetPiPlusCut(-3., 3.);
318 // StFlowEvent::SetPiMinusCut(-3., 3.);
319 // StFlowEvent::SetProtonCut(-3., 3.);
320 // StFlowEvent::SetAntiProtonCut(-3., 3.);
321 // StFlowEvent::SetKPlusCut(-3., 3.);
322 // StFlowEvent::SetKMinusCut(-3., 3.);
323 // StFlowEvent::SetDeuteronCut(-3., 3.);
324 // StFlowEvent::SetAntiDeuteronCut(-3., 3.);
325 // StFlowEvent::SetElectronCut(-3., 3.);
326 // StFlowEvent::SetPositronCut(-3., 3.);
327 
328  TTable *tabl=0;
329  TDataSet *obj=0;
330  TDataSet *ddb=0;
331  TDataSet *ddstBranch=0;
332 
333  //
334  // Event loop
335  //
336  int istat = 0, i = 1;
337  EventLoop: if (i <= nevents && istat != 2) {
338 
339  cout << endl << "============================ Event " << i
340  << " start ============================" << endl;
341 
342  chain->Clear();
343  istat = chain->Make(i);
344  if (istat == 2)
345  {cout << "Last event processed. Status = " << istat << endl;}
346  if (istat == 3)
347  {cout << "Error event processed. Status = " << istat << endl;}
348 
349 // if (!istat) {
350 // ddstBranch=chain->GetDataSet("dstBranch");
351 // TDataSetIter dstbranchIter(ddstBranch);
352 // if (ddstBranch) {
353 // cout << endl << " QAInfo: in dstBranch " << endl;
354 // while (ddb=dstbranchIter.Next()) {
355 // cout << " QAInfo: found object: " << ddb->GetName() << endl;
356 // TString dsName = ddb->GetName();
357 // if (ddb->InheritsFrom("TTable")) {
358 // tabl = (TTable *)ddb;
359 // cout << " QAInfo: it's a table with #rows = "
360 // << tabl->GetNRows() << endl;
361 // if (dsName == "BfcStatus") {
362 // // Now print out contents of BfcStatus for QA purposes
363 // TDataSetIter bfcstatiter(ddb);
364 // St_dst_bfc_status *bfcstat =
365 // (St_dst_bfc_status *) bfcstatiter.Find("BfcStatus");
366 // dst_bfc_status_st *bth = bfcstat->GetTable();
367 // // loop over all rows in table BfcStatus:
368 // Int_t ij = 0;
369 // for (ij=0; ij< bfcstat->GetNRows(); ij++)
370 // {
371 // cout << " QAInfo: BfcStatus table -- row " << ij <<
372 // ", Maker: " << bth[ij]->maker_name <<
373 // " has istat = " << bth[ij]->status << endl;
374 // } // for bfcstat
375 // } // if dsName
376 // } // if ddb
377 // } // while obj Next
378 // } // if dstBranch
379 // } // if !istat
380 
381  i++;
382  goto EventLoop;
383  }
384 
385  i--;
386  cout << endl << "============================ Event " << i
387  << " finish ============================" << endl;
388 
389  //
390  // Chain Finish
391  //
392  if (nevents > 1) {
393  chain->Clear();
394  chain->Finish();
395  delete chain;
396  }
397  else {
398  if (!b) {
399  b = new TBrowser;
400  }
401  }
402 
403 END:
404 }
405 
406 // ----------- This concatenates the path and the file name ---------------------
407 void doFlowEvents(const Int_t nevents, const Char_t *path, const Char_t *file, const char *qaflag, const Int_t wrStEOut)
408 {
409  const char *fileListQQ[] = {0,0};
410  if (strncmp(path, "GC", 2) == 0) {
411  fileListQQ = 0;
412  } else if (path[0] == '-') {
413  fileListQQ[0] = file;
414  } else {
415  fileListQQ[0] = gSystem->ConcatFileName(path,file);
416  }
417 
418  doFlowEvents(nevents, fileListQQ, qaflag, wrStEOut);
419 }
420 
421 // ----------- This sets default path and file names ---------------------------
422 void doFlowEvents(const Int_t nevents)
423 {
424  // Commit to cvs with these defaults:
425  const Char_t *filePath="-";
426  const Char_t *fileExt="/afs/rhic.bnl.gov/star/data/samples/gstar.dst.root";
427 
428  // BNL
429  //Char_t* filePath="/star/rcf/scratch/posk/P00hg3";
430  //Char_t* fileExt="*.flowpicoevent.root";
431  //Char_t* fileExt="st_physics_1229055_raw_0013.dst.root.flowpicoevent.root";
432 
433  //Char_t* filePath="../Data/FtpcSim/Markus/";
434  //Char_t* fileExt="*flowpicoevent.root";
435 
436  //Char_t* filePath="./";
437  //Char_t* fileExt="*.event.root";
438 
439  // LBNL
440 // Char_t* filePath="/auto/pdsfdv08/starspec/pDST/P00hm/minbias/";
441 // if (nevents < 250) {
442 // Char_t* fileExt="st_physics_1244014_raw_0001.event.root.flowpicoevent.root";
443 // } else {
444 // Char_t* fileExt="*.flowpicoevent.root";
445 // }
446 
447  doFlowEvents(nevents, filePath, fileExt);
448 }
449 
451 //
452 // $Log: doFlowEvents.C,v $
453 // Revision 1.3 2006/08/15 21:42:07 jeromel
454 // Fix rhic -> rhic.bnl.gov
455 //
456 // Revision 1.2 2002/09/30 20:29:39 aihong
457 // to make it read in MuDst
458 //
459 // Revision 1.1 2002/02/14 21:25:55 aihong
460 // re-install the new version
461 //
462 // Revision 1.32 2001/06/07 20:12:12 posk
463 // Added global dca cut for event plane particles.
464 // Changed SePtWgt() to SetPtWgt(Bool_t).
465 //
466 // Revision 1.31 2001/05/22 19:58:42 posk
467 // Can take centrality from the shell script.
468 // Removed multiple instances feature.
469 //
470 // Revision 1.30 2000/12/12 18:49:18 posk
471 // Moved log comments to the end of the file.
472 //
473 // Revision 1.29 2000/12/08 17:04:36 oldi
474 // Phi weights for both FTPCs included.
475 //
476 // Revision 1.27 2000/11/15 14:41:51 posk
477 // Protected against running Finish() twice.
478 //
479 // Revision 1.26 2000/11/13 01:32:35 snelling
480 // load StEventUtilities
481 //
482 // Revision 1.25 2000/11/09 17:39:14 snelling
483 // Added switch for probability pid
484 //
485 // Revision 1.24 2000/09/16 22:21:15 snelling
486 // Added lines to set selection on P and global DCA
487 //
488 // Revision 1.23 2000/09/15 22:54:44 posk
489 // Added Pt weighting for event plane calculation.
490 //
491 // Revision 1.22 2000/09/15 01:22:27 snelling
492 // Added the new selection options to the macro
493 //
494 // Revision 1.21 2000/09/05 16:29:43 snelling
495 // Added cuts for new particles
496 //
497 // Revision 1.18 2000/08/28 16:15:50 snelling
498 // Added Pt and Eta cuts to macro
499 //
500 // Revision 1.17 2000/08/26 21:39:51 snelling
501 // Modified IO for multiple pico events
502 //
503 // Revision 1.15 2000/06/30 14:57:34 posk
504 // Updated to latest doEvents.C .
505 //
506 // Revision 1.11 2000/05/17 16:20:59 kathy
507 // add some print stmts and also run some IOMaker methods in order to get default input files that are softlinks to other files working correctly
508 //
509 // Revision 1.10 2000/05/16 20:57:31 posk
510 // Voloshin's flownanoevent.root added.
511 //
512 // Revision 1.9 2000/05/11 00:22:28 posk
513 // Can read StEvent files which have extention .event.root .
514 //
515 // Revision 1.8 2000/05/09 19:38:22 kathy
516 // update to use standard default input files and only process few events by default - to make it easy to run in automatic macro testing script
517 //
518 // Revision 1.6 2000/04/13 21:46:34 kathy
519 // remove loading of libtpc_Tables since l3Track table is now dst_track type from global
520 //
521 // Revision 1.5 2000/04/12 15:06:53 kathy
522 // changed all macros that read DSTs to load Tables from libraries: gen,sim,global,dst instead of ALL Tables (previously loaded St_Tables); currently, if you are using DEV to read a DST in NEW,PRO, you must comment out the loading of libtpc_Tables because of a mismatch with tpt_track table
523 //
524 // Revision 1.4 2000/03/28 23:26:46 posk
525 // Allow multiple instances of the AnalysisMaker.
526 //
527 // Revision 1.3 2000/03/15 23:33:54 posk
528 // Added StFlowSelection.
529 //
530 // Revision 1.2 2000/03/07 17:51:23 snelling
531 // Added switch for Nano DST
532 //
533 // Revision 1.1 2000/03/02 23:49:11 posk
534 // Version of doEvents.C for flow analysis which can set cut parameters.
535 //
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
Definition: TTable.h:48