KaliVeda
Toolkit for HIC analysis
KVDataQualityAuditReporting_INDRA.cpp
1 #include "KVDataQualityAuditReporting_INDRA.h"
2 #include "KVDataSetManager.h"
3 #include "KVINDRA.h"
4 #include <KVGeoDNTrajectory.h>
5 #include <TColor.h>
6 #include <TLatex.h>
7 #include <TLegend.h>
8 #include <TMarker.h>
9 #include "TLegend.h"
10 
12 
13 
14 
18 {
19  // Make an A4-size canvas
20  Double_t w = 297 * 6;
21  Double_t h = 210 * 6;
22  if (style == canvas_t::kPortrait) std::swap(w, h);
23  myCanvas = ::new TCanvas("c", "c", w, h);
24  myCanvas->SetWindowSize(w + (w - myCanvas->GetWw()), h + (h - myCanvas->GetWh()));
25 }
26 
27 
28 
30 
32 {
33  if (!gMultiDetArray) {
34  auto dsm = new KVDataSetManager;
35  dsm->Init();
37  }
38 
39  make_canvas();
40 
41  TString pdf_file = Form("%s_DataQualityAudit_%s.pdf", dataset_name.Data(), fAudit->GetName());
42  auto first_page = pdf_file + "(";
43  auto last_page = pdf_file + ")";
44  current_page = first_page;
45  // INDRA Z identification bilan
46  int nx(2), ny(3);
47  myCanvas->Divide(nx, ny);
48  int pad = 1;
49  std::vector<TString> indra_id_types = {"PHOS_R_L", "CI_SI", "SI_CSI", "CI_CSI", "CI_SI75", "SI75_SILI", indra_csi_idtype};
50  for (auto id : indra_id_types) {
51  for (int ring = 1; ring <= 17; ++ring) {
52  if (id != "PHOS_R_L" && ring == 1) continue;
53  if (id == "PHOS_R_L" && ring > 1) break;
54  if ((id == "CI_SI" || id == "SI_CSI") && ring > 9) break;
55  if ((id == "CI_CSI" || id.Contains("SI75")) && ring < 10) continue;
56 
57  myCanvas->cd(pad)->SetFillStyle(4000);//transparent pad
58  INDRA_ring_reporting_Z(ring, id);
59  ++pad;
60  if (pad > nx * ny) {
62  myCanvas->Print(current_page, Form("Title:INDRA Z %s ID Quality by Ring", id.Data()));
63  if (current_page == first_page) current_page = pdf_file;
64  myCanvas->Clear();
65  myCanvas->Divide(nx, ny);
66  pad = 1;
67  }
68  }
69  if (pad != 1) {
71  myCanvas->Print(current_page, Form("Title:INDRA Z %s ID Quality by Ring", id.Data()));
72  if (current_page == first_page) current_page = pdf_file;
73  myCanvas->Clear();
74  myCanvas->Divide(nx, ny);
75  pad = 1;
76  }
77  nx = 4;
78  ny = 3;
79  myCanvas->Clear();
80  myCanvas->Divide(nx, ny);
81  pad = 1;
82  for (int ring = 1; ring <= 17; ++ring) {
83  INDRA_ring_Z_threshold_vs_Z(ring, id, pad, nx, ny);
84  }
85  if (pad != 1) {
86  myCanvas->Print(current_page, Form("Title:INDRA Z thresh. vs Z %s by Ring", id.Data()));
87  myCanvas->Clear();
88  myCanvas->Divide(nx, ny);
89  pad = 1;
90  }
91  if (id == indra_csi_idtype) {
92  for (int ring = 2; ring <= 17; ++ring) {
93  INDRA_ring_mean_A_vs_Z(ring, id, pad, nx, ny);
94  }
95  }
96  else if (id == "SI75_SILI") {
97  for (int ring = 10; ring <= 17; ++ring) {
98  INDRA_ring_mean_A_vs_Z(ring, id, pad, nx, ny);
99  }
100  }
101  if (pad != 1) {
102  myCanvas->Print(current_page, Form("Title:INDRA <A> vs Z %s by Ring", id.Data()));
103  myCanvas->Clear();
104  myCanvas->Divide(nx, ny);
105  pad = 1;
106  }
107  }
108 
109  myCanvas->Clear();
110  myCanvas->Print(last_page, "Title:Last page");
111 }
112 
113 
114 
116 
118 {
119  if (!gIndra) {
120  Error("INDRA_ring_reporting", "You need to build INDRA first...");
121  return;
122  }
123  TList tels;
124  fill_list_of_telescopes(idtype, tels, ring);
125 
126  auto get_module_number = [](const KVIDTelescope * idt) {
127  return (int)dynamic_cast<KVINDRADetector*>(idt->GetDetectors()->Last())->GetModuleNumber();
128  };
129  auto zmean = fReport.get_mean_Z_for_telescopes(&tels, get_module_number);
130  auto zmax = fReport.get_max_Z_for_telescopes(&tels, get_module_number, 24);
131  auto zmax_iso = fReport.get_max_Z_with_isotopes_for_telescopes(&tels, get_module_number, 30);
132  zmax_iso->SetMarkerColor(kOrange - 2);
133  auto zmin = fReport.get_min_Z_for_telescopes(&tels, get_module_number, 25);
134  TMultiGraph* mg = ::new TMultiGraph;
135  mg->SetTitle(Form("Ring %d %s Min/Mean/Max Z vs. Module", ring, idtype.Data()));
136  mg->Add(zmin);
137  mg->Add(zmean);
138  mg->Add(zmax);
139  mg->Add(zmax_iso);
140  mg->Draw("ap");
141 }
142 
143 
144 
146 
148 {
149  for (int mod = 1; mod <= 24; ++mod) {
150  TString name;
151  if (ring > 1)
152  name = Form("%s_%02d%02d", idtype.Data(), ring, mod);
153  else
154  name = Form("%s_%02d", idtype.Data(), mod);
155  auto tel = gIndra->GetIDTelescope(name);
156  if (tel) tels.Add(tel);
157  }
158 }
159 
160 
161 
163 
164 void KVDataQualityAuditReporting_INDRA::INDRA_ring_mean_A_vs_Z(int ring, const TString& idtype, int& pad, int nx, int ny)
165 {
166  TList tels;
167  fill_list_of_telescopes(idtype, tels, ring);
168  int nmods = tels.GetEntries();
169  auto mod_set = get_mod_set(nmods);
170  int color_step = TColor::GetPalette().GetSize() / (mod_set + 1);
171  KVIDTelescope* idt;
172  nmods = 0;
173  while (tels.GetEntries()) {
174  TMultiGraph* mg = ::new TMultiGraph;
175  int i = 1;
176  while (i <= mod_set) {
177  idt = (KVIDTelescope*)tels.Remove(tels.First()); // "pop" the first one in the list
178  if (fAudit->HasTelescope(idt->GetName())) {
179  auto gr = fReport[idt->GetName()].get_mean_isotopic_mass_by_Z();
180  gr->SetMarkerColor(TColor::GetPalette()[color_step * i]);
181  gr->SetMarkerStyle(markers[i - 1]);
182  gr->SetLineWidth(0);
183  mg->Add(gr);
184  }
185  ++i;
186  ++nmods;
187  }
188  myCanvas->cd(pad);
189  ++pad;
190  // change title of graph => title of pad
191  mg->SetTitle(Form("INDRA <A> vs. Z %s Ring %d [%d-%d]", idtype.Data(), ring, nmods - mod_set + 1, nmods));
192  mg->Draw("ap");
193  TLegend* leg;
194  if (i > 12) {
195  leg = gPad->BuildLegend(.11, .89, .61, .69);
196  leg->SetNColumns(3);
197  }
198  else if (i > 6) {
199  leg = gPad->BuildLegend(.11, .89, .61, .69);
200  leg->SetNColumns(2);
201  }
202  else {
203  leg = gPad->BuildLegend(.11, .89, .61, .69);
204  }
205  leg->SetBorderSize(0);
206  leg->SetFillColorAlpha(kWhite, 1.00);
207  if (pad > nx * ny) {
208  myCanvas->Print(current_page, Form("Title:INDRA <A> vs Z %s by Ring", idtype.Data()));
209  myCanvas->Clear();
210  myCanvas->Divide(nx, ny);
211  pad = 1;
212  }
213  }
214 }
215 
216 
217 
220 
222 {
223  // 24 => 4 sets of 6, 16 => 2 sets of 8, 12 => 4 sets of 3, 8 => 1 set of 8
224  int mod_set;
225  switch (nmods) {
226  case 24:
227  mod_set = 6;
228  break;
229  case 16:
230  mod_set = 8;
231  break;
232  case 12:
233  mod_set = 3;
234  break;
235  case 8:
236  mod_set = 8;
237  break;
238  default:
239  mod_set = 1;
240  }
241 
242  return mod_set;
243 }
244 
245 
246 
248 
249 void KVDataQualityAuditReporting_INDRA::INDRA_ring_Z_threshold_vs_Z(int ring, const TString& idtype, int& pad, int nx, int ny)
250 {
251  TList tels;
252  fill_list_of_telescopes(idtype, tels, ring);
253  int nmods = tels.GetEntries();
254  auto mod_set = get_mod_set(nmods);
255 
256  int color_step = TColor::GetPalette().GetSize() / (mod_set + 1);
257  KVIDTelescope* idt;
258  nmods = 0;
259  while (tels.GetEntries()) {
260  TMultiGraph* mg = ::new TMultiGraph;
261  int i = 1;
262  while (i <= mod_set) {
263  idt = (KVIDTelescope*)tels.Remove(tels.First()); // "pop" the first one in the list
264  if (fAudit->HasTelescope(idt->GetName())) {
265  auto gr = fReport[idt->GetName()].get_element_thresholds_by_Z_mev_per_nuc(TColor::GetPalette()[color_step * i]);
266  gr->SetMarkerStyle(markers[i - 1]);
267  gr->SetLineWidth(0);
268  mg->Add(gr);
269  if (gr->GetMean(2) < 0) {
270  // threshold = -1 => uncalibrated particles
271  std::cout << idt->GetName() << " : particles are UNCALIBRATED";
272  // check detector calibrations
273  KVGeoDNTrajectory* traj;
274  if (idt->GetSize() > 1) traj = (KVGeoDNTrajectory*)idt->GetDetector(2)->GetNode()->GetForwardTrajectories()->First();
275  else traj = (KVGeoDNTrajectory*)idt->GetDetector(1)->GetNode()->GetForwardTrajectories()->First();
276  int nuncal = 0;
277  traj->IterateFrom();
278  KVGeoDetectorNode* dn;
279  while ((dn = traj->GetNextNode())) nuncal += (!dn->GetDetector()->IsCalibrated());
280  if (nuncal == traj->GetN()) std::cout << " ... just like ALL DETECTORS";
281  else {
282  std::cout << " ... just like ";
283  traj->IterateFrom();
284  KVGeoDetectorNode* dn;
285  while ((dn = traj->GetNextNode())) {
286  if (!dn->GetDetector()->IsCalibrated()) {
287  std::cout << dn->GetName() << " ";
288  }
289  }
290  }
291  std::cout << std::endl;
292  }
293  }
294  ++i;
295  ++nmods;
296  }
297  myCanvas->cd(pad);
298  ++pad;
299  // change title of graph => title of pad
300  mg->SetTitle(Form("INDRA Z thresh. [MeV/u] vs. Z %s Ring %d [%d-%d]", idtype.Data(), ring, nmods - mod_set + 1, nmods));
301  mg->Draw("ap");
302  double x1, x2;
303 // if(idtype == "CSI")
304 // {
305 // return;// no legend - doesn't fit
306 // //x1 = .39; x2 = .89;
307 // }
308 // else
309 // {
310  x1 = .11;
311  x2 = .61;
312 // }
313  TLegend* leg;
314  if (mod_set > 12) {
315  leg = gPad->BuildLegend(x1, .89, x2, .69);
316  leg->SetNColumns(3);
317  }
318  else if (mod_set > 6) {
319  leg = gPad->BuildLegend(x1, .89, x2, .69);
320  leg->SetNColumns(2);
321  }
322  else {
323  leg = gPad->BuildLegend(x1, .89, x2, .69);
324  }
325  leg->SetBorderSize(0);
326  leg->SetFillColorAlpha(kWhite, 1.00);
327  if (pad > nx * ny) {
328  myCanvas->Print(current_page, Form("Title:INDRA Z thresh. vs Z %s by Ring", idtype.Data()));
329  myCanvas->Clear();
330  myCanvas->Divide(nx, ny);
331  pad = 1;
332  }
333  }
334 }
335 
336 
337 
341 
343 {
344 //=========Macro generated from canvas: c1/c1
345 //========= (Tue Jul 27 11:21:28 2021) by ROOT version 6.24/02
346 
347  myCanvas->cd();
348  // make sure all pads are transparent
350  TObject* obj;
351  while ((obj = it())) {
352  if (obj->InheritsFrom("TPad")) {
353  dynamic_cast<TPad*>(obj)->SetFillStyle(4000);
354  }
355  }
356  TLatex* tex = ::new TLatex(0.02336825, 0.86604, "Max. Z");
357  tex->SetTextSize(0.028);
358  tex->SetTextAngle(90);
359  tex->SetLineWidth(2);
360  tex->Draw();
361  TMarker* marker = ::new TMarker(0.01611604, 0.8519389, 4);
362 
363  Int_t ci; // for color index setting
364  TColor* color; // for color definition with alpha
365  ci = TColor::GetColor("#333399");
366  marker->SetMarkerColor(ci);
367  marker->SetMarkerStyle(4);
368  marker->SetMarkerSize(1.7);
369  marker->Draw();
370  marker = ::new TMarker(0.01772764, 0.4453584, 30);
371 
372  ci = TColor::GetColor("#ffcc33");
373  marker->SetMarkerColor(ci);
374  marker->SetMarkerStyle(30);
375  marker->SetMarkerSize(1.7);
376  marker->Draw();
377  tex = ::new TLatex(0.02497985, 0.4629847, "Max. Z with identified A");
378  tex->SetTextSize(0.028);
379  tex->SetTextAngle(90);
380  tex->SetLineWidth(2);
381  tex->Draw();
382  tex = ::new TLatex(0.02659146, 0.2632197, "Mean Z");
383  tex->SetTextSize(0.028);
384  tex->SetTextAngle(90);
385  tex->SetLineWidth(2);
386  tex->Draw();
387  tex = ::new TLatex(0.02820306, 0.1045828, "Min. Z");
388  tex->SetTextSize(0.028);
389  tex->SetTextAngle(90);
390  tex->SetLineWidth(2);
391  tex->Draw();
392  marker = ::new TMarker(0.01853344, 0.2479436, 20);
393 
394  ci = TColor::GetColor("#333399");
395  marker->SetMarkerColor(ci);
396  marker->SetMarkerStyle(20);
397  marker->SetMarkerSize(1.7);
398  marker->Draw();
399  marker = ::new TMarker(0.02095085, 0.08578143, 25);
400 
401  ci = TColor::GetColor("#333399");
402  marker->SetMarkerColor(ci);
403  marker->SetMarkerStyle(25);
404  marker->SetMarkerSize(1.7);
405  marker->Draw();
406 }
407 
408 
409 
int Int_t
double Double_t
kOrange
kWhite
winID w
Option_t Option_t SetFillStyle
Option_t Option_t TPoint TPoint const char x2
Option_t Option_t TPoint TPoint const char x1
Option_t Option_t style
char name[80]
char * Form(const char *fmt,...)
#define gPad
void Error(const char *method, const char *msgfmt,...) const override
Definition: KVBase.cpp:1650
TGraph * get_max_Z_for_telescopes(TSeqCollection *idtels, TelescopeIndexFunction F, Marker_t marker_style=20) const
TGraph * get_mean_Z_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
TGraph * get_min_Z_for_telescopes(TSeqCollection *idtels, TelescopeIndexFunction F, Marker_t marker_style=20) const
Prepare PDF report on data quality audits for INDRA experiments.
void INDRA_ring_Z_threshold_vs_Z(int ring, const TString &idtype, int &pad, int nx, int ny)
void INDRA_ring_mean_A_vs_Z(int ring, const TString &idtype, int &pad, int nx, int ny)
void make_canvas(canvas_t style=canvas_t::kLandscape)
Make an A4-size canvas.
void INDRA_ring_reporting_Z(int ring, const TString &idtype)
int get_mod_set(int nmods)
24 => 4 sets of 6, 16 => 2 sets of 8, 12 => 4 sets of 3, 8 => 1 set of 8
void fill_list_of_telescopes(const TString &idtype, TList &tels, int ring)
Bool_t HasTelescope(const TString &tel_name) const
Manage all datasets contained in a given data repository.
virtual Bool_t Init(KVDataRepository *=0)
Path taken by particles through multidetector geometry.
KVGeoDetectorNode * GetNextNode() const
void IterateFrom(const KVGeoDetectorNode *node0=nullptr) const
Information on relative positions of detectors & particle trajectories.
KVDetector * GetDetector() const
const Char_t * GetName() const override
Name of node is same as name of associated detector.
Base class for all detectors or associations of detectors in array which can identify charged particl...
Definition: KVIDTelescope.h:85
KVDetector * GetDetector(UInt_t n) const
UInt_t GetSize() const
Base class for detectors of INDRA array.
static KVMultiDetArray * MakeMultiDetector(const Char_t *dataset_name, Int_t run=-1, TString classname="KVMultiDetArray", KVExpDB *db=nullptr)
KVIDTelescope * GetIDTelescope(const Char_t *name) const
Return pointer to DeltaE-E ID Telescope with "name".
Int_t GetSize() const
virtual void SetFillStyle(Style_t fstyle)
virtual void SetLineWidth(Width_t lwidth)
virtual void SetMarkerColor(Color_t mcolor=1)
virtual void SetMarkerStyle(Style_t mstyle=1)
virtual void SetMarkerSize(Size_t msize=1)
virtual void SetTextAngle(Float_t tangle=0)
virtual void SetTextSize(Float_t tsize=1)
void Clear(Option_t *option="") override
TVirtualPad * cd(Int_t subpadnumber=0) override
virtual Int_t GetEntries() const
static const TArrayI & GetPalette()
static Int_t GetColor(const char *hexcolor)
virtual Double_t GetMean(Int_t axis=1) const
void Add(TObject *obj) override
TObject * Remove(const TObjLinkPtr_t &lnk)
TObject * First() const override
void Draw(Option_t *option="") override
const char * GetName() const override
virtual Bool_t InheritsFrom(const char *classname) const
virtual void Draw(Option_t *option="")
void Divide(Int_t nx=1, Int_t ny=1, Float_t xmargin=0.01, Float_t ymargin=0.01, Int_t color=0) override
TList * GetListOfPrimitives() const override
void Print(const char *filename, Option_t *option) override
const char * Data() const
void swap(RVec< T > &lhs, RVec< T > &rhs)
TGraphErrors * gr
leg
TH1 * h
ClassImp(TPyArg)