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