StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
runCentralityAnalyzer.C
1 #include <iostream>
2 
3 class StMaker;
4 class StChain;
5 class StPicoDstReader;
6 
7 const Char_t* testInFName = "/star/u/gnigmat/soft/u/centrality_definition/Centrality/input/st_physics_adc_19084053_raw_0000006.picoDst.root";
8 
9 //________________
10 void runCentralityAnalyzer(const Char_t* inFileName = testInFName,
11  const Char_t* oFileName = "oTestAna.root") {
12 
13  std::cout << "Start running centrality analyzer" << std::endl;
14  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
15  loadSharedLibraries();
16  // Load specific libraries
17  gSystem->Load("StPicoEvent");
18  gSystem->Load("StPicoDstMaker");
19  gSystem->Load("StCentralityAnalyzer");
20 
21  // Create new chain
22  StChain *chain = new StChain();
23 
24  StPicoDstReader *reader = new StPicoDstReader(inFileName);
25  reader->Init();
26  reader->SetStatus("*", 0);
27  reader->SetStatus("Event*", 1);
28  reader->SetStatus("Track*", 1);
29  reader->SetStatus("BTofPidTraits*", 1);
30 
31  StCentralityAnalyzer *anaMaker = new StCentralityAnalyzer(reader, oFileName);
32  anaMaker->setUsePileUp(false);
33  anaMaker->setVtxZCut(-35., 25.);
34  anaMaker->addTriggerId(600001);
35  anaMaker->addTriggerId(600011);
36  anaMaker->addTriggerId(600021);
37  anaMaker->addTriggerId(600031);
38  anaMaker->setRunIdParameters(57990, 19071030, 19129020);
39 
40  //These are found by the pileup code in ../QA/pileup
41  //Test parameters
42  double a0=-1.27785869748694, a1=0.918278154432662, a2=-0.000421651379949012, a3=1.20429516308073e-06, a4=-1.54521733920117e-09;
43  double b0=13.2397261316822, b1=1.46248491801055, b2=-0.00310419986439369, b3=8.21875717651988e-06, b4=-8.61348326634967e-09;
44  double c0=-11.2055760170529, c1=0.415626210975414, c2=0.00191757674104115, c3=-4.93833806589717e-06, c4=4.74283345256434e-09;
45  anaMaker->setPileUpParameters(a0,a1,a2,a3,a4,b0,b1,b2,b3,b4,c0,c1,c2,c3,c4);
46 
47  std::cout << "Initializing chain" << std::endl;
48  // Check that all maker has been successfully initialized
49  if( chain->Init() == kStErr ){
50  std::cout << "Error during the chain initializtion. Exit. " << std::endl;
51  return;
52  }
53  std::cout << "... done" << std::endl;
54 
55  int nEvents2Process = reader->chain()->GetEntries();
56  std::cout << " Number of events in files: " << nEvents2Process << std::endl;
57 
58  // Processing events
59  for (Int_t iEvent=0; iEvent<nEvents2Process; iEvent++) {
60 
61  if( iEvent % 1000 == 0 ) std::cout << "Macro: working on event: " << iEvent << std::endl;
62  chain->Clear();
63 
64  // Check return code
65  int iret = chain->Make();
66  // Quit event processing if return code is not 0
67  if (iret) { std::cout << "Bad return code!" << iret << endl; break; }
68  } // for (Int_t iEvent=0; iEvent<nEvents2Process; iEvent++)
69  std::cout << "Data have been processed, Master" << std::endl;
70 
71  std::cout << "Finalizing chain" << std::endl;
72  // Finalize all makers in chain
73  chain->Finish();
74  std::cout << "... done" << std::endl;
75 
76  std::cout << "Centrality analyzer finished the work" << std::endl;
77 }
Allows to read picoDst file(s)
TChain * chain()
Return pointer to the chain of .picoDst.root files.
virtual void Clear(Option_t *option="")
User defined functions.
Definition: StChain.cxx:77
void SetStatus(const Char_t *branchNameRegex, Int_t enable)
Set enable/disable branch matching when reading picoDst.
virtual Int_t Finish()
Definition: StChain.cxx:85
Process and build distributions for centrality determination.
virtual Int_t Make()
Definition: StChain.cxx:110
void Init()
Calls openRead()
StPicoDstReader(const Char_t *inFileName)
Definition: Stypes.h:44