StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
RunStiMaker2.C
1 #include <iostream>
2 
3 Bool_t doProfile = false;
4 Int_t usePath = 0;
5 Int_t nFile = 0;
6 TString thePath;
7 TString theFileName;
8 TString originalPath;
9 class StChain;
10 StChain *chain=0;
11 class StEventDisplayMaker;
12 StEventDisplayMaker *dsMaker = 0;
13 TBrowser *b=0;
14 
15 const char *dstFile = 0;
16 const char *xdfFile = 0;
17 const char *mdcFile = 0;
18 const char *fileList[] = {dstFile,xdfFile,mdcFile,0};
19 
20 void Help()
21 {
22  cout << "Usage: doEvents.C(nevents,\"-\",\"some_directory/some_dst_file.xdf\")" << endl;
23  cout << " doEvents.C(nevents,\"-\",\"some_directory/some_dst_file.root\")" << endl;
24  cout << " doEvents.C(nevents,\"some_directory\",\"*.dst.root\")" << endl;
25 }
26 
27 
28 void RunStiMaker2(Int_t, const Char_t **, const Char_t *qaflag = "");
29 //const char* MainFile="/star/data22/ITTF/data/simple_geant/DEV_10_8_01/muon_10_neg.event.root")
30 
31 void RunStiMaker2(Int_t nevents=1,
32  //const Char_t *path="/star/data13/reco/dev/2002/01/",
33  const Char_t *path = "/star/data22/ITTF/data/simple_geant/DEV_10_8_01/",
34  //const Char_t *path = "data/simple_geant/DEV_10_8_01/",
35 
36  //const Char_t *file="*3007007*.event.root",
37  const Char_t *file= "muon_10_neg.event.root",
38 
39  const Char_t *qaflag = "off",
40  const Int_t wrStEOut = 0);
41 
42 // ------------------ Here is the actual method -----------------------------------------
43 void RunStiMaker2(Int_t nevents, const Char_t **fileList, const Char_t *qaflag, const Int_t wrStEOut)
44 {
45  Int_t theRunNumber=0;
46  bool simulated = true;
47  bool doFit = false;
48  bool optimized = false;
49  char* outfile = "Evaluation.root";
50 
51  cout << endl << endl <<" doEvents - input # events = " << nevents << endl;
52  Int_t ilist=0;
53  while(fileList[ilist]){
54  cout << " doEvents - input fileList = " << fileList[ilist] << endl;
55  ilist++;
56  }
57  cout << " doEvents - input qaflag = " << qaflag << endl;
58  cout << " doEvents - input wrStEOut = " << wrStEOut << endl << endl << endl;
59 
60  //
61  // First load some shared libraries we need
62  //
63 
64  gSystem->Load("St_base");
65  gSystem->Load("StUtilities");
66  gSystem->Load("StChain");
67  gSystem->Load("StBFChain");
68  gSystem->Load("St_Tables");
69 
70  gSystem->Load("libgen_Tables");
71  gSystem->Load("libsim_Tables");
72  gSystem->Load("libglobal_Tables");
73  gSystem->Load("geometry");
74 
75  gSystem->Load("St_g2t");
76  gSystem->Load("St_geant_Maker");
77 
78  gSystem->Load("StIOMaker");
79  gSystem->Load("StTreeMaker");
80  gSystem->Load("StarClassLibrary");
81 
82  gSystem->Load("St_db_Maker");
83  gSystem->Load("StDbLib");
84  gSystem->Load("StDbBroker");
85  gSystem->Load("StSvtDbMaker");
86  gSystem->Load("StDbUtilities");
87  gSystem->Load("StTpcDb");
88  gSystem->Load("StEvent");
89  gSystem->Load("StEventMaker");
90  gSystem->Load("StEmcUtil");
91  gSystem->Load("StMcEvent");
92  gSystem->Load("StMcEventMaker");
93  gSystem->Load("StAssociationMaker");
94  gSystem->Load("StDaqLib");
95  gSystem->Load("StDAQMaker");
96 
97  gSystem->Load("StDetectorDbMaker");
98 
99  gSystem->Load("StSvtClassLibrary");
100  gSystem->Load("StSvtDaqMaker");
101  gSystem->Load("StSvtSimulationMaker");
102  gSystem->Load("StSvtCalibMaker");
103  gSystem->Load("StSvtSeqAdjMaker");
104  //gSystem->Load("StSvtEvalMaker");
105  gSystem->Load("StSvtClusterMaker");
106 
107  //cout <<"Loading StMcEventMaker"<<endl;
108  //gSystem->Load("StMcEventMaker");
109 
110  //cout <<"Loading AssociationMaker"<<endl;
111  //gSystem->Load("StAssociationMaker");
112 
113  cout <<"Loading Sti"<<endl;
114  gSystem->Load("Sti");
115 
116  cout <<"Loading StiGui"<<endl;
117  gSystem->Load("StiGui");
118 
119  cout <<"Loading StiEvaluator"<<endl;
120  gSystem->Load("StiEvaluator");
121 
122 
123  cout <<"Loading libGui"<<endl;
124  gSystem->Load("libGui");
125 
126  cout <<"Loading StiMaker"<<endl;
127  gSystem->Load("StiMaker");
128 
129  if(doProfile){
130  cout <<"Loading Jprof"<<endl;
131  gSystem->Setenv("JPROF_FLAGS", "JP_START JP_PERIOD=0.001");
132  gSystem->Load("libJprof");
133  }
134 
135  //
136  // Handling depends on whether file is a ROOT file or XDF file
137  //
138  chain = new StChain("StChain");
139 
140  StFileI *setFiles =0;
141  if (fileList) { //Normal case
142  setFiles= new StFile(fileList);
143  } else { //Grand Challenge
144  gSystem->Load("StChallenger");
145  setFiles = StChallenger::Challenge();
146  setFiles->SetDebug();
147  const char *Argv[]= {
148  "-s","daq", // list of components needed
149  "-q","mRunNumber=1228023", // example of user query
150  "-c","/afs/rhic.bnl.gov/star/incoming/GCA/daq/stacs.rc" // pointer to GC servers for daq
151  };
152  Int_t Argc=sizeof(Argv)/4;
153  setFiles->Init(Argc,Argv);
154  }
155 
156  StIOMaker *IOMk = new StIOMaker("inputStream","r",setFiles);
157  //IOMk->SetBranch("*",0,"0"); //deactivate all branches
158  //IOMk->SetBranch("dstBranch",0,"r");
159  //IOMk->SetBranch("runcoBranch",0,"r");
160  IOMk->SetBranch("eventBranch",0,"r");
161  if (simulated) { //addded by MLM
162  IOMk->SetBranch("geantBranch",0,"r");
163  }
164  IOMk->SetDebug();
165 
166  St_geant_Maker *geantMk = new St_geant_Maker("geant");
167  geantMk->SetActive(kFALSE);
168 
169  //
170  // Maker to read events from file or database into StEvent
171  //
172  //StEventMaker *readerMaker = new StEventMaker("events","title");
173 
174  //
175  // DB maker
176  //
177  // dbaseMk = new St_db_Maker("svt","$PWD/svtcvs/StarDb");
178  //dbaseMk = new St_db_Maker("db","StarDb");
179  dbaseMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb");
180  //dbaseMk->SetDateTime("year_1h");
181  //dbaseMk->SetDateTime("year_2a");
182  dbaseMk-> SetDateTime(20010801,000000);
183 
184  //
185  // TPC Db maker
186  //
187  tpcDbMk = new StTpcDbMaker("tpcDb");
188 
189  //
190  // SVT Db maker
191  //
192  svtDbMk = new StSvtDbMaker("svtDb");
193 
194  //
195  // Detector Db Maker (TPC rdos, etc)
196  //
197  detDbMk = new StDetectorDbMaker("detDb");
198 
199  //StMcEventMaker
200  StMcEventMaker* mcEventReader = 0;
201  //Association
202  StAssociationMaker* assocMaker = 0;
203 
204  if (simulated) {
205 
206  mcEventReader = new StMcEventMaker();
207  assocMaker = new StAssociationMaker();
208  }
209 
210  //StiMaker
211  StiMaker* anaMk = StiMaker::instance();
212 
213  cout <<"\n --- Setup StiIOBroker ---\n"<<endl;
214 
215  //StiIOBroker
216  StiRootIOBroker* stiIO = anaMk->getIOBroker();//StiRootIOBroker::instance();
217 
218  stiIO->setTPHFMinPadrow(1);
219  stiIO->setTPHFMaxPadrow(45);
220  stiIO->setETSFLowerBound(5);
221  stiIO->setETSFMaxHits(6);
222 
223  stiIO->setDoTrackFit(doFit);
224 
225  //Set Kalman Track Finder (KTF) run-time values:
226  stiIO->setKTFMcsCalculated(false);
227  stiIO->setKTFElossCalculated(false);
228  stiIO->setKTFMaxChi2ForSelection(50);
229  stiIO->setKTFBField(.5); //Tesla
230  stiIO->setKTFMassHypothesis(.1395); //GeV
231  stiIO->setKTFMinContiguousHitCount(2);
232  stiIO->setKTFMaxNullCount(40);
233  stiIO->setKTFMaxContiguousNullCount(25);
234  stiIO->setKTFMinSearchRadius(.5); //cm
235  stiIO->setKTFMaxSearchRadius(4.); //cm
236  stiIO->setKTFSearchWindowScale(5.); //cm
237 
238  //Set Local Track Seed Finder (LTSF) run-time values
239  stiIO->setLTSFZWindow(5.);
240  stiIO->setLTSFYWindow(2.);
241  stiIO->setLTSFSeedLength(2);
242 
243  stiIO->setLTSFDoHelixFit(true);
244  stiIO->setLTSFExtrapYWindow(1.);
245  stiIO->setLTSFExtrapZWindow(2.);
246  stiIO->setLTSFExtrapMaxSkipped(2);
247  stiIO->setLTSFExtrapMinLength(4);
248  stiIO->setLTSFExtrapMaxLength(5);
249  stiIO->setLTSFUseVertex(true);
250 
251  stiIO->setLTMDeltaR(1.); //10% in r
252 
253  //Add sectors:
254  for (unsigned int sector=1; sector<=12; ++sector) {
255  stiIO->addLTSFSector(sector);
256  }
257  //Add padrows;
258  //for (unsigned int padrow=1; padrow<=45; ++padrow) {
259  for (unsigned int padrow=6; padrow<=45; padrow+=1) {
260  stiIO->addLTSFPadrow(padrow);
261  }
262 
263  //This line has to match the corresponding enumeration in StiIOBroker.h
264  enum SeedFinderType {kUndefined=0, kComposite=1, kEvaluable=2};
265  //stiIO->setSeedFinderType(kEvaluable);
266  stiIO->setSeedFinderType(kComposite);
267 
268  //Set up the track filter (this mas to macth the correspoinding enumeration in StiIOBroker.h)
269  enum FilterType {kPtFilter=0, kEtaFilter=1, kChi2Filter=2, kNptsFilter=3, kNFitPtsFilter=4,
270  kNGapsFilter=5, kFitPointRatioFilter=6, kPrimaryDcaFilter=7};
271 
272  stiIO->addFilterType(kPtFilter);
273  stiIO->setFilterPtMin(.1); //GeV
274  stiIO->setFilterPtMax(50.); //GeV
275 
276  stiIO->addFilterType(kEtaFilter);
277  stiIO->setFilterEtaMin(-2.);
278  stiIO->setFilterEtaMax(2.);
279 
280  stiIO->addFilterType(kChi2Filter);
281  stiIO->setFilterChi2Max(10.);
282 
283  stiIO->addFilterType(kNptsFilter);
284  stiIO->setFilterNptsMin(8);
285 
286  stiIO->addFilterType(kNFitPtsFilter);
287  stiIO->setFilterNFitPtsMin(5);
288 
289  stiIO->addFilterType(kNGapsFilter);
290  stiIO->setFilterNGapsMax(20);
291 
292  //stiIO->addFilterType(kFitPointRatioFilter);
293  //stiIO->setFilterFitPointRatioMin(.5);
294 
295  stiIO->addFilterType(kPrimaryDcaFilter);
296  stiIO->setFilterPrimaryDcaMax(100.);
297 
298  stiIO->setSimulated(simulated);
299  anaMk->setEvaluationFileName(outfile);
300 
301  if (simulated) {
302  anaMk->setMcEventMaker(mcEventReader);
303  anaMk->setAssociationMaker(assocMaker);
304  }
305 
306  //Make Control Window if not batch
307  MainFrame* sti=0;
308  StiGuiIOBroker* guiIO=0;
309 
310  if (gROOT->IsBatch()==false) {
311 
312  cout <<"No batch option detected. Run Integrated Tracker in Gui Mode."<<endl;
313 
314  sti = new MainFrame(gClient->GetRoot(), 400, 220);
315 
316  sti->setStChain(chain);
317  sti->setIoMaker(IOMk);
318 
319  //we're in batch mode
320  stiIO->setUseGui(true);
321 
322  //Maker io gateway
323  guiIO = StiGuiIOBroker::instance();
324 
325  //Values for hits not assigned to tracks
326  guiIO->setUnMarkedHitSize(.3);
327  guiIO->setUnMarkedHitColor(4);
328  guiIO->setUnMarkedHitStyle(8);
329  guiIO->setUpdateEachTrack(false);
330 
331  //Values for hits assigned to tracks
332  guiIO->setMarkedHitSize(.3);
333  guiIO->setMarkedHitColor(2);
334  guiIO->setMarkedHitStyle(3);
335  }
336  else {
337  cout <<"Batch option detector. Run Integrated Tracker in non-Gui Mode."<<endl;
338  stiIO->setUseGui(false);
339  }
340 
341  cout <<"\n --- Done setting up StiIOBroker --- \n"<<endl;
342 
343  // WriteOut StEvent
344  if (wrStEOut) {
345  cout << "!!!! doEvents: will write out .event.root file !!" << endl << endl;
346  StTreeMaker *outMk = new StTreeMaker("EvOut","","bfcTree");
347  outMk->SetIOMode("w");
348  outMk->SetBranch("eventBranch","test.event.root","w");
349  outMk->IntoBranch("eventBranch","StEvent");
350  }
351 
352 
353  /*
354  dbaseMk->Init();
355  svtDbMk->setSvtDb_Reader();
356  dbaseMk->Make();
357  svtDbMk->readSvtConfig();
358  svtDbMk->readSvtGeometry();
359  */
360 
361  //
362  // Initialize chain
363  //
364 
365  Int_t iInit = chain->Init();
366  if (iInit) chain->Fatal(iInit,"on init");
367  //chain->PrintInfo();
368  chain->InitRun(theRunNumber);
369 
370  //
371  // Event loop
372  //
373  int istat=0,i=1;
374  EventLoop: if (i <= nevents && istat!=2) {
375 
376  cout << endl << "============================ Event " << i
377  << " start ============================" << endl;
378 
379  chain->Clear();
380  istat = chain->Make(i);
381 
382  if (istat==2)
383  {cout << "Last event processed. Status = " << istat << endl;}
384  if (istat==3)
385  {cout << "Error event processed. Status = " << istat << endl;}
386 
387  i++;
388  goto EventLoop;
389  }
390 
391  //chain->Finish();
392 
393  i--;
394  cout << endl << "============================ Event " << i
395  << " finish ============================" << endl;
396 
397 }
398 
399 //--------------------------------------------------------------------------
400 
401 void RunStiMaker2(const Int_t nevents, const Char_t *path, const Char_t *file,
402  const Char_t *qaflag, const Int_t wrStEOut)
403 {
404  if (nevents==-1) { Help(); return;}
405 
406  const char *fileListQQ[]={0,0};
407  if (strncmp(path,"GC",2)==0) {
408  fileListQQ=0;
409  } else if (path[0]=='-') {
410  fileListQQ[0]=file;
411  } else if (!file[0]) {
412  fileListQQ[0]=path;
413  } else {
414  fileListQQ[0] = gSystem->ConcatFileName(path,file);
415  }
416 
417  /*
418  const char *fileListQQ[3];
419  fileListQQ[0] = "/star/svt/online/jundata/st_pedestal_2165026_raw_0001.daq";
420  fileListQQ[1] = "/star/svt/online/jundata/st_pedestal_2165027_raw_0001.daq";
421  fileListQQ[2] = NULL;
422  */
423 
424  RunStiMaker2(nevents,fileListQQ,qaflag,wrStEOut);
425 }
426 
427 
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
Filling of all StMcEvent classes from g2t tables Transform all the data in the g2t tables into the co...
virtual Int_t Make()
Definition: StChain.cxx:110
virtual void SetActive(Bool_t k=kTRUE)
Setters for flags and switches.
Definition: StMaker.h:208