5 #ifndef PNDCACOUNTERSBASE_H 6 #define PNDCACOUNTERSBASE_H 34 TTracksCatCounters(
int nCounters) : NCounters(nCounters), counters() { counters.resize(NCounters, T(0)); };
39 counters.push_back(T(0));
43 NCounters += nCounters;
44 counters.resize(NCounters, T(0));
50 cout <<
" TTracksCatCounters: Error. Addition of counters of different sizes: " << NCounters <<
" " << a.
NCounters << endl;
66 template <
typename T2>
71 cout <<
" TTracksCatCounters: Error. Addition of counters of different sizes: " << NCounters <<
" " << a.
NCounters << endl;
80 template <
typename T2>
85 b.
counters[iC] =
static_cast<T2
>(Div(counters[iC], a));
90 friend std::fstream &operator<<(std::fstream &strm, const TTracksCatCounters<T> &a)
92 strm << a.
NCounters <<
" " << a.counters.size() <<
" ";
93 for (
unsigned int iV = 0; iV < a.counters.size(); iV++)
94 strm << a.counters[iV] <<
" ";
99 friend std::ostream &operator<<(std::ostream &strm, const TTracksCatCounters<T> &a)
101 strm << a.NCounters <<
" " << a.counters.size() <<
" ";
102 for (
unsigned int iV = 0; iV < a.counters.size(); iV++)
103 strm << a.counters[iV] <<
" ";
115 for (
int iV = 0; iV < tmp; iV++) {
124 double Div(
double a,
double b) {
return (b > 0) ? a / b : -1.; };
129 : ratio_ghosts(0), ratio_clones(0), ghosts(0), clones(0), nEvents(0){
134 virtual void AddCounter(
string shortname,
string name);
138 void Inc(
bool isReco,
string name);
158 indices[shortname] = names.size();
159 names.push_back(name);
161 ratio_reco.AddCounter();
168 ratio_reco = reco / mc;
169 if (mc.counters[indices[
"total"]] > 0) {
170 ratio_clones = clones / double(mc.counters[indices[
"total"]]);
174 if (reco.counters[indices[
"total"]] + ghosts > 0) {
175 ratio_ghosts = ghosts / double(reco.counters[indices[
"total"]] + ghosts);
194 const int index = indices[name];
196 mc.counters[index]++;
198 reco.counters[index]++;
203 cout.setf(ios::fixed);
204 cout.setf(ios::showpoint);
206 cout <<
"Track category : " 213 cout << names[iC] <<
" : " << ratio_reco.counters[iC] <<
" | " << mc.counters[iC] << endl;
216 cout <<
"Clone probability : " << ratio_clones <<
" | " << clones << endl;
217 cout <<
"Ghost probability : " << ratio_ghosts <<
" | " << ghosts << endl;
TTracksCatCounters(int nCounters)
TTracksCatCounters< double > operator/(TTracksCatCounters< T2 > &a)
counters used for efficiency calculation
TTracksCatCounters< T2 > operator/(double a)
friend std::fstream & operator>>(std::fstream &strm, TTracksCatCounters< T > &a)
void Inc(bool isReco, string name)
TTracksCatCounters & operator+=(TTracksCatCounters &a)
map< string, int > indices
TTracksCatCounters< double > ratio_reco
TTracksCatCounters operator+(TTracksCatCounters &a)
void AddCounters(int nCounters)
TTracksCatCounters< int > mc
TTracksCatCounters< int > reco
TEfficiencies & operator+=(TEfficiencies &a)
virtual void AddCounter(string shortname, string name)