Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-07-21 01:09:44

0001 #ifndef RecoLocalMuon_CSCValHists_H
0002 #define RecoLocalMuon_CSCValHists_H
0003 
0004 /** \class CSCValHists
0005  *
0006  *  Manages Histograms for CSCValidation
0007  *
0008  *  original author:
0009  *  Andy Kubik (Northwestern University)
0010  *
0011  *  contact
0012  *  CSC DPG
0013  *
0014  */
0015 
0016 // system include files
0017 #include <memory>
0018 #include <iostream>
0019 #include <vector>
0020 #include <map>
0021 #include <string>
0022 #include <sstream>
0023 #include <iomanip>
0024 #include <fstream>
0025 #include <cmath>
0026 
0027 #include "TH1F.h"
0028 #include "TH2F.h"
0029 #include "TH3F.h"
0030 #include "TProfile.h"
0031 #include "TProfile2D.h"
0032 #include "TFile.h"
0033 #include "TTree.h"
0034 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
0035 
0036 class CSCValHists {
0037 public:
0038   // constructor
0039   CSCValHists();
0040 
0041   // destructor
0042   ~CSCValHists();
0043 
0044   // write histograms the theFile
0045   void writeHists(TFile* theFile);
0046 
0047   // write trees to theFile
0048   void writeTrees(TFile* theFile);
0049 
0050   // setup trees
0051   void setupTrees();
0052 
0053   // fill the global rechit position tree (this needs work!)
0054   void fillRechitTree(float x, float y, float gx, float gy, int en, int st, int ri, int ch, int la);
0055 
0056   // fill the global segment position tree
0057   void fillSegmentTree(float x, float y, float gx, float gy, int en, int st, int ri, int ch);
0058 
0059   // insert any TH1 into the big map
0060   void insertPlot(TH1* thePlot, std::string name, std::string folder);
0061 
0062   // calib hists are special because they are constants stored in a histogram, 1 per bin
0063   void fillCalibHist(
0064       float x, std::string name, std::string title, int bins, float xmin, float xmax, int bin, std::string folder);
0065 
0066   // fill 1D histogram
0067   void fill1DHist(float x, std::string name, std::string title, int bins, float xmin, float xmax, std::string folder);
0068 
0069   // fill 2D histogram
0070   void fill2DHist(float x,
0071                   float y,
0072                   std::string name,
0073                   std::string title,
0074                   int binsx,
0075                   float xmin,
0076                   float xmax,
0077                   int binsy,
0078                   float ymin,
0079                   float ymax,
0080                   std::string folder);
0081 
0082   // fill 1D histogram
0083   // a histogram is created for every chamber type
0084   void fill1DHistByType(
0085       float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder);
0086 
0087   // fill 2D histogram
0088   // a histogram is created for every chamber type
0089   void fill2DHistByType(float x,
0090                         float y,
0091                         std::string name,
0092                         std::string title,
0093                         CSCDetId id,
0094                         int binsx,
0095                         float xmin,
0096                         float xmax,
0097                         int binsy,
0098                         float ymin,
0099                         float ymax,
0100                         std::string folder);
0101 
0102   // fill 1D histogram
0103   // a histogram is created for every peripheral crate
0104   void fill1DHistByCrate(
0105       float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder);
0106 
0107   // fill 2D histogram
0108   // a histogram is created for every peripheral crate
0109   void fill2DHistByCrate(float x,
0110                          float y,
0111                          std::string name,
0112                          std::string title,
0113                          CSCDetId id,
0114                          int binsx,
0115                          float xmin,
0116                          float xmax,
0117                          int binsy,
0118                          float ymin,
0119                          float ymax,
0120                          std::string folder);
0121 
0122   // fill 2D histogram
0123   // a histogram is created for every station
0124   void fill1DHistByStation(
0125       float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder);
0126 
0127   // fill 2D histogram
0128   // a histogram is created for every station
0129   void fill2DHistByStation(float x,
0130                            float y,
0131                            std::string name,
0132                            std::string title,
0133                            CSCDetId id,
0134                            int binsx,
0135                            float xmin,
0136                            float xmax,
0137                            int binsy,
0138                            float ymin,
0139                            float ymax,
0140                            std::string folder);
0141 
0142   // fill 1D histogram
0143   // a histogram is created for every chamber
0144   void fill1DHistByChamber(
0145       float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder);
0146 
0147   // fill 2D histogram
0148   // a histogram is created for every chamber
0149   void fill2DHistByChamber(float x,
0150                            float y,
0151                            std::string name,
0152                            std::string title,
0153                            CSCDetId id,
0154                            int binsx,
0155                            float xmin,
0156                            float xmax,
0157                            int binsy,
0158                            float ymin,
0159                            float ymax,
0160                            std::string folder);
0161 
0162   // fill 2D histogram of entire detector
0163   // once per event
0164   void fill2DHistByEvent(
0165       int run, int event, float x, std::string name, std::string title, CSCDetId id, std::string folder);
0166 
0167   // fill 2D histogram of entire detector
0168   // with a value z for the specified chamber
0169   void fill2DHist(float z, std::string name, std::string title, CSCDetId id, std::string folder);
0170 
0171   // fill 1D histogram
0172   // a histogram is created for every layer in every chamber
0173   void fill1DHistByLayer(
0174       float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder);
0175 
0176   // fill 2D histogram
0177   // a histogram is created for every layer in every chamber
0178   void fill2DHistByLayer(float x,
0179                          float y,
0180                          std::string name,
0181                          std::string title,
0182                          CSCDetId id,
0183                          int binsx,
0184                          float xmin,
0185                          float xmax,
0186                          int binsy,
0187                          float ymin,
0188                          float ymax,
0189                          std::string folder);
0190 
0191   // make a profile histogram
0192   void fillProfile(float x,
0193                    float y,
0194                    std::string name,
0195                    std::string title,
0196                    int binsx,
0197                    float xmin,
0198                    float xmax,
0199                    float ymin,
0200                    float ymax,
0201                    std::string folder);
0202 
0203   // make a profile histogram
0204   // one will be made for every chamber type
0205   void fillProfileByType(float x,
0206                          float y,
0207                          std::string name,
0208                          std::string title,
0209                          CSCDetId id,
0210                          int binsx,
0211                          float xmin,
0212                          float xmax,
0213                          float ymin,
0214                          float ymax,
0215                          std::string folder);
0216 
0217   // make a profile histogram
0218   // one will be made for every chamber
0219   void fillProfileByChamber(float x,
0220                             float y,
0221                             std::string name,
0222                             std::string title,
0223                             CSCDetId id,
0224                             int binsx,
0225                             float xmin,
0226                             float xmax,
0227                             float ymin,
0228                             float ymax,
0229                             std::string folder);
0230 
0231   // make a 2D profile histogram (usefull for summary plots)
0232   void fill2DProfile(float x,
0233                      float y,
0234                      float z,
0235                      std::string name,
0236                      std::string title,
0237                      int binsx,
0238                      float xmin,
0239                      float xmax,
0240                      int binsy,
0241                      float ymin,
0242                      float ymax,
0243                      float zmin,
0244                      float zmax,
0245                      std::string folder);
0246 
0247   // look-up which crate this chamber belongs to
0248   int crate_lookup(CSCDetId id);
0249 
0250 protected:
0251 private:
0252   // map to hold histograms
0253   std::map<std::string, std::pair<TH1*, std::string> > theMap;
0254 
0255   // A struct for creating a Tree/Branch of position info
0256   struct posRecord {
0257     int endcap;
0258     int station;
0259     int ring;
0260     int chamber;
0261     int layer;
0262     float localx;
0263     float localy;
0264     float globalx;
0265     float globaly;
0266   } rHpos, segpos;
0267 
0268   // The root tree
0269   TTree* rHTree;
0270   TTree* segTree;
0271 };
0272 
0273 #endif