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 _output_directory(output_directory + TString(output_directory.EndsWith(
"/") ?
"" :
"/")),
29 _output_filename(
"comparison.root"),
50 cout <<
">>> TALKATIVE MODE ACTIVATED <<<" << endl;
53 cout <<
">>> DEBUG MODE ACTIVATED <<<" << endl;
54 cout << __FILE__ <<
":"<< __LINE__ <<
":Info: inside constructor of GeometryComparisonPlotter utility"<< endl;
67 tree_file =
new TFile(tree_file_name,
"UPDATE");
74 data->SetBranchAddress(
"sublevel" ,&
branch_i[
"sublevel"]);
75 data->SetBranchAddress(
"useDetId" ,&
branch_i[
"useDetId"]);
95 if (
data->GetBranch(
"rdphi") == 0x0)
98 cout << __FILE__ <<
":" << __LINE__ <<
":Info: computing the rdphi branch from r and dphi branches (assuming they exist...)" << endl;
100 TBranch * br_rdphi =
data->Branch(
"rdphi", &
branch_f[
"rdphi"],
"rdphi/F");
101 for (
unsigned int ientry = 0 ; ientry <
data->GetEntries() ; ientry++)
103 data->GetEntry(ientry);
112 cout << __FILE__ <<
":" << __LINE__ <<
":Info: branch addresses set" << endl;
118 data->SetMarkerSize(0.5);
119 data->SetMarkerStyle(6);
121 gStyle->SetOptStat(
"emr");
122 gStyle->SetTitleAlign(22);
123 gStyle->SetTitleX(0.5);
124 gStyle->SetTitleY(0.97);
125 gStyle->SetTitleFont(62);
128 gStyle->SetTextFont(132);
129 gStyle->SetTextSize(0.08);
130 gStyle->SetLabelFont(132,
"x");
131 gStyle->SetLabelFont(132,
"y");
132 gStyle->SetLabelFont(132,
"z");
133 gStyle->SetTitleSize(0.08,
"x");
134 gStyle->SetTitleSize(0.08,
"y");
135 gStyle->SetTitleSize(0.08,
"z");
136 gStyle->SetLabelSize(0.08,
"x");
137 gStyle->SetLabelSize(0.08,
"y");
138 gStyle->SetLabelSize(0.08,
"z");
140 gStyle->SetMarkerStyle(8);
141 gStyle->SetHistLineWidth(2);
142 gStyle->SetLineStyleString(2,
"[12 12]");
144 gStyle->SetFrameBorderMode(0);
145 gStyle->SetCanvasBorderMode(0);
146 gStyle->SetPadBorderMode(0);
147 gStyle->SetPadColor(0);
148 gStyle->SetCanvasColor(0);
149 gStyle->SetTitleColor(1);
150 gStyle->SetStatColor(0);
151 gStyle->SetStatBorderSize(1);
152 gStyle->SetFrameFillColor(0);
154 gStyle->SetPadTickX(1);
155 gStyle->SetPadTickY(1);
157 gStyle->SetPadTopMargin(0.1);
158 gStyle->SetPadRightMargin(0.05);
159 gStyle->SetPadBottomMargin(0.16);
160 gStyle->SetPadLeftMargin(0.18);
163 cout << __FILE__ <<
":" << __LINE__ <<
":Info: end of constructor" << endl;
170 cout << __FILE__ <<
":" << __LINE__ <<
":Info: in destructor of the GeometryComparisonPlotter utility" << endl;
174 cout << __FILE__ <<
":" << __LINE__ <<
":Info: ending." << endl;
184 #define CHECK_BRANCHES(branchname_vector) \
185 for (unsigned int i = 0 ; i < branchname_vector.size() ; i++) \
187 if (branch_f.find(branchname_vector[i]) == branch_f.end()) \
189 cout << __FILE__ << ":" << __LINE__ << ":Error: The branch " << branchname_vector[i] << " is not recognised." << endl; \
196 const unsigned int nentries =
data->GetEntries();
206 #define LIMITS(axes_vector) \
207 for (unsigned int i = 0 ; i < axes_vector.size() ; i++) \
209 if ( _SF.find(axes_vector[i]) == _SF.end()) _SF[axes_vector[i]] = 1.; \
210 if (_min.find(axes_vector[i]) == _min.end()) _min[axes_vector[i]] = _SF[axes_vector[i]]*data->GetMinimum(axes_vector[i]); \
211 if (_max.find(axes_vector[i]) == _max.end()) _max[axes_vector[i]] = _SF[axes_vector[i]]*data->GetMaximum(axes_vector[i]); \
230 #define NB_SUBLEVELS 6
232 #define NB_Z_SLICES 2
235 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
237 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
243 ipoint[ix][iy][igraph] = 0;
244 graphs[ix][iy][igraph] =
new TGraph ();
245 #define COLOR_CODE(icolor) int(icolor/4)+icolor+1
246 graphs[ix][iy][igraph]->SetMarkerColor(
COLOR_CODE(igraph));
247 graphs[ix][iy][igraph]->SetMarkerStyle(6);
253 graphs[ix][iy][igraph]->SetMarkerStyle(6);
258 cout << __FILE__ <<
":" << __LINE__ <<
":Info: Creation of the TGraph[" << x.size() <<
"][" << y.size() <<
"][" <<
NB_SUBLEVELS*
NB_Z_SLICES <<
"] ended." << endl;
263 cout << __FILE__ <<
":" << __LINE__ <<
":Info: Looping on the TTree" << endl;
266 unsigned int progress = 0;
267 cout << __FILE__ <<
":" << __LINE__ <<
":Info: 0%" << endl;
269 for (
unsigned int ientry = 0 ; ientry < nentries ; ientry++)
272 if (10*ientry/nentries != progress)
274 progress = 10*ientry/nentries;
275 cout << __FILE__ <<
":" << __LINE__ <<
":Info: " << 10*progress <<
"%" << endl;
279 data->GetEntry(ientry);
287 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
298 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
313 graphs[ix][iy][igraph]->SetPoint(ipoint[ix][iy][igraph],
316 ipoint[ix][iy][igraph]++;
321 cout << __FILE__ <<
":" << __LINE__ <<
":Info: 100%\tLoop ended" << endl;
339 TMultiGraph * mgraphs[x.size()][y.size()][1+
NB_SUBLEVELS];
345 c_global[ic] =
new TCanvas (TString::Format(
"global_%s_%d", ic==0?
"tracker":
_sublevel_names[ic-1].
Data(),
347 TString::Format(
"Global overview of the %s variables", ic==0?
"tracker":
_sublevel_names[ic-1].
Data()),
350 c_global[ic]->Divide(x.size(),y.size());
352 #define INDEX_IN_GLOBAL_CANVAS(i1,i2) 1 + i1 + i2*x.size()
355 if (
_write) legend->Write();
357 for (
unsigned int ix = 0 ; ix < x.size() ; ix++)
360 cout << __FILE__ <<
":" << __LINE__ <<
":Info: x[" << ix <<
"]="<< x[ix] << endl;
374 for (
unsigned int iy = 0 ; iy < y.size() ; iy++)
390 cout << __FILE__ <<
":" << __LINE__ <<
":Info: x[" << ix <<
"]=" << x[ix]
391 <<
" and y[" << iy <<
"]=" << y[iy]
392 <<
"\t-> creating TMultiGraph" << endl;
394 mgraphs[ix][iy][0] =
new TMultiGraph (TString::Format(
"mgr_%s_vs_%s_tracker_%d", x[ix].
Data(),
406 unsigned short int igraph =
NB_SUBLEVELS*NB_Z_SLICES - jgraph - 1;
421 cout << __FILE__ <<
":" << __LINE__ <<
":Info: writing TGraph to file" << endl;
424 if (
_write) graphs[ix][iy][igraph]->Write();
425 if (graphs[ix][iy][igraph]->GetN() == 0)
428 cout << __FILE__ <<
":" << __LINE__ <<
":Info: " << graphs[ix][iy][igraph]->GetName() <<
" is empty." << endl;
433 cout << __FILE__ <<
":" << __LINE__ <<
":Info: cloning, coloring and adding TGraph "
436 <<
" to global TMultiGraph" << endl;
439 TGraph * gr = (TGraph *) graphs[ix][iy][igraph]->Clone();
442 mgraphs[ix][iy][0]->Add(gr,
"P");
446 for (
unsigned int isublevel = 1 ; isublevel <=
NB_SUBLEVELS ; isublevel++)
449 cout << __FILE__ <<
":" << __LINE__ <<
":Info: cloning, coloring and adding TGraph "
452 mgraphs[ix][iy][isublevel] =
new TMultiGraph (TString::Format(
"%s_vs_%s_%s_%d", x[ix].
Data(),
460 graphs[ix][iy][ isublevel-1]->SetMarkerColor(kBlack);
461 graphs[ix][iy][
NB_SUBLEVELS+isublevel-1]->SetMarkerColor(kRed);
462 if (graphs[ix][iy][ isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][ isublevel-1],
"P");
464 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;
466 if (graphs[ix][iy][
NB_SUBLEVELS+isublevel-1]->GetN() > 0) mgraphs[ix][iy][isublevel]->Add(graphs[ix][iy][
NB_SUBLEVELS+isublevel-1],
"P");
468 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;
471 cout << __FILE__ <<
":" << __LINE__ <<
":Error: color code incomplete for Z slices..." << endl;
477 for (
unsigned short int imgr = 0 ; imgr <=
NB_SUBLEVELS ; imgr++)
480 cout << __FILE__ <<
":" << __LINE__ <<
":Info: treating individual canvases." << endl;
483 c[ix][iy][imgr] =
new TCanvas (TString::Format(
"c_%s_vs_%s_%s_%d", x[ix].
Data(),
487 TString::Format(
"%s vs. %s at %s level", x[ix].
Data(),
493 if (mgraphs[ix][iy][imgr]->GetListOfGraphs() != 0) mgraphs[ix][iy][imgr]->Draw(
"A");
494 if (imgr == 0 &&
_legend) legend->Draw();
510 if (
_write) mgraphs[ix][iy][imgr]->Write();
516 if (mgraphs[ix][iy][imgr]->GetListOfGraphs() != 0) mgraphs[ix][iy][imgr]->Draw(
"A");
523 gStyle->SetOptTitle(0);
527 c_global[ic]->Draw();
531 TCanvas * c_temp = (TCanvas *) c_global[ic]->Clone(c_global[ic]->GetTitle() + TString(
"_sub"));
533 c_global[ic] =
new TCanvas (c_temp->GetName() + TString(
"_final"), c_temp->GetTitle(), c_temp->GetWindowWidth(), c_temp->GetWindowHeight());
534 c_global[ic]->Draw();
535 TPad * p_up =
new TPad (TString(
"legend_") + c_temp->GetName(),
"",
538 * p_down =
new TPad (TString(
"main_") + c_temp->GetName(),
"",
544 c_temp->DrawClonePad();
551 TLegend * global_legend =
MakeLegend(.05,.1,.95,.8);
552 global_legend->Draw();
556 TPaveText *
pt =
new TPaveText(.05,.1,.95,.8,
"NB");
563 if (
_write) c_global[ic]->Write();
569 cout << __FILE__ <<
":" << __LINE__ <<
":Info: End of MakePlots method" << endl;
583 const int kGridY) {
_grid_x = kGridX ;
590 const float SF) {
_SF[branchname] = SF ; }
599 + TString(name.EndsWith(
"/") ?
"" :
"/") ; }
605 if (word.BeginsWith(
"d")) word.ReplaceAll(
"d",
"#Delta");
606 if (word == TString(
"rdphi")) word =
"r#Delta#phi";
607 else if (word.EndsWith(
"phi")) word.ReplaceAll(
"phi",
"#phi");
608 else if (word.EndsWith(
"alpha")) word.ReplaceAll(
"alpha",
"#alpha");
609 else if (word.EndsWith(
"beta")) word.ReplaceAll(
"beta" ,
"#beta");
610 else if (word.EndsWith(
"gamma")) word.ReplaceAll(
"gamma",
"#gamma");
611 else if (word.EndsWith(
"eta")) word.ReplaceAll(
"eta",
"#eta");
617 if (print_option.Contains(
"pdf" ))
return TString(
".pdf" );
618 else if (print_option.Contains(
"eps" ))
return TString(
".eps" );
619 else if (print_option.Contains(
"ps" ))
return TString(
".ps" );
620 else if (print_option.Contains(
"svg" ))
return TString(
".svg" );
621 else if (print_option.Contains(
"tex" ))
return TString(
".tex" );
622 else if (print_option.Contains(
"gif" ))
return TString(
".gif" );
623 else if (print_option.Contains(
"xpm" ))
return TString(
".xpm" );
624 else if (print_option.Contains(
"png" ))
return TString(
".png" );
625 else if (print_option.Contains(
"jpg" ))
return TString(
".jpg" );
626 else if (print_option.Contains(
"tiff"))
return TString(
".tiff");
627 else if (print_option.Contains(
"cxx" ))
return TString(
".cxx" );
628 else if (print_option.Contains(
"xml" ))
return TString(
".xml" );
629 else if (print_option.Contains(
"root"))
return TString(
".root");
632 cout << __FILE__ <<
":" << __LINE__ <<
":Warning: unknown format. Returning .pdf, but possibly wrong..." << endl;
633 return TString(
".pdf");
643 TLegend * legend =
new TLegend (x1, y1, x2, y2, title.Data(),
"NBNDC");
645 legend->SetFillColor(0);
646 legend->SetLineColor(0);
647 legend->SetLineWidth(0);
648 for (
unsigned int isublevel = 0 ; isublevel <
NB_SUBLEVELS ; isublevel++)
650 TGraph *
g =
new TGraph (0);
653 g->SetMarkerStyle(kFullSquare);
654 g->SetMarkerSize(10);
void SetCanvasSize(const int window_width=3508, const int window_height=2480)
void Set1dModule(const bool)
map< TString, float > branch_f
void MakePlots(const vector< TString >, const vector< 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)
void SetWrite(const bool)
TString _output_directory
map< TString, TString > _units
TString _sublevel_names[6]
GeometryComparisonPlotter(TString tree_file_name, TString outputDirname="output/")
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
volatile std::atomic< bool > shutdown_flag false
#define DEFAULT_WINDOW_HEIGHT
#define COLOR_CODE(icolor)
void SetBranchMin(const TString, const float)
#define INSIDE_VECTOR(vector)
void SetLevelCut(const int)
map< TString, float > _SF