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;
50  with_phoswich = (dataset_name=="INDRA_camp1" || dataset_name=="INDRA_camp2");
51  if(with_phoswich)
52  indra_id_types.push_back("PHOS_R_L");
53  indra_id_types.push_back("CI_SI");
54  indra_id_types.push_back("SI_CSI");
55  indra_id_types.push_back("CI_CSI");
56  indra_id_types.push_back("CI_SI75");
57  indra_id_types.push_back("SI75_SILI");
58  indra_id_types.push_back(indra_csi_idtype);
59  for (auto id : indra_id_types) {
60  for (int ring = 1; ring <= 17; ++ring) {
61  if (id == "CI_SI" && ring < 2) continue;
62  if (id == "PHOS_R_L" && ring > 1) break;
63  if (with_phoswich && (id == indra_csi_idtype) && ring<2) continue;
64  if ((id == "CI_SI" || id == "SI_CSI") && ring > 9) break;
65  if ((id == "CI_CSI" || id.Contains("SI75")) && ring < 10) continue;
66 
67  myCanvas->cd(pad)->SetFillStyle(4000);//transparent pad
68  INDRA_ring_reporting_Z(ring, id);
69  ++pad;
70  if (pad > nx * ny) {
72  myCanvas->Print(current_page, Form("Title:INDRA Z %s ID Quality by Ring", id.Data()));
73  if (current_page == first_page) current_page = pdf_file;
74  myCanvas->Clear();
75  myCanvas->Divide(nx, ny);
76  pad = 1;
77  }
78  }
79  if (pad != 1) {
81  myCanvas->Print(current_page, Form("Title:INDRA Z %s ID Quality by Ring", id.Data()));
82  if (current_page == first_page) current_page = pdf_file;
83  myCanvas->Clear();
84  myCanvas->Divide(nx, ny);
85  pad = 1;
86  }
87  nx = 4;
88  ny = 3;
89  myCanvas->Clear();
90  myCanvas->Divide(nx, ny);
91  pad = 1;
92  for (int ring = 1; ring <= 17; ++ring) {
93  INDRA_ring_Z_threshold_vs_Z(ring, id, pad, nx, ny);
94  }
95  if (pad != 1) {
96  myCanvas->Print(current_page, Form("Title:INDRA Z thresh. vs Z %s by Ring", id.Data()));
97  myCanvas->Clear();
98  myCanvas->Divide(nx, ny);
99  pad = 1;
100  }
101  if (id == indra_csi_idtype) {
102  for (int ring = with_phoswich ? 2 : 1; ring <= 17; ++ring) {
103  INDRA_ring_mean_A_vs_Z(ring, id, pad, nx, ny);
104  }
105  }
106  else if (id == "SI75_SILI") {
107  for (int ring = 10; ring <= 17; ++ring) {
108  INDRA_ring_mean_A_vs_Z(ring, id, pad, nx, ny);
109  }
110  }
111  if (pad != 1) {
112  myCanvas->Print(current_page, Form("Title:INDRA <A> vs Z %s by Ring", id.Data()));
113  myCanvas->Clear();
114  myCanvas->Divide(nx, ny);
115  pad = 1;
116  }
117  }
118 
119  myCanvas->Clear();
120  myCanvas->Print(last_page, "Title:Last page");
121 }
122 
123 
124 
126 
128 {
129  if (!gIndra) {
130  Error("INDRA_ring_reporting", "You need to build INDRA first...");
131  return;
132  }
133  TList tels;
134  fill_list_of_telescopes(idtype, tels, ring);
135 
136  auto get_module_number = [](const KVIDTelescope * idt) {
137  return (int)dynamic_cast<KVINDRADetector*>(idt->GetDetectors()->Last())->GetModuleNumber();
138  };
139  auto zmean = fReport.get_mean_Z_for_telescopes(&tels, get_module_number);
140  auto zmax = fReport.get_max_Z_for_telescopes(&tels, get_module_number, 24);
141  auto zmax_iso = fReport.get_max_Z_with_isotopes_for_telescopes(&tels, get_module_number, 30);
142  zmax_iso->SetMarkerColor(kOrange - 2);
143  auto zmin = fReport.get_min_Z_for_telescopes(&tels, get_module_number, 25);
144  TMultiGraph* mg = ::new TMultiGraph;
145  mg->SetTitle(Form("Ring %d %s Min/Mean/Max Z vs. Module", ring, idtype.Data()));
146  mg->Add(zmin);
147  mg->Add(zmean);
148  mg->Add(zmax);
149  mg->Add(zmax_iso);
150  mg->Draw("ap");
151 }
152 
153 
154 
156 
158 {
159  for (int mod = 1; mod <= 24; ++mod) {
160  TString name;
161  if (idtype != "PHOS_R_L")
162  name = Form("%s_%02d%02d", idtype.Data(), ring, mod);
163  else
164  name = Form("%s_%02d", idtype.Data(), mod);
165  auto tel = gIndra->GetIDTelescope(name);
166  if (tel) tels.Add(tel);
167  }
168 }
169 
170 
171 
173 
174 void KVDataQualityAuditReporting_INDRA::INDRA_ring_mean_A_vs_Z(int ring, const TString& idtype, int& pad, int nx, int ny)
175 {
176  TList tels;
177  fill_list_of_telescopes(idtype, tels, ring);
178  int nmods = tels.GetEntries();
179  auto mod_set = get_mod_set(nmods);
180  int color_step = TColor::GetPalette().GetSize() / (mod_set + 1);
181  KVIDTelescope* idt;
182  nmods = 0;
183  while (tels.GetEntries()) {
184  TMultiGraph* mg = ::new TMultiGraph;
185  int i = 1;
186  while (i <= mod_set) {
187  idt = (KVIDTelescope*)tels.Remove(tels.First()); // "pop" the first one in the list
188  if (fAudit->HasTelescope(idt->GetName())) {
189  auto gr = fReport[idt->GetName()].get_mean_isotopic_mass_by_Z();
190  gr->SetMarkerColor(TColor::GetPalette()[color_step * i]);
191  gr->SetMarkerStyle(markers[i - 1]);
192  gr->SetLineWidth(0);
193  mg->Add(gr);
194  }
195  ++i;
196  ++nmods;
197  }
198  myCanvas->cd(pad);
199  ++pad;
200  // change title of graph => title of pad
201  mg->SetTitle(Form("INDRA <A> vs. Z %s Ring %d [%d-%d]", idtype.Data(), ring, nmods - mod_set + 1, nmods));
202  mg->Draw("ap");
203  TLegend* leg;
204  if (i > 12) {
205  leg = gPad->BuildLegend(.11, .89, .61, .69);
206  leg->SetNColumns(3);
207  }
208  else if (i > 6) {
209  leg = gPad->BuildLegend(.11, .89, .61, .69);
210  leg->SetNColumns(2);
211  }
212  else {
213  leg = gPad->BuildLegend(.11, .89, .61, .69);
214  }
215  leg->SetBorderSize(0);
216  leg->SetFillColorAlpha(kWhite, 1.00);
217  if (pad > nx * ny) {
218  myCanvas->Print(current_page, Form("Title:INDRA <A> vs Z %s by Ring", idtype.Data()));
219  myCanvas->Clear();
220  myCanvas->Divide(nx, ny);
221  pad = 1;
222  }
223  }
224 }
225 
226 
227 
230 
232 {
233  // 24 => 4 sets of 6, 16 => 2 sets of 8, 12 => 4 sets of 3, 8 => 1 set of 8
234  int mod_set;
235  switch (nmods) {
236  case 24:
237  mod_set = 6;
238  break;
239  case 16:
240  mod_set = 8;
241  break;
242  case 12:
243  mod_set = 3;
244  break;
245  case 8:
246  mod_set = 8;
247  break;
248  default:
249  mod_set = 1;
250  }
251 
252  return mod_set;
253 }
254 
255 
256 
258 
259 void KVDataQualityAuditReporting_INDRA::INDRA_ring_Z_threshold_vs_Z(int ring, const TString& idtype, int& pad, int nx, int ny)
260 {
261  TList tels;
262  fill_list_of_telescopes(idtype, tels, ring);
263  int nmods = tels.GetEntries();
264  auto mod_set = get_mod_set(nmods);
265 
266  int color_step = TColor::GetPalette().GetSize() / (mod_set + 1);
267  KVIDTelescope* idt;
268  nmods = 0;
269  while (tels.GetEntries()) {
270  TMultiGraph* mg = ::new TMultiGraph;
271  int i = 1;
272  while (i <= mod_set) {
273  idt = (KVIDTelescope*)tels.Remove(tels.First()); // "pop" the first one in the list
274  if (fAudit->HasTelescope(idt->GetName())) {
275  auto gr = fReport[idt->GetName()].get_element_thresholds_by_Z_mev_per_nuc(TColor::GetPalette()[color_step * i]);
276  gr->SetMarkerStyle(markers[i - 1]);
277  gr->SetLineWidth(0);
278  mg->Add(gr);
279  if (gr->GetMean(2) < 0) {
280  // threshold = -1 => uncalibrated particles
281  std::cout << idt->GetName() << " : particles are UNCALIBRATED";
282  // check detector calibrations
283  KVGeoDNTrajectory* traj;
284  if (idt->GetSize() > 1) traj = (KVGeoDNTrajectory*)idt->GetDetector(2)->GetNode()->GetForwardTrajectories()->First();
285  else traj = (KVGeoDNTrajectory*)idt->GetDetector(1)->GetNode()->GetForwardTrajectories()->First();
286  int nuncal = 0;
287  traj->IterateFrom();
288  KVGeoDetectorNode* dn;
289  while ((dn = traj->GetNextNode())) nuncal += (!dn->GetDetector()->IsCalibrated());
290  if (nuncal == traj->GetN()) std::cout << " ... just like ALL DETECTORS";
291  else {
292  std::cout << " ... just like ";
293  traj->IterateFrom();
294  KVGeoDetectorNode* dn;
295  while ((dn = traj->GetNextNode())) {
296  if (!dn->GetDetector()->IsCalibrated()) {
297  std::cout << dn->GetName() << " ";
298  }
299  }
300  }
301  std::cout << std::endl;
302  }
303  }
304  ++i;
305  ++nmods;
306  }
307  myCanvas->cd(pad);
308  ++pad;
309  // change title of graph => title of pad
310  mg->SetTitle(Form("INDRA Z thresh. [MeV/u] vs. Z %s Ring %d [%d-%d]", idtype.Data(), ring, nmods - mod_set + 1, nmods));
311  mg->Draw("ap");
312  double x1, x2;
313 // if(idtype == "CSI")
314 // {
315 // return;// no legend - doesn't fit
316 // //x1 = .39; x2 = .89;
317 // }
318 // else
319 // {
320  x1 = .11;
321  x2 = .61;
322 // }
323  TLegend* leg;
324  if (mod_set > 12) {
325  leg = gPad->BuildLegend(x1, .89, x2, .69);
326  leg->SetNColumns(3);
327  }
328  else if (mod_set > 6) {
329  leg = gPad->BuildLegend(x1, .89, x2, .69);
330  leg->SetNColumns(2);
331  }
332  else {
333  leg = gPad->BuildLegend(x1, .89, x2, .69);
334  }
335  leg->SetBorderSize(0);
336  leg->SetFillColorAlpha(kWhite, 1.00);
337  if (pad > nx * ny) {
338  myCanvas->Print(current_page, Form("Title:INDRA Z thresh. vs Z %s by Ring", idtype.Data()));
339  myCanvas->Clear();
340  myCanvas->Divide(nx, ny);
341  pad = 1;
342  }
343  }
344 }
345 
346 
347 
351 
353 {
354 //=========Macro generated from canvas: c1/c1
355 //========= (Tue Jul 27 11:21:28 2021) by ROOT version 6.24/02
356 
357  myCanvas->cd();
358  // make sure all pads are transparent
360  TObject* obj;
361  while ((obj = it())) {
362  if (obj->InheritsFrom("TPad")) {
363  dynamic_cast<TPad*>(obj)->SetFillStyle(4000);
364  }
365  }
366  TLatex* tex = ::new TLatex(0.02336825, 0.86604, "Max. Z");
367  tex->SetTextSize(0.028);
368  tex->SetTextAngle(90);
369  tex->SetLineWidth(2);
370  tex->Draw();
371  TMarker* marker = ::new TMarker(0.01611604, 0.8519389, 4);
372 
373  Int_t ci; // for color index setting
374  TColor* color; // for color definition with alpha
375  ci = TColor::GetColor("#333399");
376  marker->SetMarkerColor(ci);
377  marker->SetMarkerStyle(4);
378  marker->SetMarkerSize(1.7);
379  marker->Draw();
380  marker = ::new TMarker(0.01772764, 0.4453584, 30);
381 
382  ci = TColor::GetColor("#ffcc33");
383  marker->SetMarkerColor(ci);
384  marker->SetMarkerStyle(30);
385  marker->SetMarkerSize(1.7);
386  marker->Draw();
387  tex = ::new TLatex(0.02497985, 0.4629847, "Max. Z with identified A");
388  tex->SetTextSize(0.028);
389  tex->SetTextAngle(90);
390  tex->SetLineWidth(2);
391  tex->Draw();
392  tex = ::new TLatex(0.02659146, 0.2632197, "Mean Z");
393  tex->SetTextSize(0.028);
394  tex->SetTextAngle(90);
395  tex->SetLineWidth(2);
396  tex->Draw();
397  tex = ::new TLatex(0.02820306, 0.1045828, "Min. Z");
398  tex->SetTextSize(0.028);
399  tex->SetTextAngle(90);
400  tex->SetLineWidth(2);
401  tex->Draw();
402  marker = ::new TMarker(0.01853344, 0.2479436, 20);
403 
404  ci = TColor::GetColor("#333399");
405  marker->SetMarkerColor(ci);
406  marker->SetMarkerStyle(20);
407  marker->SetMarkerSize(1.7);
408  marker->Draw();
409  marker = ::new TMarker(0.02095085, 0.08578143, 25);
410 
411  ci = TColor::GetColor("#333399");
412  marker->SetMarkerColor(ci);
413  marker->SetMarkerStyle(25);
414  marker->SetMarkerSize(1.7);
415  marker->Draw();
416 }
417 
418 
419 
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:1674
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)
Bool_t IsCalibrated() const
Definition: KVDetector.h:406
KVGeoDetectorNode * GetNode()
Definition: KVDetector.h:345
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 KVSeqCollection * GetForwardTrajectories() 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".
TObject * First() const override
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)