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 private:
43 
45 
46 public:
48  KVDataQualityAudit(const Char_t* name, const Char_t* title = "")
49  : KVBase(name, title)
50  {
52  }
53  virtual ~KVDataQualityAudit() {}
54  void Add(const KVReconstructedNucleus& N);
55  void Print(Option_t* opt = "") const override;
57  {
58  return &telescopes;
59  }
60  Bool_t HasTelescope(const TString& tel_name) const
61  {
62  return telescopes.FindObject(tel_name) != nullptr;
63  }
65 
66  struct isotope {
69  Float_t emin{-1.0};
70  UShort_t A{0};
71  void add(const KVReconstructedNucleus& N);
72  void print() const;
73  void merge(const isotope& isoto)
74  {
77  if (emin > 0) {
78  if (isoto.emin > 0) emin = std::min(emin, isoto.emin);
79  }
80  else if (isoto.emin > 0) emin = isoto.emin;
81  counts += isoto.counts;
82  }
84  {
85  return emin;
86  }
87 
88  ClassDef(isotope, 1)
89  };
90  struct element {
93  Float_t emin{-1.0};
94  UShort_t A{0};// default (calculated) mass given when no isotopic identification available
95  UChar_t Z{0};
96  std::map<int, isotope> isotopes;
97  void add(const KVReconstructedNucleus& N);
98  void print() const;
99  void merge(const element&);
101  {
102  return !isotopes.empty();
103  }
104  Bool_t HasIsotope(int A) const
105  {
106  return isotopes.find(A) != std::end(isotopes);
107  }
108  const isotope& GetIsotope(int A) const
109  {
110  try {
111  return isotopes.at(A);
112  }
113  catch (...) {
114  std::cerr << "Error in <KVDataQualityAudit::GetIsotope>: No isotope with A=" << A << std::endl;
115  throw;
116  }
117  }
119  {
121  KVNumberList l;
122  for (auto& p : isotopes) l.Add(p.first);
123  return l;
124  }
125  double get_mean_isotopic_mass() const;
126  int get_max_isotopic_mass() const;
127  std::map<int, double> get_isotopic_distribution() const;
128  int get_min_isotopic_mass() const;
130  double get_minimum_isotopic_threshold(int&) const;
131  int get_default_mass() const
132  {
133  return A;
134  }
136  {
137  return emin;
138  }
139  std::map<double, int> get_isotopes_sorted_by_threshold() const;
140 
141  ClassDef(element, 1)
142  };
143  class idtelescope : public TNamed {
144  std::map<int, element> elements;
145  public:
146  idtelescope(const TString& name = "") : TNamed(name, name) {}
147  ROOT_COPY_CTOR(idtelescope, TNamed)
148  ROOT_COPY_ASSIGN_OP(idtelescope)
149  void Copy(TObject& o) const override
150  {
152  TNamed::Copy(o);
153  idtelescope& other = (idtelescope&)o;
154  other.elements = elements;
155  }
156  void add(const KVReconstructedNucleus& N);
157  void Print(Option_t* opt = "") const override;
158  void merge(const idtelescope*);
159  Bool_t HasElement(int Z) const
160  {
161  return elements.find(Z) != std::end(elements);
162  }
163  const element& GetElement(int Z) const
164  {
165  try {
166  return elements.at(Z);
167  }
168  catch (...) {
169  std::cerr << "Error in <KVDataQualityAudit::GetElement>: No element with Z=" << Z << std::endl;
170  throw;
171  }
172  }
174  {
176 
177  KVNumberList l;
178  for (auto& p : elements) l.Add(p.first);
179  return l;
180  }
181  std::map<int, double> get_element_distribution() const;
182  double get_mean_Z() const;
183  int get_max_Z() const;
184  double get_mean_A() const;
185  int get_max_A() const;
186  int get_min_A() const;
187  int get_min_Z() const;
188  int get_max_Z_with_isotopes() const;
189 
191  };
192 
193  Bool_t HasTelescope(const idtelescope* idt) const
194  {
195  return HasTelescope(idt->GetName());
196  }
197  idtelescope* GetTelescope(const TString& tel_name) const
198  {
199  return (idtelescope*)telescopes.FindObject(tel_name);
200  }
202  {
203  return GetTelescope(idt->GetName());
204  }
205 
209  class IDStatus {
210  public:
211  enum class EStatus {
225  };
227  operator bool() const
228  {
233  }
234  bool operator==(EStatus s) const
235  {
236  return status == s;
237  }
238  private:
240  public:
241  friend std::ostream& operator<<(std::ostream& os, const IDStatus& st_ob)
242  {
243  os << "ID Status: ";
244  switch (st_ob.status) {
246  os << "telescope not functioning";
247  break;
249  os << "below threshold for Z identification";
250  break;
252  os << "identification not possible for this Z";
253  break;
255  os << "Z identified but not A";
256  break;
258  os << "partial isotopic identification";
259  break;
261  os << "A greater than measured Amax";
262  break;
264  os << "A less than measured Amin";
265  break;
267  os << "A_never_measured_but_between_Amin_and_Amax";
268  break;
270  os << "full isotopic identification";
271  break;
273  os << "weird result 1";
274  break;
276  os << "weird result 2";
277  break;
279  os << "weird result 3";
280  break;
282  os << "weird result 4";
283  break;
284  }
285  return os;
286  }
287  };
288 
289  IDStatus CanIdentify(const TString& tel_name, int Z, int& A, double E) const;
290 
291 private:
292  void add(const idtelescope*);
293 
294  ClassDefOverride(KVDataQualityAudit, 1) //Audit of experimental data identification and calibrations
295 };
296 
297 #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
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