StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
doEvents.C
1 #include "iostream.h"
2 
3 class StChain;
4 StChain *chain=0;
5 class St_db_Maker;
6 St_db_Maker *dbMk =0;
7 
8 Int_t iEvt=0,istat=0,nEvents=0;
9 // ------------------ Here is the actual method -----------------------------------------
10 void doEvents(const Char_t *inname, const Char_t *histname, const Char_t *ntuplename)
11 {
12  Int_t nEvents = 10;
13  Int_t nfiles = 100;
14 
15  //
16  // First load some shared libraries we need
17  //
18  if (gClassTable->GetID("TTable") < 0) {
19  gSystem->Load("libStar");
20  gSystem->Load("libPhysics");
21  }
22  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
23  loadSharedLibraries();
24  gSystem->Load("StarMagField");
25  gSystem->Load("StMagF");
26  gSystem->Load("StTpcDb");
27 // gSystem->Load("StDbUtilities");
28  gSystem->Load("StDaqLib");
29  gSystem->Load("StDbBroker");
30  gSystem->Load("StDetectorDbMaker");
31  gSystem->Load("StDbUtilities");
32  gSystem->Load("St_db_Maker");
33 
34  gSystem->Load("StEvent");
35  gSystem->Load("StEventMaker");
36  gSystem->Load("StarMagField");
37  gSystem->Load("StTofUtil");
38  gSystem->Load("StTofMaker");
39 
40  gSystem->Load("libtpc_Tables");
41  gSystem->Load("libGeom");
42  gSystem->Load("St_g2t");
43  gSystem->Load("geometry");
44  gSystem->Load("St_geant_Maker");
45 
46  gSystem->Load("StTofrMatchMaker");
47  // gSystem->Load("StTofpMatchMaker");
48  // gSystem->Load("StTofCalibMaker");
49  // gSystem->Load("StTofFlowMaker");
50  gSystem->Load("StTofrNtupleMaker");
51 
52  // Handling depends on whether file is a ROOT file or XDF file
53  //
54  chain = new StChain("StChain");
55 
56  StIOMaker* ioMaker = new StIOMaker();
57  ioMaker->SetFile(inname);
58  ioMaker->SetIOMode("r");
59  ioMaker->SetBranch("*",0,"0");
60  ioMaker->SetBranch("eventBranch",0,"r");
61  ioMaker->SetDebug(0);
62 
63  int NwGeant=5000000, IwType=0, NwPaw=0;
64  St_geant_Maker *geantMk = new St_geant_Maker("geant",NwGeant,NwPaw,IwType);
65  geantMk->LoadGeometry("detp geometry y2008");
66  geantMk->SetActive(kFALSE);
67 
68  cout<<endl<<"============ Data Base ========="<<endl;
69  dbMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb","StarDb");
70 
71  StTofrMatchMaker *matchMaker = new StTofrMatchMaker("tofrMatch");
72  matchMaker->SetDebug(0);
73  matchMaker->SetMode(1);
74  matchMaker->setSaveGeometry(kTRUE);
75  matchMaker->setCreateHistoFlag(kTRUE);
76  matchMaker->setCreateTreeFlag(kTRUE);
77  matchMaker->setHistoFileName(histname);
78  //matchMaker->setNtupleFileName("test2.root");
79  StTofrNtupleMaker *tofrNtuple = new StTofrNtupleMaker("tofrNtuple", ntuplename);
80  tofrNtuple->SetDebug(0);
81  tofrNtuple->setInitGeomFromOther(kTRUE);
82  //
83 
84  // Initialize chain
85  //
86  Int_t iInit = chain->Init();
87  if (iInit) chain->Fatal(iInit,"on init");
88  chain->PrintInfo();
89  //
90  // Event loop
91  //
92  int istat = 0, i = 1;
93 EventLoop: if (i <= nEvents && istat != 2) {
94 
95  cout << endl << "============================ Event " << i
96  << " start ============================" << endl;
97 
98  chain->Clear();
99  istat = chain->Make(i);
100  if (istat == 2)
101  {cout << "Last event processed. Status = " << istat << endl;}
102  if (istat == 3)
103  {cout << "Error event processed. Status = " << istat << endl;}
104 
105  // gObjectTable->Print();
106  i++;
107  goto EventLoop;
108  }
109 
110  i--;
111  cout<<endl<<"============================ Event "<<i<<" finish ============================"<<endl;
112 
113  //
114  // Chain Finish
115  //
116  if (nEvents > 1) {
117  chain->Finish();
118  }
119 
120 
121 }
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
virtual void SetActive(Bool_t k=kTRUE)
Setters for flags and switches.
Definition: StMaker.h:208
virtual void LoadGeometry(const Char_t *option="detp geometry field_only")
Specifies GEANT3 geometry command.