CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/RecoLocalMuon/CSCValidation/src/CSCValHists.h

Go to the documentation of this file.
00001 #ifndef RecoLocalMuon_CSCValHists_H
00002 #define RecoLocalMuon_CSCValHists_H
00003 
00004 
00014 // system include files
00015 #include <memory>
00016 #include <iostream>
00017 #include <vector>
00018 #include <map>
00019 #include <string>
00020 #include <sstream>
00021 #include <iomanip>
00022 #include <fstream>
00023 #include <cmath>
00024 
00025 #include "TH1F.h"
00026 #include "TH2F.h"
00027 #include "TH3F.h"
00028 #include "TProfile.h"
00029 #include "TProfile2D.h"
00030 #include "TFile.h"
00031 #include "TTree.h"
00032 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00033 
00034 
00035 
00036 class CSCValHists{
00037 
00038   public:
00039 
00040   // constructor
00041   CSCValHists();
00042 
00043   // destructor
00044   ~CSCValHists();
00045 
00046     // write histograms the theFile
00047   void writeHists(TFile* theFile);
00048 
00049   // write trees to theFile
00050   void writeTrees(TFile* theFile);
00051 
00052   // setup trees
00053   void setupTrees();
00054 
00055   // fill the global rechit position tree (this needs work!)  
00056   void fillRechitTree(float x, float y, float gx, float gy,
00057                       int en, int st, int ri, int ch, int la);
00058 
00059   // fill the global segment position tree
00060   void fillSegmentTree(float x, float y, float gx, float gy,
00061                        int en, int st, int ri, int ch);
00062 
00063   // insert any TH1 into the big map
00064   void insertPlot(TH1* thePlot, std::string name, std::string folder);
00065 
00066   // calib hists are special because they are constants stored in a histogram, 1 per bin
00067   void fillCalibHist(float x, std::string name, std::string title, int bins, float xmin, float xmax,
00068                      int bin, std::string folder);
00069 
00070   // fill 1D histogram 
00071   void fill1DHist(float x, std::string name, std::string title,
00072                   int bins, float xmin, float xmax, std::string folder);
00073 
00074   // fill 2D histogram
00075   void fill2DHist(float x, float y, std::string name, std::string title,
00076                   int binsx, float xmin, float xmax,
00077                   int binsy, float ymin, float ymax, std::string folder);
00078 
00079   // fill 1D histogram
00080   // a histogram is created for every chamber type
00081   void fill1DHistByType(float x, std::string name, std::string title, CSCDetId id,
00082                         int bins, float xmin, float xmax, std::string folder);
00083 
00084   // fill 2D histogram
00085   // a histogram is created for every chamber type
00086   void fill2DHistByType(float x, float y, std::string name, std::string title, CSCDetId id,
00087                         int binsx, float xmin, float xmax,
00088                         int binsy, float ymin, float ymax, std::string folder);
00089 
00090   // fill 1D histogram
00091   // a histogram is created for every peripheral crate
00092   void fill1DHistByCrate(float x, std::string name, std::string title, CSCDetId id,
00093                         int bins, float xmin, float xmax, std::string folder);
00094 
00095   // fill 2D histogram
00096   // a histogram is created for every peripheral crate
00097   void fill2DHistByCrate(float x, float y, std::string name, std::string title, CSCDetId id,
00098                         int binsx, float xmin, float xmax,
00099                         int binsy, float ymin, float ymax, std::string folder);
00100 
00101   // fill 2D histogram
00102   // a histogram is created for every station
00103   void fill1DHistByStation(float x, std::string name, std::string title, CSCDetId id,
00104                            int bins, float xmin, float xmax, std::string folder);
00105 
00106 
00107   // fill 2D histogram
00108   // a histogram is created for every station
00109   void fill2DHistByStation(float x, float y, std::string name, std::string title, CSCDetId id,
00110                            int binsx, float xmin, float xmax,
00111                            int binsy, float ymin, float ymax, std::string folder);
00112 
00113   // fill 1D histogram
00114   // a histogram is created for every chamber
00115   void fill1DHistByChamber(float x, std::string name, std::string title, CSCDetId id,
00116                            int bins, float xmin, float xmax, std::string folder);
00117 
00118   // fill 2D histogram
00119   // a histogram is created for every chamber
00120   void fill2DHistByChamber(float x, float y, std::string name, std::string title, CSCDetId id,
00121                            int binsx, float xmin, float xmax,
00122                            int binsy, float ymin, float ymax, std::string folder);
00123 
00124   // fill 2D histogram of entire detector
00125   // once per event
00126   void fill2DHistByEvent(int run, int event, float x, std::string name, std::string title, CSCDetId id, std::string folder);
00127   
00128   // fill 2D histogram of entire detector
00129   // with a value z for the specified chamber
00130   void fill2DHist(float z, std::string name, std::string title, CSCDetId id, std::string folder);
00131 
00132   // fill 1D histogram
00133   // a histogram is created for every layer in every chamber
00134   void fill1DHistByLayer(float x, std::string name, std::string title, CSCDetId id,
00135                          int bins, float xmin, float xmax, std::string folder);
00136 
00137   // fill 2D histogram
00138   // a histogram is created for every layer in every chamber
00139   void fill2DHistByLayer(float x, float y, std::string name, std::string title, CSCDetId id,
00140                          int binsx, float xmin, float xmax,
00141                          int binsy, float ymin, float ymax, std::string folder);
00142 
00143 
00144   // make a profile histogram
00145   void fillProfile(float x, float y, std::string name, std::string title, 
00146                    int binsx, float xmin, float xmax,
00147                    float ymin, float ymax, std::string folder);
00148 
00149   // make a profile histogram
00150   // one will be made for every chamber type
00151   void fillProfileByType(float x, float y, std::string name, std::string title, CSCDetId id,
00152                          int binsx, float xmin, float xmax,
00153                          float ymin, float ymax, std::string folder);
00154 
00155   // make a profile histogram
00156   // one will be made for every chamber
00157   void fillProfileByChamber(float x, float y, std::string name, std::string title, CSCDetId id,
00158                             int binsx, float xmin, float xmax,
00159                             float ymin, float ymax, std::string folder);
00160 
00161   // make a 2D profile histogram (usefull for summary plots)
00162   void fill2DProfile(float x, float y, float z, std::string name, std::string title, 
00163                      int binsx, float xmin, float xmax,
00164                      int binsy, float ymin, float ymax,
00165                      float zmin, float zmax, std::string folder);
00166 
00167   // look-up which crate this chamber belongs to
00168   int crate_lookup(CSCDetId id);
00169 
00170   protected:
00171 
00172   private:
00173 
00174   // map to hold histograms
00175   std::map<std::string,std::pair<TH1*,std::string> > theMap;
00176 
00177   // A struct for creating a Tree/Branch of position info
00178   struct posRecord {
00179     int endcap;
00180     int station;
00181     int ring;
00182     int chamber;
00183     int layer;
00184     float localx;
00185     float localy;
00186     float globalx;
00187     float globaly;
00188   } rHpos, segpos;
00189 
00190   // The root tree
00191   TTree *rHTree;
00192   TTree *segTree;
00193 
00194 };
00195 
00196 #endif