PandaRoot
PndCACounters.h
Go to the documentation of this file.
1 //****************************************************************************
2 //* This file is part of PandaRoot. *
3 //* *
4 //* PandaRoot is distributed under the terms of the *
5 //* GNU General Public License (GPL) version 3, *
6 //* copied verbatim in the file "LICENSE". *
7 //* *
8 //* Copyright (C) 2006 - 2024 FAIR GmbH and copyright holders of PandaRoot *
9 //* The copyright holders are listed in the file "COPYRIGHTHOLDERS". *
10 //* The authors are listed in the file "AUTHORS". *
11 //****************************************************************************
12 
17 #ifndef PNDCACOUNTERS_H
18 #define PNDCACOUNTERS_H
19 
20 #include "PndCACountersBase.h"
21 #include "PndCAParameters.h"
22 
23 #include <iostream>
24 using std::cout;
25 using std::endl;
26 using std::ios;
27 
28 #include <string>
29 using std::string;
30 
31 #include <vector>
32 using std::vector;
33 
34 #include <map>
35 using std::map;
36 
39  {
40 
41  AddCounter("ref_prim_long", "LRefPrim efficiency");
42  AddCounter("ref_prim", "RefPrim efficiency");
43  AddCounter("ref_sec", "RefSec efficiency");
44  AddCounter("ref", "Refset efficiency");
45  AddCounter("extra_prim", "ExtraPrim efficiency");
46  AddCounter("extra_sec", "ExtraSec efficiency");
47  AddCounter("extra", "Extra efficiency");
48  AddCounter("total", "Allset efficiency");
49  AddCounter("rest", "Rest efficiency");
50  }
51  virtual ~PndCAEfficiencies(){};
52 
53  virtual void AddCounter(string shortname, string name)
54  {
55  TEfficiencies::AddCounter(shortname, name);
61  clone.AddCounter();
64  }
65 
67  {
69  killed += a.killed;
70  clone += a.clone;
73  return *this;
74  }
75 
76  void CalcEff()
77  {
80  ratio_clone = clone / mc;
82  ratio_length = reco_length / allReco;
83  ratio_fakes = reco_fakes / allReco;
84  }
85 
86  void Inc(bool isReco, bool isKilled, double _ratio_length, double _ratio_fakes, int _nclones, string name)
87  {
88  TEfficiencies::Inc(isReco, name);
89 
90  const int index = indices[name];
91 
92  if (isKilled)
93  killed.counters[index]++;
94  reco_length.counters[index] += _ratio_length;
95  reco_fakes.counters[index] += _ratio_fakes;
96  clone.counters[index] += _nclones;
97  }
98 
99  void Print()
100  {
101  std::cout.setf(ios::fixed);
102  std::cout.setf(ios::showpoint);
103  std::cout.precision(3);
104  std::cout << "Track category : "
105  << " Eff "
106  //<<" / "<< "Killed"
107  << " / "
108  << "Length"
109  << " / "
110  << "Fakes "
111  << " / "
112  << "Clones"
113  << " / "
114  << "All Reco"
115  << " | "
116  << "All MC" << std::endl;
117 
118  int NCounters = mc.NCounters;
119  for (int iC = 0; iC < NCounters; iC++) {
120  if ((names[iC] != "D0 efficiency") || (mc.counters[iC] != 0))
121  std::cout << names[iC] << " : "
122  << ratio_reco.counters[iC]
123  //<< " / " << ratio_killed.counters[iC] // tracks with aren't reco because other tracks takes their hit(-s)
124  << " / " << ratio_length.counters[iC] // nRecoMCHits/nMCHits
125  << " / " << ratio_fakes.counters[iC] // nFakeHits/nRecoAllHits
126  << " / " << ratio_clone.counters[iC] // nCloneTracks/nMCTracks
127  << " / " << double(reco.counters[iC]) / double(nEvents) << " | " << double(mc.counters[iC]) / double(nEvents) << std::endl;
128  }
129  std::cout << "Ghost probability : " << ratio_ghosts << " | " << double(ghosts) / double(nEvents) << std::endl;
130  std::cout << "All reco tracks/ev : " << int(double(reco.counters[indices["total"]]) / double(nEvents) + .5) << endl;
131  }
132 
137 
142 };
143 
146  public:
148  {
149  set = 0;
150  isReconstructable = 0;
151  };
152 
153  void SetSet(int set_) { set = set_; }
154  void SetAsReconstructable() { isReconstructable = true; }
155  void AddReconstructed(int itr = 0) { recoTrackIds.push_back(itr); }
156 
157  int GetSet() { return set; }
158  bool IsReconstructable() { return isReconstructable; }
159  bool IsReconstructed() { return recoTrackIds.size() >= 1; }
160  bool GetNClones() { return (recoTrackIds.size() > 1) ? recoTrackIds.size() - 1 : 0; }
161 
162  const std::vector<int> &RecoTrackIds() const { return recoTrackIds; }
163  void Print() { cout << "Set: " << set << " RecoAble: " << isReconstructable << " NReco: " << recoTrackIds.size() << endl; }
164 
165  private:
166  int set; // set of tracks 0-OutSet, 1-ExtraSet, 2-RefSet, 3-ExtraSecSet, 4-ExtraPrimSet, 5-RefSecSet, 6-RefPrimSet, 7-LongRefPrimSet
167  bool isReconstructable;
168 
169  std::vector<int> recoTrackIds;
170 };
171 
174  public:
175  PndCAPerformanceRecoTrackData() { mcTrackId = -1; };
176 
177  void SetMCTrack(int mcTrackId_, float purity_, int nHits_)
178  {
179  mcTrackId = mcTrackId_;
180  purity = purity_;
181  nHits = nHits_;
182  }
183 
184  int GetMCTrackId() { return mcTrackId; }
185  float GetPurity() { return purity; }
186  bool IsGhost(float minPurity = 0) { return (mcTrackId == -1) || (purity < minPurity); }
187  bool IsReco(float minPurity = 0, int minNHits = 0) { return (mcTrackId != -1) && (purity >= minPurity) && (nHits >= minNHits); }
188  int NHits() { return nHits; }
189 
190  void Print() { cout << "Track: " << mcTrackId << " Purity: " << purity << endl; }
191 
192  private:
193  int mcTrackId;
194  float purity;
195  int nHits;
196 };
197 
198 #endif
TTracksCatCounters< double > ratio_clone
virtual void AddCounter(string shortname, string name)
Definition: PndCACounters.h:53
TTracksCatCounters< double > ratio_killed
void Inc(bool isReco, bool isKilled, double _ratio_length, double _ratio_fakes, int _nclones, string name)
Definition: PndCACounters.h:86
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:51
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:66
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)