StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
TestEvalIT.C
1 //
2 // $Id: TestEvalIT.C,v 1.15 2006/08/15 21:42:27 jeromel Exp $
3 //
4 //
5 // $Log: TestEvalIT.C,v $
6 // Revision 1.15 2006/08/15 21:42:27 jeromel
7 // Fix rhic -> rhic.bnl.gov
8 //
9 // Revision 1.14 2002/10/04 01:55:03 pruneau
10 // DefaultToolkit now uses the StiHitLoader scheme rahter than the StiHitFiller.
11 //
12 // Revision 1.13 2002/09/27 19:19:28 mmiller
13 // Hid some necessary calls behind if (simulated) to restore proper handling of both mc and data.
14 //
15 // Revision 1.12 2002/08/28 17:14:28 pruneau
16 // Simplified the interface of StiKalmanTrackFinder and the calls
17 // required in StiMaker.
18 //
19 // Revision 1.11 2002/08/23 18:16:56 pruneau
20 // Added StiSimpleTrackFilter to StiMaker to enable simple and
21 // fast track finding diagnostics.
22 //
23 // Revision 1.10 2002/08/22 21:46:14 pruneau
24 // Made a fix to StiStEventFiller to remove calls to StHelix and StPhysicalHelix.
25 // Currently there is one instance of StHelix used a calculation broker to
26 // get helix parameters such as the distance of closest approach to the main
27 // vertex.
28 //
29 // Revision 1.9 2002/08/19 19:33:19 pruneau
30 // eliminated cout when unnecessary, made helix member of the EventFiller
31 //
32 // Revision 1.8 2002/06/28 23:33:46 calderon
33 // Changes to work with bug fixes and new conventions in StMiniMcMaker
34 // Output file names will begin with "EvalItTest" and the rest of the input
35 // filename will be appended to this prefix.
36 //
37 // Revision 1.7 2002/06/25 21:44:40 pruneau
38 // *** empty log message ***
39 //
40 // Revision 1.6 2002/06/25 15:09:16 pruneau
41 // *** empty log message ***
42 //
43 // Revision 1.5 2002/06/21 22:06:46 andrewar
44 // Add command line flag for Sti track/ Tpt track association: associateStiTrack
45 // (=1 for StiTracks)....A. Rose, 6.21.2002
46 //
47 // Revision 1.4 2002/06/18 20:25:12 pruneau
48 // Changed TestEvalIT.C to have nevent==1 imply GUI mode
49 //
50 // Revision 1.3 2002/06/05 20:45:27 calderon
51 // -Make sure that StMcEventMaker and StAssociationMaker are loaded, the last
52 // commit had these commented out for some reason (?)
53 // -Remove any extraneous reference to the (private code) StItTestMaker to
54 // avoid confusion.
55 // -Make sure all branches are deactivated in the IO maker first, then turn
56 // on only the ones we need, event, geant, etc.
57 //
58 // Revision 1.2 2002/06/04 18:13:26 andrewar
59 //
60 // ----------------------------------------------------------------------
61 //
62 // Committing in StRoot/StiMaker/macros
63 //
64 // Modified Files:
65 // TestEvalIT.C
66 //
67 //
68 // Corrected TestEvalIT.C to work with current
69 // repository software.
70 //
71 // A. Rose, M. Calderon
72 //
73 //
74 // ----------------------------------------------------------------------
75 //
76 // Revision 1.1 2002/05/29 19:18:23 calderon
77 // First version to test primary tracks from IT.
78 // This writes the StMiniMcEvent tree from Bum and Manuel,
79 // later this can be switched to something else.
80 //
81 //
82 #include <iostream>
83 #include <stdexcept>
84 Bool_t doProfile = false;
85 Int_t usePath = 0;
86 Int_t nFile = 0;
87 TString thePath;
88 TString theFileName;
89 TString originalPath;
90 class StChain;
91 StChain *chain=0;
92 class StEventDisplayMaker;
93 StEventDisplayMaker *dsMaker = 0;
94 TBrowser *b=0;
95 
96 const char *dstFile = 0;
97 const char *xdfFile = 0;
98 const char *mdcFile = 0;
99 const char *fileList[] = {dstFile,xdfFile,mdcFile,0};
100 
101 void Help()
102 {
103  cout << "Usage: TestEvalIT.C(firstEvtIndex,nevents,\"-\",\"some_directory/some_dst_file.xdf\")" << endl;
104  cout << " TestEvalIT.C(firstEvtIndex,nevents,\"-\",\"some_directory/some_dst_file.root\")" << endl;
105  cout << " TestEvalIT.C(firstEvtIndex,nevents,\"some_directory\",\"*.dst.root\")" << endl;
106 }
107 
108 void loadLibrairies(bool doProfile)
109 {
110  cout<<"Loading modules:"<<endl;
111  gSystem->Load("St_base");
112  gSystem->Load("StChain");
113  gSystem->Load("StUtilities");
114  gSystem->Load("StBFChain");
115  gSystem->Load("St_Tables");
116 
117  gSystem->Load("libgen_Tables");
118  gSystem->Load("libsim_Tables");
119  gSystem->Load("libglobal_Tables");
120  gSystem->Load("geometry");
121  gSystem->Load("St_g2t");
122  gSystem->Load("St_geant_Maker");
123  gSystem->Load("StIOMaker");
124  gSystem->Load("StTreeMaker");
125  gSystem->Load("StarClassLibrary");
126  gSystem->Load("St_db_Maker");
127  gSystem->Load("StDbLib");
128  gSystem->Load("StDbBroker");
129  gSystem->Load("StSvtDbMaker");
130  gSystem->Load("StDbUtilities");
131  gSystem->Load("StTpcDb");
132  gSystem->Load("StEvent");
133  gSystem->Load("StEventMaker");
134  gSystem->Load("StEmcUtil");
135  gSystem->Load("StMcEvent");
136  gSystem->Load("StMcEventMaker");
137  gSystem->Load("StAssociationMaker");
138  gSystem->Load("StDaqLib");
139  gSystem->Load("StDAQMaker");
140  gSystem->Load("StDetectorDbMaker");
141  gSystem->Load("StSvtClassLibrary");
142  gSystem->Load("StSvtDaqMaker");
143  gSystem->Load("StSvtSimulationMaker");
144  gSystem->Load("StSvtCalibMaker");
145  gSystem->Load("StSvtSeqAdjMaker");
146  //gSystem->Load("StSvtEvalMaker");
147  gSystem->Load("StSvtClusterMaker");
148 
149  cout <<"/Sti" << endl; gSystem->Load("Sti");
150  cout <<"/StiGui"<< endl; gSystem->Load("StiGui");
151  cout <<"/StiEvaluator"<< endl; gSystem->Load("StiEvaluator");
152  cout <<"/libGui"<< endl; gSystem->Load("libGui");
153  cout <<"/StiMaker"<< endl; gSystem->Load("StiMaker");
154  cout <<"/StMiniMcEvent"<< endl; gSystem->Load("StMiniMcEvent");
155  cout <<"/StMiniMcMaker"<< endl; gSystem->Load("StMiniMcMaker");
156 
157  if(doProfile)
158  {
159  cout <<"/Jprof";
160  gSystem->Setenv("JPROF_FLAGS", "JP_START JP_PERIOD=0.001");
161  gSystem->Load("libJprof");
162  }
163  cout <<"\nDone.";
164 }
165 
166 void TestEvalIT(Int_t firstEvtIndex=0,
167  Int_t nevents=1,
168  //const Char_t* path ="/star/data11/reco/ppMinBias/ReversedFullField/P02gh2/2002/009/", //pp-data
169  //const Char_t* file = "st_physics_3009012_raw_0001.event.root",
170  const Char_t* path = "/star/data22/ITTF/EvalData/MCFiles/auau200/", //mc test
171  const Char_t* file="rcf0183_12_300evts.geant.root",
172  const Char_t *qaflag = "off",
173  const Int_t wrStEOut = 0,
174  const int associateStiTrack=1,
175  const char* filePrefix = "rcf")
176 {
177  if (nevents==-1)
178  {
179  Help();
180  return;
181  }
182  const char *fileListQQ[]={0,0};
183  if (strncmp(path,"GC",2)==0)
184  fileListQQ=0;
185  else if (path[0]=='-')
186  fileListQQ[0]=file;
187  else if (!file[0])
188  fileListQQ[0]=path;
189  else
190  fileListQQ[0] = gSystem->ConcatFileName(path,file);
191  TestEvalIT(firstEvtIndex, nevents,fileListQQ,qaflag,wrStEOut,associateStiTrack,filePrefix);
192 }
193 
194 
195 // ------------------ Here is the actual method -----------------------------------------
196 
197 void TestEvalIT(Int_t firstEvtIndex,
198  Int_t nevents,
199  const Char_t **fileList,
200  const Char_t *qaflag,
201  const Int_t wrStEOut,
202  const int associateStiTrack,
203  const char* filePrefix)
204 {
205  Int_t theRunNumber=0;
206  bool simulated = true;
207  bool doFit = false;
208  bool optimized = false;
209  bool doProfile = false;
210  char* outfile = "Evaluation.root";
211 
212  cout << endl << endl <<" TestEvalIT - input # events = " << nevents << endl;
213  Int_t ilist=0;
214  while(fileList[ilist]){
215  cout << " TestEvalIT - input fileList = " << fileList[ilist] << endl;
216  ilist++;
217  }
218  cout << " TestEvalIT - input qaflag = " << qaflag << endl;
219  cout << " TestEvalIT - input wrStEOut = " << wrStEOut << endl;
220  cout << " TestEvalIT - file Prefix = " << filePrefix << endl << endl;
221 
222  // String Manipulation to create the output name
223  TString fileName = "EvalItTest";
224  TString MainFile = fileList[0];
225  int fileBeginIndex = MainFile.Index(filePrefix,0);
226  MainFile.Remove(0,fileBeginIndex);
227  fileName.Append(MainFile);
228  cout << "Output MiniMcTree : " << fileName << endl;
229 
230  loadLibrairies(doProfile);
231 
232  // Handling depends on whether file is a ROOT file or XDF file
233  //
234  chain = new StChain("StChain");
235 
236  StFileI *setFiles =0;
237  if (fileList) { //Normal case
238  setFiles= new StFile(fileList);
239  } else { //Grand Challenge
240  gSystem->Load("StChallenger");
241  setFiles = StChallenger::Challenge();
242  setFiles->SetDebug();
243  const char *Argv[]= {
244  "-s","daq", // list of components needed
245  "-q","mRunNumber=1228023", // example of user query
246  "-c","/afs/rhic.bnl.gov/star/incoming/GCA/daq/stacs.rc" // pointer to GC servers for daq
247  };
248  Int_t Argc=sizeof(Argv)/4;
249  setFiles->Init(Argc,Argv);
250  }
251 
252  StIOMaker *IOMk = new StIOMaker("IO","r",setFiles); //StMiniMcMaker wants this name
253  IOMk->SetBranch("*",0,"0"); //deactivate all branches
254  //IOMk->SetBranch("dstBranch",0,"r");
255  //IOMk->SetBranch("runcoBranch",0,"r");
256  IOMk->SetBranch("eventBranch",0,"r");
257  if (simulated) { //addded by MLM
258  IOMk->SetBranch("geantBranch",0,"r");
259  }
260  IOMk->SetDebug();
261 
262  St_geant_Maker *geantMk = new St_geant_Maker("geant");
263  geantMk->SetActive(kFALSE);
264 
265  // Maker to read events from file or database into StEvent
266  //StEventMaker *readerMaker = new StEventMaker("events","title");
267 
268  // DB maker
269  // dbaseMk = new St_db_Maker("svt","$PWD/svtcvs/StarDb");
270  //dbaseMk = new St_db_Maker("db","StarDb");
271  dbaseMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb");
272  //dbaseMk->SetDateTime("year_1h");
273  //dbaseMk->SetDateTime("year_2a");
274  if (simulated) dbaseMk-> SetDateTime(20010801,000000);
275 
276  // TPC Db maker
277  tpcDbMk = new StTpcDbMaker("tpcDb");
278 
279  // SVT Db maker
280  svtDbMk = new StSvtDbMaker("svtDb");
281 
282  // Detector Db Maker (TPC rdos, etc)
283  detDbMk = new StDetectorDbMaker("detDb");
284 
285  //StMcEventMaker
286  StMcEventMaker* mcEventReader = 0;
287  //Association
288  StAssociationMaker* assocMaker = 0;
289 
290  if (simulated)
291  {
292  mcEventReader = new StMcEventMaker();
293  assocMaker = new StAssociationMaker("EgrStAssociationMaker");
294  }
295  //StiMaker
296  StiMaker* anaMk = StiMaker::instance();
297 
298  //StiIOBroker
299  cout <<"\n --- Setup StiIOBroker ---\n"<<endl;
300  StiRootIOBroker* stiIO = anaMk->getIOBroker();//StiRootIOBroker::instance();
301  stiIO->setTPHFMinPadrow(1);
302  stiIO->setTPHFMaxPadrow(45);
303  stiIO->setETSFLowerBound(5);
304  stiIO->setETSFMaxHits(6);
305  stiIO->setDoTrackFit(doFit);
306  //Set Kalman Track Finder (KTF) run-time values:
307  //stiIO->setKTFMcsCalculated(true);
308  //stiIO->setKTFElossCalculated(true);
309  stiIO->setKTFMcsCalculated(false);
310  stiIO->setKTFElossCalculated(false);
311  stiIO->setKTFMaxChi2ForSelection(50);
312  stiIO->setKTFBField(.5); //Tesla
313  stiIO->setKTFMassHypothesis(.1395); //GeV
314  stiIO->setKTFMinContiguousHitCount(2);
315  stiIO->setKTFMaxNullCount(40);
316  stiIO->setKTFMaxContiguousNullCount(25);
317  stiIO->setKTFMinSearchRadius(.5); //cm
318  stiIO->setKTFMaxSearchRadius(4.); //cm
319  stiIO->setKTFSearchWindowScale(5.); //cm
320  //Set Local Track Seed Finder (LTSF) run-time values
321  //stiIO->setLTSFZWindow(5.);
322  //stiIO->setLTSFYWindow(2.);
323  stiIO->setLTSFZWindow(10.);
324  stiIO->setLTSFYWindow(4.);
325  stiIO->setLTSFSeedLength(2);
326  stiIO->setLTSFDoHelixFit(true);
327  stiIO->setLTSFExtrapYWindow(1.);
328  stiIO->setLTSFExtrapZWindow(2.);
329  stiIO->setLTSFExtrapMaxSkipped(2);
330  stiIO->setLTSFExtrapMinLength(4);
331  stiIO->setLTSFExtrapMaxLength(5);
332  stiIO->setLTSFUseVertex(true);
333  stiIO->setLTMDeltaR(1.); //10% in r
334 
335  //Add sectors:
336  for (unsigned int sector=1; sector<=12; ++sector) {
337  stiIO->addLTSFSector(sector);
338  }
339  //Add padrows;
340  //for (unsigned int padrow=1; padrow<=45; ++padrow) {
341  for (unsigned int padrow=6; padrow<=45; padrow+=1) {
342  stiIO->addLTSFPadrow(padrow);
343  }
344 
345  //This line has to match the corresponding enumeration in StiIOBroker.h
346  enum SeedFinderType {kUndefined=0, kComposite=1, kEvaluable=2};
347 
348  //Set up the track filter (this mas to macth the correspoinding enumeration in StiIOBroker.h)
349  enum FilterType {kPtFilter=0, kEtaFilter=1, kChi2Filter=2, kNptsFilter=3, kNFitPtsFilter=4,
350  kNGapsFilter=5, kFitPointRatioFilter=6, kPrimaryDcaFilter=7};
351 
352  //stiIO->setSeedFinderType(kEvaluable);
353  stiIO->setSeedFinderType(kComposite);
354  stiIO->addFilterType(kPtFilter);
355  stiIO->setFilterPtMin(.1); //GeV
356  stiIO->setFilterPtMax(50.); //GeV
357  stiIO->addFilterType(kEtaFilter);
358  stiIO->setFilterEtaMin(-2.);
359  stiIO->setFilterEtaMax(2.);
360  stiIO->addFilterType(kChi2Filter);
361  stiIO->setFilterChi2Max(10.);
362  stiIO->addFilterType(kNptsFilter);
363  stiIO->setFilterNptsMin(8);
364  stiIO->addFilterType(kNFitPtsFilter);
365  stiIO->setFilterNFitPtsMin(5);
366  stiIO->addFilterType(kNGapsFilter);
367  stiIO->setFilterNGapsMax(20);
368  //stiIO->addFilterType(kFitPointRatioFilter);
369  //stiIO->setFilterFitPointRatioMin(.5);
370  stiIO->addFilterType(kPrimaryDcaFilter);
371  stiIO->setFilterPrimaryDcaMax(100.);
372  stiIO->setSimulated(simulated);
373  anaMk->setEvaluationFileName(outfile);
374  if (simulated)
375  {
376  anaMk->setMcEventMaker(mcEventReader);
377  anaMk->setAssociationMaker(assocMaker);
378  }
379 
380  //Make Control Window if not batch
381  MainFrame* sti=0;
382  StiGuiIOBroker* guiIO=0;
383 
384  if (gROOT->IsBatch()||nevents>1)
385  {
386  cout <<"Batch mode selected. Run Integrated Tracker in non-Gui Mode."<<endl;
387  stiIO->setUseGui(false);
388  }
389  else
390  {
391  cout <<"Interactive mode selected. Run Integrated Tracker in Gui Mode."<<endl;
392  sti = new MainFrame(gClient->GetRoot(), 400, 220);
393  sti->setStChain(chain);
394  sti->setIoMaker(IOMk);
395  stiIO->setUseGui(true);
396  guiIO = StiGuiIOBroker::instance();
397  //Values for hits not assigned to tracks
398  guiIO->setUnMarkedHitSize(.3);
399  guiIO->setUnMarkedHitColor(4);
400  guiIO->setUnMarkedHitStyle(8);
401  guiIO->setUpdateEachTrack(false);
402  //Values for hits assigned to tracks
403  guiIO->setMarkedHitSize(.3);
404  guiIO->setMarkedHitColor(2);
405  guiIO->setMarkedHitStyle(3);
406  }
407  cout <<"\n --- Done setting up StiIOBroker --- \n"<<endl;
408 
409  // WriteOut StEvent
410  if (wrStEOut) {
411  cout << "!!!! doEvents: will write out .event.root file !!" << endl << endl;
412  StTreeMaker *outMk = new StTreeMaker("EvOut","","bfcTree");
413  outMk->SetIOMode("w");
414  outMk->SetBranch("eventBranch","test.event.root","w");
415  outMk->IntoBranch("eventBranch","StEvent");
416  }
417 
418  StMiniMcMaker* minimcMaker = 0;
419  if (simulated) {
420  assocMakerIt = new StAssociationMaker();
421  if(associateStiTrack) assocMakerIt->useInTracker();
422  assocMakerIt->SetDebug();
423 
424  minimcMaker = new StMiniMcMaker;
425  minimcMaker->setDebug();
426  minimcMaker->setOutDir("./");
427  minimcMaker->setFileName(fileName);
428  }
429  //} // mlm (9/27/02 (these were after the simulated catch?)
430  //StMiniMcMaker* minimcMaker = new StMiniMcMaker;
431  //minimcMaker->setDebug();
432  //minimcMaker->setOutDir("./");
433  //minimcMaker->setFileName(fileName);
434 
435  // Initialize chain
436  chain->PrintInfo();
437  Int_t iInit = chain->Init();
438  if (iInit) chain->Fatal(iInit,"on init");
439  chain->InitRun(theRunNumber);
440 
441  // Event loop
442  int i=firstEvtIndex;
443  int iLast=firstEvtIndex+nevents;
444  int istat;
445  while (i < iLast && istat!=2)
446  {
447  cout << "============= Event " <<i<< " started =============" << endl;
448  chain->Clear();
449  try
450  {
451  istat =chain->Make(i);
452  switch(istat)
453  {
454  case 2: cout << "Event completed with Status = 2" << endl; break;
455  case 3: cout << "Event completed with error Status = 3" << endl; break;
456  }
457  i++;
458  }
459  catch (runtime_error & rte)
460  {
461  cout << "TestEvalIT.C - ERROR -" << rte.what() << endl;
462  }
463  catch (exception & eee)
464  {
465  cout << "TestEvalIT.C - ERROR -" << eee.what() << endl;
466  }
467  catch (...)
468  {
469  cout << " TestEvalIT.C - ERROR - Unknown exception"<<endl;
470  }
471  }
472  //chain->Finish();
473  cout << "\n=============== Event "<<i<< " finished ============" << endl;
474 }
475 
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