CMS 3D CMS Logo

MELaserPrim.h
Go to the documentation of this file.
1 #ifndef MELaserPrim_hh
2 #define MELaserPrim_hh
3 
4 #include <iostream>
5 #include <fstream>
6 #include <vector>
7 #include <map>
8 
9 #include <TROOT.h>
10 #include <TChain.h>
11 #include <TH2I.h>
12 #include <TH2F.h>
13 #include <TFile.h>
14 #include <TString.h>
15 
16 #include "ME.h"
17 
18 class MELaserPrim {
19 public:
20  // Julie's ntuple variables
26 
28 
29  // channel views & logic ids
30  enum {
40  };
41  static TString channelViewName(int);
42  static int logicId(int channelView, int id1, int id2 = 0);
43  static bool getViewIds(int logicId, int &channelView, int &id1, int &id2);
44 
45  // constructor
46  MELaserPrim(ME::Header header, ME::Settings settings, const char *inpath, const char *outfile);
47 
48  // destructor
49  virtual ~MELaserPrim();
50 
51  // functions
52  bool init_ok;
53  void init();
54  void bookHistograms();
55  void fillHistograms();
56  void writeHistograms();
57  void print(std::ostream &o);
58 
59  // name of tables
60  static TString lmfLaserName(int table, int type, int color = ME::iBlue);
61 
62  // fill histograms from a user application (e.g. DB )
63  bool setInt(const char *, int ix, int iy, int ival);
64  bool setVal(const char *, int ix, int iy, float val);
65 
66  // fill tree variables from a user application (e.g. DB )
67  bool setInt(const char *tname, const char *vname, int ival);
68  bool setVal(const char *tname, const char *vname, float val);
69 
70  bool fill(const char *tname);
71 
72  // access
73  Int_t getInt(const char *, int ix, int iy);
74  Float_t getVal(const char *, int ix, int iy);
75 
76  static TString separator;
77 
78 private:
79  // monitoring region (dcc+side), wavelength, run number and timestamp
80  int _reg;
81  bool _isBarrel;
82  int _lmr;
83  int _dcc;
84  int _side;
85  int _run;
86  int _lb;
87  int _events;
88 
89  int _type;
90  int _color;
91  int _power;
92  int _filter;
93  int _delay;
94 
95  // GHM
99 
101  int _memgain;
102 
103  // useful
105  int _sm;
106  // std::map< int, std::pair<int, int> > _pn; // association module -> pair of PN diodes
107 
108  TString _sectorStr;
109  TString _regionStr;
110  TString _primStr;
111  TString _pnPrimStr;
112  TString _pulseStr;
113  TString _tpPrimStr;
114  TString _tpPnPrimStr;
115 
116  // root files
117  TFile *apdpn_file;
118  TFile *ab_file;
119  TFile *pn_file;
120  TFile *mtq_file;
121  TFile *tpapd_file;
122  TFile *out_file;
123 
124  // root trees
125  TTree *apdpn_tree;
126  TTree *ab_tree;
127  TTree *pn_tree;
128  TTree *mtq_tree;
129  TTree *tpapd_tree;
130  TTree *tppn_tree;
131 
132  // paths to laser monitoring trees
133  TString _inpath;
134 
135  // root file in output
136  TString _outfile;
137 
138  // index limits (depends on dcc)
139  int nx;
140  int ixmin;
141  int ixmax;
142  int ny;
143  int iymin;
144  int iymax;
145 
146  // 2D-histograms
147  std::map<TString, TH2 *> i_h; // integer quantities
148  std::map<TString, TH2 *> f_h; // floating point quantities
149 
150  // trees
151  std::map<TString, TTree *> t_t; // map of trees
152  std::map<TString, int> i_t; // integer values
153  std::map<TString, float> f_t; // float values
154  std::map<TString, const char *> c_t; // string values
155 
156  // leaves for the APDPN ntuple
157  Int_t apdpn_dccID;
161  // Double_t apdpn_gainID;
162  Int_t apdpn_side;
163  Int_t apdpn_ieta;
164  Int_t apdpn_iphi;
165  Int_t apdpn_flag;
166  Double_t apdpn_ShapeCor;
168 
169  // leaves for the AB ntuple
170  Int_t ab_dccID;
171  Int_t ab_towerID;
173  Int_t ab_ieta;
174  Int_t ab_iphi;
175  Int_t ab_flag;
176  Double_t ab_ab[iSize_ab];
177 
178  // leaves for the PN ntuple
179  Int_t pn_side;
180  Int_t pn_pnID;
181  Int_t pn_moduleID;
182  Double_t pn_PN[iSize_apdpn];
186 
187  // leaves for the MTQ ntuple
188  Int_t mtq_side;
189  Int_t mtq_color;
190  Double_t mtq_mtq[iSize_mtq];
191 
192  // leaves for the TPAPD ntuple
193  Int_t tpapd_iphi;
194  Int_t tpapd_ieta;
195  Int_t tpapd_dccID;
196  Int_t tpapd_side;
200  Int_t tpapd_flag;
201  Int_t tpapd_gain;
203 
204  // leaves for the TPPN ntuple
205  Int_t tppn_side;
206  Int_t tppn_pnID;
208  Int_t tppn_gain;
209  Double_t tppn_PN[iSize_apdpn];
210 
211  // List of branches for APDPN
212  TBranch *b_apdpn_dccID;
213  TBranch *b_apdpn_towerID;
214  TBranch *b_apdpn_channelID;
215  TBranch *b_apdpn_moduleID;
216  // TBranch *b_apdpn_gainID; //!
217  TBranch *b_apdpn_side;
218  TBranch *b_apdpn_ieta;
219  TBranch *b_apdpn_iphi;
220  TBranch *b_apdpn_flag;
221  TBranch *b_apdpn_ShapeCor;
223 
224  // List of branches for AB
225  TBranch *b_ab_dccID;
226  TBranch *b_ab_towerID;
227  TBranch *b_ab_channelID;
228  TBranch *b_ab_ieta;
229  TBranch *b_ab_iphi;
230  TBranch *b_ab_flag;
231  TBranch *b_ab_ab[iSize_ab];
232 
233  // List of branches for PN
234  TBranch *b_pn_side;
235  TBranch *b_pn_pnID;
236  TBranch *b_pn_moduleID;
237  TBranch *b_pn_PN;
238  TBranch *b_pn_PNoPN;
239  TBranch *b_pn_PNoPNA;
240  TBranch *b_pn_PNoPNB;
241 
242  // List of branches for MTQ
243  TBranch *b_mtq_side;
244  TBranch *b_mtq_color;
245  TBranch *b_mtq_mtq[iSize_mtq];
246 
247  // List of branches for TPAPD
248  TBranch *b_tpapd_iphi;
249  TBranch *b_tpapd_ieta;
250  TBranch *b_tpapd_dccID;
251  TBranch *b_tpapd_side;
252  TBranch *b_tpapd_towerID;
253  TBranch *b_tpapd_channelID;
254  TBranch *b_tpapd_moduleID;
255  TBranch *b_tpapd_flag;
256  TBranch *b_tpapd_gain;
257  TBranch *b_tpapd_APD;
258 
259  // List of branches for TPPN
260  TBranch *b_tppn_side;
261  TBranch *b_tppn_pnID;
262  TBranch *b_tppn_moduleID;
263  TBranch *b_tppn_gain;
264  TBranch *b_tppn_PN;
265 
267  static TString apdpn_varName[iSize_apdpn];
271  static TString ab_varName[iSize_ab];
272  static TString mtq_varName[iSize_mtq];
273  static TString mtq_varUnit[iSize_mtq];
274 
275  void setHistoStyle(TH1 *);
276  void refresh();
277  void addBranchI(const char *t_name, const char *v_name);
278  void addBranchF(const char *t_name, const char *v_name);
279  void addBranchC(const char *t_name, const char *v_name);
280  void bookHistoI(const char *t_name, const char *v_name);
281  void bookHistoF(const char *t_name, const char *v_name);
282 
283  // ClassDef( MELaserPrim, 0 ) // reads/writes Laser primitives
284 };
285 
286 #endif
Int_t apdpn_dccID
Definition: MELaserPrim.h:157
Double_t tpapd_APD[iSize_apdpn]
Definition: MELaserPrim.h:202
type
Definition: HCALResponse.h:21
TBranch * b_ab_channelID
Definition: MELaserPrim.h:227
Int_t pn_pnID
Definition: MELaserPrim.h:180
bool _isBarrel
Definition: MELaserPrim.h:81
TBranch * b_tppn_moduleID
Definition: MELaserPrim.h:262
TBranch * b_apdpn_apdpn[iSizeArray_apdpn]
Definition: MELaserPrim.h:222
TString _inpath
Definition: MELaserPrim.h:133
TBranch * b_tppn_PN
Definition: MELaserPrim.h:264
TString _outfile
Definition: MELaserPrim.h:136
static bool getViewIds(int logicId, int &channelView, int &id1, int &id2)
Definition: MELaserPrim.cc:125
static TString mtq_varUnit[iSize_mtq]
Definition: MELaserPrim.h:273
TBranch * b_tppn_pnID
Definition: MELaserPrim.h:261
TTree * apdpn_tree
Definition: MELaserPrim.h:125
TBranch * b_mtq_color
Definition: MELaserPrim.h:244
TBranch * b_apdpn_channelID
Definition: MELaserPrim.h:214
Double_t pn_PN[iSize_apdpn]
Definition: MELaserPrim.h:182
TBranch * b_pn_pnID
Definition: MELaserPrim.h:235
TFile * mtq_file
Definition: MELaserPrim.h:120
void writeHistograms()
Definition: MELaserPrim.cc:916
TBranch * b_pn_PNoPNA
Definition: MELaserPrim.h:239
void fillHistograms()
Definition: MELaserPrim.cc:507
Double_t pn_PNoPNB[iSize_apdpn]
Definition: MELaserPrim.h:185
Int_t pn_moduleID
Definition: MELaserPrim.h:181
TString _tpPrimStr
Definition: MELaserPrim.h:113
TTree * tppn_tree
Definition: MELaserPrim.h:130
static char const * tname
Definition: GTSchema.h:13
Int_t tppn_moduleID
Definition: MELaserPrim.h:207
Int_t tpapd_ieta
Definition: MELaserPrim.h:194
TBranch * b_ab_ab[iSize_ab]
Definition: MELaserPrim.h:231
Double_t pn_PNoPN[iSize_apdpn]
Definition: MELaserPrim.h:183
TBranch * b_ab_towerID
Definition: MELaserPrim.h:226
Double_t ab_ab[iSize_ab]
Definition: MELaserPrim.h:176
Int_t getInt(const char *, int ix, int iy)
TBranch * b_tpapd_dccID
Definition: MELaserPrim.h:250
TBranch * b_mtq_side
Definition: MELaserPrim.h:243
std::map< TString, TTree * > t_t
Definition: MELaserPrim.h:151
static TString apdpn_varName[iSize_apdpn]
Definition: MELaserPrim.h:267
bool setVal(const char *, int ix, int iy, float val)
Int_t ab_flag
Definition: MELaserPrim.h:175
static TString apdpn_arrayName[iSizeArray_apdpn]
Definition: MELaserPrim.h:266
Int_t tppn_gain
Definition: MELaserPrim.h:208
Double_t mtq_mtq[iSize_mtq]
Definition: MELaserPrim.h:190
TBranch * b_tpapd_gain
Definition: MELaserPrim.h:256
Int_t ab_towerID
Definition: MELaserPrim.h:171
TBranch * b_tpapd_APD
Definition: MELaserPrim.h:257
Int_t tpapd_dccID
Definition: MELaserPrim.h:195
Int_t ab_ieta
Definition: MELaserPrim.h:173
Int_t tppn_side
Definition: MELaserPrim.h:205
static TString channelViewName(int)
Definition: MELaserPrim.cc:96
TBranch * b_ab_ieta
Definition: MELaserPrim.h:228
TBranch * b_apdpn_ieta
Definition: MELaserPrim.h:218
Int_t tpapd_side
Definition: MELaserPrim.h:196
Int_t ab_channelID
Definition: MELaserPrim.h:172
Int_t apdpn_iphi
Definition: MELaserPrim.h:164
ME::TimeStamp _ts_end
Definition: MELaserPrim.h:98
Int_t tpapd_towerID
Definition: MELaserPrim.h:197
TFile * pn_file
Definition: MELaserPrim.h:119
TBranch * b_pn_moduleID
Definition: MELaserPrim.h:236
TTree * ab_tree
Definition: MELaserPrim.h:126
Int_t tpapd_iphi
Definition: MELaserPrim.h:193
Definition: ME.h:64
bool init_ok
Definition: MELaserPrim.h:52
TTree * mtq_tree
Definition: MELaserPrim.h:128
static TString apdpn_extraVarUnit[iSizeExtra_apdpn]
Definition: MELaserPrim.h:270
bool fill(const char *tname)
MELaserPrim(ME::Header header, ME::Settings settings, const char *inpath, const char *outfile)
Definition: MELaserPrim.cc:39
TBranch * b_pn_PN
Definition: MELaserPrim.h:237
Int_t pn_side
Definition: MELaserPrim.h:179
static TString mtq_varName[iSize_mtq]
Definition: MELaserPrim.h:272
Float_t getVal(const char *, int ix, int iy)
void addBranchC(const char *t_name, const char *v_name)
void print(std::ostream &o)
Definition: MELaserPrim.cc:980
TBranch * b_pn_side
Definition: MELaserPrim.h:234
TBranch * b_tpapd_flag
Definition: MELaserPrim.h:255
void bookHistograms()
Definition: MELaserPrim.cc:335
TBranch * b_tppn_gain
Definition: MELaserPrim.h:263
TFile * apdpn_file
Definition: MELaserPrim.h:117
Int_t mtq_side
Definition: MELaserPrim.h:188
TBranch * b_ab_dccID
Definition: MELaserPrim.h:225
TBranch * b_apdpn_ShapeCor
Definition: MELaserPrim.h:221
bool setInt(const char *, int ix, int iy, int ival)
TBranch * b_pn_PNoPN
Definition: MELaserPrim.h:238
TString _primStr
Definition: MELaserPrim.h:110
Int_t tpapd_flag
Definition: MELaserPrim.h:200
static int logicId(int channelView, int id1, int id2=0)
Definition: MELaserPrim.cc:120
Int_t apdpn_moduleID
Definition: MELaserPrim.h:160
TBranch * b_tpapd_towerID
Definition: MELaserPrim.h:252
std::map< TString, float > f_t
Definition: MELaserPrim.h:153
Int_t apdpn_flag
Definition: MELaserPrim.h:165
static TString lmfLaserName(int table, int type, int color=ME::iBlue)
Definition: MELaserPrim.cc:997
unsigned long long TimeStamp
Definition: ME.h:69
void refresh()
TBranch * b_tppn_side
Definition: MELaserPrim.h:260
Int_t ab_iphi
Definition: MELaserPrim.h:174
void addBranchI(const char *t_name, const char *v_name)
TBranch * b_pn_PNoPNB
Definition: MELaserPrim.h:240
static TString ab_varName[iSize_ab]
Definition: MELaserPrim.h:271
static TString apdpn_varUnit[iSizeArray_apdpn][iSize_apdpn]
Definition: MELaserPrim.h:268
TBranch * b_apdpn_flag
Definition: MELaserPrim.h:220
Int_t tpapd_gain
Definition: MELaserPrim.h:201
TBranch * b_ab_flag
Definition: MELaserPrim.h:230
TBranch * b_mtq_mtq[iSize_mtq]
Definition: MELaserPrim.h:245
TBranch * b_tpapd_side
Definition: MELaserPrim.h:251
Double_t apdpn_ShapeCor
Definition: MELaserPrim.h:166
Int_t tpapd_moduleID
Definition: MELaserPrim.h:199
Double_t pn_PNoPNA[iSize_apdpn]
Definition: MELaserPrim.h:184
Int_t apdpn_channelID
Definition: MELaserPrim.h:159
std::map< TString, const char * > c_t
Definition: MELaserPrim.h:154
Int_t apdpn_ieta
Definition: MELaserPrim.h:163
Int_t ab_dccID
Definition: MELaserPrim.h:170
Definition: ME.h:72
TBranch * b_tpapd_iphi
Definition: MELaserPrim.h:248
Int_t tppn_pnID
Definition: MELaserPrim.h:206
std::map< TString, int > i_t
Definition: MELaserPrim.h:152
TBranch * b_tpapd_channelID
Definition: MELaserPrim.h:253
std::map< TString, TH2 * > f_h
Definition: MELaserPrim.h:148
TString _pnPrimStr
Definition: MELaserPrim.h:111
TTree * tpapd_tree
Definition: MELaserPrim.h:129
std::map< TString, TH2 * > i_h
Definition: MELaserPrim.h:147
static TString apdpn_extraVarName[iSizeExtra_apdpn]
Definition: MELaserPrim.h:269
TString _pulseStr
Definition: MELaserPrim.h:112
Int_t mtq_color
Definition: MELaserPrim.h:189
TBranch * b_tpapd_moduleID
Definition: MELaserPrim.h:254
Int_t apdpn_towerID
Definition: MELaserPrim.h:158
Int_t tpapd_channelID
Definition: MELaserPrim.h:198
ME::TimeStamp _ts_beg
Definition: MELaserPrim.h:97
TBranch * b_tpapd_ieta
Definition: MELaserPrim.h:249
TBranch * b_apdpn_iphi
Definition: MELaserPrim.h:219
virtual ~MELaserPrim()
Definition: MELaserPrim.cc:947
TFile * ab_file
Definition: MELaserPrim.h:118
TBranch * b_apdpn_towerID
Definition: MELaserPrim.h:213
void addBranchF(const char *t_name, const char *v_name)
TBranch * b_apdpn_side
Definition: MELaserPrim.h:217
ME::TimeStamp _ts
Definition: MELaserPrim.h:96
TFile * out_file
Definition: MELaserPrim.h:122
void setHistoStyle(TH1 *)
Double_t apdpn_apdpn[iSizeArray_apdpn][iSize_apdpn]
Definition: MELaserPrim.h:167
void bookHistoI(const char *t_name, const char *v_name)
TBranch * b_ab_iphi
Definition: MELaserPrim.h:229
static TString separator
Definition: MELaserPrim.h:76
TString _sectorStr
Definition: MELaserPrim.h:108
TString _regionStr
Definition: MELaserPrim.h:109
Double_t tppn_PN[iSize_apdpn]
Definition: MELaserPrim.h:209
TString _tpPnPrimStr
Definition: MELaserPrim.h:114
TFile * tpapd_file
Definition: MELaserPrim.h:121
int _ecal_region
Definition: MELaserPrim.h:104
TBranch * b_apdpn_dccID
Definition: MELaserPrim.h:212
TTree * pn_tree
Definition: MELaserPrim.h:127
TBranch * b_apdpn_moduleID
Definition: MELaserPrim.h:215
Int_t apdpn_side
Definition: MELaserPrim.h:162
void bookHistoF(const char *t_name, const char *v_name)