KaliVeda
Toolkit for HIC analysis
KVDataQualityAuditReportMaker.cpp
1 #include "KVDataQualityAuditReportMaker.h"
2 #include "KVMultiDetArray.h"
3 #include <TColor.h>
4 
5 
8 
10 {
11  // \returns histogram P(Z) probability distribution for elements
12 
14  // find largest Z
15  auto last = proba.rbegin();
16  auto Zmax = (*last).first;
17  auto histo = ::new TH1F(Form("Z_%s", this_telescope->GetName()), Form("P(Z) %s", this_telescope->GetName()),
18  Zmax + 1, .5, Zmax + 1.5);
19  for (auto& p : proba) {
20  histo->SetBinContent(p.first, p.second);
21  }
22  return KVDataQualityAuditReportMaker::FormatHisto(histo, color);
23 }
24 
25 
26 
29 
31 {
32  // \returns graph of energy threshold for each element identified by telescope
33 
34  auto gr = ::new TGraph;
35  gr->SetTitle(Form("%s Z thresholds [MeV]", this_telescope->GetName()));
36  gr->SetName(this_telescope->GetName());
37  auto Zlist = this_telescope->GetElementList();
38  Zlist.Begin();
39  while (!Zlist.End()) {
40  auto Z = Zlist.Next();
41  gr->SetPoint(gr->GetN(), Z, this_telescope->GetElement(Z).emin);
42  }
44 }
45 
46 
47 
51 
53 {
54  // \returns graph of energy threshold in MeV/nucleon for each element identified by telescope
55  // for uncalibrated particles, threshold is -1 for all
56 
57  auto gr = ::new TGraph;
58  gr->SetTitle(Form("%s Z thresholds [MeV/u]", this_telescope->GetName()));
59  gr->SetName(this_telescope->GetName());
60  auto Zlist = this_telescope->GetElementList();
61  Zlist.Begin();
62  KVNumberList abnormal;
63  while (!Zlist.End()) {
64  auto Z = Zlist.Next();
65  double thresh;
66  if (this_telescope->GetElement(Z).HasIsotopes())
67  thresh = this_telescope->GetElement(Z).emin / this_telescope->GetElement(Z).get_mean_isotopic_mass();
68  else
69  thresh = this_telescope->GetElement(Z).emin / this_telescope->GetElement(Z).get_default_mass();
70  if (thresh < 0) thresh = -1;
71  gr->SetPoint(gr->GetN(), Z, thresh);
72  if (TString(this_telescope->GetName()).BeginsWith("ID_CSI") && thresh > 0 && thresh < 10) {
73  abnormal.Add(Z);
74  }
75  }
76  if (abnormal.GetEntries()) {
77  std::cout << "abnormal Z threshold (<10MeV/u): " << this_telescope->GetName() << " Z=" << abnormal.AsString();
78  TString p(this_telescope->GetName());
79  p.Remove(0, 7);
80  p.Prepend("CSI-");
81  if (!gMultiDetArray->GetDetector(p)->IsCalibrated()) std::cout << " : Detector " << p << " NOT CALIBRATED";
82  std::cout << std::endl;
83  }
85 }
86 
87 
88 
93 
95 {
96  // \returns graph of energy threshold in MeV/nucleon for isotopic identification of each element identified by telescope.
97  //
98  // this is the lowest recorded threshold value (in MeV/u) for the element to be isotopically identified
99 
100  auto gr = ::new TGraph;
101  gr->SetTitle(Form("%s A thresholds [MeV/u]", this_telescope->GetName()));
102  gr->SetName(this_telescope->GetName());
103  auto Zlist = this_telescope->GetElementList();
104  Zlist.Begin();
105  int a;
106  while (!Zlist.End()) {
107  auto Z = Zlist.Next();
108  // only include elements with isotopic identification
109  if (this_telescope->GetElement(Z).HasIsotopes())
110  gr->SetPoint(gr->GetN(), Z, this_telescope->GetElement(Z).get_minimum_isotopic_threshold_mev_per_nuc(a));
111  }
113 }
114 
115 
116 
119 
121 {
122  // \returns graph of mean isotopic mass for each isotopically-identified Z
123  auto gr = ::new TGraph;
124  gr->SetTitle(Form("%s <A> vs. Z", this_telescope->GetName()));
125  gr->SetName(this_telescope->GetName());
126  auto Zlist = this_telescope->GetElementList();
127  Zlist.Begin();
128  while (!Zlist.End()) {
129  auto Z = Zlist.Next();
130  auto elem = this_telescope->GetElement(Z);
131  if (elem.HasIsotopes()) {
132  gr->SetPoint(gr->GetN(), Z, elem.get_mean_isotopic_mass());
133  }
134  }
136 }
137 
138 
139 
142 
144 {
145  // \returns multigraph of isotope distributions for all isotopically identified elements
146 
147  auto mg = ::new TMultiGraph;
148  auto Zlist = this_telescope->GetElementList();
149  int color_step = TColor::GetPalette().GetSize() / (Zlist.GetNValues() + 1);
150  Zlist.Begin();
151  int i = 1;
152  while (!Zlist.End()) {
153  auto Z = Zlist.Next();
154  auto elem = get_element(Z);
155  if (this_telescope->GetElement(Z).HasIsotopes()) {
156  auto gr = elem.get_isotope_distribution(TColor::GetPalette()[color_step * i]);
157  mg->Add(gr);
158  }
159  ++i;
160  }
161  return mg;
162 }
163 
164 
165 
168 
170 {
171  // \returns multigraph of isotope thresholds in [MeV] for all isotopically identified elements
172 
173  auto mg = ::new TMultiGraph;
174  auto Zlist = this_telescope->GetElementList();
175  int color_step = TColor::GetPalette().GetSize() / (Zlist.GetNValues() + 1);
176  Zlist.Begin();
177  int i = 1;
178  while (!Zlist.End()) {
179  auto Z = Zlist.Next();
180  auto elem = get_element(Z);
181  if (this_telescope->GetElement(Z).HasIsotopes()) {
182  mg->Add(elem.get_isotope_thresholds_by_A(TColor::GetPalette()[color_step * i]));
183  }
184  ++i;
185  }
186  return mg;
187 }
188 
189 
190 
193 
195 {
196  // \returns multigraph of isotope thresholds in [MeV/u] for all isotopically identified elements
197 
198  auto mg = ::new TMultiGraph;
199  auto Zlist = this_telescope->GetElementList();
200  int color_step = TColor::GetPalette().GetSize() / (Zlist.GetNValues() + 1);
201  Zlist.Begin();
202  int i = 1;
203  while (!Zlist.End()) {
204  auto Z = Zlist.Next();
205  auto elem = get_element(Z);
206  if (this_telescope->GetElement(Z).HasIsotopes()) {
207  mg->Add(elem.get_isotope_thresholds_by_A_mev_per_nuc(TColor::GetPalette()[color_step * i]));
208  }
209  ++i;
210  }
211  return mg;
212 }
213 
214 
215 
218 
220 {
221  // provide uniform style for all graphs
222 
223  if (!col) col = kBlue - 2;
224  if (!mark) mark = 20;
225  G->SetMarkerStyle(mark);
226  G->SetMarkerSize(1.7);
227  G->SetMarkerColor(col);
228  G->SetLineWidth(2);
229  G->SetLineColor(col);
230  return G;
231 }
232 
233 
234 
237 
239 {
240  // provide uniform style for all histos
241 
242  if (!col) col = kBlue - 2;
243  G->SetLineWidth(2);
244  G->SetLineColor(col);
245  return G;
246 }
247 
248 
249 
253 
255 {
256  // \returns graph of isotope distribution P(A) for element.
257  // The distribution is weighted by the number of elements Z observed.
258 
259  auto proba = this_element->get_isotopic_distribution();
260  auto gr = ::new TGraph;
261  gr->SetName(Form("Z=%d", (int)this_element->Z));
262  gr->SetTitle(Form("P(A) Z=%d %s", (int)this_element->Z, telescope_name.c_str()));
263  for (auto& p : proba) {
264  gr->SetPoint(gr->GetN(), p.first, this_element->counts * p.second);
265  }
267 }
268 
269 
270 
273 
275 {
276  // \returns thresholds in [MeV] for each isotope as a function of A
277  auto gr = ::new TGraph;
278  gr->SetTitle(Form("%s Z=%d A thresholds [MeV]", telescope_name.c_str(), this_element->Z));
279  gr->SetName(Form("Z=%d", this_element->Z));
280  auto Alist = this_element->GetIsotopeList();
281  Alist.Begin();
282  while (!Alist.End()) {
283  auto A = Alist.Next();
284  gr->SetPoint(gr->GetN(), A, this_element->GetIsotope(A).emin);
285  }
287 }
288 
289 
290 
293 
295 {
296  // \returns thresholds in [MeV/nucleon] for each isotope as a function of A
297  auto gr = ::new TGraph;
298  gr->SetTitle(Form("%s Z=%d A thresholds [MeV/u]", telescope_name.c_str(), this_element->Z));
299  gr->SetName(Form("Z=%d", this_element->Z));
300  auto Alist = this_element->GetIsotopeList();
301  Alist.Begin();
302  while (!Alist.End()) {
303  auto A = Alist.Next();
304  gr->SetPoint(gr->GetN(), A, this_element->GetIsotope(A).emin / A);
305  }
307 }
308 
309 
311 
312 
313 
316 {
317  Double_t Red[] = {0., 1.0, 0.0, 0.0, 1.0, 1.0};
318  Double_t Green[] = {0., 0.0, 0.0, 1.0, 0.0, 1.0};
319  Double_t Blue[] = {0., 1.0, 1.0, 0.0, 0.0, 0.0};
320  Double_t Length[] = {0., .2, .4, .6, .8, 1.0};
321  TColor::CreateGradientColorTable(6, Length, Red, Green, Blue, ncols);
322 }
323 
324 
short Color_t
short Marker_t
double Double_t
kBlue
winID h TVirtualViewer3D TVirtualGLPainter p
char * Form(const char *fmt,...)
Produce graphs and histograms from KVDataQualityAudit.
static TGraph * FormatGraph(TGraph *, Color_t=0, Marker_t=0)
provide uniform style for all graphs
static TH1F * FormatHisto(TH1F *, Color_t=0)
provide uniform style for all histos
std::map< int, double > get_element_distribution() const
virtual KVDetector * GetDetector(const Char_t *name) const
Return detector in this structure with given name.
Strings used to represent a set of ranges of values.
Definition: KVNumberList.h:85
const Char_t * AsString(Int_t maxchars=0) const
Int_t GetEntries() const
Definition: KVNumberList.h:171
void Add(Int_t)
Add value 'n' to the list.
Int_t Next(void) const
Int_t GetSize() const
static const TArrayI & GetPalette()
static Int_t CreateGradientColorTable(UInt_t Number, Double_t *Stops, Double_t *Red, Double_t *Green, Double_t *Blue, UInt_t NColors, Float_t alpha=1., Bool_t setPalette=kTRUE)
virtual void SetPoint(Int_t i, Double_t x, Double_t y)
Int_t GetN() const
void SetName(const char *name="") override
void SetTitle(const char *title="") override
const char * GetName() const override
TGraphErrors * gr
constexpr Double_t G()
TGraph * get_isotope_thresholds_by_Z_mev_per_nuc(Color_t color=0) const
KVDataQualityAudit::idtelescope * this_telescope
TArc a
ClassImp(TPyArg)
#define mark(osub)