CMS 3D CMS Logo

GeometryComparisonPlotter.h
Go to the documentation of this file.
1 #include <TROOT.h>
2 #include <iostream>
3 #include <fstream>
4 #include <sstream>
5 #include <vector>
6 
7 #include <TString.h>
8 #include <TStyle.h>
9 #include <TAxis.h>
10 #include <TGraph.h>
11 #include <TF1.h>
12 #include <TH1.h>
13 #include <TH2.h>
14 #include <TMultiGraph.h>
15 #include <TFile.h>
16 #include <TCanvas.h>
17 #include <TLegend.h>
18 #include <TTree.h>
19 #include <TDirectory.h>
20 #include <TMath.h>
21 #include <TPaveText.h>
22 #include <TLatex.h>
23 #include <TList.h>
24 
25 
27 {
28  // internal variables
29 #ifndef NB_SUBLEVELS
30 #define NB_SUBLEVELS 6
31 #endif
39  bool _print,
40  _legend,
41  _write,
44  _batchMode,
45  _1dModule,
46  _2dModule;
47  int _levelCut,
48  _grid_x,
49  _grid_y,
52 
53  // branches
54  map<TString, int> branch_i;
55  map<TString, float> branch_f,
56  _max, _min, _SF;
57  map<TString, TString> _units;
58 
59  // variables of external objects
60  TFile * tree_file;
61  TFile * output;
62  TTree * data;
63 
64  // methods
65  TString LateXstyle (TString);
66  TString LateXstyleTable (TString);
67  TString ExtensionFromPrintOption (TString);
68  TLegend * MakeLegend (double x1,
69  double y1,
70  double x2,
71  double y2,
72  const TString title = "");
73 
74 public:
75 
76  static int canvas_index; // to append to the name of the canvases in case of duplication
77  static int canvas_profile_index; // to append to the name of the canvases in case of duplication
78 
79  // constructor and destructor
80  GeometryComparisonPlotter(TString tree_file_name,
81  TString outputDirname = "output/",
82  TString modulesToPlot="all",
83  TString referenceName="Ideal",
84  TString alignmentName="Alignment",
85  bool plotOnlyGlobal=false,
86  bool makeProfilePlots=false);
88 
89  // main methods
90  void MakePlots (const vector<TString>,
91  const vector<TString>,
92  const vector<float>,
93  const vector<float>
94  );
95 
96  void MakeTables (const vector<TString>,
97  const vector<TString>,
98  const vector<float>,
99  const vector<float>);
100 
101  void WriteTable (const vector<TString> x,
102  unsigned int nLevelsTimesSlices,
103  float meanValue[10][24],
104  float RMS[10][24],
105  const TString nDigits,
106  const TString tableCaption,
107  const TString tableFileName);
108 
109 
110  // option methods
111  void SetPrint (const bool); // activates the printing of the individual and global pdf
112  void SetLegend (const bool); // activates the legends
113  void SetWrite (const bool); // activates the writing into a Root file
114  void Set1dModule (const bool); // cut to include 1D modules
115  void Set2dModule (const bool); // cut to include 2D modules
116 #define DEFAULT_LEVEL 1
117  void SetLevelCut (const int); // module level: level=1 (default)
118  void SetBatchMode (const bool); // activates the display of the canvases
119  void SetGrid (const int, // activates the display of the grids
120  const int);
121  void SetBranchMax (const TString, // sets a max value for the variable
122  const float); // by giving the name and the value
123  void SetBranchMin (const TString, // sets a min value for the variable
124  const float); // by giving the name and the value
125  void SetBranchSF (const TString, // sets a rescaling factor for the variable
126  const float); // by giving the name and the value
127  void SetBranchUnits (const TString, // writes de units next on the axis
128  const TString);
129  void SetOutputDirectoryName (const TString); // sets the output name of the directory
130  void SetOutputFileName (const TString); // sets the name of the root file (if applicable)
131  void SetPrintOption (const Option_t *); // litteraly the print option of the TPad::Print()
132 #define DEFAULT_WINDOW_WIDTH 3508
133 #define DEFAULT_WINDOW_HEIGHT 2480
134  void SetCanvasSize (const int window_width = DEFAULT_WINDOW_WIDTH,
135  const int window_height = DEFAULT_WINDOW_HEIGHT);
136 };
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 SetGrid(const int, const int)
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="")
map< TString, TString > _units
void SetBranchSF(const TString, const float)
#define NB_SUBLEVELS
void MakeTables(const vector< TString >, const vector< TString >, const vector< float >, const vector< float >)
#define DEFAULT_WINDOW_HEIGHT
void SetBranchMin(const TString, const float)
GeometryComparisonPlotter(TString tree_file_name, TString outputDirname="output/", TString modulesToPlot="all", TString referenceName="Ideal", TString alignmentName="Alignment", bool plotOnlyGlobal=false, bool makeProfilePlots=false)