CbmRoot
Loading...
Searching...
No Matches
CbmEbEventEfficiencies.h
Go to the documentation of this file.
1/* Copyright (C) 2017 IKF-UFra, GSI
2 SPDX-License-Identifier: GPL-3.0-only
3 Authors: Valentina Akishina , Maksym Zyzak, Valentina Akishina [committer] */
4
10#include "CbmL1Counters.h"
11
12#include <cstring>
13#include <iostream>
14#include <vector>
15
17 public:
19 : names()
20 , indices()
21 , ratio_reco()
22 , ratio_ghosts(0)
23 , mc()
24 , reco()
25 , ghosts(0)
26 , nEvents(0)
27 , ratio_clone()
28 , clone()
29 {
30 AddCounter("reconstructable", "Reconstructable tracks ");
31 AddCounter("reconstructed", "Reconstructed tracks ");
32 }
33
35
36 void AddCounter(std::string shortname, std::string name)
37 {
38 indices[shortname] = names.size();
39 names.push_back(name);
40
42 mc.AddCounter();
46 }
47
49 {
50 mc += a.mc;
51 reco += a.reco;
52 clone += a.clone;
53 ghosts += a.ghosts;
54 nEvents += a.nEvents;
55 return *this;
56 }
57
58 void CalcEff()
59 {
60 ratio_reco = reco / mc;
61 const double total = reco.counters[indices["reconstructed"]] + ghosts + clone.counters[indices["reconstructed"]];
62 if (total > 0)
63 ratio_ghosts = ghosts / total;
64 else
65 ratio_ghosts = -1;
67 }
68
69
70 void Inc(bool isReco, int _nclones, std::string name)
71 {
72 const int index = indices[name];
73 mc.counters[index]++;
74 if (isReco) reco.counters[index]++;
75 clone.counters[index] += _nclones;
76 }
77
78 void IncNEvents() { nEvents++; };
79
80 void AddGhost(int i) { ghosts += i; }
81
82 void PrintEff()
83 {
84
85 std::cout.setf(std::ios::fixed);
86 std::cout.setf(std::ios::showpoint);
87 std::cout.precision(3);
88 std::cout << "Event category normalised to: "
89 << " Eff "
90 << " / "
91 << "Clones"
92 << " / "
93 << "All Reco"
94 << " | "
95 << "All MC" << std::endl;
96
97 int NCounters = mc.GetNcounters();
98 for (int iC = 0; iC < NCounters; iC++) {
99 std::cout << names[iC] << " : " << ratio_reco.counters[iC] << " / "
100 << ratio_clone.counters[iC] // nCloneTracks/nMCTracks
101 << " / " << std::setw(8) << reco.counters[iC] / double(nEvents) << " | " << std::setw(8)
102 << mc.counters[iC] / double(nEvents) << std::endl;
103 }
104 std::cout << "Ghost probability : " << ratio_ghosts << " | " << ghosts << std::endl;
105 }
106
107 private:
108 std::vector<std::string> names; // names counters indexed by index of counter
109 std::map<std::string, int> indices; // indices of counters indexed by a counter shortname
110
113
118
121};
TL1TracksCatCounters< int > clone
TL1TracksCatCounters< int > reco
void Inc(bool isReco, int _nclones, std::string name)
CbmEbEventEfficiencies & operator+=(CbmEbEventEfficiencies &a)
TL1TracksCatCounters< int > mc
TL1TracksCatCounters< double > ratio_clone
void AddCounter(std::string shortname, std::string name)
std::vector< std::string > names
TL1TracksCatCounters< double > ratio_reco
std::map< std::string, int > indices
counters used for efficiency calculation
int GetNcounters() const
cacore::Vector< T > counters