Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:46:03

0001 #include <TROOT.h>
0002 #include <iostream>
0003 #include <fstream>
0004 #include <sstream>
0005 #include <vector>
0006 
0007 #include <TString.h>
0008 #include <TStyle.h>
0009 #include <TAxis.h>
0010 #include <TGraph.h>
0011 #include <TF1.h>
0012 #include <TH1.h>
0013 #include <TH2.h>
0014 #include <TMultiGraph.h>
0015 #include <TFile.h>
0016 #include <TCanvas.h>
0017 #include <TLegend.h>
0018 #include <TTree.h>
0019 #include <TDirectory.h>
0020 #include <TMath.h>
0021 #include <TPaveText.h>
0022 #include <TLatex.h>
0023 #include <TList.h>
0024 
0025 
0026 class GeometryComparisonPlotter
0027 {
0028     // internal variables
0029 #ifndef NB_SUBLEVELS
0030 #define NB_SUBLEVELS 6
0031 #endif
0032     TString _sublevel_names[NB_SUBLEVELS],
0033             _output_directory,
0034             _output_filename,
0035             _print_option,
0036             _module_plot_option,
0037             _alignment_name,
0038             _reference_name;
0039     bool _print,
0040          _legend,
0041          _write,
0042          _print_only_global,
0043          _make_profile_plots,
0044          _batchMode,
0045          _1dModule,
0046          _2dModule;
0047     int _levelCut,
0048         _grid_x,
0049         _grid_y,
0050         _window_width,
0051         _window_height;
0052 
0053     // branches
0054     map<TString, int> branch_i;
0055     map<TString, float> branch_f,
0056                         _max, _min, _SF;
0057     map<TString, TString> _units;
0058 
0059     // variables of external objects
0060     TFile * tree_file;
0061     TFile * output;
0062     TTree * data;
0063 
0064     // methods
0065     TString LateXstyle (TString);
0066     TString LateXstyleTable (TString);
0067     TString ExtensionFromPrintOption (TString);
0068     TLegend * MakeLegend (double x1,
0069                           double y1,
0070                           double x2,  
0071                           double y2,
0072                           int nPlottedSublevels,
0073                           const TString title = "");
0074 
0075 public:
0076 
0077     static int canvas_index; // to append to the name of the canvases in case of duplication
0078     static int canvas_profile_index; // to append to the name of the canvases in case of duplication
0079 
0080     // constructor and destructor
0081     GeometryComparisonPlotter(TString tree_file_name,
0082                               TString outputDirname = "output/",
0083                               TString modulesToPlot="all",
0084                               TString referenceName="Ideal",
0085                               TString alignmentName="Alignment",
0086                               bool plotOnlyGlobal=false,
0087                               bool makeProfilePlots=false);
0088     ~GeometryComparisonPlotter ();
0089 
0090     // main methods
0091     void MakePlots (const vector<TString>,
0092                     const vector<TString>,
0093                     const vector<float>,
0094                     const vector<float>
0095                     );
0096                     
0097     void MakeTables (const vector<TString>,
0098                     const vector<TString>,
0099                     const vector<float>,
0100                     const vector<float>);
0101                  
0102     void WriteTable (const vector<TString> x,
0103                     unsigned int nLevelsTimesSlices,
0104                     float meanValue[10][24],
0105                     float RMS[10][24],                  
0106                     const TString nDigits,                  
0107                     const TString tableCaption,
0108                     const TString tableFileName);
0109                  
0110 
0111     // option methods
0112     void SetPrint               (const bool);           // activates the printing of the individual and global pdf
0113     void SetLegend              (const bool);           // activates the legends
0114     void SetWrite               (const bool);           // activates the writing into a Root file
0115     void Set1dModule            (const bool);           // cut to include 1D modules
0116     void Set2dModule            (const bool);           // cut to include 2D modules
0117 #define DEFAULT_LEVEL 1
0118     void SetLevelCut            (const int);            // module level: level=1 (default)
0119     void SetBatchMode           (const bool);           // activates the display of the canvases
0120     void SetGrid                (const int,             // activates the display of the grids
0121                                  const int);
0122     void SetBranchMax           (const TString,         // sets a max value for the variable
0123                                  const float);          // by giving the name and the value
0124     void SetBranchMin           (const TString,         // sets a min value for the variable
0125                                  const float);          // by giving the name and the value
0126     void SetBranchSF            (const TString,         // sets a rescaling factor for the variable
0127                                  const float);          // by giving the name and the value
0128     void SetBranchUnits         (const TString,         // writes de units next on the axis
0129                                  const TString);
0130     void SetOutputDirectoryName (const TString);        // sets the output name of the directory
0131     void SetOutputFileName      (const TString);        // sets the name of the root file (if applicable)
0132     void SetPrintOption         (const Option_t *);     // litteraly the print option of the TPad::Print()
0133 #define DEFAULT_WINDOW_WIDTH  3508
0134 #define DEFAULT_WINDOW_HEIGHT 2480
0135     void SetCanvasSize          (const int window_width  = DEFAULT_WINDOW_WIDTH,
0136                                  const int window_height = DEFAULT_WINDOW_HEIGHT);
0137 };