1 #include "KVDataQualityAuditReporting_INDRAFAZIA.h"
2 #include "KVDataSetManager.h"
5 #include <KVFAZIADetector.h>
6 #include <KVGeoDNTrajectory.h>
19 void KVDataQualityAuditReporting_INDRAFAZIA::make_canvas(canvas_t style)
24 if (style == canvas_t::kPortrait) std::swap(w, h);
25 myCanvas = ::new TCanvas(
"c",
"c", w, h);
26 myCanvas->SetWindowSize(w + (w - myCanvas->GetWw()), h + (h - myCanvas->GetWh()));
34 void KVDataQualityAuditReporting_INDRAFAZIA::make_fazia_map(
double theta_bin)
40 std::map<double, std::vector<KVDetector*>> tmp_map;
44 int bin = TMath::Nint(det->
GetTheta() * (1 / theta_bin));
45 tmp_map[bin].push_back(det);
50 for (
auto& p : tmp_map) {
51 auto grp_theta = p.first;
53 return a->GetTheta() < b->GetTheta();
55 if(p.second.size()>10)
57 auto new_size = p.second.size() - p.second.size()/2;
61 KVError::Info(
this,
"make_fazia_map",
"group %f has %d members: split in 3", p.first, p.second.size());
62 new_size = p.second.size() - 2*p.second.size()/3;
63 fazia_map[grp_theta] = {p.second.begin(),p.second.begin()+new_size};
65 fazia_map[grp_theta] = {p.second.begin()+new_size, p.second.begin()+2*new_size};
67 fazia_map[grp_theta] = {p.second.begin()+2*new_size, p.second.end()};
71 KVError::Info(
this,
"make_fazia_map",
"group %f has %d members: split in 2", p.first, p.second.size());
72 fazia_map[grp_theta] = {p.second.begin(),p.second.begin()+new_size};
74 fazia_map[grp_theta] = {p.second.begin()+new_size, p.second.end()};
78 fazia_map[grp_theta] = p.second;
98 TString pdf_file = Form(
"%s_DataQualityAudit_%s.pdf", dataset_name.Data(), fAudit->GetName());
99 auto first_page = pdf_file +
"(";
100 auto last_page = pdf_file +
")";
101 current_page = first_page;
104 myCanvas->Divide(nx, ny);
106 std::vector<TString> indra_id_types = {
"SI",
"SI_CSI", indra_csi_idtype};
107 for (
auto&
id : indra_id_types) {
108 for (
int ring = 6; ring <= 17; ++ring) {
109 if ((
id ==
"SI_CSI" ||
id ==
"SI") && ring > 9)
break;
111 myCanvas->cd(pad)->SetFillStyle(4000);
116 draw_sidebar_legend();
117 myCanvas->Print(current_page, Form(
"Title:INDRA Z %s ID Quality by Ring",
id.Data()));
118 if (current_page == first_page) current_page = pdf_file;
120 myCanvas->Divide(nx, ny);
126 draw_sidebar_legend();
127 myCanvas->Print(current_page, Form(
"Title:INDRA Z %s ID Quality by Ring",
id.Data()));
128 if (current_page == first_page) current_page = pdf_file;
130 myCanvas->Divide(nx, ny);
136 myCanvas->Divide(nx, ny);
138 for (
int ring = 6; ring <= 17; ++ring) {
139 if ((
id ==
"SI_CSI" ||
id ==
"SI")) {
146 myCanvas->Print(current_page, Form(
"Title:INDRA <A> vs Z %s by Ring",
id.Data()));
148 myCanvas->Divide(nx, ny);
151 for (
int ring = 6; ring <= 17; ++ring) {
155 myCanvas->Print(current_page, Form(
"Title:INDRA Z thresh. vs Z %s by Ring",
id.Data()));
157 myCanvas->Divide(nx, ny);
163 std::vector<TString> fazia_id_types = {
"SI1",
"SI1_SI2", fazia_si_csi_idtype,
"CSI"};
166 for (
auto&
id : fazia_id_types) {
168 myCanvas->Divide(nx, ny);
171 for (
auto& p : fazia_map) {
179 draw_sidebar_legend_fazia();
180 myCanvas->Print(pdf_file, Form(
"Title:FAZIA Z %s ID Quality by Group",
id.Data()));
182 myCanvas->Divide(nx, ny);
188 draw_sidebar_legend_fazia();
189 myCanvas->Print(pdf_file, Form(
"Title:FAZIA Z %s ID Quality by Group",
id.Data()));
193 myCanvas->Divide(nx, ny);
196 for (
auto& p : fazia_map) {
204 myCanvas->Print(pdf_file, Form(
"Title:FAZIA <A> vs Z %s by Group",
id.Data()));
206 myCanvas->Divide(nx, ny);
211 if (pad != 1) myCanvas->Print(pdf_file, Form(
"Title:FAZIA <A> vs Z %s by Group",
id.Data()));
214 myCanvas->Divide(nx, ny);
217 for (
auto& p : fazia_map) {
225 myCanvas->Print(pdf_file, Form(
"Title:FAZIA Z thresh. vs Z %s by Group",
id.Data()));
227 myCanvas->Divide(nx, ny);
232 if (pad != 1) myCanvas->Print(pdf_file, Form(
"Title:FAZIA Z thresh. vs Z %s by Group",
id.Data()));
235 myCanvas->Divide(nx, ny);
238 for (
auto& p : fazia_map) {
246 myCanvas->Print(pdf_file, Form(
"Title:FAZIA A thresh. vs Z %s by Group",
id.Data()));
248 myCanvas->Divide(nx, ny);
253 if (pad != 1) myCanvas->Print(pdf_file, Form(
"Title:FAZIA A thresh. vs Z %s by Group",
id.Data()));
256 myCanvas->Print(last_page,
"Title:Last page");
263 std::optional<KVUnownedList> KVDataQualityAuditReporting_INDRAFAZIA::get_indra_telescopes(
int ring,
const TString& idtype)
267 for (
int mod = 1; mod <= 24; ++mod) {
268 TString name = Form(
"%s_%02d%02d", idtype.Data(), ring, mod);
287 auto tels = get_indra_telescopes(ring, idtype);
293 return (
int)
dynamic_cast<KVINDRADetector*
>(idt->GetDetector(1))->GetModuleNumber();
298 zmax_iso->SetMarkerColor(kOrange - 2);
300 TMultiGraph* mg = ::new TMultiGraph;
301 mg->SetTitle(Form(
"Ring %d %s Min/Mean/Max Z vs. Module", ring, idtype.Data()));
316 auto tels = get_indra_telescopes(ring,idtype);
320 int nmods = tels->GetEntries();
322 int mod_set = (nmods > 16 ? 6 : 8);
323 int color_step = TColor::GetPalette().
GetSize() / (mod_set + 1);
326 while (tels->GetEntries()) {
327 TMultiGraph* mg = ::new TMultiGraph;
329 while (i <= mod_set) {
332 auto gr = fReport[idt->GetName()].get_mean_isotopic_mass_by_Z();
333 gr->SetMarkerColor(TColor::GetPalette()[color_step * i]);
334 gr->SetMarkerStyle(markers[(i-1)%max_marker]);
344 mg->SetTitle(Form(
"INDRA <A> vs. Z %s Ring %d [%d-%d]", idtype.Data(), ring, nmods - mod_set + 1, nmods));
348 leg = gPad->BuildLegend(.11, .89, .61, .69);
352 leg = gPad->BuildLegend(.11, .89, .61, .69);
356 leg = gPad->BuildLegend(.11, .89, .61, .69);
358 leg->SetBorderSize(0);
359 leg->SetFillColorAlpha(kWhite, 1.00);
361 myCanvas->Print(current_page, Form(
"Title:INDRA <A> vs Z %s by Ring", idtype.Data()));
363 myCanvas->Divide(nx, ny);
375 auto tels = get_indra_telescopes(ring,idtype);
380 int nmods = tels->GetEntries();
382 int mod_set = (nmods > 16 ? 6 : 8);
383 int color_step = TColor::GetPalette().
GetSize() / (mod_set + 1);
386 while (tels->GetEntries()) {
387 TMultiGraph* mg = ::new TMultiGraph;
389 while (i <= mod_set) {
392 auto gr = fReport[idt->GetName()].get_element_thresholds_by_Z_mev_per_nuc(TColor::GetPalette()[color_step * i]);
393 gr->SetMarkerStyle(markers[(i-1)%max_marker]);
396 if (gr->GetMean(2) < 0) {
398 std::cout << idt->GetName() <<
" : particles are UNCALIBRATED";
408 if (nuncal == traj->
GetN()) std::cout <<
" ... just like ALL DETECTORS";
410 std::cout <<
" ... just like ";
415 std::cout << dn->
GetName() <<
" ";
420 std::cout << std::endl;
429 mg->SetTitle(Form(
"INDRA Z thresh. [MeV/u] vs. Z %s Ring %d [%d-%d]", idtype.Data(), ring, nmods - mod_set + 1, nmods));
444 leg = gPad->BuildLegend(x1, .89, x2, .69);
447 else if (mod_set > 6) {
448 leg = gPad->BuildLegend(x1, .89, x2, .69);
452 leg = gPad->BuildLegend(x1, .89, x2, .69);
454 leg->SetBorderSize(0);
455 leg->SetFillColorAlpha(kWhite, 1.00);
457 myCanvas->Print(current_page, Form(
"Title:INDRA Z thresh. vs Z %s by Ring", idtype.Data()));
459 myCanvas->Divide(nx, ny);
470 bool KVDataQualityAuditReporting_INDRAFAZIA::fill_telescopes_of_group(TList& tels, std::vector<KVDetector*>& dets,
const TString& idtype,
double& theta_min,
double& theta_max)
474 for (
auto d : dets) {
476 TString name = Form(
"ID_%s_%d", idtype.Data(), index);
484 if (tel->IsReadyForID()) std::cout << tel->GetName() <<
" is absent from audit - BUT IS READY TO IDENTIFY!" << std::endl;
487 theta_min = std::min(theta_min, d->GetTheta());
488 theta_max = std::max(theta_min, d->GetTheta());
503 double theta_min{360}, theta_max{0};
504 Info(
"FAZIA_group_reporting_Z",
"id=%s Group %d", idtype.Data(), group_num);
505 if(!fill_telescopes_of_group(tels, dets, idtype, theta_min, theta_max))
507 Info(
"FAZIA_group_reporting_Z",
"id=%s Group %d: NO TELESCOPES IN AUDIT", idtype.Data(), group_num);
520 zmax_iso->SetMarkerColor(kOrange - 2);
523 TMultiGraph* mg = ::new TMultiGraph;
524 mg->SetTitle(Form(
"Group %d [%.2f#leq#theta#leq%.2f] %s Min/Mean/Max Z", group_num, theta_min, theta_max, idtype.Data()));
541 double theta_min{360}, theta_max{0};
542 if(!fill_telescopes_of_group(tels, dets, idtype, theta_min, theta_max))
545 int color_step = TColor::GetPalette().GetSize() / (dets.size() + 1);
549 TMultiGraph* mg = ::new TMultiGraph;
551 auto gr = fReport[idt->GetName()].get_mean_isotopic_mass_by_Z();
552 gr->SetMarkerColor(TColor::GetPalette()[color_step * i]);
553 gr->SetMarkerStyle(markers[(i-1)%max_marker]);
559 mg->SetTitle(Form(
"FAZIA <A> vs. Z %s Group %d [%.2f#leq#theta#leq%.2f]", idtype.Data(), group_num, theta_min, theta_max));
563 leg = gPad->BuildLegend(.11, .89, .61, .69);
567 leg = gPad->BuildLegend(.11, .89, .61, .69);
571 leg = gPad->BuildLegend(.11, .89, .61, .69);
573 leg->SetBorderSize(0);
574 leg->SetFillColorAlpha(kWhite, 1.00);
585 double theta_min{360}, theta_max{0};
586 if(!fill_telescopes_of_group(tels, dets, idtype, theta_min, theta_max))
589 int color_step = TColor::GetPalette().GetSize() / (dets.size() + 1);
593 TMultiGraph* mg = ::new TMultiGraph;
595 auto gr = fReport[idt->GetName()].get_element_thresholds_by_Z_mev_per_nuc(TColor::GetPalette()[color_step * i]);
596 gr->SetMarkerStyle(markers[(i-1)%max_marker]);
599 if (gr->GetMean(2) < 0) {
601 std::cout << idt->GetName() <<
" : particles are UNCALIBRATED";
610 else std::cout <<
" ... just like " << idt->
GetDetector(1)->GetName();
618 if (nuncal == traj->
GetN()) std::cout <<
" ... just like ALL DETECTORS";
620 std::cout <<
" ... just like ";
625 std::cout << dn->
GetName() <<
" ";
630 std::cout << std::endl;
635 mg->SetTitle(Form(
"FAZIA Z thresh. [MeV/u] vs. Z %s Group %d [%.2f#leq#theta#leq%.2f]", idtype.Data(), group_num, theta_min, theta_max));
638 if (idtype ==
"CSI") {
648 leg = gPad->BuildLegend(x1, .89, x2, .69);
652 leg = gPad->BuildLegend(x1, .89, x2, .69);
656 leg = gPad->BuildLegend(x1, .89, x2, .69);
658 leg->SetBorderSize(0);
659 leg->SetFillColorAlpha(kWhite, 1.00);
670 double theta_min{360}, theta_max{0};
671 if(!fill_telescopes_of_group(tels, dets, idtype, theta_min, theta_max))
674 int color_step = TColor::GetPalette().GetSize() / (dets.size() + 1);
678 TMultiGraph* mg = ::new TMultiGraph;
680 auto gr = fReport[idt->GetName()].get_isotope_thresholds_by_Z_mev_per_nuc(TColor::GetPalette()[color_step * i]);
681 gr->SetMarkerStyle(markers[(i-1)%max_marker]);
687 mg->SetTitle(Form(
"FAZIA A thresh. [MeV/u] vs. Z %s Group %d [%.2f#leq#theta#leq%.2f]", idtype.Data(), group_num, theta_min, theta_max));
690 if (idtype ==
"CSI") {
700 leg = gPad->BuildLegend(x1, .89, x2, .69);
704 leg = gPad->BuildLegend(x1, .89, x2, .69);
708 leg = gPad->BuildLegend(x1, .89, x2, .69);
710 leg->SetBorderSize(0);
711 leg->SetFillColorAlpha(kWhite, 1.00);
721 auto N =
dynamic_cast<TGraph*
>(graf->GetListOfGraphs()->First())->GetN();
722 for (
int i = 0; i < N; ++i) {
723 auto bin = graf->GetXaxis()->FindBin(i);
724 graf->GetXaxis()->SetBinLabel(bin, tels->At(i)->GetName());
726 graf->GetXaxis()->LabelsOption(
"u");
735 void KVDataQualityAuditReporting_INDRAFAZIA::draw_sidebar_legend()
742 TIter it(myCanvas->GetListOfPrimitives());
744 while ((obj = it())) {
745 if (obj->InheritsFrom(
"TPad")) {
746 dynamic_cast<TPad*
>(obj)->SetFillStyle(4000);
749 TLatex* tex = ::new TLatex(0.02336825, 0.86604,
"Max. Z");
750 tex->SetTextSize(0.028);
751 tex->SetTextAngle(90);
752 tex->SetLineWidth(2);
754 TMarker* marker = ::new TMarker(0.01611604, 0.8519389, 4);
758 ci = TColor::GetColor(
"#333399");
759 marker->SetMarkerColor(ci);
760 marker->SetMarkerStyle(4);
761 marker->SetMarkerSize(1.7);
763 marker = ::new TMarker(0.01772764, 0.4453584, 30);
765 ci = TColor::GetColor(
"#ffcc33");
766 marker->SetMarkerColor(ci);
767 marker->SetMarkerStyle(30);
768 marker->SetMarkerSize(1.7);
770 tex = ::new TLatex(0.02497985, 0.4629847,
"Max. Z with identified A");
771 tex->SetTextSize(0.028);
772 tex->SetTextAngle(90);
773 tex->SetLineWidth(2);
775 tex = ::new TLatex(0.02659146, 0.2632197,
"Mean Z");
776 tex->SetTextSize(0.028);
777 tex->SetTextAngle(90);
778 tex->SetLineWidth(2);
780 tex = ::new TLatex(0.02820306, 0.1045828,
"Min. Z");
781 tex->SetTextSize(0.028);
782 tex->SetTextAngle(90);
783 tex->SetLineWidth(2);
785 marker = ::new TMarker(0.01853344, 0.2479436, 20);
787 ci = TColor::GetColor(
"#333399");
788 marker->SetMarkerColor(ci);
789 marker->SetMarkerStyle(20);
790 marker->SetMarkerSize(1.7);
792 marker = ::new TMarker(0.02095085, 0.08578143, 25);
794 ci = TColor::GetColor(
"#333399");
795 marker->SetMarkerColor(ci);
796 marker->SetMarkerStyle(25);
797 marker->SetMarkerSize(1.7);
807 void KVDataQualityAuditReporting_INDRAFAZIA::draw_sidebar_legend_fazia()
813 TIter it(myCanvas->GetListOfPrimitives());
815 while ((obj = it())) {
816 if (obj->InheritsFrom(
"TPad")) {
817 dynamic_cast<TPad*
>(obj)->SetFillStyle(4000);
820 TLatex* tex =
new TLatex(0.9813084, 0.9470954,
"Max. Z");
821 tex->SetTextSize(0.028);
822 tex->SetTextAngle(270);
823 tex->SetLineWidth(2);
825 TMarker* marker =
new TMarker(0.9853972, 0.9688797, 4);
829 ci = TColor::GetColor(
"#333399");
830 marker->SetMarkerColor(ci);
831 marker->SetMarkerStyle(4);
832 marker->SetMarkerSize(1.7);
834 marker =
new TMarker(0.984229, 0.8309129, 30);
836 ci = TColor::GetColor(
"#ffcc33");
837 marker->SetMarkerColor(ci);
838 marker->SetMarkerStyle(30);
839 marker->SetMarkerSize(1.7);
841 tex =
new TLatex(0.9807243, 0.8143154,
"Max. Z with identified A");
842 tex->SetTextSize(0.028);
843 tex->SetTextAngle(270);
844 tex->SetLineWidth(2);
846 tex =
new TLatex(0.9813084, 0.4419087,
"Mean Z");
847 tex->SetTextSize(0.028);
848 tex->SetTextAngle(270);
849 tex->SetLineWidth(2);
851 tex =
new TLatex(0.978972, 0.2479253,
"Min. Z");
852 tex->SetTextSize(0.028);
853 tex->SetTextAngle(270);
854 tex->SetLineWidth(2);
856 marker =
new TMarker(0.9853972, 0.4564315, 20);
858 ci = TColor::GetColor(
"#333399");
859 marker->SetMarkerColor(ci);
860 marker->SetMarkerStyle(20);
861 marker->SetMarkerSize(1.7);
863 marker =
new TMarker(0.9830607, 0.2645228, 25);
865 ci = TColor::GetColor(
"#333399");
866 marker->SetMarkerColor(ci);
867 marker->SetMarkerStyle(25);
868 marker->SetMarkerSize(1.7);
Bool_t IsLabelled(const Char_t *l, bool case_insensitive=false) const
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-FAZIA experiments.
void relabel_FAZIA_telescope_axis(TMultiGraph *graf, const TList *tels) const
bool FAZIA_group_reporting_Z(int group_num, std::vector< KVDetector * > &, const TString &idtype)
bool FAZIA_group_Z_threshold_vs_Z(int group_num, std::vector< KVDetector * > &dets, const TString &idtype)
bool INDRA_ring_reporting_Z(int ring, const TString &idtype)
void INDRA_ring_Z_threshold_vs_Z(int ring, const TString &idtype, int &pad, int nx, int ny)
bool FAZIA_group_mean_A_vs_Z(int group_num, std::vector< KVDetector * > &, const TString &idtype)
void INDRA_ring_mean_A_vs_Z(int ring, const TString &idtype, int &pad, int nx, int ny)
bool FAZIA_group_A_threshold_vs_Z(int group_num, std::vector< KVDetector * > &dets, const TString &idtype)
Bool_t HasTelescope(const TString &tel_name) const
Base class for detector geometry description, interface to energy-loss calculations.
Bool_t IsCalibrated(const KVNameValueList ¶ms={}) const
KVGeoDetectorNode * GetNode()
Double_t GetTheta() const override
Base class for FAZIA detectors.
TString GetSiCsIIDType() const
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.
const KVSeqCollection * GetDetectors() const
Base class for all detectors or associations of detectors in array which can identify charged particl...
KVDetector * GetDetector(UInt_t n) const
Base class for detectors of INDRA array.
TString GetCsIIDType() const
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
TObject * Remove(TObject *obj) override
Remove object from list.
void Add(TObject *obj) override
Int_t GetSize() const override
Extended TList class which does not own its objects by default.
void Info(UserClass p, const char *location, const char *va_(fmt),...)