PandaRoot
PndCACounters.h
Go to the documentation of this file.
1 
5 #ifndef PNDCACOUNTERS_H
6 #define PNDCACOUNTERS_H
7 
8 #include "PndCACountersBase.h"
9 #include "PndCAParameters.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 ~PndCAEfficiencies(){};
40 
41  virtual void AddCounter(string shortname, string name)
42  {
43  TEfficiencies::AddCounter(shortname, name);
49  clone.AddCounter();
52  }
53 
55  {
57  killed += a.killed;
58  clone += a.clone;
61  return *this;
62  }
63 
64  void CalcEff()
65  {
68  ratio_clone = clone / mc;
70  ratio_length = reco_length / allReco;
71  ratio_fakes = reco_fakes / allReco;
72  }
73 
74  void Inc(bool isReco, bool isKilled, double _ratio_length, double _ratio_fakes, int _nclones, string name)
75  {
76  TEfficiencies::Inc(isReco, name);
77 
78  const int index = indices[name];
79 
80  if (isKilled)
81  killed.counters[index]++;
82  reco_length.counters[index] += _ratio_length;
83  reco_fakes.counters[index] += _ratio_fakes;
84  clone.counters[index] += _nclones;
85  }
86 
87  void Print()
88  {
89  std::cout.setf(ios::fixed);
90  std::cout.setf(ios::showpoint);
91  std::cout.precision(3);
92  std::cout << "Track category : "
93  << " Eff "
94  //<<" / "<< "Killed"
95  << " / "
96  << "Length"
97  << " / "
98  << "Fakes "
99  << " / "
100  << "Clones"
101  << " / "
102  << "All Reco"
103  << " | "
104  << "All MC" << std::endl;
105 
106  int NCounters = mc.NCounters;
107  for (int iC = 0; iC < NCounters; iC++) {
108  if ((names[iC] != "D0 efficiency") || (mc.counters[iC] != 0))
109  std::cout << names[iC] << " : "
110  << ratio_reco.counters[iC]
111  //<< " / " << ratio_killed.counters[iC] // tracks with aren't reco because other tracks takes their hit(-s)
112  << " / " << ratio_length.counters[iC] // nRecoMCHits/nMCHits
113  << " / " << ratio_fakes.counters[iC] // nFakeHits/nRecoAllHits
114  << " / " << ratio_clone.counters[iC] // nCloneTracks/nMCTracks
115  << " / " << double(reco.counters[iC]) / double(nEvents) << " | " << double(mc.counters[iC]) / double(nEvents) << std::endl;
116  }
117  std::cout << "Ghost probability : " << ratio_ghosts << " | " << double(ghosts) / double(nEvents) << std::endl;
118  std::cout << "All reco tracks/ev : " << int(double(reco.counters[indices["total"]]) / double(nEvents) + .5) << endl;
119  }
120 
125 
130 };
131 
134  public:
136  {
137  set = 0;
138  isReconstructable = 0;
139  };
140 
141  void SetSet(int set_) { set = set_; }
142  void SetAsReconstructable() { isReconstructable = true; }
143  void AddReconstructed(int itr = 0) { recoTrackIds.push_back(itr); }
144 
145  int GetSet() { return set; }
146  bool IsReconstructable() { return isReconstructable; }
147  bool IsReconstructed() { return recoTrackIds.size() >= 1; }
148  bool GetNClones() { return (recoTrackIds.size() > 1) ? recoTrackIds.size() - 1 : 0; }
149 
150  const std::vector<int> &RecoTrackIds() const { return recoTrackIds; }
151  void Print() { cout << "Set: " << set << " RecoAble: " << isReconstructable << " NReco: " << recoTrackIds.size() << endl; }
152 
153  private:
154  int set; // set of tracks 0-OutSet, 1-ExtraSet, 2-RefSet, 3-ExtraSecSet, 4-ExtraPrimSet, 5-RefSecSet, 6-RefPrimSet, 7-LongRefPrimSet
155  bool isReconstructable;
156 
157  std::vector<int> recoTrackIds;
158 };
159 
162  public:
163  PndCAPerformanceRecoTrackData() { mcTrackId = -1; };
164 
165  void SetMCTrack(int mcTrackId_, float purity_, int nHits_)
166  {
167  mcTrackId = mcTrackId_;
168  purity = purity_;
169  nHits = nHits_;
170  }
171 
172  int GetMCTrackId() { return mcTrackId; }
173  float GetPurity() { return purity; }
174  bool IsGhost(float minPurity = 0) { return (mcTrackId == -1) || (purity < minPurity); }
175  bool IsReco(float minPurity = 0, int minNHits = 0) { return (mcTrackId != -1) && (purity >= minPurity) && (nHits >= minNHits); }
176  int NHits() { return nHits; }
177 
178  void Print() { cout << "Track: " << mcTrackId << " Purity: " << purity << endl; }
179 
180  private:
181  int mcTrackId;
182  float purity;
183  int nHits;
184 };
185 
186 #endif
TTracksCatCounters< double > ratio_clone
virtual void AddCounter(string shortname, string name)
Definition: PndCACounters.h:41
TTracksCatCounters< double > ratio_killed
void Inc(bool isReco, bool isKilled, double _ratio_length, double _ratio_fakes, int _nclones, string name)
Definition: PndCACounters.h:74
const std::vector< int > & RecoTrackIds() const
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:39
TTracksCatCounters< double > reco_length
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
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
TEfficiencies & operator+=(TEfficiencies &a)
TTracksCatCounters< double > reco_fakes
virtual void AddCounter(string shortname, string name)