FairRoot/PandaRoot
Functions
QAmacro_gem_2.C File Reference
#include "../auxi.C"

Go to the source code of this file.

Functions

int QAmacro_gem_2 ()
 

Function Documentation

int QAmacro_gem_2 ( )

Definition at line 2 of file QAmacro_gem_2.C.

References allDigiFile, Bool_t, CloseGeoManager(), Double_t, fRun, Geane, gemDigitize, gemFindHits, MCFile, outFile, parFile, parInput1, parIo1, recoKalman, rtdb, PndGemTrackFinderOnHits::SetPrimary(), PndRecoKalmanTask::SetTrackInBranchName(), PndRecoKalmanTask::SetTrackOutBranchName(), PndGemFindTracks::SetUseHitOrDigi(), PndGemTrackFinderQA::SetVerbose(), PndGemTrackFinderOnHits::SetVerbose(), sysFile, TString, PndGemFindTracks::UseFinder(), and verboseLevel.

3 {
4  Int_t verboseLevel = 0;
5 
6  // ---- Load libraries -------------------------------------------------
7  TString sysFile = gSystem->Getenv("VMCWORKDIR");
8 
9  //FileNames
10  TString MCFile = "tstQA.points.root";
11  TString parFile = "tstQA.param.root";
12  TString outFile = "tstQA.reco.root";
13 
14  // ----- Reconstruction run -------------------------------------------
15  FairRunAna *fRun= new FairRunAna();
16  fRun->SetInputFile(MCFile);
17  fRun->SetOutputFile(outFile);
18 
19  // ----- Parameter database --------------------------------------------
20  TString allDigiFile = sysFile+"/macro/params/all.par";
21 
22  FairRuntimeDb* rtdb = fRun->GetRuntimeDb();
23  FairParRootFileIo* parInput1 = new FairParRootFileIo();
24  parInput1->open(parFile.Data());
25 
26  FairParAsciiFileIo* parIo1 = new FairParAsciiFileIo();
27  parIo1->open(allDigiFile.Data(),"in");
28 
29  rtdb->setFirstInput(parInput1);
30  rtdb->setSecondInput(parIo1);
31  // ------------------------------------------------------------------------
32 
33  // ----- Digitizer and Hit Finder -------------------------------------
34  PndGemDigitize* gemDigitize = new PndGemDigitize("GEM Digitizer", verboseLevel);
35  fRun->AddTask(gemDigitize);
36 
37  PndGemFindHits* gemFindHits = new PndGemFindHits("GEM Hit Finder", verboseLevel);
38  fRun->AddTask(gemFindHits);
39 
40  //------ Track finder ------------------------------
41  //Create and add finder task
42  PndGemFindTracks* finderTask = new PndGemFindTracks("PndGemFindTracks");
43  finderTask->SetUseHitOrDigi("hit"); // hit = (default), digi
44  fRun->AddTask(finderTask);
45 
46  //------ Realistic Track finder --------------------
47  PndGemTrackFinderOnHits* mcTrackFinder = new PndGemTrackFinderOnHits();
48  mcTrackFinder->SetVerbose(verboseLevel); // verbosity level
49  mcTrackFinder->SetPrimary(0); // 1 = Only primary tracks are processed, 0 = all (default)
50  finderTask->UseFinder(mcTrackFinder);
51  //--------------------------------------------------
52 
53  // ----- Prepare GEANE --------------------------------------------
54  // this will load Geant3 and execute setup macros to initialize geometry:
55  FairGeane *Geane = new FairGeane();
56  fRun->AddTask(Geane);
57  //--------------------------------------------------
58 
59  // ----- Run Kalman fitter --------------------------------------------
61  recoKalman->SetTrackInBranchName("GEMTrack");
62  recoKalman->SetTrackOutBranchName("GEMFitTrack");
63  //recoKalman->SetNumIterations(3);
64  fRun->AddTask(recoKalman);
65  // -------------------------------------------------
66 
67  // ----- Run Track finder QA --------------------------------------------
68  PndGemTrackFinderQA* trackFinderQA = new PndGemTrackFinderQA();
69  trackFinderQA->SetVerbose(verboseLevel);
70  fRun->AddTask(trackFinderQA);
71  // -------------------------------------------------
72 
73  // ----- Intialise and run --------------------------------------------
74  fRun->Init();
75  fRun->Run(0,100);
76 
77  //============================================================================
78  cout << endl;
79  cout << "=====================================================================" << endl;
80  cout << "Trying to read histograms..." << flush;
81 
82  TH1F* fhMCPrimVsP = (TH1F*)gDirectory->Get("GemTrackFinderQA/hMCPrimVsP");
83  TH1F* fhRecoPrimVsP = (TH1F*)gDirectory->Get("GemTrackFinderQA/hRecoPrimVsP");
84  TH1F* fhRecoPrimP = (TH1F*)gDirectory->Get("GemTrackFinderQA/hRecoPrimP");
85  TH1F* fhNofHitsPT = (TH1F*)gDirectory->Get("GemTrackFinderQA/hNofHitsPerTrack");
86 
87  Double_t minEfficiency = 80.;
88  Double_t minQuality = 1./1.2;
89  Double_t maxQuality = 1./minQuality;
90  Double_t maxResolution = 5.;
91 
92  Bool_t fTest = kFALSE;
93 
94  if ( fhMCPrimVsP && fhRecoPrimVsP && fhRecoPrimP ) {
95  cout << " DONE" << endl;
96  Int_t fNofMCPrim = fhMCPrimVsP ->Integral();
97  Int_t fNofRecoPrim = fhRecoPrimVsP->Integral();
98  Int_t fNofRecoTracks = fhNofHitsPT ->Integral();
99  Double_t effPrim = 0.;
100  if ( fNofMCPrim ) effPrim = 100.*(Double_t)fNofRecoPrim/((Double_t)fNofMCPrim);
101  cout << " Simulated / Reconstructed:" << endl;
102  cout << " quantity : " << fNofMCPrim << " / " << fNofRecoPrim << " >>>> " << effPrim << "%" << endl;
103  Double_t mcMomenta = fhRecoPrimVsP->GetMean();
104  Double_t recoMomenta = fhRecoPrimP ->GetMean();
105  Double_t momQuality = 0.;
106  if ( recoMomenta != 0. ) momQuality = mcMomenta/recoMomenta;
107  cout << " quality : " << mcMomenta << " / " << recoMomenta << " >>>> " << momQuality << "" << endl;
108 
109  Double_t recoMomRMS = fhRecoPrimP ->GetRMS();
110  Double_t momResolution = 0.;
111  if ( mcMomenta != 0. ) momResolution = recoMomRMS/mcMomenta*100.;
112  cout << " resolution: >>>> " << momResolution << "%" << endl;
113 
114  if ( effPrim > minEfficiency &&
115  momQuality > minQuality &&
116  momQuality < maxQuality &&
117  momResolution < maxResolution )
118  fTest = kTRUE;
119 
120  // in case can't match reco tracks to mc tracks
121  if ( !fTest && fNofRecoTracks > fNofMCPrim*minEfficiency/100. ) {
122  cout << "=====================================================================" << endl;
123  cout << "Reconstructed tracks do not match MC tracks, but there are enough of them" << endl;
124  fTest = kTRUE;
125  }
126  }
127  else
128  cout << " FAILED" << endl;
129  cout << "=====================================================================" << endl;
130 
131  //============================================================================
132 
133  if (fTest){
134  cout << " Test passed" << endl;
135  cout << " All ok " << endl;
136  }else{
137  cout << " Test Failed" << endl;
138  cout << " Not Ok " << endl;
139  }
140 
141  CloseGeoManager();
142  return 0;
143 
144 }
PndGemFindHits * gemFindHits
void SetPrimary(const Int_t &primary)
int verboseLevel
Definition: Lars/runMvdSim.C:7
TString outFile
Definition: hit_dirc.C:17
OnHits track finding algorithm.
void UseFinder(PndGemTrackFinder *finder)
TString allDigiFile
Definition: hit_muo.C:36
void SetTrackOutBranchName(const TString &name)
void CloseGeoManager()
Definition: QA/auxi.C:11
FairGeane * Geane
FairRunAna * fRun
Definition: hit_dirc.C:58
void SetVerbose(const Int_t &verbose)
TString sysFile
Double_t
TString parFile
Definition: hit_dirc.C:14
FairRuntimeDb * rtdb
Definition: hit_dirc.C:66
void SetVerbose(const Int_t &verbose)
FairParRootFileIo * parInput1
Definition: hit_dirc.C:67
PndGemDigitize * gemDigitize
FairParAsciiFileIo * parIo1
Definition: bump_emc.C:53
void SetTrackInBranchName(const TString &name)
TString MCFile
PndRecoKalmanTask * recoKalman
track finding quality assesment task
Task class for track finding in the Gem.
void SetUseHitOrDigi(TString useHitOrDigi="hit")