KaliVeda
Toolkit for HIC analysis
KVDataQualityAudit.h
1 #ifndef __KVDATAQUALITYAUDIT_H
2 #define __KVDATAQUALITYAUDIT_H
3 
4 #include "KVBase.h"
5 
6 #include <KVNumberList.h>
7 #include <KVReconstructedNucleus.h>
8 #include <KVUniqueNameList.h>
9 
40 class KVDataQualityAudit : public KVBase {
41 
43 
44 private:
46 
48 
49 public:
51  KVDataQualityAudit(const Char_t* name, const Char_t* title = "")
52  : KVBase(name, title)
53  {
55  }
56  virtual ~KVDataQualityAudit() {}
57  void Add(const KVReconstructedNucleus& N);
58  void Print(Option_t* opt = "") const override;
60  {
61  return &telescopes;
62  }
63  Bool_t HasTelescope(const TString& tel_name) const
64  {
65  return telescopes.FindObject(tel_name) != nullptr;
66  }
68 
69  struct isotope {
72  Float_t emin{-1.0};
73  UShort_t A{0};
74  void add(const KVReconstructedNucleus& N);
75  void print() const;
76  void merge(const isotope& isoto)
77  {
80  if (emin > 0) {
81  if (isoto.emin > 0) emin = std::min(emin, isoto.emin);
82  }
83  else if (isoto.emin > 0) emin = isoto.emin;
84  counts += isoto.counts;
85  }
87  {
88  return emin;
89  }
90 
91  ClassDef(isotope, 1)
92  };
93  struct element {
96  Float_t emin{-1.0};
97  UShort_t A{0};// default (calculated) mass given when no isotopic identification available
98  UChar_t Z{0};
99  std::map<int, isotope> isotopes;
100  void add(const KVReconstructedNucleus& N);
101  void print() const;
102  void merge(const element&);
104  {
105  return !isotopes.empty();
106  }
107  Bool_t HasIsotope(int A) const
108  {
109  return isotopes.find(A) != std::end(isotopes);
110  }
111  const isotope& GetIsotope(int A) const
112  {
113  try {
114  return isotopes.at(A);
115  }
116  catch (...) {
117  std::cerr << "Error in <KVDataQualityAudit::GetIsotope>: No isotope with A=" << A << std::endl;
118  throw;
119  }
120  }
122  {
124  KVNumberList l;
125  for (auto& p : isotopes) l.Add(p.first);
126  return l;
127  }
128  double get_mean_isotopic_mass() const;
129  int get_max_isotopic_mass() const;
130  std::map<int, double> get_isotopic_distribution() const;
131  int get_min_isotopic_mass() const;
133  double get_minimum_isotopic_threshold(int&) const;
134  int get_default_mass() const
135  {
136  return A;
137  }
139  {
140  return emin;
141  }
142  std::map<double, int> get_isotopes_sorted_by_threshold() const;
143 
144  ClassDef(element, 1)
145  };
146  class idtelescope : public TNamed {
147  std::map<int, element> elements;
148  public:
149  idtelescope(const TString& name = "") : TNamed(name, name) {}
150  ROOT_COPY_CTOR(idtelescope, TNamed)
151  ROOT_COPY_ASSIGN_OP(idtelescope)
152  void Copy(TObject& o) const override
153  {
155  TNamed::Copy(o);
156  idtelescope& other = (idtelescope&)o;
157  other.elements = elements;
158  }
159  void add(const KVReconstructedNucleus& N);
160  void Print(Option_t* opt = "") const override;
161  void merge(const idtelescope*);
162  Bool_t HasElement(int Z) const
163  {
164  return elements.find(Z) != std::end(elements);
165  }
166  const element& GetElement(int Z) const
167  {
168  try {
169  return elements.at(Z);
170  }
171  catch (...) {
172  std::cerr << "Error in <KVDataQualityAudit::GetElement>: No element with Z=" << Z << std::endl;
173  throw;
174  }
175  }
177  {
179 
180  KVNumberList l;
181  for (auto& p : elements) l.Add(p.first);
182  return l;
183  }
184  std::map<int, double> get_element_distribution() const;
185  double get_mean_Z() const;
186  int get_max_Z() const;
187  double get_mean_A() const;
188  int get_max_A() const;
189  int get_min_A() const;
190  int get_min_Z() const;
191  int get_max_Z_with_isotopes() const;
192 
194  };
195 
196  Bool_t HasTelescope(const idtelescope* idt) const
197  {
198  return HasTelescope(idt->GetName());
199  }
200  idtelescope* GetTelescope(const TString& tel_name) const
201  {
202  return (idtelescope*)telescopes.FindObject(tel_name);
203  }
205  {
206  return GetTelescope(idt->GetName());
207  }
208 
212  class IDStatus {
213  public:
214  enum class EStatus {
228  };
230  operator bool() const
231  {
236  }
237  bool operator==(EStatus s) const
238  {
239  return status == s;
240  }
241  private:
243  public:
244  friend std::ostream& operator<<(std::ostream& os, const IDStatus& st_ob)
245  {
246  os << "ID Status: ";
247  switch (st_ob.status) {
249  os << "telescope not functioning";
250  break;
252  os << "below threshold for Z identification";
253  break;
255  os << "identification not possible for this Z";
256  break;
258  os << "Z identified but not A";
259  break;
261  os << "partial isotopic identification";
262  break;
264  os << "A greater than measured Amax";
265  break;
267  os << "A less than measured Amin";
268  break;
270  os << "A_never_measured_but_between_Amin_and_Amax";
271  break;
273  os << "full isotopic identification";
274  break;
276  os << "weird result 1";
277  break;
279  os << "weird result 2";
280  break;
282  os << "weird result 3";
283  break;
285  os << "weird result 4";
286  break;
287  }
288  return os;
289  }
290  };
291 
292  IDStatus CanIdentify(const TString& tel_name, int Z, int& A, double E) const;
293 
294 private:
295  void add(const idtelescope*);
296 
297  ClassDefOverride(KVDataQualityAudit, 1) //Audit of experimental data identification and calibrations
298 };
299 
300 #endif
bool Bool_t
unsigned short UShort_t
unsigned char UChar_t
char Char_t
float Float_t
double Double_t
const char Option_t
#define ClassDef(name, id)
#define ClassDefOverride(name, id)
winID h TVirtualViewer3D TVirtualGLPainter p
char name[80]
Base class for KaliVeda framework.
Definition: KVBase.h:139
Use audits of different id types from different datasets to form a composite audit.
Helper class used by CanIdentify() to test whether particles can be identified.
friend std::ostream & operator<<(std::ostream &os, const IDStatus &st_ob)
bool operator==(EStatus s) const
void Print(Option_t *opt="") const override
void add(const KVReconstructedNucleus &N)
std::map< int, element > elements
void Copy(TObject &o) const override
void merge(const idtelescope *)
const element & GetElement(int Z) const
std::map< int, double > get_element_distribution() const
idtelescope(const TString &name="")
Audit of experimental data identification and calibrations.
Long64_t merge(KVDataQualityAudit *)
void Print(Option_t *opt="") const override
Long64_t Merge(TCollection *)
Bool_t HasTelescope(const TString &tel_name) const
IDStatus CanIdentify(const TString &tel_name, int Z, int &A, double E) const
KVDataQualityAudit(const Char_t *name, const Char_t *title="")
idtelescope * GetTelescope(const TString &tel_name) const
KVUniqueNameList telescopes
const KVSeqCollection * GetTelescopeList() const
Bool_t HasTelescope(const idtelescope *idt) const
void Add(const KVReconstructedNucleus &N)
Add this reconstructed nucleus to the audit.
void add(const idtelescope *)
Add copy of idtelescope data to this audit.
idtelescope * GetTelescope(const idtelescope *idt) const
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
Nuclei reconstructed from data measured by a detector array .
KaliVeda extensions to ROOT collection classes.
TObject * FindObject(const char *name) const override
void SetOwner(Bool_t enable=kTRUE) override
Optimised list in which named objects can only be placed once.
void Copy(TObject &named) const override
const char * GetName() const override
long long Long64_t
double get_mean_isotopic_mass() const
calculate and return mean mass of isotopes measured for this element
std::map< double, int > get_isotopes_sorted_by_threshold() const
double get_minimum_isotopic_threshold(int &) const
KVNumberList GetIsotopeList() const
const isotope & GetIsotope(int A) const
std::map< int, double > get_isotopic_distribution() const
std::map< int, isotope > isotopes
Double_t counts
watch the alignment !
Bool_t HasIsotope(int A) const
int get_min_isotopic_mass() const
return min A of isotopes measured for this element
double get_minimum_isotopic_threshold_mev_per_nuc(int &) const
void add(const KVReconstructedNucleus &N)
int get_max_isotopic_mass() const
return max A of isotopes measured for this element
void add(const KVReconstructedNucleus &N)
Double_t counts
watch the alignment !
void merge(const isotope &isoto)
TLine l