CMS 3D CMS Logo

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