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 class StFileI;
8 StFileI *setFiles =0;
9 
10 Int_t iEvt=0,istat=0,nEvents=0;
11 // ProtoTypes
12 
13 void doEvents(const Char_t *file="StRoot/StTofPool/StTofMuDstReader/macros/test.lis", const Char_t *outputname="test.root");
14 
15 
16 // ------------------ Here is the actual method -----------------------------------------
17 void doEvents(const Char_t *fileList, const Char_t *outputname)
18 {
19  Int_t nEvents = 100;
20  Int_t nfiles = 100;
21 
22  //
23  // First load some shared libraries we need
24  //
25  if (gClassTable->GetID("TTable") < 0) {
26  gSystem->Load("libStar");
27  gSystem->Load("libPhysics");
28  }
29  gROOT->LoadMacro("$STAR/StRoot/StMuDSTMaker/COMMON/macros/loadSharedLibraries.C");
30  loadSharedLibraries();
31  gSystem->Load("StarMagField");
32  gSystem->Load("StMagF");
33  gSystem->Load("StTpcDb");
34 // gSystem->Load("StDbUtilities");
35  gSystem->Load("StDaqLib");
36  gSystem->Load("StDbBroker");
37  gSystem->Load("StDetectorDbMaker");
38  gSystem->Load("StDbUtilities");
39  gSystem->Load("St_db_Maker");
40 
41  gSystem->Load("StEvent");
42  gSystem->Load("StEventMaker");
43  gSystem->Load("StarMagField");
44  gSystem->Load("StTofUtil");
45  gSystem->Load("StTofMaker");
46 
47  gSystem->Load("libtpc_Tables");
48  gSystem->Load("libGeom");
49  gSystem->Load("St_g2t");
50  gSystem->Load("geometry");
51  gSystem->Load("St_geant_Maker");
52 
53  gSystem->Load("StTofMuDstReader");
54  //
55  // Handling depends on whether file is a ROOT file or XDF file
56  //
57  chain = new StChain("StChain");
58 
59 
60  int NwGeant=5000000, IwType=0, NwPaw=0;
61  St_geant_Maker *geantMk = new St_geant_Maker("geant",NwGeant,NwPaw,IwType);
62  geantMk->LoadGeometry("detp geometry y2005F");
63  geantMk->SetActive(kFALSE);
64 
65 
66  delete setFiles; setFiles =0;
67  if (fileList) { //Normal case
68  setFiles= new StFile();
69  } else { //
70  return;
71  }
72  ifstream* inputStream = new ifstream;
73  inputStream->open(fileList);
74  if (!(inputStream)) {
75  cout << "can not open list file" << endl;
76  return;
77  }
78  cout<<"Open file list: --- "<<fileList<<endl;
79 
80  char line[512];
81  for (;inputStream->good();) {
82  inputStream->getline(line,512);
83  if ( inputStream->good() ) {
84  //cout<<" root file "<<line<<endl;
85  TFile *ftmp = new TFile(line);
86  //----------
87  if (!(ftmp->IsOpen())) {
88  cout<<line<<" open failed ! not chained"<<endl;
89  continue;
90  }
91  if (ftmp->IsZombie()) {
92  cout<<"sth. very wrong with "<<line<<", not chained "<<endl;
93  continue;
94  }
95  if (ftmp->TestBit(1024)) {
96  cout<<"revocer procedure applied to "<<line<<endl;
97  continue;
98  }
99  //--------------------------
100  if( ftmp && ftmp->IsOpen() && ftmp->GetNkeys()) {
101  cout << "add file " << line << endl;
102  setFiles->AddFile(line);
103  } else {
104  cout << " cannot open file " << line << endl;
105  }
106  delete ftmp;
107  }
108  }
109 
110  StMuDstMaker* muDstMaker = new StMuDstMaker(0,0,"",fileList,"MuDst.root",nfiles);
111  muDstMaker->SetStatus("*",0);
112  muDstMaker->SetStatus("MuEvent",1);
113  muDstMaker->SetStatus("PrimaryVertices",1);
114  muDstMaker->SetStatus("PrimaryTracks",1);
115  muDstMaker->SetStatus("TofRawData",1);
116  muDstMaker->SetStatus("TofData",1);
117  muDstMaker->SetStatus("TofHit",1);
118 
119  gSystem->Load("StTofMuDstReader");
120 
121  StTofMuDstEval *tofEval = new StTofMuDstEval("tofMuDstEval",muDstMaker);
122  StTofMuDstReader *tofMaker = new StTofMuDstReader("tofMaker",outputname,muDstMaker);
123 
124 
125  //
126  // Initialize chain
127  //
128  Int_t iInit = chain->Init();
129  if (iInit) chain->Fatal(iInit,"on init");
130  chain->PrintInfo();
131 
132  //
133  // Event loop
134  //
135  int istat = 0, i = 1;
136 EventLoop: if (i <= nEvents && istat != 2) {
137 
138  cout << endl << "============================ Event " << i
139  << " start ============================" << endl;
140 
141  chain->Clear();
142  istat = chain->Make(i);
143  if (istat == 2)
144  {cout << "Last event processed. Status = " << istat << endl;}
145  if (istat == 3)
146  {cout << "Error event processed. Status = " << istat << endl;}
147 
148  // gObjectTable->Print();
149  i++;
150  goto EventLoop;
151  }
152 
153  i--;
154  cout<<endl<<"============================ Event "<<i<<" finish ============================"<<endl;
155 
156  //
157  // Chain Finish
158  //
159  if (nEvents > 1) {
160  chain->Finish();
161  }
162 
163 
164 }
165 
166 
167 
168 
169 
Definition: StTree.h:125
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
void SetStatus(const char *arrType, int status)
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.