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