CMS 3D CMS Logo

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