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,
31 TString printOnlyGlobal
33 _output_directory(output_directory + TString(output_directory.EndsWith(
"/") ?
"" :
"/")),
34 _output_filename(
"comparison.root"),
36 _module_plot_option(modulesToPlot),
37 _alignment_name(alignmentName),
38 _reference_name(referenceName),
39 _print_only_global(printOnlyGlobal),
59 cout <<
">>> TALKATIVE MODE ACTIVATED <<<" << endl;
62 cout <<
">>> DEBUG MODE ACTIVATED <<<" << endl;
63 cout << __FILE__ <<
":"<< __LINE__ <<
":Info: inside constructor of GeometryComparisonPlotter utility"<< endl;
76 tree_file =
new TFile(tree_file_name,
"UPDATE");
80 data->SetBranchAddress(
"inModuleList" ,&
branch_i[
"inModuleList"]);
81 data->SetBranchAddress(
"badModuleQuality" ,&
branch_i[
"badModuleQuality"]);
85 data->SetBranchAddress(
"sublevel" ,&
branch_i[
"sublevel"]);
86 data->SetBranchAddress(
"useDetId" ,&
branch_i[
"useDetId"]);
106 if (
data->GetBranch(
"rdphi") == 0x0)
109 cout << __FILE__ <<
":" << __LINE__ <<
":Info: computing the rdphi branch from r and dphi branches (assuming they exist...)" << endl;
111 TBranch * br_rdphi =
data->Branch(
"rdphi", &
branch_f[
"rdphi"],
"rdphi/F");
112 for (
unsigned int ientry = 0 ; ientry <
data->GetEntries() ; ientry++)
114 data->GetEntry(ientry);
123 cout << __FILE__ <<
":" << __LINE__ <<
":Info: branch addresses set" << endl;
129 data->SetMarkerSize(0.5);
130 data->SetMarkerStyle(6);
132 gStyle->SetOptStat(
"emr");
133 gStyle->SetTitleAlign(22);
134 gStyle->SetTitleX(0.5);
135 gStyle->SetTitleY(0.97);
136 gStyle->SetTitleFont(62);
139 gStyle->SetTextFont(132);
140 gStyle->SetTextSize(0.08);
141 gStyle->SetLabelFont(132,
"x");
142 gStyle->SetLabelFont(132,
"y");
143 gStyle->SetLabelFont(132,
"z");
144 gStyle->SetTitleSize(0.08,
"x");
145 gStyle->SetTitleSize(0.08,
"y");
146 gStyle->SetTitleSize(0.08,
"z");
147 gStyle->SetLabelSize(0.08,
"x");
148 gStyle->SetLabelSize(0.08,
"y");
149 gStyle->SetLabelSize(0.08,
"z");
151 gStyle->SetMarkerStyle(8);
152 gStyle->SetHistLineWidth(2);
153 gStyle->SetLineStyleString(2,
"[12 12]");
155 gStyle->SetFrameBorderMode(0);
156 gStyle->SetCanvasBorderMode(0);
157 gStyle->SetPadBorderMode(0);
158 gStyle->SetPadColor(0);
159 gStyle->SetCanvasColor(0);
160 gStyle->SetTitleColor(1);
161 gStyle->SetStatColor(0);
162 gStyle->SetStatBorderSize(1);
163 gStyle->SetFrameFillColor(0);
165 gStyle->SetPadTickX(1);
166 gStyle->SetPadTickY(1);
168 gStyle->SetPadTopMargin(0.1);
169 gStyle->SetPadRightMargin(0.05);
170 gStyle->SetPadBottomMargin(0.16);
171 gStyle->SetPadLeftMargin(0.18);
174 cout << __FILE__ <<
":" << __LINE__ <<
":Info: end of constructor" << endl;
181 cout << __FILE__ <<
":" << __LINE__ <<
":Info: in destructor of the GeometryComparisonPlotter utility" << endl;
185 cout << __FILE__ <<
":" << __LINE__ <<
":Info: ending." << endl;
197 #define CHECK_BRANCHES(branchname_vector) \ 198 for (unsigned int i = 0 ; i < branchname_vector.size() ; i++) \ 200 if (branch_f.find(branchname_vector[i]) == branch_f.end()) \ 202 cout << __FILE__ << ":" << __LINE__ << ":Error: The branch " << branchname_vector[i] << " is not recognised." << endl; \ 209 const unsigned int nentries =
data->GetEntries();
219 #define LIMITS(axes_vector) \ 220 for (unsigned int i = 0 ; i < axes_vector.size() ; i++) \ 222 if ( _SF.find(axes_vector[i]) == _SF.end()) _SF[axes_vector[i]] = 1.; \ 223 if (_min.find(axes_vector[i]) == _min.end()) _min[axes_vector[i]] = _SF[axes_vector[i]]*data->GetMinimum(axes_vector[i]); \ 224 if (_max.find(axes_vector[i]) == _max.end()) _max[axes_vector[i]] = _SF[axes_vector[i]]*data->GetMaximum(axes_vector[i]); \ 247 #define NB_SUBLEVELS 6 249 #define NB_Z_SLICES 2 250 #define NB_MODULE_QUALITY 3 255 TMultiGraph * mgraphs[x.size()][y.size()][1+
NB_SUBLEVELS];
263 c_global[ic] =
new TCanvas (TString::Format(
"global_%s_%d", ic==0?
"tracker":
_sublevel_names[ic-1].Data(),
265 TString::Format(
"Global overview of the %s variables", ic==0?
"tracker":
_sublevel_names[ic-1].Data()),
268 c_global[ic]->Divide(x.size(),y.size());
271 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
273 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
279 ipoint[ix][iy][igraph] = 0;
280 graphs[ix][iy][igraph] =
new TGraph ();
281 #define COLOR_CODE(icolor) int(icolor/4)+icolor+1 282 graphs[ix][iy][igraph]->SetMarkerColor(
COLOR_CODE(igraph));
283 graphs[ix][iy][igraph]->SetMarkerStyle(6);
288 ( igraph >= 2*
NB_SUBLEVELS*NB_Z_SLICES ?
"bad" :
"list") :
"good" ));
292 ( igraph >= 2*
NB_SUBLEVELS*NB_Z_SLICES ?
" bad modules" :
" in list") :
" good modules" )
295 graphs[ix][iy][igraph]->SetMarkerStyle(igraph >=
NB_SUBLEVELS*NB_Z_SLICES ?
307 cout << __FILE__ <<
":" << __LINE__ <<
":Info: Looping on the TTree" << endl;
310 unsigned int progress = 0;
311 cout << __FILE__ <<
":" << __LINE__ <<
":Info: 0%" << endl;
313 for (
unsigned int ientry = 0 ; ientry < nentries ; ientry++)
316 if (10*ientry/nentries != progress)
318 progress = 10*ientry/nentries;
319 cout << __FILE__ <<
":" << __LINE__ <<
":Info: " << 10*progress <<
"%" << endl;
323 data->GetEntry(ientry);
331 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
342 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
356 if (y.size() >= x.size()){
358 const short int igraph = (
branch_i[
"sublevel"]-1)
360 graphs[ix][iy][igraph]->SetPoint(ipoint[ix][iy][igraph],
363 ipoint[ix][iy][igraph]++;
366 const short int igraph = (
branch_i[
"sublevel"]-1)
369 graphs[ix][iy][igraph]->SetPoint(ipoint[ix][iy][igraph],
372 ipoint[ix][iy][igraph]++;
374 if (
branch_i[
"badModuleQuality"]>0){
375 const short int igraph = (
branch_i[
"sublevel"]-1)
378 graphs[ix][iy][igraph]->SetPoint(ipoint[ix][iy][igraph],
381 ipoint[ix][iy][igraph]++;
386 const short int igraph = (
branch_i[
"sublevel"]-1)
388 graphs[iy][ix][igraph]->SetPoint(ipoint[iy][ix][igraph],
391 ipoint[iy][ix][igraph]++;
394 const short int igraph = (
branch_i[
"sublevel"]-1)
397 graphs[iy][ix][igraph]->SetPoint(ipoint[iy][ix][igraph],
400 ipoint[iy][ix][igraph]++;
402 if (
branch_i[
"badModuleQuality"]>0){
403 const short int igraph = (
branch_i[
"sublevel"]-1)
406 graphs[iy][ix][igraph]->SetPoint(ipoint[ix][iy][igraph],
409 ipoint[iy][ix][igraph]++;
416 cout << __FILE__ <<
":" << __LINE__ <<
":Info: 100%\tLoop ended" << endl;
437 if (
_write) legend->Write();
440 unsigned int n_module_types = 1;
452 #define INDEX_IN_GLOBAL_CANVAS(i1,i2) 1 + i1 + i2*x.size() 454 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
457 cout << __FILE__ <<
":" << __LINE__ <<
":Info: x[" << ix <<
"]="<< x[ix] << endl;
461 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
466 cout << __FILE__ <<
":" << __LINE__ <<
":Info: x[" << ix <<
"]=" << x[ix]
467 <<
" and y[" << iy <<
"]=" << y[iy]
468 <<
"\t-> creating TMultiGraph" << endl;
470 mgraphs[ix][iy][0] =
new TMultiGraph (TString::Format(
"mgr_%s_vs_%s_tracker_%d", x[ix].Data(),
485 cout << __FILE__ <<
":" << __LINE__ <<
":Info: writing TGraph to file" << endl;
488 if (
_write) graphs[ix][iy][igraph]->Write();
489 if (graphs[ix][iy][igraph]->GetN() == 0)
492 cout << __FILE__ <<
":" << __LINE__ <<
":Info: " << graphs[ix][iy][igraph]->GetName() <<
" is empty." << endl;
497 cout << __FILE__ <<
":" << __LINE__ <<
":Info: cloning, coloring and adding TGraph " 500 <<
" to global TMultiGraph" << endl;
503 TGraph * gr = (TGraph *) graphs[ix][iy][igraph]->Clone();
506 mgraphs[ix][iy][0]->Add(gr,
"P");
511 for (
unsigned int isublevel = 1 ; isublevel <=
NB_SUBLEVELS ; isublevel++)
514 cout << __FILE__ <<
":" << __LINE__ <<
":Info: cloning, coloring and adding TGraph " 517 mgraphs[ix][iy][isublevel] =
new TMultiGraph (TString::Format(
"%s_vs_%s_%s_%d", x[ix].Data(),
526 graphs[ix][iy][ isublevel-1]->SetMarkerColor(kBlack);
527 graphs[ix][iy][
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kRed);
528 graphs[ix][iy][2*
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kGray+1);
529 graphs[ix][iy][3*
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kRed-7);
530 graphs[ix][iy][4*
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kGray+1);
531 graphs[ix][iy][5*
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kRed-7);
532 if (graphs[ix][iy][ isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][ isublevel-1],
"P");
534 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;
536 if (graphs[ix][iy][
NB_SUBLEVELS+isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][
NB_SUBLEVELS+isublevel-1],
"P");
538 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;
541 cout << __FILE__ <<
":" << __LINE__ <<
":Error: color code incomplete for Z slices..." << endl;
544 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");
545 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");
546 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");
547 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");
550 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");
551 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");
558 for (
unsigned short int imgr = 0 ; imgr <=
NB_SUBLEVELS ; imgr++)
561 cout << __FILE__ <<
":" << __LINE__ <<
":Info: treating individual canvases." << endl;
564 c[ix][iy][imgr] =
new TCanvas (TString::Format(
"c_%s_vs_%s_%s_%d", x[ix].Data(),
568 TString::Format(
"%s vs. %s at %s level", x[ix].Data(),
576 if (mgraphs[ix][iy][imgr]->GetListOfGraphs() != 0) {
577 if (dyMin[iy] != -99999) {
578 mgraphs[ix][iy][imgr]->SetMinimum(dyMin[iy]);
580 if (dyMax[iy] != -99999) {
581 mgraphs[ix][iy][imgr]->SetMaximum(dyMax[iy]);
583 mgraphs[ix][iy][imgr]->Draw(
"A");
585 if (imgr == 0 &&
_legend) legend->Draw();
589 if (
_write) mgraphs[ix][iy][imgr]->Write();
595 if (mgraphs[ix][iy][imgr]->GetListOfGraphs() != 0) {
596 if (dyMin[iy] != -99999) {
597 mgraphs[ix][iy][imgr]->SetMinimum(dyMin[iy]);
599 if (dyMax[iy] != -99999) {
600 mgraphs[ix][iy][imgr]->SetMaximum(dyMax[iy]);
602 mgraphs[ix][iy][imgr]->Draw(
"A");
612 gStyle->SetOptTitle(0);
616 c_global[ic]->Draw();
620 TCanvas * c_temp = (TCanvas *) c_global[ic]->Clone(c_global[ic]->GetTitle() + TString(
"_sub"));
622 c_global[ic] =
new TCanvas (c_temp->GetName() + TString(
"_final"), c_temp->GetTitle(), c_temp->GetWindowWidth(), c_temp->GetWindowHeight());
623 c_global[ic]->Draw();
624 TPad * p_up =
new TPad (TString(
"legend_") + c_temp->GetName(),
"",
627 * p_down =
new TPad (TString(
"main_") + c_temp->GetName(),
"",
633 c_temp->DrawClonePad();
640 TLegend * global_legend =
MakeLegend(.05,.1,.7,.8);
641 global_legend->Draw();
642 TPaveText * pt_geom =
new TPaveText(.75,.1,.95,.8,
"NB");
643 pt_geom->SetFillColor(0);
644 pt_geom->SetTextSize(0.25);
651 TPaveText *
pt =
new TPaveText(.05,.1,.7,.8,
"NB");
655 TPaveText * pt_geom =
new TPaveText(.6,.1,.95,.8,
"NB");
656 pt_geom->SetFillColor(0);
657 pt_geom->SetTextSize(0.3);
664 if (
_write) c_global[ic]->Write();
670 cout << __FILE__ <<
":" << __LINE__ <<
":Info: End of MakePlots method" << endl;
684 const int kGridY) {
_grid_x = kGridX ;
691 const float SF) {
_SF[branchname] = SF ; }
700 + TString(name.EndsWith(
"/") ?
"" :
"/") ; }
706 if (word.BeginsWith(
"d")) word.ReplaceAll(
"d",
"#Delta");
707 if (word == TString(
"rdphi")) word =
"r#Delta#phi";
708 else if (word.EndsWith(
"phi")) word.ReplaceAll(
"phi",
"#phi");
709 else if (word.EndsWith(
"alpha")) word.ReplaceAll(
"alpha",
"#alpha");
710 else if (word.EndsWith(
"beta")) word.ReplaceAll(
"beta" ,
"#beta");
711 else if (word.EndsWith(
"gamma")) word.ReplaceAll(
"gamma",
"#gamma");
712 else if (word.EndsWith(
"eta")) word.ReplaceAll(
"eta",
"#eta");
718 if (print_option.Contains(
"pdf" ))
return TString(
".pdf" );
719 else if (print_option.Contains(
"eps" ))
return TString(
".eps" );
720 else if (print_option.Contains(
"ps" ))
return TString(
".ps" );
721 else if (print_option.Contains(
"svg" ))
return TString(
".svg" );
722 else if (print_option.Contains(
"tex" ))
return TString(
".tex" );
723 else if (print_option.Contains(
"gif" ))
return TString(
".gif" );
724 else if (print_option.Contains(
"xpm" ))
return TString(
".xpm" );
725 else if (print_option.Contains(
"png" ))
return TString(
".png" );
726 else if (print_option.Contains(
"jpg" ))
return TString(
".jpg" );
727 else if (print_option.Contains(
"tiff"))
return TString(
".tiff");
728 else if (print_option.Contains(
"cxx" ))
return TString(
".cxx" );
729 else if (print_option.Contains(
"xml" ))
return TString(
".xml" );
730 else if (print_option.Contains(
"root"))
return TString(
".root");
733 cout << __FILE__ <<
":" << __LINE__ <<
":Warning: unknown format. Returning .pdf, but possibly wrong..." << endl;
734 return TString(
".pdf");
744 TLegend *
legend =
new TLegend (x1, y1, x2, y2, title.Data(),
"NBNDC");
746 legend->SetFillColor(0);
747 legend->SetLineColor(0);
748 legend->SetLineWidth(0);
749 for (
unsigned int isublevel = 0 ; isublevel <
NB_SUBLEVELS ; isublevel++)
751 TGraph *
g =
new TGraph (0);
754 g->SetMarkerStyle(kFullSquare);
755 g->SetMarkerSize(10);
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)
TString _print_only_global
map< TString, float > branch_f
TString LateXstyle(TString)
void SetGrid(const int, const int)
void SetBatchMode(const bool)
GeometryComparisonPlotter(TString tree_file_name, TString outputDirname="output/", TString modulesToPlot="all", TString referenceName="Ideal", TString alignmentName="Alignment", TString plotOnlyGlobal="false")
#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
#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