PandaRoot
PndFTSCounters.h
Go to the documentation of this file.
1 
5 #ifndef PNDFTSCounters_H
6 #define PNDFTSCounters_H
7 
8 #include "Counters.h"
9 #include "PndFTSCAParameters.h"
10 
11 #include <iostream>
12 using std::cout;
13 using std::endl;
14 using std::ios;
15 
16 #include <string>
17 using std::string;
18 
19 #include <vector>
20 using std::vector;
21 
22 #include <map>
23 using std::map;
24 
27  {
28 
29  AddCounter("ref_prim_long", "LRefPrim efficiency");
30  AddCounter("ref_prim", "RefPrim efficiency");
31  AddCounter("ref_sec", "RefSec efficiency");
32  AddCounter("ref", "Refset efficiency");
33  AddCounter("extra_prim", "ExtraPrim efficiency");
34  AddCounter("extra_sec", "ExtraSec efficiency");
35  AddCounter("extra", "Extra efficiency");
36  AddCounter("total", "Allset efficiency");
37  AddCounter("rest", "Rest efficiency");
38  }
39  virtual ~PndFTSEfficiencies(){};
40  virtual void AddCounter(string shortname, string name)
41  {
42  TEfficiencies::AddCounter(shortname, name);
48  clone.AddCounter();
51  }
52 
54  {
56  killed += a.killed;
57  clone += a.clone;
60  return *this;
61  }
62 
63  void CalcEff()
64  {
67  ratio_clone = clone / mc;
69  ratio_length = reco_length / allReco;
70  ratio_fakes = reco_fakes / allReco;
71  }
72 
73  void Inc(bool isReco, bool isKilled, double _ratio_length, double _ratio_fakes, int _nclones, string name)
74  {
75  TEfficiencies::Inc(isReco, name);
76 
77  const int index = indices[name];
78 
79  if (isKilled)
80  killed.counters[index]++;
81  reco_length.counters[index] += _ratio_length;
82  reco_fakes.counters[index] += _ratio_fakes;
83  clone.counters[index] += _nclones;
84  }
85 
86  void Print()
87  {
88 
89  // save original cout flags
90  std::ios_base::fmtflags coutFlags = cout.flags();
91  std::cout.setf(ios::fixed);
92  std::cout.setf(ios::showpoint);
93  std::cout.precision(3);
94  std::cout << "Track category : "
95  << " Eff "
96  //<<" / "<< "Killed"
97  << " / "
98  << "Length"
99  << " / "
100  << "Fakes "
101  << " / "
102  << "Clones"
103  << " / "
104  << "All Reco"
105  << " | "
106  << "All MC" << std::endl;
107 
108  int NCounters = mc.NCounters;
109  for (int iC = 0; iC < NCounters; iC++) {
110  if ((names[iC] != "D0 efficiency") || (mc.counters[iC] != 0))
111  std::cout << names[iC] << " : "
112  << ratio_reco.counters[iC]
113  //<< " / " << ratio_killed.counters[iC] // tracks with aren't reco because other tracks takes their hit(-s)
114  << " / " << ratio_length.counters[iC] // nRecoMCHits/nMCHits
115  << " / " << ratio_fakes.counters[iC] // nFakeHits/nRecoAllHits
116  << " / " << ratio_clone.counters[iC] // nCloneTracks/nMCTracks
117  << " / " << double(reco.counters[iC]) / double(nEvents) << " | " << double(mc.counters[iC]) / double(nEvents) << std::endl;
118  }
119  std::cout << "Ghost probability : " << ratio_ghosts << " | " << double(ghosts) / double(nEvents) << std::endl;
120  std::cout << "All reco tracks/ev : " << int(double(reco.counters[indices["total"]]) / double(nEvents) + .5) << endl;
121 
122  // restore original cout flags
123  cout.flags(coutFlags);
124  }
125 
130 
135 };
136 
139  public:
141  {
142  set = 0;
143  isReconstructable = 0;
144  };
145 
146  void SetSet(int set_) { set = set_; }
147  void SetAsReconstructable() { isReconstructable = true; }
148  void AddReconstructed(int itr = 0) { recoTrackIds.push_back(itr); }
149 
150  int GetSet() { return set; }
151  bool IsReconstructable() { return isReconstructable; }
152  bool IsReconstructed() { return recoTrackIds.size() >= 1; }
153  bool GetNClones() { return (recoTrackIds.size() > 1) ? recoTrackIds.size() - 1 : 0; }
154 
155  const std::vector<int> &RecoTrackIds() const { return recoTrackIds; }
156  void Print() { cout << "Set: " << set << " RecoAble: " << isReconstructable << " NReco: " << recoTrackIds.size() << endl; }
157 
158  private:
159  int set; // set of tracks 0-OutSet, 1-ExtraSet, 2-RefSet, 3-ExtraSecSet, 4-ExtraPrimSet, 5-RefSecSet, 6-RefPrimSet, 7-LongRefPrimSet
160  bool isReconstructable;
161 
162  std::vector<int> recoTrackIds;
163 };
164 
167  public:
168  PndFTSCAPerformanceRecoTrackData() { mcTrackId = -1; };
169 
170  void SetMCTrack(int mcTrackId_, float purity_, int nHits_)
171  {
172  mcTrackId = mcTrackId_;
173  purity = purity_;
174  nHits = nHits_;
175  }
176 
177  int GetMCTrackId() { return mcTrackId; }
178  float GetPurity() { return purity; }
179  bool IsGhost(float minPurity = 0) { return (mcTrackId == -1) || (purity < minPurity); }
180  bool IsReco(float minPurity = 0, int minNHits = 0) { return (mcTrackId != -1) && (purity >= minPurity) && (nHits >= minNHits); }
181  int NHits() { return nHits; }
182 
183  void Print() { cout << "Track: " << mcTrackId << " Purity: " << purity << endl; }
184 
185  private:
186  int mcTrackId;
187  float purity;
188  int nHits;
189 };
190 
191 #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)
virtual ~PndFTSEfficiencies()
TTracksCatCounters< int > killed
TTracksCatCounters< double > ratio_killed
TTracksCatCounters< double > ratio_clone
const std::vector< int > & RecoTrackIds() const
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
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)