KaliVeda  1.13/01
Heavy-Ion Analysis Toolkit
KVDataQualityAuditReportMaker.h
Go to the documentation of this file.
1 #ifndef __KVDATAQUALITYAUDITREPORTMAKER_H
2 #define __KVDATAQUALITYAUDITREPORTMAKER_H
3 
4 #include "KVBase.h"
5 #include "KVDataQualityAudit.h"
6 #include "TGraph.h"
7 #include <THStack.h>
8 #include <TMultiGraph.h>
37 public:
38  struct element {
39  std::string telescope_name;
41  element(const std::string& n, const KVDataQualityAudit::element& e)
46  };
47  struct telescope {
49  telescope(const TString& name, const KVDataQualityAudit* audit)
50  : this_telescope{audit->GetTelescope(name)}
51  {
52  if (!this_telescope) std::cerr << "Requested telescope not found in audit: " << name << std::endl;
53  }
58  element operator[](int Z) const
59  {
60  return get_element(Z);
61  }
62  element get_element(int Z) const
63  {
65  }
71  };
72 
73 private:
74  const KVDataQualityAudit* fAudit{nullptr};
75  void init_colors(int ncols = 100);
76 public:
78  : KVBase("KVDataQualityReportMaker", "Produce graphs and histograms from KVDataQualityAudit")
79  {
80  init_colors();
81  }
83  : KVBase(audit_name)
84  {
87  init_colors();
88  fAudit = dynamic_cast<KVDataQualityAudit*>(gDirectory->Get(audit_name));
89  if (fAudit) SetTitle(fAudit->GetTitle());
90  else MakeZombie();
91  }
93  : KVBase(audit->GetName(), audit->GetTitle()), fAudit(audit)
94  {
95  init_colors();
96  }
98 
99  telescope operator[](const TString& name) const
100  {
101  return telescope(name, fAudit);
102  }
103 
104  static TGraph* FormatGraph(TGraph*, Color_t = 0, Marker_t = 0);
105  static TH1F* FormatHisto(TH1F*, Color_t = 0);
106 
108  {
109  return fAudit;
110  }
111 
112  template<typename TelescopeIndexFunction>
113  TGraph* get_mean_Z_for_telescopes(TSeqCollection* idtels, TelescopeIndexFunction F, Marker_t marker_style = 20) const
114  {
119 
120  auto gr = ::new TGraph;
121  gr->SetTitle("Mean Z vs. telescope number");
122  KVIDTelescope* idt;
123  TIter next(idtels);
124  while ((idt = (KVIDTelescope*)next())) {
125  auto t = fAudit->GetTelescope(idt->GetName());
126  if (t) gr->SetPoint(gr->GetN(), F(idt), t->get_mean_Z());
127  }
128  return FormatGraph(gr, 0, marker_style);
129  }
130  template<typename TelescopeIndexFunction>
131  TGraph* get_max_Z_for_telescopes(TSeqCollection* idtels, TelescopeIndexFunction F, Marker_t marker_style = 20) const
132  {
137 
138  auto gr = ::new TGraph;
139  gr->SetTitle("Max Z vs. telescope number");
140  KVIDTelescope* idt;
141  TIter next(idtels);
142  while ((idt = (KVIDTelescope*)next())) {
143  auto t = fAudit->GetTelescope(idt->GetName());
144  if (t) gr->SetPoint(gr->GetN(), F(idt), t->get_max_Z());
145  }
146  return FormatGraph(gr, 0, marker_style);
147  }
148  template<typename TelescopeIndexFunction>
149  TGraph* get_max_Z_with_isotopes_for_telescopes(TSeqCollection* idtels, TelescopeIndexFunction F, Marker_t marker_style = 20) const
150  {
155 
156  auto gr = ::new TGraph;
157  gr->SetTitle("Max Z with isotopes vs. telescope number");
158  KVIDTelescope* idt;
159  TIter next(idtels);
160  while ((idt = (KVIDTelescope*)next())) {
161  auto t = fAudit->GetTelescope(idt->GetName());
162  if (t) gr->SetPoint(gr->GetN(), F(idt), t->get_max_Z_with_isotopes());
163  }
164  return FormatGraph(gr, 0, marker_style);
165  }
166  template<typename TelescopeIndexFunction>
167  TGraph* get_min_Z_for_telescopes(TSeqCollection* idtels, TelescopeIndexFunction F, Marker_t marker_style = 20) const
168  {
173 
174  auto gr = ::new TGraph;
175  gr->SetTitle("Min Z vs. telescope number");
176  KVIDTelescope* idt;
177  TIter next(idtels);
178  while ((idt = (KVIDTelescope*)next())) {
179  auto t = fAudit->GetTelescope(idt->GetName());
180  if (t) gr->SetPoint(gr->GetN(), F(idt), t->get_min_Z());
181  }
182  return FormatGraph(gr, 0, marker_style);
183  }
184  template<typename TelescopeIndexFunction>
185  TGraph* get_mean_A_for_telescopes(TSeqCollection* idtels, TelescopeIndexFunction F, Marker_t marker_style = 20) const
186  {
191 
192  auto gr = ::new TGraph;
193  gr->SetTitle("Mean A vs. telescope number");
194  KVIDTelescope* idt;
195  TIter next(idtels);
196  while ((idt = (KVIDTelescope*)next())) {
197  auto t = fAudit->GetTelescope(idt->GetName());
198  if (t) gr->SetPoint(gr->GetN(), F(idt), t->get_mean_A());
199  }
200  return FormatGraph(gr, 0, marker_style);
201  }
202  template<typename TelescopeIndexFunction>
203  TGraph* get_max_A_for_telescopes(TSeqCollection* idtels, TelescopeIndexFunction F, Marker_t marker_style = 20) const
204  {
209 
210  auto gr = ::new TGraph;
211  gr->SetTitle("Max A vs. telescope number");
212  KVIDTelescope* idt;
213  TIter next(idtels);
214  while ((idt = (KVIDTelescope*)next())) {
215  auto t = fAudit->GetTelescope(idt->GetName());
216  if (t) gr->SetPoint(gr->GetN(), F(idt), t->get_max_A());
217  }
218  return FormatGraph(gr, 0, marker_style);
219  }
220 
221  template<typename TelescopeIndexFunction>
222  TGraph* get_min_A_for_telescopes(TSeqCollection* idtels, TelescopeIndexFunction F, Marker_t marker_style = 20) const
223  {
228 
229  auto gr = ::new TGraph;
230  gr->SetTitle("Min A vs. telescope number");
231  KVIDTelescope* idt;
232  TIter next(idtels);
233  while ((idt = (KVIDTelescope*)next())) {
234  auto t = fAudit->GetTelescope(idt->GetName());
235  if (t) gr->SetPoint(gr->GetN(), F(idt), t->get_min_A());
236  }
237  return FormatGraph(gr, 0, marker_style);
238  }
239 
240  ClassDef(KVDataQualityAuditReportMaker, 1) //Produce graphs and histograms from KVDataQualityAudit
241 };
242 
243 #endif
#define e(i)
short Marker_t
short Color_t
#define ClassDef(name, id)
#define gDirectory
Base class for KaliVeda framework.
Definition: KVBase.h:141
Produce graphs and histograms from KVDataQualityAudit.
TGraph * get_mean_A_for_telescopes(TSeqCollection *idtels, TelescopeIndexFunction F, Marker_t marker_style=20) const
TGraph * get_max_Z_for_telescopes(TSeqCollection *idtels, TelescopeIndexFunction F, Marker_t marker_style=20) const
static TGraph * FormatGraph(TGraph *, Color_t=0, Marker_t=0)
provide uniform style for all graphs
KVDataQualityAuditReportMaker(const KVDataQualityAudit *audit)
static TH1F * FormatHisto(TH1F *, Color_t=0)
provide uniform style for all histos
TGraph * get_mean_Z_for_telescopes(TSeqCollection *idtels, TelescopeIndexFunction F, Marker_t marker_style=20) const
KVDataQualityAuditReportMaker(const TString &audit_name)
TGraph * get_max_A_for_telescopes(TSeqCollection *idtels, TelescopeIndexFunction F, Marker_t marker_style=20) const
TGraph * get_max_Z_with_isotopes_for_telescopes(TSeqCollection *idtels, TelescopeIndexFunction F, Marker_t marker_style=20) const
telescope operator[](const TString &name) const
const KVDataQualityAudit * GetAudit() const
TGraph * get_min_A_for_telescopes(TSeqCollection *idtels, TelescopeIndexFunction F, Marker_t marker_style=20) const
TGraph * get_min_Z_for_telescopes(TSeqCollection *idtels, TelescopeIndexFunction F, Marker_t marker_style=20) const
const element & GetElement(int Z) const
Audit of experimental data identification and calibrations.
idtelescope * GetTelescope(const TString &tel_name) const
Base class for all detectors or associations of detectors in array which can identify charged particl...
Definition: KVIDTelescope.h:83
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Int_t GetN() const
virtual void SetTitle(const char *title="")
virtual const char * GetName() const
virtual void SetTitle(const char *title="")
virtual const char * GetTitle() const
void MakeZombie()
const Int_t n
TGraphErrors * gr
#define F(x, y, z)
const KVDataQualityAudit::element * this_element
element(const std::string &n, const KVDataQualityAudit::element &e)
TGraph * get_isotope_thresholds_by_Z_mev_per_nuc(Color_t color=0) const
telescope(const TString &name, const KVDataQualityAudit *audit)
KVDataQualityAudit::idtelescope * this_telescope