FairRoot/PandaRoot
PndFTSCounters.h
Go to the documentation of this file.
1 
6 #ifndef PNDFTSCounters_H
7 #define PNDFTSCounters_H
8 
9 #include "Counters.h"
10 #include "PndFTSCAParameters.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 ~PndFTSEfficiencies(){};
41  virtual void AddCounter(string shortname, string name){
42  TEfficiencies::AddCounter(shortname, name);
48  clone.AddCounter();
51  }
52 
55  killed += a.killed; clone += a.clone;
58  return *this;
59  }
60 
61  void CalcEff(){
66  ratio_length = reco_length/allReco;
67  ratio_fakes = reco_fakes/allReco;
68  }
69 
70  void Inc(bool isReco, bool isKilled, double _ratio_length, double _ratio_fakes, int _nclones, string name){
71  TEfficiencies::Inc(isReco, name);
72 
73  const int index = indices[name];
74 
75  if (isKilled) killed.counters[index]++;
76  reco_length.counters[index] += _ratio_length;
77  reco_fakes.counters[index] += _ratio_fakes;
78  clone.counters[index] += _nclones;
79  }
80 
81  void Print(){
82 
83  //save original cout flags
84  std::ios_base::fmtflags coutFlags = cout.flags();
85  std::cout.setf(ios::fixed);
86  std::cout.setf(ios::showpoint);
87  std::cout.precision(3);
88  std::cout << "Track category : " << " Eff "
89  //<<" / "<< "Killed"
90  <<" / "<< "Length" <<" / "<< "Fakes " <<" / "<< "Clones" <<" / "<< "All Reco" <<" | "<< "All MC" << std::endl;
91 
92  int NCounters = mc.NCounters;
93  for (int iC = 0; iC < NCounters; iC++){
94  if (( names[iC] != "D0 efficiency") || (mc.counters[iC] != 0))
95  std::cout << names[iC] << " : "
96  << ratio_reco.counters[iC]
97  //<< " / " << ratio_killed.counters[iC] // tracks with aren't reco because other tracks takes their hit(-s)
98  << " / " << ratio_length.counters[iC] // nRecoMCHits/nMCHits
99  << " / " << ratio_fakes.counters[iC] // nFakeHits/nRecoAllHits
100  << " / " << ratio_clone.counters[iC] // nCloneTracks/nMCTracks
101  << " / " << double(reco.counters[iC])/double(nEvents)
102  << " | " << double(mc.counters[iC])/double(nEvents) << std::endl;
103  }
104  std::cout << "Ghost probability : " << ratio_ghosts <<" | "<< double(ghosts)/double(nEvents) << std::endl;
105  std::cout << "All reco tracks/ev : " << int(double(reco.counters[indices["total"]])/double(nEvents)+.5) << endl;
106 
107  //restore original cout flags
108  cout.flags(coutFlags);
109  }
110 
115 
120 };
121 
124  public:
126  set = 0;
127  isReconstructable = 0;
128  };
129 
130  void SetSet(int set_){ set = set_; }
132  void AddReconstructed(int itr = 0){ recoTrackIds.push_back(itr); }
133 
134  int GetSet(){ return set; }
136  bool IsReconstructed(){ return recoTrackIds.size() >= 1; }
137  bool GetNClones(){ return (recoTrackIds.size() > 1) ? recoTrackIds.size() - 1 : 0; }
138 
139  const std::vector<int>& RecoTrackIds() const { return recoTrackIds; }
140  void Print(){ cout << "Set: " << set << " RecoAble: " << isReconstructable << " NReco: " << recoTrackIds.size() << endl; }
141  private:
142  int set; // set of tracks 0-OutSet, 1-ExtraSet, 2-RefSet, 3-ExtraSecSet, 4-ExtraPrimSet, 5-RefSecSet, 6-RefPrimSet, 7-LongRefPrimSet
144 
145  std::vector<int> recoTrackIds;
146 };
147 
150  public:
152  mcTrackId = -1;
153  };
154 
155  void SetMCTrack(int mcTrackId_, float purity_, int nHits_){
156  mcTrackId = mcTrackId_;
157  purity = purity_;
158  nHits = nHits_;
159  }
160 
161  int GetMCTrackId(){ return mcTrackId; }
162  float GetPurity(){ return purity; }
163  bool IsGhost( float minPurity = 0) { return (mcTrackId == -1) || (purity < minPurity); }
164  bool IsReco( float minPurity = 0, int minNHits = 0) { return (mcTrackId != -1) && (purity >= minPurity) && (nHits >= minNHits); }
165  int NHits(){ return nHits; }
166 
167  void Print(){ cout << "Track: " << mcTrackId << " Purity: " << purity << endl; }
168  private:
170  float purity;
171  int nHits;
172 };
173 
174 
175 #endif
PndFTSEfficiencies & operator+=(PndFTSEfficiencies &a)
virtual void AddCounter(string shortname, string name)
TTracksCatCounters< int > clone
void Inc(bool isReco, bool isKilled, double _ratio_length, double _ratio_fakes, int _nclones, string name)
PndTransMap * map
Definition: sim_emc_apd.C:99
virtual ~PndFTSEfficiencies()
TTracksCatCounters< int > killed
std::vector< int > recoTrackIds
TTracksCatCounters< double > ratio_killed
const std::vector< int > & RecoTrackIds() const
TTracksCatCounters< double > ratio_clone
Int_t a
Definition: anaLmdDigi.C:126
void Inc(bool isReco, string name)
map< string, int > indices
TTracksCatCounters< double > ratio_reco
Information about reconstruction of Reconstructed Track.
TTracksCatCounters< double > ratio_length
TTracksCatCounters< double > reco_fakes
TString name
TTracksCatCounters< int > mc
vector< string > names
TTracksCatCounters< int > reco
TTracksCatCounters< double > reco_length
bool IsReco(float minPurity=0, int minNHits=0)
bool IsGhost(float minPurity=0)
Information about reconstruction of MCTrack.
void SetMCTrack(int mcTrackId_, float purity_, int nHits_)
TTracksCatCounters< double > ratio_fakes
TEfficiencies & operator+=(TEfficiencies &a)
virtual void AddCounter(string shortname, string name)