FairRoot/PandaRoot
PndCACounters.h
Go to the documentation of this file.
1 
6 #ifndef PNDCACOUNTERS_H
7 #define PNDCACOUNTERS_H
8 
9 #include "PndCACountersBase.h"
10 #include "PndCAParameters.h"
11 
12 #include <iostream>
13 using std::cout;
14 using std::endl;
15 using std::ios;
16 
17 #include <string>
18 using std::string;
19 
20 #include <vector>
21 using std::vector;
22 
23 #include <map>
24 using std::map;
25 
27 {
29 
30  AddCounter("ref_prim_long" ,"LRefPrim efficiency");
31  AddCounter("ref_prim" ,"RefPrim efficiency");
32  AddCounter("ref_sec" ,"RefSec efficiency");
33  AddCounter("ref" ,"Refset efficiency");
34  AddCounter("extra_prim" ,"ExtraPrim efficiency");
35  AddCounter("extra_sec" ,"ExtraSec efficiency");
36  AddCounter("extra" ,"Extra efficiency");
37  AddCounter("total" ,"Allset efficiency");
38  AddCounter("rest" ,"Rest efficiency");
39  }
40  virtual ~PndCAEfficiencies(){};
41 
42  virtual void AddCounter(string shortname, string name){
43  TEfficiencies::AddCounter(shortname, name);
49  clone.AddCounter();
52  }
53 
56  killed += a.killed; clone += a.clone;
59  return *this;
60  }
61 
62  void CalcEff(){
67  ratio_length = reco_length/allReco;
68  ratio_fakes = reco_fakes/allReco;
69  }
70 
71  void Inc(bool isReco, bool isKilled, double _ratio_length, double _ratio_fakes, int _nclones, string name){
72  TEfficiencies::Inc(isReco, name);
73 
74  const int index = indices[name];
75 
76  if (isKilled) killed.counters[index]++;
77  reco_length.counters[index] += _ratio_length;
78  reco_fakes.counters[index] += _ratio_fakes;
79  clone.counters[index] += _nclones;
80  }
81 
82  void Print(){
83  std::cout.setf(ios::fixed);
84  std::cout.setf(ios::showpoint);
85  std::cout.precision(3);
86  std::cout << "Track category : " << " Eff "
87  //<<" / "<< "Killed"
88  <<" / "<< "Length" <<" / "<< "Fakes " <<" / "<< "Clones" <<" / "<< "All Reco" <<" | "<< "All MC" << std::endl;
89 
90  int NCounters = mc.NCounters;
91  for (int iC = 0; iC < NCounters; iC++){
92  if (( names[iC] != "D0 efficiency") || (mc.counters[iC] != 0))
93  std::cout << names[iC] << " : "
94  << ratio_reco.counters[iC]
95  //<< " / " << ratio_killed.counters[iC] // tracks with aren't reco because other tracks takes their hit(-s)
96  << " / " << ratio_length.counters[iC] // nRecoMCHits/nMCHits
97  << " / " << ratio_fakes.counters[iC] // nFakeHits/nRecoAllHits
98  << " / " << ratio_clone.counters[iC] // nCloneTracks/nMCTracks
99  << " / " << double(reco.counters[iC])/double(nEvents)
100  << " | " << double(mc.counters[iC])/double(nEvents) << std::endl;
101  }
102  std::cout << "Ghost probability : " << ratio_ghosts <<" | "<< double(ghosts)/double(nEvents) << std::endl;
103  std::cout << "All reco tracks/ev : " << int(double(reco.counters[indices["total"]])/double(nEvents)+.5) << endl;
104  }
105 
110 
115 };
116 
119  public:
121  set = 0;
122  isReconstructable = 0;
123  };
124 
125  void SetSet(int set_){ set = set_; }
127  void AddReconstructed(int itr = 0){ recoTrackIds.push_back(itr); }
128 
129  int GetSet(){ return set; }
131  bool IsReconstructed(){ return recoTrackIds.size() >= 1; }
132  bool GetNClones(){ return (recoTrackIds.size() > 1) ? recoTrackIds.size() - 1 : 0; }
133 
134  const std::vector<int>& RecoTrackIds() const { return recoTrackIds; }
135  void Print(){ cout << "Set: " << set << " RecoAble: " << isReconstructable << " NReco: " << recoTrackIds.size() << endl; }
136  private:
137  int set; // set of tracks 0-OutSet, 1-ExtraSet, 2-RefSet, 3-ExtraSecSet, 4-ExtraPrimSet, 5-RefSecSet, 6-RefPrimSet, 7-LongRefPrimSet
139 
140  std::vector<int> recoTrackIds;
141 };
142 
145  public:
147  mcTrackId = -1;
148  };
149 
150  void SetMCTrack(int mcTrackId_, float purity_, int nHits_){
151  mcTrackId = mcTrackId_;
152  purity = purity_;
153  nHits = nHits_;
154  }
155 
156  int GetMCTrackId(){ return mcTrackId; }
157  float GetPurity(){ return purity; }
158  bool IsGhost( float minPurity = 0) { return (mcTrackId == -1) || (purity < minPurity); }
159  bool IsReco( float minPurity = 0, int minNHits = 0) { return (mcTrackId != -1) && (purity >= minPurity) && (nHits >= minNHits); }
160  int NHits(){ return nHits; }
161 
162  void Print(){ cout << "Track: " << mcTrackId << " Purity: " << purity << endl; }
163  private:
165  float purity;
166  int nHits;
167 };
168 
169 
170 #endif
TTracksCatCounters< double > ratio_clone
std::vector< int > recoTrackIds
PndTransMap * map
Definition: sim_emc_apd.C:99
virtual void AddCounter(string shortname, string name)
Definition: PndCACounters.h:42
TTracksCatCounters< double > ratio_killed
void Inc(bool isReco, bool isKilled, double _ratio_length, double _ratio_fakes, int _nclones, string name)
Definition: PndCACounters.h:71
void SetMCTrack(int mcTrackId_, float purity_, int nHits_)
bool IsReco(float minPurity=0, int minNHits=0)
TTracksCatCounters< double > ratio_fakes
TTracksCatCounters< int > clone
virtual ~PndCAEfficiencies()
Definition: PndCACounters.h:40
TTracksCatCounters< double > reco_length
Int_t a
Definition: anaLmdDigi.C:126
void AddReconstructed(int itr=0)
void Inc(bool isReco, string name)
Information about reconstruction of MCTrack.
map< string, int > indices
TTracksCatCounters< double > ratio_reco
TTracksCatCounters< double > ratio_length
TString name
bool IsGhost(float minPurity=0)
PndCAEfficiencies & operator+=(PndCAEfficiencies &a)
Definition: PndCACounters.h:54
Information about reconstruction of Reconstructed Track.
TTracksCatCounters< int > mc
vector< string > names
TTracksCatCounters< int > reco
TTracksCatCounters< int > killed
const std::vector< int > & RecoTrackIds() const
TEfficiencies & operator+=(TEfficiencies &a)
TTracksCatCounters< double > reco_fakes
virtual void AddCounter(string shortname, string name)