CbmRoot
CbmEbEventEfficiencies.h
Go to the documentation of this file.
1 
6 #include "CbmL1Counters.h"
7 
8 #include <cstring>
9 #include <iostream>
10 
11 using std::string;
12 
14 public:
16  : names()
17  , indices()
18  , ratio_reco()
19  , ratio_ghosts(0)
20  , mc()
21  , reco()
22  , ghosts(0)
23  , nEvents(0)
24  , ratio_clone()
25  , clone() {
26  AddCounter("reconstructable", "Reconstructable tracks ");
27  AddCounter("reconstructed", "Reconstructed tracks ");
28  }
29 
31 
32  void AddCounter(string shortname, string name) {
33  indices[shortname] = names.size();
34  names.push_back(name);
35 
37  mc.AddCounter();
38  reco.AddCounter();
40  clone.AddCounter();
41  }
42 
44  mc += a.mc;
45  reco += a.reco;
46  clone += a.clone;
47  ghosts += a.ghosts;
48  nEvents += a.nEvents;
49  return *this;
50  }
51 
52  void CalcEff() {
53  ratio_reco = reco / mc;
54  const double total = reco.counters[indices["reconstructed"]] + ghosts
55  + clone.counters[indices["reconstructed"]];
56  if (total > 0)
57  ratio_ghosts = ghosts / total;
58  else
59  ratio_ghosts = -1;
60  ratio_clone = clone / mc;
61  }
62 
63 
64  void Inc(bool isReco, int _nclones, string name) {
65  const int index = indices[name];
66  mc.counters[index]++;
67  if (isReco) reco.counters[index]++;
68  clone.counters[index] += _nclones;
69  }
70 
71  void IncNEvents() { nEvents++; };
72 
73  void AddGhost(int i) { ghosts += i; }
74 
75  void PrintEff() {
76 
77  std::cout.setf(ios::fixed);
78  std::cout.setf(ios::showpoint);
79  std::cout.precision(3);
80  std::cout << "Event category normalised to: "
81  << " Eff "
82  << " / "
83  << "Clones"
84  << " / "
85  << "All Reco"
86  << " | "
87  << "All MC" << std::endl;
88 
89  int NCounters = mc.NCounters;
90  for (int iC = 0; iC < NCounters; iC++) {
91  std::cout << names[iC] << " : " << ratio_reco.counters[iC] << " / "
92  << ratio_clone.counters[iC] // nCloneTracks/nMCTracks
93  << " / " << setw(8) << reco.counters[iC] / double(nEvents)
94  << " | " << setw(8) << mc.counters[iC] / double(nEvents)
95  << std::endl;
96  }
97  std::cout << "Ghost probability : " << ratio_ghosts << " | "
98  << ghosts << std::endl;
99  }
100 
101 private:
102  vector<string> names; // names counters indexed by index of counter
103  map<string, int>
104  indices; // indices of counters indexed by a counter shortname
105 
107  double ratio_ghosts;
108 
111  int ghosts;
112  int nEvents;
113 
116 };
CbmEbEventEfficiencies::AddCounter
void AddCounter(string shortname, string name)
Definition: CbmEbEventEfficiencies.h:32
CbmEbEventEfficiencies::names
vector< string > names
Definition: CbmEbEventEfficiencies.h:102
TL1TracksCatCounters::counters
vector< T > counters
Definition: CbmL1Counters.h:114
CbmEbEventEfficiencies::IncNEvents
void IncNEvents()
Definition: CbmEbEventEfficiencies.h:71
CbmEbEventEfficiencies::mc
TL1TracksCatCounters< int > mc
Definition: CbmEbEventEfficiencies.h:109
i
int i
Definition: L1/vectors/P4_F32vec4.h:25
CbmEbEventEfficiencies::Inc
void Inc(bool isReco, int _nclones, string name)
Definition: CbmEbEventEfficiencies.h:64
TL1TracksCatCounters< double >
CbmEbEventEfficiencies::operator+=
CbmEbEventEfficiencies & operator+=(CbmEbEventEfficiencies &a)
Definition: CbmEbEventEfficiencies.h:43
TL1TracksCatCounters::AddCounter
void AddCounter()
Definition: CbmL1Counters.h:24
CbmEbEventEfficiencies::clone
TL1TracksCatCounters< int > clone
Definition: CbmEbEventEfficiencies.h:115
CbmEbEventEfficiencies::nEvents
int nEvents
Definition: CbmEbEventEfficiencies.h:112
CbmEbEventEfficiencies::ratio_ghosts
double ratio_ghosts
Definition: CbmEbEventEfficiencies.h:107
CbmEbEventEfficiencies::reco
TL1TracksCatCounters< int > reco
Definition: CbmEbEventEfficiencies.h:110
CbmEbEventEfficiencies::CalcEff
void CalcEff()
Definition: CbmEbEventEfficiencies.h:52
CbmEbEventEfficiencies::ratio_reco
TL1TracksCatCounters< double > ratio_reco
Definition: CbmEbEventEfficiencies.h:106
CbmEbEventEfficiencies::~CbmEbEventEfficiencies
~CbmEbEventEfficiencies()
Definition: CbmEbEventEfficiencies.h:30
CbmL1Counters.h
CbmEbEventEfficiencies::AddGhost
void AddGhost(int i)
Definition: CbmEbEventEfficiencies.h:73
CbmEbEventEfficiencies::PrintEff
void PrintEff()
Definition: CbmEbEventEfficiencies.h:75
CbmEbEventEfficiencies::CbmEbEventEfficiencies
CbmEbEventEfficiencies()
Definition: CbmEbEventEfficiencies.h:15
CbmEbEventEfficiencies::ratio_clone
TL1TracksCatCounters< double > ratio_clone
Definition: CbmEbEventEfficiencies.h:114
CbmEbEventEfficiencies
Definition: CbmEbEventEfficiencies.h:13
CbmEbEventEfficiencies::ghosts
int ghosts
Definition: CbmEbEventEfficiencies.h:111
CbmEbEventEfficiencies::indices
map< string, int > indices
Definition: CbmEbEventEfficiencies.h:104
TL1TracksCatCounters::NCounters
int NCounters
Definition: CbmL1Counters.h:110