15 #define TALKATIVE // get some comments while processing 19 #define INSIDE_VECTOR(vector) \ 20 cout << #vector << "={"; for (unsigned int i = 0 ; i < vector.size()-1 ; i++) cout << vector[i] << ","; cout << vector.back() << "}"; 21 #define CHECK_MAP_CONTENT(m,type) \ 22 for (map<TString,type>::iterator it = m.begin() ; it != m.end() ; it++) \ 23 cout << __FILE__ << ":" << __LINE__ << ":Info: " << #m << "[" << it->first << "]=" << it->second << endl; 27 TString output_directory,
28 TString modulesToPlot,
29 TString alignmentName,
30 TString referenceName,
34 _output_directory(output_directory + TString(output_directory.EndsWith(
"/") ?
"" :
"/")),
35 _output_filename(
"comparison.root"),
37 _module_plot_option(modulesToPlot),
38 _alignment_name(alignmentName),
39 _reference_name(referenceName),
40 _print_only_global(printOnlyGlobal),
41 _make_profile_plots(makeProfilePlots),
61 cout <<
">>> TALKATIVE MODE ACTIVATED <<<" << endl;
64 cout <<
">>> DEBUG MODE ACTIVATED <<<" << endl;
65 cout << __FILE__ <<
":"<< __LINE__ <<
":Info: inside constructor of GeometryComparisonPlotter utility"<< endl;
78 tree_file =
new TFile(tree_file_name,
"UPDATE");
82 data->SetBranchAddress(
"inModuleList" ,&
branch_i[
"inModuleList"]);
83 data->SetBranchAddress(
"badModuleQuality" ,&
branch_i[
"badModuleQuality"]);
87 data->SetBranchAddress(
"sublevel" ,&
branch_i[
"sublevel"]);
88 data->SetBranchAddress(
"useDetId" ,&
branch_i[
"useDetId"]);
108 if (
data->GetBranch(
"rdphi") == 0x0)
111 cout << __FILE__ <<
":" << __LINE__ <<
":Info: computing the rdphi branch from r and dphi branches (assuming they exist...)" << endl;
113 TBranch * br_rdphi =
data->Branch(
"rdphi", &
branch_f[
"rdphi"],
"rdphi/F");
114 for (
unsigned int ientry = 0 ; ientry <
data->GetEntries() ; ientry++)
116 data->GetEntry(ientry);
125 cout << __FILE__ <<
":" << __LINE__ <<
":Info: branch addresses set" << endl;
131 data->SetMarkerSize(0.5);
132 data->SetMarkerStyle(6);
134 gStyle->SetOptStat(
"emr");
135 gStyle->SetTitleAlign(22);
136 gStyle->SetTitleX(0.5);
137 gStyle->SetTitleY(0.97);
138 gStyle->SetTitleFont(62);
141 gStyle->SetTextFont(132);
142 gStyle->SetTextSize(0.08);
143 gStyle->SetLabelFont(132,
"x");
144 gStyle->SetLabelFont(132,
"y");
145 gStyle->SetLabelFont(132,
"z");
146 gStyle->SetTitleSize(0.08,
"x");
147 gStyle->SetTitleSize(0.08,
"y");
148 gStyle->SetTitleSize(0.08,
"z");
149 gStyle->SetLabelSize(0.08,
"x");
150 gStyle->SetLabelSize(0.08,
"y");
151 gStyle->SetLabelSize(0.08,
"z");
153 gStyle->SetMarkerStyle(8);
154 gStyle->SetHistLineWidth(2);
155 gStyle->SetLineStyleString(2,
"[12 12]");
157 gStyle->SetFrameBorderMode(0);
158 gStyle->SetCanvasBorderMode(0);
159 gStyle->SetPadBorderMode(0);
160 gStyle->SetPadColor(0);
161 gStyle->SetCanvasColor(0);
162 gStyle->SetTitleColor(1);
163 gStyle->SetStatColor(0);
164 gStyle->SetStatBorderSize(1);
165 gStyle->SetFrameFillColor(0);
167 gStyle->SetPadTickX(1);
168 gStyle->SetPadTickY(1);
170 gStyle->SetPadTopMargin(0.1);
171 gStyle->SetPadRightMargin(0.05);
172 gStyle->SetPadBottomMargin(0.16);
173 gStyle->SetPadLeftMargin(0.18);
176 cout << __FILE__ <<
":" << __LINE__ <<
":Info: end of constructor" << endl;
183 cout << __FILE__ <<
":" << __LINE__ <<
":Info: in destructor of the GeometryComparisonPlotter utility" << endl;
187 cout << __FILE__ <<
":" << __LINE__ <<
":Info: ending." << endl;
199 #define CHECK_BRANCHES(branchname_vector) \ 200 for (unsigned int i = 0 ; i < branchname_vector.size() ; i++) \ 202 if (branch_f.find(branchname_vector[i]) == branch_f.end()) \ 204 cout << __FILE__ << ":" << __LINE__ << ":Error: The branch " << branchname_vector[i] << " is not recognised." << endl; \ 211 const unsigned int nentries =
data->GetEntries();
221 #define LIMITS(axes_vector) \ 222 for (unsigned int i = 0 ; i < axes_vector.size() ; i++) \ 224 if ( _SF.find(axes_vector[i]) == _SF.end()) _SF[axes_vector[i]] = 1.; \ 225 if (_min.find(axes_vector[i]) == _min.end()) _min[axes_vector[i]] = _SF[axes_vector[i]]*data->GetMinimum(axes_vector[i]); \ 226 if (_max.find(axes_vector[i]) == _max.end()) _max[axes_vector[i]] = _SF[axes_vector[i]]*data->GetMaximum(axes_vector[i]); \ 254 #define NB_SUBLEVELS 6 256 #define NB_Z_SLICES 2 257 #define NB_MODULE_QUALITY 3 258 #define COLOR_CODE(icolor) int(icolor/4)+icolor+1 263 TMultiGraph * mgraphs[x.size()][y.size()][1+
NB_SUBLEVELS];
285 c_global[ic] =
new TCanvas (TString::Format(
"global_%s_%d", ic==0?
"tracker":
_sublevel_names[ic-1].Data(),
287 TString::Format(
"Global overview of the %s variables", ic==0?
"tracker":
_sublevel_names[ic-1].Data()),
290 c_global[ic]->Divide(x.size(),y.size());
293 c_global_hist[ic] =
new TCanvas (TString::Format(
"global_profile_plots_%s_%d", ic==0?
"tracker":
_sublevel_names[ic-1].Data(),
295 TString::Format(
"Global overview profile plots of the %s variables", ic==0?
"tracker":
_sublevel_names[ic-1].Data()),
298 c_global_hist[ic]->Divide(x.size(),y.size());
304 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
306 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
312 ipoint[ix][iy][igraph] = 0;
313 graphs[ix][iy][igraph] =
new TGraph ();
315 graphs[ix][iy][igraph]->SetMarkerColor(
COLOR_CODE(igraph));
316 graphs[ix][iy][igraph]->SetMarkerStyle(6);
321 ( igraph >= 2*
NB_SUBLEVELS*NB_Z_SLICES ?
"bad" :
"list") :
"good" ));
325 ( igraph >= 2*
NB_SUBLEVELS*NB_Z_SLICES ?
" bad modules" :
" in list") :
" good modules" )
328 graphs[ix][iy][igraph]->SetMarkerStyle(igraph >=
NB_SUBLEVELS*NB_Z_SLICES ?
336 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
338 if ( x[ix] ==
"phi") nXBins = 10;
341 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
362 cout << __FILE__ <<
":" << __LINE__ <<
":Info: Looping on the TTree" << endl;
365 unsigned int progress = 0;
366 cout << __FILE__ <<
":" << __LINE__ <<
":Info: 0%" << endl;
368 for (
unsigned int ientry = 0 ; ientry < nentries ; ientry++)
371 if (10*ientry/nentries != progress)
373 progress = 10*ientry/nentries;
374 cout << __FILE__ <<
":" << __LINE__ <<
":Info: " << 10*progress <<
"%" << endl;
378 data->GetEntry(ientry);
386 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
397 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
406 const short int igraph = (
branch_i[
"sublevel"]-1)
408 histos2D[ix][iy][igraph]->Fill(
_SF[x[ix]]*
branch_f[x[ix]],
412 const short int igraph = (
branch_i[
"sublevel"]-1)
414 histos2D[ix][iy][igraph]->Fill(
_SF[x[ix]]*
branch_f[x[ix]],
418 const short int igraph = (
branch_i[
"sublevel"]-1)
420 histos2D[ix][iy][igraph]->Fill(
_SF[x[ix]]*
branch_f[x[ix]],
435 if (y.size() >= x.size()){
437 const short int igraph = (
branch_i[
"sublevel"]-1)
439 graphs[ix][iy][igraph]->SetPoint(ipoint[ix][iy][igraph],
442 ipoint[ix][iy][igraph]++;
445 const short int igraph = (
branch_i[
"sublevel"]-1)
448 graphs[ix][iy][igraph]->SetPoint(ipoint[ix][iy][igraph],
451 ipoint[ix][iy][igraph]++;
453 if (
branch_i[
"badModuleQuality"]>0){
454 const short int igraph = (
branch_i[
"sublevel"]-1)
457 graphs[ix][iy][igraph]->SetPoint(ipoint[ix][iy][igraph],
460 ipoint[ix][iy][igraph]++;
465 const short int igraph = (
branch_i[
"sublevel"]-1)
467 graphs[iy][ix][igraph]->SetPoint(ipoint[iy][ix][igraph],
470 ipoint[iy][ix][igraph]++;
473 const short int igraph = (
branch_i[
"sublevel"]-1)
476 graphs[iy][ix][igraph]->SetPoint(ipoint[iy][ix][igraph],
479 ipoint[iy][ix][igraph]++;
481 if (
branch_i[
"badModuleQuality"]>0){
482 const short int igraph = (
branch_i[
"sublevel"]-1)
485 graphs[iy][ix][igraph]->SetPoint(ipoint[ix][iy][igraph],
488 ipoint[iy][ix][igraph]++;
495 cout << __FILE__ <<
":" << __LINE__ <<
":Info: 100%\tLoop ended" << endl;
516 if (
_write) legend->Write();
519 unsigned int n_module_types = 1;
531 #define INDEX_IN_GLOBAL_CANVAS(i1,i2) 1 + i1 + i2*x.size() 533 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
536 cout << __FILE__ <<
":" << __LINE__ <<
":Info: x[" << ix <<
"]="<< x[ix] << endl;
540 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
545 cout << __FILE__ <<
":" << __LINE__ <<
":Info: x[" << ix <<
"]=" << x[ix]
546 <<
" and y[" << iy <<
"]=" << y[iy]
547 <<
"\t-> creating TMultiGraph" << endl;
549 mgraphs[ix][iy][0] =
new TMultiGraph (TString::Format(
"mgr_%s_vs_%s_tracker_%d", x[ix].Data(),
564 cout << __FILE__ <<
":" << __LINE__ <<
":Info: writing TGraph to file" << endl;
567 if (
_write) graphs[ix][iy][igraph]->Write();
568 if (graphs[ix][iy][igraph]->GetN() == 0)
571 cout << __FILE__ <<
":" << __LINE__ <<
":Info: " << graphs[ix][iy][igraph]->GetName() <<
" is empty." << endl;
576 cout << __FILE__ <<
":" << __LINE__ <<
":Info: cloning, coloring and adding TGraph " 579 <<
" to global TMultiGraph" << endl;
582 TGraph * gr = (TGraph *) graphs[ix][iy][igraph]->Clone();
585 mgraphs[ix][iy][0]->Add(gr,
"P");
590 for (
unsigned int isublevel = 1 ; isublevel <=
NB_SUBLEVELS ; isublevel++)
593 cout << __FILE__ <<
":" << __LINE__ <<
":Info: cloning, coloring and adding TGraph " 596 mgraphs[ix][iy][isublevel] =
new TMultiGraph (TString::Format(
"%s_vs_%s_%s_%d", x[ix].Data(),
605 graphs[ix][iy][ isublevel-1]->SetMarkerColor(kBlack);
606 graphs[ix][iy][
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kRed);
607 graphs[ix][iy][2*
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kGray+1);
608 graphs[ix][iy][3*
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kRed-7);
609 graphs[ix][iy][4*
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kGray+1);
610 graphs[ix][iy][5*
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kRed-7);
611 if (graphs[ix][iy][ isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][ isublevel-1],
"P");
613 else cout << __FILE__ <<
":" << __LINE__ <<
":Info: graphs[ix][iy][isublevel-1]=" << graphs[ix][iy][isublevel-1]->GetName() <<
" is empty -> not added into " << mgraphs[ix][iy][isublevel]->GetName() << endl;
615 if (graphs[ix][iy][
NB_SUBLEVELS+isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][
NB_SUBLEVELS+isublevel-1],
"P");
617 else cout << __FILE__ <<
":" << __LINE__ <<
":Info: graphs[ix][iy][NB_SUBLEVEL+isublevel-1]=" << graphs[ix][iy][
NB_Z_SLICES+isublevel-1]->GetName() <<
" is empty -> not added into " << mgraphs[ix][iy][isublevel]->GetName() << endl;
620 cout << __FILE__ <<
":" << __LINE__ <<
":Error: color code incomplete for Z slices..." << endl;
623 if (graphs[ix][iy][2*
NB_SUBLEVELS+isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][2*
NB_SUBLEVELS+isublevel-1],
"P");
624 if (graphs[ix][iy][3*
NB_SUBLEVELS+isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][3*
NB_SUBLEVELS+isublevel-1],
"P");
625 if (graphs[ix][iy][4*
NB_SUBLEVELS+isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][4*
NB_SUBLEVELS+isublevel-1],
"P");
626 if (graphs[ix][iy][5*
NB_SUBLEVELS+isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][5*
NB_SUBLEVELS+isublevel-1],
"P");
629 if (graphs[ix][iy][2*
NB_SUBLEVELS+isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][2*
NB_SUBLEVELS+isublevel-1],
"P");
630 if (graphs[ix][iy][3*
NB_SUBLEVELS+isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][3*
NB_SUBLEVELS+isublevel-1],
"P");
637 for (
unsigned short int imgr = 0 ; imgr <=
NB_SUBLEVELS ; imgr++)
640 cout << __FILE__ <<
":" << __LINE__ <<
":Info: treating individual canvases." << endl;
643 c[ix][iy][imgr] =
new TCanvas (TString::Format(
"c_%s_vs_%s_%s_%d", x[ix].Data(),
647 TString::Format(
"%s vs. %s at %s level", x[ix].Data(),
655 if (mgraphs[ix][iy][imgr]->GetListOfGraphs() != 0) {
656 if (dyMin[iy] != -99999) {
657 mgraphs[ix][iy][imgr]->SetMinimum(dyMin[iy]);
659 if (dyMax[iy] != -99999) {
660 mgraphs[ix][iy][imgr]->SetMaximum(dyMax[iy]);
662 mgraphs[ix][iy][imgr]->Draw(
"A");
664 if (imgr == 0 &&
_legend) legend->Draw();
668 if (
_write) mgraphs[ix][iy][imgr]->Write();
674 if (mgraphs[ix][iy][imgr]->GetListOfGraphs() != 0) {
675 if (dyMin[iy] != -99999) {
676 mgraphs[ix][iy][imgr]->SetMinimum(dyMin[iy]);
678 if (dyMax[iy] != -99999) {
679 mgraphs[ix][iy][imgr]->SetMaximum(dyMax[iy]);
681 mgraphs[ix][iy][imgr]->Draw(
"A");
691 gStyle->SetOptTitle(0);
695 c_global[ic]->Draw();
699 TCanvas * c_temp = (TCanvas *) c_global[ic]->Clone(c_global[ic]->GetTitle() + TString(
"_sub"));
701 c_global[ic] =
new TCanvas (c_temp->GetName() + TString(
"_final"), c_temp->GetTitle(), c_temp->GetWindowWidth(), c_temp->GetWindowHeight());
702 c_global[ic]->Draw();
703 TPad * p_up =
new TPad (TString(
"legend_") + c_temp->GetName(),
"",
706 * p_down =
new TPad (TString(
"main_") + c_temp->GetName(),
"",
712 c_temp->DrawClonePad();
719 TLegend * global_legend =
MakeLegend(.05,.1,.7,.8);
720 global_legend->Draw();
721 TPaveText * pt_geom =
new TPaveText(.75,.1,.95,.8,
"NB");
722 pt_geom->SetFillColor(0);
723 pt_geom->SetTextSize(0.25);
730 TPaveText *
pt =
new TPaveText(.05,.1,.7,.8,
"NB");
734 TPaveText * pt_geom =
new TPaveText(.6,.1,.95,.8,
"NB");
735 pt_geom->SetFillColor(0);
736 pt_geom->SetTextSize(0.3);
743 if (
_write) c_global[ic]->Write();
756 bool entries =
false;
757 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
759 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
768 "",histos2D[ix][iy][igraph]->GetXaxis()->GetNbins(),
_min[x[ix]],
_max[x[ix]]);
769 histos[ix][iy][igraph]->SetMarkerColor(
COLOR_CODE(igraph));
770 histos[ix][iy][igraph]->SetLineColor(
COLOR_CODE(igraph));
771 histos[ix][iy][igraph]->StatOverflows(kTRUE);
775 for (
int binx = 0 ; binx <= histos2D[ix][iy][igraph]->GetXaxis()->GetNbins() ; binx++)
782 +std::to_string(binx),
783 "",histos2D[ix][iy][igraph]->GetYaxis()->GetNbins(),
786 histosYValues[ix][iy][igraph]->StatOverflows(kTRUE);
789 for (
int biny = 0 ; biny <= histos2D[ix][iy][igraph]->GetYaxis()->GetNbins()+1 ; biny++)
791 if (histos2D[ix][iy][igraph]->GetBinContent(binx,biny) > 1.)
793 histosYValues[ix][iy][igraph]->SetBinContent(biny,histos2D[ix][iy][igraph]->GetBinContent(binx,biny));
799 histos[ix][iy][igraph]->SetBinContent(binx,histosYValues[ix][iy][igraph]->GetMean());
800 histos[ix][iy][igraph]->SetBinError(binx,histosYValues[ix][iy][igraph]->GetRMS());
802 else histos[ix][iy][igraph]->SetBinContent(binx,-999999.);
813 c_hist[ix][iy][0] =
new TCanvas (TString::Format(
"c_hist_%s_vs_%s_tracker_%d", x[ix].Data(),
816 TString::Format(
"Profile plot %s vs. %s at tracker level", x[ix].Data(),
823 c_hist[ix][iy][0]->GetPad(0)->DrawFrame(
_min[x[ix]],
824 dyMin[iy] != -99999 ? dyMin[iy] :
_min[y[iy]],
826 dyMax[iy] != -99999 ? dyMax[iy] :
_max[y[iy]],
829 if (
_legend) legend->Draw(
"same");
833 unsigned short int igraph =
NB_SUBLEVELS*NB_Z_SLICES - jgraph - 1;
836 histosTracker[ix][iy][igraph] = (TH1F *) histos[ix][iy][igraph]->Clone();
839 histosTracker[ix][iy][igraph]->SetLineColor(
COLOR_CODE(igraph%NB_SUBLEVELS));
840 histosTracker[ix][iy][igraph]->SetMarkerStyle(6);
841 histosTracker[ix][iy][igraph]->Draw(
"same pe0");
846 + TString::Format(
"Profile_plot_%s_vs_%s_tracker_%d", x[ix].Data(), y[iy].Data(),
canvas_index)
855 dyMin[iy] != -99999 ? dyMin[iy] :
_min[y[iy]],
857 dyMax[iy] != -99999 ? dyMax[iy] :
_max[y[iy]],
863 unsigned short int igraph =
NB_SUBLEVELS*NB_Z_SLICES - jgraph - 1;
864 histosTracker[ix][iy][igraph]->Draw(
"same pe0");
868 for (
unsigned int isublevel = 1 ; isublevel <=
NB_SUBLEVELS ; isublevel++)
872 c_hist[ix][iy][isublevel] =
new TCanvas (TString::Format(
"c_hist_%s_vs_%s_%s_%d", x[ix].Data(),
876 TString::Format(
"Profile plot %s vs. %s at %s level", x[ix].Data(),
882 c_hist[ix][iy][isublevel]->GetPad(0)->DrawFrame(
_min[x[ix]],
883 dyMin[iy] != -99999 ? dyMin[iy] :
_min[y[iy]],
885 dyMax[iy] != -99999 ? dyMax[iy] :
_max[y[iy]],
889 histos[ix][iy][ isublevel-1]->SetMarkerColor(kBlack);
890 histos[ix][iy][ isublevel-1]->SetLineColor(kBlack);
891 histos[ix][iy][
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kRed);
892 histos[ix][iy][
NB_SUBLEVELS+isublevel-1]->SetLineColor(kRed);
895 histos[ix][iy][ isublevel-1]->Draw(
"same pe0");
896 histos[ix][iy][
NB_SUBLEVELS+isublevel-1]->Draw(
"same pe0");
909 dyMin[iy] != -99999 ? dyMin[iy] :
_min[y[iy]],
911 dyMax[iy] != -99999 ? dyMax[iy] :
_max[y[iy]],
916 histos[ix][iy][ isublevel-1]->Draw(
"same pe0");
917 histos[ix][iy][
NB_SUBLEVELS+isublevel-1]->Draw(
"same pe0");
926 gStyle->SetOptTitle(0);
935 TCanvas * c_temp_hist = (TCanvas *) c_global_hist[ic]->Clone(c_global_hist[ic]->GetTitle() + TString(
"_sub"));
937 c_global_hist[ic] =
new TCanvas (c_temp_hist->GetName() + TString(
"_final"), c_temp_hist->GetTitle(), c_temp_hist->GetWindowWidth(), c_temp_hist->GetWindowHeight());
938 c_global_hist[ic]->Draw();
939 TPad * p_up =
new TPad (TString(
"legend_") + c_temp_hist->GetName(),
"",
942 * p_down =
new TPad (TString(
"main_") + c_temp_hist->GetName(),
"",
948 c_temp_hist->DrawClonePad();
949 c_global_hist[ic]->cd();
955 TLegend * global_legend =
MakeLegend(.05,.1,.7,.8);
956 global_legend->Draw();
957 TPaveText * pt_geom =
new TPaveText(.75,.1,.95,.8,
"NB");
958 pt_geom->SetFillColor(0);
959 pt_geom->SetTextSize(0.25);
966 TPaveText *
pt =
new TPaveText(.05,.1,.7,.8,
"NB");
970 TPaveText * pt_geom =
new TPaveText(.6,.1,.95,.8,
"NB");
971 pt_geom->SetFillColor(0);
972 pt_geom->SetTextSize(0.3);
984 cout << __FILE__ <<
":" << __LINE__ <<
":Info: End of MakePlots method" << endl;
999 #define CHECK_BRANCHES(branchname_vector) \ 1000 for (unsigned int i = 0 ; i < branchname_vector.size() ; i++) \ 1002 if (branch_f.find(branchname_vector[i]) == branch_f.end()) \ 1004 cout << __FILE__ << ":" << __LINE__ << ":Error: The branch " << branchname_vector[i] << " is not recognised." << endl; \ 1011 const unsigned int nentries =
data->GetEntries();
1022 #define LIMITS(axes_vector) \ 1023 for (unsigned int i = 0 ; i < axes_vector.size() ; i++) \ 1025 if ( _SF.find(axes_vector[i]) == _SF.end()) _SF[axes_vector[i]] = 1.; \ 1026 if (_min.find(axes_vector[i]) == _min.end()) _min[axes_vector[i]] = _SF[axes_vector[i]]*data->GetMinimum(axes_vector[i]); \ 1027 if (_max.find(axes_vector[i]) == _max.end()) _max[axes_vector[i]] = _SF[axes_vector[i]]*data->GetMaximum(axes_vector[i]); \ 1053 #ifndef NB_SUBLEVELS 1054 #define NB_SUBLEVELS 6 1056 #define NB_Z_SLICES 2 1057 #define NB_X_SLICES 2 1070 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
1078 +TString(ihist>=
NB_SUBLEVELS*NB_Z_SLICES ?
"xn" :
"xp" ),
1082 histos[iy][ihist]->StatOverflows(kTRUE);
1087 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
1095 +TString(ihist>=
NB_SUBLEVELS*NB_Z_SLICES ?
"xn" :
"xp" ),
1099 histosx[ix][ihist]->StatOverflows(kTRUE);
1110 cout << __FILE__ <<
":" << __LINE__ <<
":Info: Looping on the TTree" << endl;
1113 unsigned int progress = 0;
1114 cout << __FILE__ <<
":" << __LINE__ <<
":Info: 0%" << endl;
1116 for (
unsigned int ientry = 0 ; ientry < nentries ; ientry++)
1119 if (10*ientry/nentries != progress)
1121 progress = 10*ientry/nentries;
1122 cout << __FILE__ <<
":" << __LINE__ <<
":Info: " << 10*progress <<
"%" << endl;
1126 data->GetEntry(ientry);
1134 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
1160 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
1187 cout << __FILE__ <<
":" << __LINE__ <<
":Info: 100%\tLoop ended" << endl;
1192 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
1199 histos[iy][ihist]->Add(histos[iy][ihist+
NB_SUBLEVELS]);
1203 histos[iy][ihist]->Add(histos[iy][ihist+
NB_SUBLEVELS*NB_Z_SLICES]);
1205 meanValue[iy][ihist] = histos[iy][ihist]->GetMean();
1206 RMS[iy][ihist] = histos[iy][ihist]->GetRMS();
1208 histos[iy][ihist]->Fit(
"gaus");
1209 gausFit[iy][ihist] = histos[iy][ihist]->GetFunction(
"gaus");
1210 meanValueGaussian[iy][ihist] = gausFit[iy][ihist]->GetParameter(1);
1211 RMSGaussian[iy][ihist] = gausFit[iy][ihist]->GetParameter(2);
1218 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
1225 histosx[ix][ihist]->Add(histosx[ix][ihist+
NB_SUBLEVELS]);
1229 histosx[ix][ihist]->Add(histosx[ix][ihist+
NB_SUBLEVELS*NB_Z_SLICES]);
1231 meanValuex[ix][ihist] = histosx[ix][ihist]->GetMean();
1232 RMSx[ix][ihist] = histosx[ix][ihist]->GetRMS();
1237 TString tableFileName,tableCaption,tableAlign,tableHeadline;
1238 TString PXBpLine,PXBmLine,PXFpLine,PXFmLine,TIBpLine,TIBmLine,TOBpLine,TOBmLine,TIDpLine,TIDmLine,TECpLine,TECmLine;
1242 tableFileName =
"table_differences.tex";
1244 else if (
_module_plot_option ==
"good") tableCaption =
"Means and standard deviations of "+
_alignment_name+
" - "+_reference_name+
" for each subdetector, only good modules used.";
1245 else if (
_module_plot_option ==
"list") tableCaption =
"Means and standard deviations of "+
_alignment_name+
" - "+_reference_name+
" for each subdetector, good modules and those in given list used.";
1251 tableFileName =
"table_differences_Gaussian.tex";
1252 if (
_module_plot_option ==
"all") tableCaption =
"Means and standard deviations for Gaussian fit of "+
_alignment_name+
" - "+_reference_name+
" for each subdetector, all modules used.";
1253 else if (
_module_plot_option ==
"good") tableCaption =
"Means and standard deviations for Gaussian fit of "+
_alignment_name+
" - "+_reference_name+
" for each subdetector, only good modules used.";
1254 else if (
_module_plot_option ==
"list") tableCaption =
"Means and standard deviations for Gaussian fit of "+
_alignment_name+
" - "+_reference_name+
" for each subdetector, good modules and those in given list used.";
1262 tableFileName =
"table_meanPos.tex";
1264 if (
_module_plot_option ==
"all") tableCaption =
"Mean positions and standard deviations in "+_reference_name+
" geometry for each subdetector, all modules used.";
1265 else if (
_module_plot_option ==
"good") tableCaption =
"Mean positions and standard deviations in "+_reference_name+
" geometry for each subdetector, only good modules used.";
1266 else if (
_module_plot_option ==
"list") tableCaption =
"Mean positions and standard deviations in "+_reference_name+
" geometry for each subdetector, good modules and those in given list used.";
1272 cout << __FILE__ <<
":" << __LINE__ <<
":Info: End of MakeLegends method" << endl;
1286 const int kGridY) {
_grid_x = kGridX ;
1289 const float max) {
_max[branchname] =
max ; }
1291 const float min) {
_min[branchname] =
min ; }
1293 const float SF) {
_SF[branchname] = SF ; }
1302 + TString(name.EndsWith(
"/") ?
"" :
"/") ; }
1308 if (word.BeginsWith(
"d")) word.ReplaceAll(
"d",
"#Delta");
1309 if (word == TString(
"rdphi")) word =
"r#Delta#phi";
1310 else if (word.EndsWith(
"phi")) word.ReplaceAll(
"phi",
"#phi");
1311 else if (word.EndsWith(
"alpha")) word.ReplaceAll(
"alpha",
"#alpha");
1312 else if (word.EndsWith(
"beta")) word.ReplaceAll(
"beta" ,
"#beta");
1313 else if (word.EndsWith(
"gamma")) word.ReplaceAll(
"gamma",
"#gamma");
1314 else if (word.EndsWith(
"eta")) word.ReplaceAll(
"eta",
"#eta");
1321 if (word.BeginsWith(
"d")) word.ReplaceAll(
"d",
"$\\Delta$");
1322 if (word == TString(
"rdphi")) word =
"r$\\Delta\\phi$";
1323 else if (word.EndsWith(
"phi")) word.ReplaceAll(
"phi",
"$\\phi$");
1324 else if (word.EndsWith(
"alpha")) word.ReplaceAll(
"alpha",
"$\\alpha$");
1325 else if (word.EndsWith(
"beta")) word.ReplaceAll(
"beta" ,
"$\\beta$");
1326 else if (word.EndsWith(
"gamma")) word.ReplaceAll(
"gamma",
"#$\\gamma$");
1327 else if (word.EndsWith(
"eta")) word.ReplaceAll(
"eta",
"$\\eta$");
1333 if (print_option.Contains(
"pdf" ))
return TString(
".pdf" );
1334 else if (print_option.Contains(
"eps" ))
return TString(
".eps" );
1335 else if (print_option.Contains(
"ps" ))
return TString(
".ps" );
1336 else if (print_option.Contains(
"svg" ))
return TString(
".svg" );
1337 else if (print_option.Contains(
"tex" ))
return TString(
".tex" );
1338 else if (print_option.Contains(
"gif" ))
return TString(
".gif" );
1339 else if (print_option.Contains(
"xpm" ))
return TString(
".xpm" );
1340 else if (print_option.Contains(
"png" ))
return TString(
".png" );
1341 else if (print_option.Contains(
"jpg" ))
return TString(
".jpg" );
1342 else if (print_option.Contains(
"tiff"))
return TString(
".tiff");
1343 else if (print_option.Contains(
"cxx" ))
return TString(
".cxx" );
1344 else if (print_option.Contains(
"xml" ))
return TString(
".xml" );
1345 else if (print_option.Contains(
"root"))
return TString(
".root");
1348 cout << __FILE__ <<
":" << __LINE__ <<
":Warning: unknown format. Returning .pdf, but possibly wrong..." << endl;
1349 return TString(
".pdf");
1357 const TString
title)
1359 TLegend *
legend =
new TLegend (x1, y1, x2, y2, title.Data(),
"NBNDC");
1361 legend->SetFillColor(0);
1362 legend->SetLineColor(0);
1363 legend->SetLineWidth(0);
1364 for (
unsigned int isublevel = 0 ; isublevel <
NB_SUBLEVELS ; isublevel++)
1366 TGraph *
g =
new TGraph (0);
1369 g->SetMarkerStyle(kFullSquare);
1370 g->SetMarkerSize(10);
1378 unsigned int nLevelsTimesSlices,
1379 float meanValue[10][24],
1381 const TString nDigits,
1382 const TString tableCaption,
1383 const TString tableFileName)
1387 TString tableAlign,tableHeadline;
1388 TString PXBpLine,PXBmLine,PXFpLine,PXFmLine,TIBpLine,TIBmLine,TOBpLine,TOBmLine,TIDpLine,TIDmLine,TECpLine,TECmLine;
1389 char meanChar[x.size()][nLevelsTimesSlices][10];
1390 char RMSChar[x.size()][nLevelsTimesSlices][10];
1394 PXBpLine =
"PXB x$+$";
1395 PXBmLine =
"PXB x$-$";
1396 PXFpLine =
"PXF z$+$";
1397 PXFmLine =
"PXF z$-$";
1398 TIBpLine =
"TIB x$+$";
1399 TIBmLine =
"TIB x$-$";
1400 TIDpLine =
"TID z$+$";
1401 TIDmLine =
"TID z$-$";
1402 TOBpLine =
"TOB x$+$";
1403 TOBmLine =
"TOB x$-$";
1404 TECpLine =
"TEC z$+$";
1405 TECmLine =
"TEC z$-$";
1409 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
1411 for (
unsigned int isubDet = 0 ; isubDet < nLevelsTimesSlices; isubDet++)
1414 sprintf(meanChar[ix][isubDet],
"%."+nDigits+
"f",meanValue[ix][isubDet]);
1415 sprintf(RMSChar[ix][isubDet],
"%."+nDigits+
"f",RMS[ix][isubDet]);
1418 tableHeadline +=
" & " +
LateXstyleTable(x[ix]) +
" / " +
_units[x[ix]].ReplaceAll(
"#mum",
"$\\mu$m");
1420 PXBpLine +=
" & $"; PXBpLine += meanChar[ix][0]; PXBpLine +=
"\\pm"; PXBpLine += RMSChar[ix][0]; PXBpLine +=
" $";
1421 PXBmLine +=
" & $"; PXBmLine += meanChar[ix][12]; PXBmLine +=
"\\pm"; PXBmLine += RMSChar[ix][12]; PXBmLine +=
" $";
1422 PXFpLine +=
" & $"; PXFpLine += meanChar[ix][1]; PXFpLine +=
"\\pm"; PXFpLine += RMSChar[ix][1]; PXFpLine +=
" $";
1423 PXFmLine +=
" & $"; PXFmLine += meanChar[ix][7]; PXFmLine +=
"\\pm"; PXFmLine += RMSChar[ix][7]; PXFmLine +=
" $";
1424 TIBpLine +=
" & $"; TIBpLine += meanChar[ix][2]; TIBpLine +=
"\\pm"; TIBpLine += RMSChar[ix][2]; TIBpLine +=
" $";
1425 TIBmLine +=
" & $"; TIBmLine += meanChar[ix][14]; TIBmLine +=
"\\pm"; TIBmLine += RMSChar[ix][14]; TIBmLine +=
" $";
1426 TIDpLine +=
" & $"; TIDpLine += meanChar[ix][3]; TIDpLine +=
"\\pm"; TIDpLine += RMSChar[ix][3]; TIDpLine +=
" $";
1427 TIDmLine +=
" & $"; TIDmLine += meanChar[ix][9]; TIDmLine +=
"\\pm"; TIDmLine += RMSChar[ix][9]; TIDmLine +=
" $";
1428 TOBpLine +=
" & $"; TOBpLine += meanChar[ix][4]; TOBpLine +=
"\\pm"; TOBpLine += RMSChar[ix][4]; TOBpLine +=
" $";
1429 TOBmLine +=
" & $"; TOBmLine += meanChar[ix][16]; TOBmLine +=
"\\pm"; TOBmLine += RMSChar[ix][16]; TOBmLine +=
" $";
1430 TECpLine +=
" & $"; TECpLine += meanChar[ix][5]; TECpLine +=
"\\pm"; TECpLine += RMSChar[ix][5]; TECpLine +=
" $";
1431 TECmLine +=
" & $"; TECmLine += meanChar[ix][11]; TECmLine +=
"\\pm"; TECmLine += RMSChar[ix][11]; TECmLine +=
" $";
1435 output <<
"\\begin{table}" << std::endl;
1436 output <<
"\\caption{" << tableCaption <<
"}" << std::endl;
1437 output <<
"\\begin{tabular}{"<< tableAlign <<
"}" << std::endl;
1438 output <<
"\\hline" << std::endl;
1439 output << tableHeadline <<
" \\\\" << std::endl;
1440 output <<
"\\hline" << std::endl;
1441 output << PXBpLine <<
" \\\\"<< std::endl;
1442 output << PXBmLine <<
" \\\\"<< std::endl;
1443 output << PXFpLine <<
" \\\\"<< std::endl;
1444 output << PXFmLine <<
" \\\\"<< std::endl;
1445 output << TIBpLine <<
" \\\\"<< std::endl;
1446 output << TIBmLine <<
" \\\\"<< std::endl;
1447 output << TIDpLine <<
" \\\\"<< std::endl;
1448 output << TIDmLine <<
" \\\\"<< std::endl;
1449 output << TOBpLine <<
" \\\\"<< std::endl;
1450 output << TOBmLine <<
" \\\\"<< std::endl;
1451 output << TECpLine <<
" \\\\"<< std::endl;
1452 output << TECmLine <<
" \\\\"<< std::endl;
1453 output <<
"\\hline" << std::endl;
1454 output <<
"\\end{tabular}" << std::endl;
1455 output <<
"\\end{table}" << std::endl;
void WriteTable(const vector< TString > x, unsigned int nLevelsTimesSlices, float meanValue[10][24], float RMS[10][24], const TString nDigits, const TString tableCaption, const TString tableFileName)
void SetCanvasSize(const int window_width=3508, const int window_height=2480)
void MakePlots(const vector< TString >, const vector< TString >, const vector< float >, const vector< float >)
void Set1dModule(const bool)
map< TString, float > branch_f
TString LateXstyleTable(TString)
TString LateXstyle(TString)
void SetGrid(const int, const int)
void SetBatchMode(const bool)
#define LIMITS(axes_vector)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
~GeometryComparisonPlotter()
#define INDEX_IN_GLOBAL_CANVAS(i1, i2)
void SetBranchMax(const TString, const float)
void SetBranchUnits(const TString, const TString)
#define DEFAULT_WINDOW_WIDTH
TLegend * MakeLegend(double x1, double y1, double x2, double y2, const TString title="")
void SetOutputDirectoryName(const TString)
map< TString, float > _max
void SetPrintOption(const Option_t *)
void Set2dModule(const bool)
void SetLegend(const bool)
map< TString, float > _min
#define CHECK_MAP_CONTENT(m, type)
TString _module_plot_option
void SetWrite(const bool)
TString _output_directory
map< TString, TString > _units
TString _sublevel_names[6]
TString ExtensionFromPrintOption(TString)
void SetOutputFileName(const TString)
void SetPrint(const bool)
void SetBranchSF(const TString, const float)
TString units(TString variable, Char_t axis)
#define CHECK_BRANCHES(branchname_vector)
map< TString, int > branch_i
void MakeTables(const vector< TString >, const vector< TString >, const vector< float >, const vector< float >)
#define DEFAULT_WINDOW_HEIGHT
#define COLOR_CODE(icolor)
void SetBranchMin(const TString, const float)
#define INSIDE_VECTOR(vector)
void SetLevelCut(const int)
#define NB_MODULE_QUALITY
map< TString, float > _SF
GeometryComparisonPlotter(TString tree_file_name, TString outputDirname="output/", TString modulesToPlot="all", TString referenceName="Ideal", TString alignmentName="Alignment", bool plotOnlyGlobal=false, bool makeProfilePlots=false)