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