Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 11:56:55

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