PandaRoot
PndFTSCounters.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 PNDFTSCounters_H
18 #define PNDFTSCounters_H
19 
20 #include "Counters.h"
21 #include "PndFTSCAParameters.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 ~PndFTSEfficiencies(){};
52  virtual void AddCounter(string shortname, string name)
53  {
54  TEfficiencies::AddCounter(shortname, name);
60  clone.AddCounter();
63  }
64 
66  {
68  killed += a.killed;
69  clone += a.clone;
72  return *this;
73  }
74 
75  void CalcEff()
76  {
79  ratio_clone = clone / mc;
81  ratio_length = reco_length / allReco;
82  ratio_fakes = reco_fakes / allReco;
83  }
84 
85  void Inc(bool isReco, bool isKilled, double _ratio_length, double _ratio_fakes, int _nclones, string name)
86  {
87  TEfficiencies::Inc(isReco, name);
88 
89  const int index = indices[name];
90 
91  if (isKilled)
92  killed.counters[index]++;
93  reco_length.counters[index] += _ratio_length;
94  reco_fakes.counters[index] += _ratio_fakes;
95  clone.counters[index] += _nclones;
96  }
97 
98  void Print()
99  {
100 
101  // save original cout flags
102  std::ios_base::fmtflags coutFlags = cout.flags();
103  std::cout.setf(ios::fixed);
104  std::cout.setf(ios::showpoint);
105  std::cout.precision(3);
106  std::cout << "Track category : "
107  << " Eff "
108  //<<" / "<< "Killed"
109  << " / "
110  << "Length"
111  << " / "
112  << "Fakes "
113  << " / "
114  << "Clones"
115  << " / "
116  << "All Reco"
117  << " | "
118  << "All MC" << std::endl;
119 
120  int NCounters = mc.NCounters;
121  for (int iC = 0; iC < NCounters; iC++) {
122  if ((names[iC] != "D0 efficiency") || (mc.counters[iC] != 0))
123  std::cout << names[iC] << " : "
124  << ratio_reco.counters[iC]
125  //<< " / " << ratio_killed.counters[iC] // tracks with aren't reco because other tracks takes their hit(-s)
126  << " / " << ratio_length.counters[iC] // nRecoMCHits/nMCHits
127  << " / " << ratio_fakes.counters[iC] // nFakeHits/nRecoAllHits
128  << " / " << ratio_clone.counters[iC] // nCloneTracks/nMCTracks
129  << " / " << double(reco.counters[iC]) / double(nEvents) << " | " << double(mc.counters[iC]) / double(nEvents) << std::endl;
130  }
131  std::cout << "Ghost probability : " << ratio_ghosts << " | " << double(ghosts) / double(nEvents) << std::endl;
132  std::cout << "All reco tracks/ev : " << int(double(reco.counters[indices["total"]]) / double(nEvents) + .5) << endl;
133 
134  // restore original cout flags
135  cout.flags(coutFlags);
136  }
137 
142 
147 };
148 
151  public:
153  {
154  set = 0;
155  isReconstructable = 0;
156  };
157 
158  void SetSet(int set_) { set = set_; }
159  void SetAsReconstructable() { isReconstructable = true; }
160  void AddReconstructed(int itr = 0) { recoTrackIds.push_back(itr); }
161 
162  int GetSet() { return set; }
163  bool IsReconstructable() { return isReconstructable; }
164  bool IsReconstructed() { return recoTrackIds.size() >= 1; }
165  bool GetNClones() { return (recoTrackIds.size() > 1) ? recoTrackIds.size() - 1 : 0; }
166 
167  const std::vector<int> &RecoTrackIds() const { return recoTrackIds; }
168  void Print() { cout << "Set: " << set << " RecoAble: " << isReconstructable << " NReco: " << recoTrackIds.size() << endl; }
169 
170  private:
171  int set; // set of tracks 0-OutSet, 1-ExtraSet, 2-RefSet, 3-ExtraSecSet, 4-ExtraPrimSet, 5-RefSecSet, 6-RefPrimSet, 7-LongRefPrimSet
172  bool isReconstructable;
173 
174  std::vector<int> recoTrackIds;
175 };
176 
179  public:
180  PndFTSCAPerformanceRecoTrackData() { mcTrackId = -1; };
181 
182  void SetMCTrack(int mcTrackId_, float purity_, int nHits_)
183  {
184  mcTrackId = mcTrackId_;
185  purity = purity_;
186  nHits = nHits_;
187  }
188 
189  int GetMCTrackId() { return mcTrackId; }
190  float GetPurity() { return purity; }
191  bool IsGhost(float minPurity = 0) { return (mcTrackId == -1) || (purity < minPurity); }
192  bool IsReco(float minPurity = 0, int minNHits = 0) { return (mcTrackId != -1) && (purity >= minPurity) && (nHits >= minNHits); }
193  int NHits() { return nHits; }
194 
195  void Print() { cout << "Track: " << mcTrackId << " Purity: " << purity << endl; }
196 
197  private:
198  int mcTrackId;
199  float purity;
200  int nHits;
201 };
202 
203 #endif
PndFTSEfficiencies & operator+=(PndFTSEfficiencies &a)
virtual void AddCounter(string shortname, string name)
TTracksCatCounters< int > clone
void Inc(bool isReco, bool isKilled, double _ratio_length, double _ratio_fakes, int _nclones, string name)
virtual ~PndFTSEfficiencies()
TTracksCatCounters< int > killed
TTracksCatCounters< double > ratio_killed
TTracksCatCounters< double > ratio_clone
const std::vector< int > & RecoTrackIds() const
void Inc(bool isReco, string name)
map< string, int > indices
TTracksCatCounters< double > ratio_reco
Information about reconstruction of Reconstructed Track.
TTracksCatCounters< double > ratio_length
TTracksCatCounters< double > reco_fakes
TTracksCatCounters< int > mc
vector< string > names
TTracksCatCounters< int > reco
TTracksCatCounters< double > reco_length
bool IsReco(float minPurity=0, int minNHits=0)
bool IsGhost(float minPurity=0)
Information about reconstruction of MCTrack.
void SetMCTrack(int mcTrackId_, float purity_, int nHits_)
TTracksCatCounters< double > ratio_fakes
TEfficiencies & operator+=(TEfficiencies &a)
virtual void AddCounter(string shortname, string name)