CMS 3D CMS Logo

CSCValHists.h
Go to the documentation of this file.
1 #ifndef RecoLocalMuon_CSCValHists_H
2 #define RecoLocalMuon_CSCValHists_H
3 
4 
14 // system include files
15 #include <memory>
16 #include <iostream>
17 #include <vector>
18 #include <map>
19 #include <string>
20 #include <sstream>
21 #include <iomanip>
22 #include <fstream>
23 #include <cmath>
24 
25 #include "TH1F.h"
26 #include "TH2F.h"
27 #include "TH3F.h"
28 #include "TProfile.h"
29 #include "TProfile2D.h"
30 #include "TFile.h"
31 #include "TTree.h"
33 
34 
35 
37 
38  public:
39 
40  // constructor
41  CSCValHists();
42 
43  // destructor
44  ~CSCValHists();
45 
46  // write histograms the theFile
47  void writeHists(TFile* theFile);
48 
49  // write trees to theFile
50  void writeTrees(TFile* theFile);
51 
52  // setup trees
53  void setupTrees();
54 
55  // fill the global rechit position tree (this needs work!)
56  void fillRechitTree(float x, float y, float gx, float gy,
57  int en, int st, int ri, int ch, int la);
58 
59  // fill the global segment position tree
60  void fillSegmentTree(float x, float y, float gx, float gy,
61  int en, int st, int ri, int ch);
62 
63  // insert any TH1 into the big map
64  void insertPlot(TH1* thePlot, std::string name, std::string folder);
65 
66  // calib hists are special because they are constants stored in a histogram, 1 per bin
67  void fillCalibHist(float x, std::string name, std::string title, int bins, float xmin, float xmax,
68  int bin, std::string folder);
69 
70  // fill 1D histogram
71  void fill1DHist(float x, std::string name, std::string title,
72  int bins, float xmin, float xmax, std::string folder);
73 
74  // fill 2D histogram
75  void fill2DHist(float x, float y, std::string name, std::string title,
76  int binsx, float xmin, float xmax,
77  int binsy, float ymin, float ymax, std::string folder);
78 
79  // fill 1D histogram
80  // a histogram is created for every chamber type
81  void fill1DHistByType(float x, std::string name, std::string title, CSCDetId id,
82  int bins, float xmin, float xmax, std::string folder);
83 
84  // fill 2D histogram
85  // a histogram is created for every chamber type
86  void fill2DHistByType(float x, float y, std::string name, std::string title, CSCDetId id,
87  int binsx, float xmin, float xmax,
88  int binsy, float ymin, float ymax, std::string folder);
89 
90  // fill 1D histogram
91  // a histogram is created for every peripheral crate
92  void fill1DHistByCrate(float x, std::string name, std::string title, CSCDetId id,
93  int bins, float xmin, float xmax, std::string folder);
94 
95  // fill 2D histogram
96  // a histogram is created for every peripheral crate
97  void fill2DHistByCrate(float x, float y, std::string name, std::string title, CSCDetId id,
98  int binsx, float xmin, float xmax,
99  int binsy, float ymin, float ymax, std::string folder);
100 
101  // fill 2D histogram
102  // a histogram is created for every station
103  void fill1DHistByStation(float x, std::string name, std::string title, CSCDetId id,
104  int bins, float xmin, float xmax, std::string folder);
105 
106 
107  // fill 2D histogram
108  // a histogram is created for every station
109  void fill2DHistByStation(float x, float y, std::string name, std::string title, CSCDetId id,
110  int binsx, float xmin, float xmax,
111  int binsy, float ymin, float ymax, std::string folder);
112 
113  // fill 1D histogram
114  // a histogram is created for every chamber
115  void fill1DHistByChamber(float x, std::string name, std::string title, CSCDetId id,
116  int bins, float xmin, float xmax, std::string folder);
117 
118  // fill 2D histogram
119  // a histogram is created for every chamber
120  void fill2DHistByChamber(float x, float y, std::string name, std::string title, CSCDetId id,
121  int binsx, float xmin, float xmax,
122  int binsy, float ymin, float ymax, std::string folder);
123 
124  // fill 2D histogram of entire detector
125  // once per event
126  void fill2DHistByEvent(int run, int event, float x, std::string name, std::string title, CSCDetId id, std::string folder);
127 
128  // fill 2D histogram of entire detector
129  // with a value z for the specified chamber
130  void fill2DHist(float z, std::string name, std::string title, CSCDetId id, std::string folder);
131 
132  // fill 1D histogram
133  // a histogram is created for every layer in every chamber
134  void fill1DHistByLayer(float x, std::string name, std::string title, CSCDetId id,
135  int bins, float xmin, float xmax, std::string folder);
136 
137  // fill 2D histogram
138  // a histogram is created for every layer in every chamber
139  void fill2DHistByLayer(float x, float y, std::string name, std::string title, CSCDetId id,
140  int binsx, float xmin, float xmax,
141  int binsy, float ymin, float ymax, std::string folder);
142 
143 
144  // make a profile histogram
145  void fillProfile(float x, float y, std::string name, std::string title,
146  int binsx, float xmin, float xmax,
147  float ymin, float ymax, std::string folder);
148 
149  // make a profile histogram
150  // one will be made for every chamber type
151  void fillProfileByType(float x, float y, std::string name, std::string title, CSCDetId id,
152  int binsx, float xmin, float xmax,
153  float ymin, float ymax, std::string folder);
154 
155  // make a profile histogram
156  // one will be made for every chamber
157  void fillProfileByChamber(float x, float y, std::string name, std::string title, CSCDetId id,
158  int binsx, float xmin, float xmax,
159  float ymin, float ymax, std::string folder);
160 
161  // make a 2D profile histogram (usefull for summary plots)
162  void fill2DProfile(float x, float y, float z, std::string name, std::string title,
163  int binsx, float xmin, float xmax,
164  int binsy, float ymin, float ymax,
165  float zmin, float zmax, std::string folder);
166 
167  // look-up which crate this chamber belongs to
168  int crate_lookup(CSCDetId id);
169 
170  protected:
171 
172  private:
173 
174  // map to hold histograms
175  std::map<std::string,std::pair<TH1*,std::string> > theMap;
176 
177  // A struct for creating a Tree/Branch of position info
178  struct posRecord {
179  int endcap;
180  int station;
181  int ring;
182  int chamber;
183  int layer;
184  float localx;
185  float localy;
186  float globalx;
187  float globaly;
188  } rHpos, segpos;
189 
190  // The root tree
191  TTree *rHTree;
192  TTree *segTree;
193 
194 };
195 
196 #endif
int crate_lookup(CSCDetId id)
Definition: CSCValHists.cc:530
void fill2DHistByStation(float x, float y, std::string name, std::string title, CSCDetId id, int binsx, float xmin, float xmax, int binsy, float ymin, float ymax, std::string folder)
Definition: CSCValHists.cc:268
void fillProfileByType(float x, float y, std::string name, std::string title, CSCDetId id, int binsx, float xmin, float xmax, float ymin, float ymax, std::string folder)
Definition: CSCValHists.cc:461
void setupTrees()
Definition: CSCValHists.cc:55
void fillProfile(float x, float y, std::string name, std::string title, int binsx, float xmin, float xmax, float ymin, float ymax, std::string folder)
Definition: CSCValHists.cc:446
TTree * segTree
Definition: CSCValHists.h:192
void writeTrees(TFile *theFile)
Definition: CSCValHists.cc:41
void fill1DHist(float x, std::string name, std::string title, int bins, float xmin, float xmax, std::string folder)
Definition: CSCValHists.cc:121
void fill2DHistByCrate(float x, float y, std::string name, std::string title, CSCDetId id, int binsx, float xmin, float xmax, int binsy, float ymin, float ymax, std::string folder)
Definition: CSCValHists.cc:220
void fill1DHistByLayer(float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder)
Definition: CSCValHists.cc:397
std::map< std::string, std::pair< TH1 *, std::string > > theMap
Definition: CSCValHists.h:175
void fillProfileByChamber(float x, float y, std::string name, std::string title, CSCDetId id, int binsx, float xmin, float xmax, float ymin, float ymax, std::string folder)
Definition: CSCValHists.cc:487
void writeHists(TFile *theFile)
Definition: CSCValHists.cc:19
TTree * rHTree
Definition: CSCValHists.h:191
void insertPlot(TH1 *thePlot, std::string name, std::string folder)
Definition: CSCValHists.cc:100
void fill1DHistByType(float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder)
Definition: CSCValHists.cc:151
void fillRechitTree(float x, float y, float gx, float gy, int en, int st, int ri, int ch, int la)
Definition: CSCValHists.cc:68
void fill1DHistByCrate(float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder)
Definition: CSCValHists.cc:199
void fill2DHistByLayer(float x, float y, std::string name, std::string title, CSCDetId id, int binsx, float xmin, float xmax, int binsy, float ymin, float ymax, std::string folder)
Definition: CSCValHists.cc:421
bin
set the eta bin as selection string.
struct CSCValHists::posRecord rHpos
void fill1DHistByStation(float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder)
Definition: CSCValHists.cc:244
void fill1DHistByChamber(float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder)
Definition: CSCValHists.cc:293
void fill2DHistByChamber(float x, float y, std::string name, std::string title, CSCDetId id, int binsx, float xmin, float xmax, int binsy, float ymin, float ymax, std::string folder)
Definition: CSCValHists.cc:317
void fill2DHistByEvent(int run, int event, float x, std::string name, std::string title, CSCDetId id, std::string folder)
Definition: CSCValHists.cc:341
void fill2DHist(float x, float y, std::string name, std::string title, int binsx, float xmin, float xmax, int binsy, float ymin, float ymax, std::string folder)
Definition: CSCValHists.cc:136
void fill2DHistByType(float x, float y, std::string name, std::string title, CSCDetId id, int binsx, float xmin, float xmax, int binsy, float ymin, float ymax, std::string folder)
Definition: CSCValHists.cc:174
void fillSegmentTree(float x, float y, float gx, float gy, int en, int st, int ri, int ch)
Definition: CSCValHists.cc:84
void fill2DProfile(float x, float y, float z, std::string name, std::string title, int binsx, float xmin, float xmax, int binsy, float ymin, float ymax, float zmin, float zmax, std::string folder)
Definition: CSCValHists.cc:513
struct CSCValHists::posRecord segpos
void fillCalibHist(float x, std::string name, std::string title, int bins, float xmin, float xmax, int bin, std::string folder)
Definition: CSCValHists.cc:107
Definition: event.py:1