00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058
00059
00060
00061
00062
00063
00064
00065
00066
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082 #include <iostream>
00083 #include <stdexcept>
00084 Bool_t doProfile = false;
00085 Int_t usePath = 0;
00086 Int_t nFile = 0;
00087 TString thePath;
00088 TString theFileName;
00089 TString originalPath;
00090 class StChain;
00091 StChain *chain=0;
00092 class StEventDisplayMaker;
00093 StEventDisplayMaker *dsMaker = 0;
00094 TBrowser *b=0;
00095
00096 const char *dstFile = 0;
00097 const char *xdfFile = 0;
00098 const char *mdcFile = 0;
00099 const char *fileList[] = {dstFile,xdfFile,mdcFile,0};
00100
00101 void Help()
00102 {
00103 cout << "Usage: TestEvalIT.C(firstEvtIndex,nevents,\"-\",\"some_directory/some_dst_file.xdf\")" << endl;
00104 cout << " TestEvalIT.C(firstEvtIndex,nevents,\"-\",\"some_directory/some_dst_file.root\")" << endl;
00105 cout << " TestEvalIT.C(firstEvtIndex,nevents,\"some_directory\",\"*.dst.root\")" << endl;
00106 }
00107
00108 void loadLibrairies(bool doProfile)
00109 {
00110 cout<<"Loading modules:"<<endl;
00111 gSystem->Load("St_base");
00112 gSystem->Load("StChain");
00113 gSystem->Load("StUtilities");
00114 gSystem->Load("StBFChain");
00115 gSystem->Load("St_Tables");
00116
00117 gSystem->Load("libgen_Tables");
00118 gSystem->Load("libsim_Tables");
00119 gSystem->Load("libglobal_Tables");
00120 gSystem->Load("geometry");
00121 gSystem->Load("St_g2t");
00122 gSystem->Load("St_geant_Maker");
00123 gSystem->Load("StIOMaker");
00124 gSystem->Load("StTreeMaker");
00125 gSystem->Load("StarClassLibrary");
00126 gSystem->Load("St_db_Maker");
00127 gSystem->Load("StDbLib");
00128 gSystem->Load("StDbBroker");
00129 gSystem->Load("StSvtDbMaker");
00130 gSystem->Load("StDbUtilities");
00131 gSystem->Load("StTpcDb");
00132 gSystem->Load("StEvent");
00133 gSystem->Load("StEventMaker");
00134 gSystem->Load("StEmcUtil");
00135 gSystem->Load("StMcEvent");
00136 gSystem->Load("StMcEventMaker");
00137 gSystem->Load("StAssociationMaker");
00138 gSystem->Load("StDaqLib");
00139 gSystem->Load("StDAQMaker");
00140 gSystem->Load("StDetectorDbMaker");
00141 gSystem->Load("StSvtClassLibrary");
00142 gSystem->Load("StSvtDaqMaker");
00143 gSystem->Load("StSvtSimulationMaker");
00144 gSystem->Load("StSvtCalibMaker");
00145 gSystem->Load("StSvtSeqAdjMaker");
00146
00147 gSystem->Load("StSvtClusterMaker");
00148
00149 cout <<"/Sti" << endl; gSystem->Load("Sti");
00150 cout <<"/StiGui"<< endl; gSystem->Load("StiGui");
00151 cout <<"/StiEvaluator"<< endl; gSystem->Load("StiEvaluator");
00152 cout <<"/libGui"<< endl; gSystem->Load("libGui");
00153 cout <<"/StiMaker"<< endl; gSystem->Load("StiMaker");
00154 cout <<"/StMiniMcEvent"<< endl; gSystem->Load("StMiniMcEvent");
00155 cout <<"/StMiniMcMaker"<< endl; gSystem->Load("StMiniMcMaker");
00156
00157 if(doProfile)
00158 {
00159 cout <<"/Jprof";
00160 gSystem->Setenv("JPROF_FLAGS", "JP_START JP_PERIOD=0.001");
00161 gSystem->Load("libJprof");
00162 }
00163 cout <<"\nDone.";
00164 }
00165
00166 void TestEvalIT(Int_t firstEvtIndex=0,
00167 Int_t nevents=1,
00168
00169
00170 const Char_t* path = "/star/data22/ITTF/EvalData/MCFiles/auau200/",
00171 const Char_t* file="rcf0183_12_300evts.geant.root",
00172 const Char_t *qaflag = "off",
00173 const Int_t wrStEOut = 0,
00174 const int associateStiTrack=1,
00175 const char* filePrefix = "rcf")
00176 {
00177 if (nevents==-1)
00178 {
00179 Help();
00180 return;
00181 }
00182 const char *fileListQQ[]={0,0};
00183 if (strncmp(path,"GC",2)==0)
00184 fileListQQ=0;
00185 else if (path[0]=='-')
00186 fileListQQ[0]=file;
00187 else if (!file[0])
00188 fileListQQ[0]=path;
00189 else
00190 fileListQQ[0] = gSystem->ConcatFileName(path,file);
00191 TestEvalIT(firstEvtIndex, nevents,fileListQQ,qaflag,wrStEOut,associateStiTrack,filePrefix);
00192 }
00193
00194
00195
00196
00197 void TestEvalIT(Int_t firstEvtIndex,
00198 Int_t nevents,
00199 const Char_t **fileList,
00200 const Char_t *qaflag,
00201 const Int_t wrStEOut,
00202 const int associateStiTrack,
00203 const char* filePrefix)
00204 {
00205 Int_t theRunNumber=0;
00206 bool simulated = true;
00207 bool doFit = false;
00208 bool optimized = false;
00209 bool doProfile = false;
00210 char* outfile = "Evaluation.root";
00211
00212 cout << endl << endl <<" TestEvalIT - input # events = " << nevents << endl;
00213 Int_t ilist=0;
00214 while(fileList[ilist]){
00215 cout << " TestEvalIT - input fileList = " << fileList[ilist] << endl;
00216 ilist++;
00217 }
00218 cout << " TestEvalIT - input qaflag = " << qaflag << endl;
00219 cout << " TestEvalIT - input wrStEOut = " << wrStEOut << endl;
00220 cout << " TestEvalIT - file Prefix = " << filePrefix << endl << endl;
00221
00222
00223 TString fileName = "EvalItTest";
00224 TString MainFile = fileList[0];
00225 int fileBeginIndex = MainFile.Index(filePrefix,0);
00226 MainFile.Remove(0,fileBeginIndex);
00227 fileName.Append(MainFile);
00228 cout << "Output MiniMcTree : " << fileName << endl;
00229
00230 loadLibrairies(doProfile);
00231
00232
00233
00234 chain = new StChain("StChain");
00235
00236 StFileI *setFiles =0;
00237 if (fileList) {
00238 setFiles= new StFile(fileList);
00239 } else {
00240 gSystem->Load("StChallenger");
00241 setFiles = StChallenger::Challenge();
00242 setFiles->SetDebug();
00243 const char *Argv[]= {
00244 "-s","daq",
00245 "-q","mRunNumber=1228023",
00246 "-c","/afs/rhic.bnl.gov/star/incoming/GCA/daq/stacs.rc"
00247 };
00248 Int_t Argc=sizeof(Argv)/4;
00249 setFiles->Init(Argc,Argv);
00250 }
00251
00252 StIOMaker *IOMk = new StIOMaker("IO","r",setFiles);
00253 IOMk->SetBranch("*",0,"0");
00254
00255
00256 IOMk->SetBranch("eventBranch",0,"r");
00257 if (simulated) {
00258 IOMk->SetBranch("geantBranch",0,"r");
00259 }
00260 IOMk->SetDebug();
00261
00262 St_geant_Maker *geantMk = new St_geant_Maker("geant");
00263 geantMk->SetActive(kFALSE);
00264
00265
00266
00267
00268
00269
00270
00271 dbaseMk = new St_db_Maker("db","MySQL:StarDb","$STAR/StarDb");
00272
00273
00274 if (simulated) dbaseMk-> SetDateTime(20010801,000000);
00275
00276
00277 tpcDbMk = new StTpcDbMaker("tpcDb");
00278
00279
00280 svtDbMk = new StSvtDbMaker("svtDb");
00281
00282
00283 detDbMk = new StDetectorDbMaker("detDb");
00284
00285
00286 StMcEventMaker* mcEventReader = 0;
00287
00288 StAssociationMaker* assocMaker = 0;
00289
00290 if (simulated)
00291 {
00292 mcEventReader = new StMcEventMaker();
00293 assocMaker = new StAssociationMaker("EgrStAssociationMaker");
00294 }
00295
00296 StiMaker* anaMk = StiMaker::instance();
00297
00298
00299 cout <<"\n --- Setup StiIOBroker ---\n"<<endl;
00300 StiRootIOBroker* stiIO = anaMk->getIOBroker();
00301 stiIO->setTPHFMinPadrow(1);
00302 stiIO->setTPHFMaxPadrow(45);
00303 stiIO->setETSFLowerBound(5);
00304 stiIO->setETSFMaxHits(6);
00305 stiIO->setDoTrackFit(doFit);
00306
00307
00308
00309 stiIO->setKTFMcsCalculated(false);
00310 stiIO->setKTFElossCalculated(false);
00311 stiIO->setKTFMaxChi2ForSelection(50);
00312 stiIO->setKTFBField(.5);
00313 stiIO->setKTFMassHypothesis(.1395);
00314 stiIO->setKTFMinContiguousHitCount(2);
00315 stiIO->setKTFMaxNullCount(40);
00316 stiIO->setKTFMaxContiguousNullCount(25);
00317 stiIO->setKTFMinSearchRadius(.5);
00318 stiIO->setKTFMaxSearchRadius(4.);
00319 stiIO->setKTFSearchWindowScale(5.);
00320
00321
00322
00323 stiIO->setLTSFZWindow(10.);
00324 stiIO->setLTSFYWindow(4.);
00325 stiIO->setLTSFSeedLength(2);
00326 stiIO->setLTSFDoHelixFit(true);
00327 stiIO->setLTSFExtrapYWindow(1.);
00328 stiIO->setLTSFExtrapZWindow(2.);
00329 stiIO->setLTSFExtrapMaxSkipped(2);
00330 stiIO->setLTSFExtrapMinLength(4);
00331 stiIO->setLTSFExtrapMaxLength(5);
00332 stiIO->setLTSFUseVertex(true);
00333 stiIO->setLTMDeltaR(1.);
00334
00335
00336 for (unsigned int sector=1; sector<=12; ++sector) {
00337 stiIO->addLTSFSector(sector);
00338 }
00339
00340
00341 for (unsigned int padrow=6; padrow<=45; padrow+=1) {
00342 stiIO->addLTSFPadrow(padrow);
00343 }
00344
00345
00346 enum SeedFinderType {kUndefined=0, kComposite=1, kEvaluable=2};
00347
00348
00349 enum FilterType {kPtFilter=0, kEtaFilter=1, kChi2Filter=2, kNptsFilter=3, kNFitPtsFilter=4,
00350 kNGapsFilter=5, kFitPointRatioFilter=6, kPrimaryDcaFilter=7};
00351
00352
00353 stiIO->setSeedFinderType(kComposite);
00354 stiIO->addFilterType(kPtFilter);
00355 stiIO->setFilterPtMin(.1);
00356 stiIO->setFilterPtMax(50.);
00357 stiIO->addFilterType(kEtaFilter);
00358 stiIO->setFilterEtaMin(-2.);
00359 stiIO->setFilterEtaMax(2.);
00360 stiIO->addFilterType(kChi2Filter);
00361 stiIO->setFilterChi2Max(10.);
00362 stiIO->addFilterType(kNptsFilter);
00363 stiIO->setFilterNptsMin(8);
00364 stiIO->addFilterType(kNFitPtsFilter);
00365 stiIO->setFilterNFitPtsMin(5);
00366 stiIO->addFilterType(kNGapsFilter);
00367 stiIO->setFilterNGapsMax(20);
00368
00369
00370 stiIO->addFilterType(kPrimaryDcaFilter);
00371 stiIO->setFilterPrimaryDcaMax(100.);
00372 stiIO->setSimulated(simulated);
00373 anaMk->setEvaluationFileName(outfile);
00374 if (simulated)
00375 {
00376 anaMk->setMcEventMaker(mcEventReader);
00377 anaMk->setAssociationMaker(assocMaker);
00378 }
00379
00380
00381 MainFrame* sti=0;
00382 StiGuiIOBroker* guiIO=0;
00383
00384 if (gROOT->IsBatch()||nevents>1)
00385 {
00386 cout <<"Batch mode selected. Run Integrated Tracker in non-Gui Mode."<<endl;
00387 stiIO->setUseGui(false);
00388 }
00389 else
00390 {
00391 cout <<"Interactive mode selected. Run Integrated Tracker in Gui Mode."<<endl;
00392 sti = new MainFrame(gClient->GetRoot(), 400, 220);
00393 sti->setStChain(chain);
00394 sti->setIoMaker(IOMk);
00395 stiIO->setUseGui(true);
00396 guiIO = StiGuiIOBroker::instance();
00397
00398 guiIO->setUnMarkedHitSize(.3);
00399 guiIO->setUnMarkedHitColor(4);
00400 guiIO->setUnMarkedHitStyle(8);
00401 guiIO->setUpdateEachTrack(false);
00402
00403 guiIO->setMarkedHitSize(.3);
00404 guiIO->setMarkedHitColor(2);
00405 guiIO->setMarkedHitStyle(3);
00406 }
00407 cout <<"\n --- Done setting up StiIOBroker --- \n"<<endl;
00408
00409
00410 if (wrStEOut) {
00411 cout << "!!!! doEvents: will write out .event.root file !!" << endl << endl;
00412 StTreeMaker *outMk = new StTreeMaker("EvOut","","bfcTree");
00413 outMk->SetIOMode("w");
00414 outMk->SetBranch("eventBranch","test.event.root","w");
00415 outMk->IntoBranch("eventBranch","StEvent");
00416 }
00417
00418 StMiniMcMaker* minimcMaker = 0;
00419 if (simulated) {
00420 assocMakerIt = new StAssociationMaker();
00421 if(associateStiTrack) assocMakerIt->useInTracker();
00422 assocMakerIt->SetDebug();
00423
00424 minimcMaker = new StMiniMcMaker;
00425 minimcMaker->setDebug();
00426 minimcMaker->setOutDir("./");
00427 minimcMaker->setFileName(fileName);
00428 }
00429
00430
00431
00432
00433
00434
00435
00436 chain->PrintInfo();
00437 Int_t iInit = chain->Init();
00438 if (iInit) chain->Fatal(iInit,"on init");
00439 chain->InitRun(theRunNumber);
00440
00441
00442 int i=firstEvtIndex;
00443 int iLast=firstEvtIndex+nevents;
00444 int istat;
00445 while (i < iLast && istat!=2)
00446 {
00447 cout << "============= Event " <<i<< " started =============" << endl;
00448 chain->Clear();
00449 try
00450 {
00451 istat =chain->Make(i);
00452 switch(istat)
00453 {
00454 case 2: cout << "Event completed with Status = 2" << endl; break;
00455 case 3: cout << "Event completed with error Status = 3" << endl; break;
00456 }
00457 i++;
00458 }
00459 catch (runtime_error & rte)
00460 {
00461 cout << "TestEvalIT.C - ERROR -" << rte.what() << endl;
00462 }
00463 catch (exception & eee)
00464 {
00465 cout << "TestEvalIT.C - ERROR -" << eee.what() << endl;
00466 }
00467 catch (...)
00468 {
00469 cout << " TestEvalIT.C - ERROR - Unknown exception"<<endl;
00470 }
00471 }
00472
00473 cout << "\n=============== Event "<<i<< " finished ============" << endl;
00474 }
00475