CMS 3D CMS Logo

CSCValHists.h
Go to the documentation of this file.
1 #ifndef RecoLocalMuon_CSCValHists_H
2 #define RecoLocalMuon_CSCValHists_H
3 
12 // system include files
13 #include <memory>
14 #include <iostream>
15 #include <vector>
16 #include <map>
17 #include <string>
18 #include <sstream>
19 #include <iomanip>
20 #include <fstream>
21 #include <cmath>
22 
23 #include "TH1F.h"
24 #include "TH2F.h"
25 #include "TH3F.h"
26 #include "TProfile.h"
27 #include "TProfile2D.h"
28 #include "TFile.h"
29 #include "TTree.h"
31 
32 class CSCValHists {
33 public:
34  // constructor
35  CSCValHists();
36 
37  // destructor
38  ~CSCValHists();
39 
40  // write histograms the theFile
41  void writeHists(TFile* theFile);
42 
43  // write trees to theFile
44  void writeTrees(TFile* theFile);
45 
46  // setup trees
47  void setupTrees();
48 
49  // fill the global rechit position tree (this needs work!)
50  void fillRechitTree(float x, float y, float gx, float gy, int en, int st, int ri, int ch, int la);
51 
52  // fill the global segment position tree
53  void fillSegmentTree(float x, float y, float gx, float gy, int en, int st, int ri, int ch);
54 
55  // insert any TH1 into the big map
56  void insertPlot(TH1* thePlot, std::string name, std::string folder);
57 
58  // calib hists are special because they are constants stored in a histogram, 1 per bin
59  void fillCalibHist(
60  float x, std::string name, std::string title, int bins, float xmin, float xmax, int bin, std::string folder);
61 
62  // fill 1D histogram
63  void fill1DHist(float x, std::string name, std::string title, int bins, float xmin, float xmax, std::string folder);
64 
65  // fill 2D histogram
66  void fill2DHist(float x,
67  float y,
70  int binsx,
71  float xmin,
72  float xmax,
73  int binsy,
74  float ymin,
75  float ymax,
77 
78  // fill 1D histogram
79  // a histogram is created for every chamber type
80  void fill1DHistByType(
81  float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder);
82 
83  // fill 2D histogram
84  // a histogram is created for every chamber type
85  void fill2DHistByType(float x,
86  float y,
89  CSCDetId id,
90  int binsx,
91  float xmin,
92  float xmax,
93  int binsy,
94  float ymin,
95  float ymax,
97 
98  // fill 1D histogram
99  // a histogram is created for every peripheral crate
100  void fill1DHistByCrate(
101  float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder);
102 
103  // fill 2D histogram
104  // a histogram is created for every peripheral crate
105  void fill2DHistByCrate(float x,
106  float y,
109  CSCDetId id,
110  int binsx,
111  float xmin,
112  float xmax,
113  int binsy,
114  float ymin,
115  float ymax,
117 
118  // fill 2D histogram
119  // a histogram is created for every station
120  void fill1DHistByStation(
121  float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder);
122 
123  // fill 2D histogram
124  // a histogram is created for every station
125  void fill2DHistByStation(float x,
126  float y,
129  CSCDetId id,
130  int binsx,
131  float xmin,
132  float xmax,
133  int binsy,
134  float ymin,
135  float ymax,
137 
138  // fill 1D histogram
139  // a histogram is created for every chamber
140  void fill1DHistByChamber(
141  float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder);
142 
143  // fill 2D histogram
144  // a histogram is created for every chamber
145  void fill2DHistByChamber(float x,
146  float y,
149  CSCDetId id,
150  int binsx,
151  float xmin,
152  float xmax,
153  int binsy,
154  float ymin,
155  float ymax,
157 
158  // fill 2D histogram of entire detector
159  // once per event
160  void fill2DHistByEvent(
162 
163  // fill 2D histogram of entire detector
164  // with a value z for the specified chamber
166 
167  // fill 1D histogram
168  // a histogram is created for every layer in every chamber
169  void fill1DHistByLayer(
170  float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder);
171 
172  // fill 2D histogram
173  // a histogram is created for every layer in every chamber
174  void fill2DHistByLayer(float x,
175  float y,
178  CSCDetId id,
179  int binsx,
180  float xmin,
181  float xmax,
182  int binsy,
183  float ymin,
184  float ymax,
186 
187  // make a profile histogram
188  void fillProfile(float x,
189  float y,
192  int binsx,
193  float xmin,
194  float xmax,
195  float ymin,
196  float ymax,
198 
199  // make a profile histogram
200  // one will be made for every chamber type
201  void fillProfileByType(float x,
202  float y,
205  CSCDetId id,
206  int binsx,
207  float xmin,
208  float xmax,
209  float ymin,
210  float ymax,
212 
213  // make a profile histogram
214  // one will be made for every chamber
215  void fillProfileByChamber(float x,
216  float y,
219  CSCDetId id,
220  int binsx,
221  float xmin,
222  float xmax,
223  float ymin,
224  float ymax,
226 
227  // make a 2D profile histogram (usefull for summary plots)
228  void fill2DProfile(float x,
229  float y,
230  float z,
233  int binsx,
234  float xmin,
235  float xmax,
236  int binsy,
237  float ymin,
238  float ymax,
239  float zmin,
240  float zmax,
242 
243  // look-up which crate this chamber belongs to
244  int crate_lookup(CSCDetId id);
245 
246 protected:
247 private:
248  // map to hold histograms
249  std::map<std::string, std::pair<TH1*, std::string> > theMap;
250 
251  // A struct for creating a Tree/Branch of position info
252  struct posRecord {
253  int endcap;
254  int station;
255  int ring;
256  int chamber;
257  int layer;
258  float localx;
259  float localy;
260  float globalx;
261  float globaly;
262  } rHpos, segpos;
263 
264  // The root tree
265  TTree* rHTree;
266  TTree* segTree;
267 };
268 
269 #endif
int crate_lookup(CSCDetId id)
Definition: CSCValHists.cc:575
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:254
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:481
void setupTrees()
Definition: CSCValHists.cc:39
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:461
TTree * segTree
Definition: CSCValHists.h:266
void writeTrees(TFile *theFile)
Definition: CSCValHists.cc:29
void fill1DHist(float x, std::string name, std::string title, int bins, float xmin, float xmax, std::string folder)
Definition: CSCValHists.cc:93
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:201
void fill1DHistByLayer(float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder)
Definition: CSCValHists.cc:401
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:515
void writeHists(TFile *theFile)
Definition: CSCValHists.cc:10
TTree * rHTree
Definition: CSCValHists.h:265
void insertPlot(TH1 *thePlot, std::string name, std::string folder)
Definition: CSCValHists.cc:78
std::map< std::string, std::pair< TH1 *, std::string > > theMap
Definition: CSCValHists.h:249
void fill1DHistByType(float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder)
Definition: CSCValHists.cc:125
void fillRechitTree(float x, float y, float gx, float gy, int en, int st, int ri, int ch, int la)
Definition: CSCValHists.cc:50
void fill1DHistByCrate(float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder)
Definition: CSCValHists.cc:182
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:425
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:231
void fill1DHistByChamber(float x, std::string name, std::string title, CSCDetId id, int bins, float xmin, float xmax, std::string folder)
Definition: CSCValHists.cc:288
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:311
void fill2DHistByEvent(int run, int event, float x, std::string name, std::string title, CSCDetId id, std::string folder)
Definition: CSCValHists.cc:345
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:104
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:148
void fillSegmentTree(float x, float y, float gx, float gy, int en, int st, int ri, int ch)
Definition: CSCValHists.cc:64
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:549
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:82
Definition: event.py:1