CMS 3D CMS Logo

CaloTowersAnalyzer.cc
Go to the documentation of this file.
5 
7  tok_towers_ = consumes<CaloTowerCollection>(conf.getUntrackedParameter<edm::InputTag>("CaloTowerCollectionLabel"));
8  // DQM ROOT output
9 
10  outputFile_ = conf.getUntrackedParameter<std::string>("outputFile", "myfile.root");
11 
12  hcalselector_ = conf.getUntrackedParameter<std::string>("hcalselector", "all");
13 
14  useAllHistos_ = conf.getUntrackedParameter<bool>("useAllHistos", false);
15 }
16 
19  es.get<HcalRecNumberingRecord>().get(pHRNDC);
20  hcons = &(*pHRNDC);
21 
22  // Get Phi segmentation from geometry, use the max phi number so that all iphi
23  // values are included.
24 
25  int NphiMax = hcons->getNPhi(0);
26 
27  NphiMax = (hcons->getNPhi(1) > NphiMax ? hcons->getNPhi(1) : NphiMax);
28  NphiMax = (hcons->getNPhi(2) > NphiMax ? hcons->getNPhi(2) : NphiMax);
29  NphiMax = (hcons->getNPhi(3) > NphiMax ? hcons->getNPhi(3) : NphiMax);
30 
31  // Center the iphi bins on the integers
32  iphi_min_ = 0.5;
33  iphi_max_ = NphiMax + 0.5;
35 
36  // Retain classic behavior, all plots have same ieta range.
37 
38  int iEtaMax = (hcons->getEtaRange(0).second > hcons->getEtaRange(1).second ? hcons->getEtaRange(0).second
39  : hcons->getEtaRange(1).second);
40  iEtaMax = (iEtaMax > hcons->getEtaRange(2).second ? iEtaMax : hcons->getEtaRange(2).second);
41  iEtaMax = (iEtaMax > hcons->getEtaRange(3).second ? iEtaMax : hcons->getEtaRange(3).second);
42 
43  // Give an empty bin around the subdet ieta range to make it clear that all
44  // ieta rings have been included
45  ieta_min_ = -iEtaMax - 1.5;
46  ieta_max_ = iEtaMax + 1.5;
48 }
49 
51  edm::Run const & /* iRun*/,
52  edm::EventSetup const & /* iSetup */) {
53  etaMin[0] = 0.;
54  etaMax[0] = 1.4;
55  etaMin[1] = 1.4;
56  etaMax[1] = 2.9;
57  etaMin[2] = 2.9;
58  etaMax[2] = 5.2;
59 
60  isub = 0;
61  if (hcalselector_ == "HB")
62  isub = 1;
63  if (hcalselector_ == "HE")
64  isub = 2;
65  if (hcalselector_ == "HF")
66  isub = 3;
67 
68  if (!outputFile_.empty()) {
69  edm::LogInfo("OutputInfo") << " Hcal RecHit Task histograms will be saved to '" << outputFile_.c_str() << "'";
70  } else {
71  edm::LogInfo("OutputInfo") << " Hcal RecHit Task histograms will NOT be saved";
72  }
73 
74  Char_t histo[100];
75 
76  ibooker.setCurrentFolder("CaloTowersD/CaloTowersTask");
77 
78  // These two histos are not drawn by our macros, but they are used
79  // in the EndJob for norms and such so I am leaving them alone for now
80  //-------------------------------------------------------------------------------------------
81  sprintf(histo, "Ntowers_per_event_vs_ieta");
82  Ntowers_vs_ieta = ibooker.book1D(histo, histo, ieta_bins_, ieta_min_, ieta_max_);
83 
84  sprintf(histo, "CaloTowersTask_map_Nentries");
86  //-------------------------------------------------------------------------------------------
87 
88  // These the single pion scan histos
89  //-------------------------------------------------------------------------------------------
90  // The first three are not used
91  if (useAllHistos_) {
92  sprintf(histo, "emean_vs_ieta_E");
93  emean_vs_ieta_E = ibooker.bookProfile(histo, histo, ieta_bins_, ieta_min_, ieta_max_, 2100, -100., 2000.);
94  sprintf(histo, "emean_vs_ieta_H");
95  emean_vs_ieta_H = ibooker.bookProfile(histo, histo, ieta_bins_, ieta_min_, ieta_max_, 2100, -100., 2000.);
96  sprintf(histo, "emean_vs_ieta_EH");
97  emean_vs_ieta_EH = ibooker.bookProfile(histo, histo, ieta_bins_, ieta_min_, ieta_max_, 2100, -100., 2000.);
98  }
99  // These are drawn
100  sprintf(histo, "emean_vs_ieta_E1");
101  emean_vs_ieta_E1 = ibooker.bookProfile(histo, histo, ieta_bins_, ieta_min_, ieta_max_, 2100, -100., 2000.);
102  sprintf(histo, "emean_vs_ieta_H1");
103  emean_vs_ieta_H1 = ibooker.bookProfile(histo, histo, ieta_bins_, ieta_min_, ieta_max_, 2100, -100., 2000.);
104  sprintf(histo, "emean_vs_ieta_EH1");
105  emean_vs_ieta_EH1 = ibooker.bookProfile(histo, histo, ieta_bins_, ieta_min_, ieta_max_, 2100, -100., 2000.);
106  //-------------------------------------------------------------------------------------------
107 
108  // Map energy histos are not drawn
109  if (useAllHistos_) {
110  sprintf(histo, "CaloTowersTask_map_energy_E");
112  sprintf(histo, "CaloTowersTask_map_energy_H");
114  sprintf(histo, "CaloTowersTask_map_energy_EH");
116  }
117 
118  // All ECAL cell histos are used
119  // XXX: ECAL 0-25 [0-26, 26 bins] HCAL 0-4 [0-5, 5 bins]
120  sprintf(histo, "number_of_bad_cells_Ecal_EB");
121  numBadCellsEcal_EB = ibooker.book1D(histo, histo, 26, 0, 26);
122  sprintf(histo, "number_of_bad_cells_Ecal_EE");
123  numBadCellsEcal_EE = ibooker.book1D(histo, histo, 26, 0, 26);
124  sprintf(histo, "number_of_recovered_cells_Ecal_EB");
125  numRcvCellsEcal_EB = ibooker.book1D(histo, histo, 26, 0, 26);
126  sprintf(histo, "number_of_recovered_cells_Ecal_EE");
127  numRcvCellsEcal_EE = ibooker.book1D(histo, histo, 26, 0, 26);
128  sprintf(histo, "number_of_problematic_cells_Ecal_EB");
129  numPrbCellsEcal_EB = ibooker.book1D(histo, histo, 26, 0, 26);
130  sprintf(histo, "number_of_problematic_cells_Ecal_EE");
131  numPrbCellsEcal_EE = ibooker.book1D(histo, histo, 26, 0, 26);
132 
133  // Occupancy vs. ieta is drawn, occupancy map is needed to draw it
134  sprintf(histo, "CaloTowersTask_map_occupancy");
136 
137  sprintf(histo, "CaloTowersTask_occupancy_vs_ieta");
138  occupancy_vs_ieta = ibooker.book1D(histo, histo, ieta_bins_, ieta_min_, ieta_max_);
139 
140  if (isub == 1 || isub == 0) {
141  // All cell histos are used
142  sprintf(histo, "number_of_bad_cells_Hcal_HB");
143  numBadCellsHcal_HB = ibooker.book1D(histo, histo, 5, 0, 5);
144  sprintf(histo, "number_of_recovered_cells_Hcal_HB");
145  numRcvCellsHcal_HB = ibooker.book1D(histo, histo, 5, 0, 5);
146  sprintf(histo, "number_of_problematic_cells_Hcal_HB");
147  numPrbCellsHcal_HB = ibooker.book1D(histo, histo, 5, 0, 5);
148 
149  // These are the five oldest CaloTower histos used: NTowers, E in HCAL/ECAL,
150  // MET and SET
151  //-------------------------------------------------------------------------------------------
152  sprintf(histo, "CaloTowersTask_energy_HCAL_HB");
153  meEnergyHcal_HB = ibooker.book1D(histo, histo, 4100, -200, 8000);
154 
155  sprintf(histo, "CaloTowersTask_energy_ECAL_HB");
156  meEnergyEcal_HB = ibooker.book1D(histo, histo, 3100, -200, 6000);
157 
158  sprintf(histo, "CaloTowersTask_number_of_fired_towers_HB");
159  meNumFiredTowers_HB = ibooker.book1D(histo, histo, 1000, 0, 2000);
160 
161  sprintf(histo, "CaloTowersTask_MET_HB");
162  MET_HB = ibooker.book1D(histo, histo, 3000, 0., 3000.);
163 
164  sprintf(histo, "CaloTowersTask_SET_HB");
165  SET_HB = ibooker.book1D(histo, histo, 8000, 0., 8000.);
166  //-------------------------------------------------------------------------------------------
167 
168  // Timing histos and profiles -- all six are necessary
169  //-------------------------------------------------------------------------------------------
170  sprintf(histo, "CaloTowersTask_EM_Timing_HB");
171  emTiming_HB = ibooker.book1D(histo, histo, 110, -120., 100.);
172 
173  sprintf(histo, "CaloTowersTask_HAD_Timing_HB");
174  hadTiming_HB = ibooker.book1D(histo, histo, 70, -48., 92.);
175 
176  // Energy-Timing histos are divided into low, medium and high to reduce
177  // memory usage EM
178  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_Low_HB");
179  emEnergyTiming_Low_HB = ibooker.book2D(histo, histo, 40, 0., 40., 110, -120., 100.);
180 
181  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_HB");
182  emEnergyTiming_HB = ibooker.book2D(histo, histo, 200, 0., 400., 110, -120., 100.);
183 
184  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_High_HB");
185  emEnergyTiming_High_HB = ibooker.book2D(histo, histo, 200, 0., 3000., 110, -120., 100.);
186 
187  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_profile_Low_HB");
188  emEnergyTiming_profile_Low_HB = ibooker.bookProfile(histo, histo, 40, 0., 40., 110, -120., 100.);
189 
190  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_profile_HB");
191  emEnergyTiming_profile_HB = ibooker.bookProfile(histo, histo, 200, 0., 400., 110, -120., 100.);
192 
193  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_profile_High_HB");
194  emEnergyTiming_profile_High_HB = ibooker.bookProfile(histo, histo, 200, 0., 3000., 110, -120., 100.);
195 
196  // HAD
197  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_Low_HB");
198  hadEnergyTiming_Low_HB = ibooker.book2D(histo, histo, 40, 0., 40., 70, -48., 92.);
199 
200  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_HB");
201  hadEnergyTiming_HB = ibooker.book2D(histo, histo, 100, 0., 200., 70, -48., 92.);
202 
203  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_High_HB");
204  hadEnergyTiming_High_HB = ibooker.book2D(histo, histo, 300, 0., 3000., 70, -48., 92.);
205 
206  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_profile_Low_HB");
207  hadEnergyTiming_profile_Low_HB = ibooker.bookProfile(histo, histo, 40, 0., 40., 70, -48., 92.);
208 
209  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_profile_HB");
210  hadEnergyTiming_profile_HB = ibooker.bookProfile(histo, histo, 100, 0., 200., 70, -48., 92.);
211 
212  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_profile_High_HB");
213  hadEnergyTiming_profile_High_HB = ibooker.bookProfile(histo, histo, 300, 0., 3000., 70, -48., 92.);
214  //-------------------------------------------------------------------------------------------
215 
216  sprintf(histo, "CaloTowersTask_Iphi_HCAL_component_of_tower_HBP");
217  meIphiHcalTower_HBP = ibooker.book1D(histo, histo, iphi_bins_, iphi_min_, iphi_max_);
218  sprintf(histo, "CaloTowersTask_Iphi_HCAL_component_of_tower_HBM");
219  meIphiHcalTower_HBM = ibooker.book1D(histo, histo, iphi_bins_, iphi_min_, iphi_max_);
220 
221  //-------------------------------------------------------------------------------------------
222 
223  // Everything else is not drawn
224  if (useAllHistos_) {
225  sprintf(histo, "CaloTowersTask_sum_of_energy_HCAL_vs_ECAL_HB");
226  meEnergyHcalvsEcal_HB = ibooker.book2D(histo, histo, 500, 0., 500., 500, 0., 500.);
227 
228  sprintf(histo, "CaloTowersTask_energy_OUTER_HB");
229  meEnergyHO_HB = ibooker.book1D(histo, histo, 1640, -200, 8000);
230 
231  sprintf(histo, "CaloTowersTask_energy_of_ECAL_component_of_tower_HB");
232  meEnergyEcalTower_HB = ibooker.book1D(histo, histo, 440, -200, 2000);
233 
234  sprintf(histo, "CaloTowersTask_energy_of_HCAL_component_of_tower_HB");
235  meEnergyHcalTower_HB = ibooker.book1D(histo, histo, 440, -200, 2000);
236 
237  sprintf(histo, "CaloTowersTask_energy_HcalPlusEcalPlusHO_HB");
238  meTotEnergy_HB = ibooker.book1D(histo, histo, 400, 0., 2000.);
239 
240  sprintf(histo, "CaloTowersTask_map_energy_HB");
242  sprintf(histo, "CaloTowersTask_map_energy_HCAL_HB");
244  ibooker.book2D(histo, histo, ieta_bins_, ieta_min_, ieta_max_, iphi_bins_, iphi_min_, iphi_max_);
245  sprintf(histo, "CaloTowersTask_map_energy_ECAL_HB");
247  ibooker.book2D(histo, histo, ieta_bins_, ieta_min_, ieta_max_, iphi_bins_, iphi_min_, iphi_max_);
248 
249  sprintf(histo, "CaloTowersTask_phi_MET_HB");
250  phiMET_HB = ibooker.book1D(histo, histo, 72, -3.1415926535898, 3.1415926535898);
251  }
252  }
253 
254  if (isub == 2 || isub == 0) {
255  // All cell histos are used
256  sprintf(histo, "number_of_bad_cells_Hcal_HE");
257  numBadCellsHcal_HE = ibooker.book1D(histo, histo, 5, 0, 5);
258  sprintf(histo, "number_of_recovered_cells_Hcal_HE");
259  numRcvCellsHcal_HE = ibooker.book1D(histo, histo, 5, 0, 5);
260  sprintf(histo, "number_of_problematic_cells_Hcal_HE");
261  numPrbCellsHcal_HE = ibooker.book1D(histo, histo, 5, 0, 5);
262 
263  // These are the five oldest CaloTower histos used: NTowers, E in HCAL/ECAL,
264  // MET and SET
265  //-------------------------------------------------------------------------------------------
266  sprintf(histo, "CaloTowersTask_energy_HCAL_HE");
267  meEnergyHcal_HE = ibooker.book1D(histo, histo, 1240, -200, 6000);
268 
269  sprintf(histo, "CaloTowersTask_energy_ECAL_HE");
270  meEnergyEcal_HE = ibooker.book1D(histo, histo, 1240, -200, 6000);
271 
272  sprintf(histo, "CaloTowersTask_number_of_fired_towers_HE");
273  meNumFiredTowers_HE = ibooker.book1D(histo, histo, 1000, 0, 2000);
274 
275  sprintf(histo, "CaloTowersTask_MET_HE");
276  MET_HE = ibooker.book1D(histo, histo, 1000, 0., 1000.);
277 
278  sprintf(histo, "CaloTowersTask_SET_HE");
279  SET_HE = ibooker.book1D(histo, histo, 2000, 0., 2000.);
280  //-------------------------------------------------------------------------------------------
281 
282  // Timing histos and profiles -- all six are necessary
283  //-------------------------------------------------------------------------------------------
284  sprintf(histo, "CaloTowersTask_EM_Timing_HE");
285  emTiming_HE = ibooker.book1D(histo, histo, 110, -120., 100.);
286 
287  sprintf(histo, "CaloTowersTask_HAD_Timing_HE");
288  hadTiming_HE = ibooker.book1D(histo, histo, 70, -48., 92.);
289 
290  // Energy-Timing histos are divided into low and normal to reduce memory
291  // usage EM
292  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_Low_HE");
293  emEnergyTiming_Low_HE = ibooker.book2D(histo, histo, 160, 0., 160., 110, -120., 100.);
294 
295  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_HE");
296  emEnergyTiming_HE = ibooker.book2D(histo, histo, 200, 0., 800., 110, -120., 100.);
297 
298  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_profile_Low_HE");
299  emEnergyTiming_profile_Low_HE = ibooker.bookProfile(histo, histo, 160, 0., 160., 110, -120., 100.);
300 
301  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_profile_HE");
302  emEnergyTiming_profile_HE = ibooker.bookProfile(histo, histo, 200, 0., 800., 110, -120., 100.);
303 
304  // HAD
305  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_Low_HE");
306  hadEnergyTiming_Low_HE = ibooker.book2D(histo, histo, 160, 0., 160., 70, -48., 92.);
307 
308  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_HE");
309  hadEnergyTiming_HE = ibooker.book2D(histo, histo, 200, 0., 800., 70, -48., 92.);
310 
311  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_profile_Low_HE");
312  hadEnergyTiming_profile_Low_HE = ibooker.bookProfile(histo, histo, 160, 0., 160., 70, -48., 92.);
313 
314  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_profile_HE");
315  hadEnergyTiming_profile_HE = ibooker.bookProfile(histo, histo, 200, 0., 800., 70, -48., 92.);
316  //-------------------------------------------------------------------------------------------
317 
318  sprintf(histo, "CaloTowersTask_Iphi_HCAL_component_of_tower_HEP");
319  meIphiHcalTower_HEP = ibooker.book1D(histo, histo, iphi_bins_, iphi_min_, iphi_max_);
320  sprintf(histo, "CaloTowersTask_Iphi_HCAL_component_of_tower_HEM");
321  meIphiHcalTower_HEM = ibooker.book1D(histo, histo, iphi_bins_, iphi_min_, iphi_max_);
322 
323  //-------------------------------------------------------------------------------------------
324 
325  // Everything else is not drawn
326  if (useAllHistos_) {
327  sprintf(histo, "CaloTowersTask_sum_of_energy_HCAL_vs_ECAL_HE");
328  meEnergyHcalvsEcal_HE = ibooker.book2D(histo, histo, 500, 0., 500., 500, 0., 500.);
329 
330  sprintf(histo, "CaloTowersTask_energy_OUTER_HE");
331  meEnergyHO_HE = ibooker.book1D(histo, histo, 440, -200, 2000);
332 
333  sprintf(histo, "CaloTowersTask_energy_of_ECAL_component_of_tower_HE");
334  meEnergyEcalTower_HE = ibooker.book1D(histo, histo, 1100, -200, 2000);
335 
336  sprintf(histo, "CaloTowersTask_energy_of_HCAL_component_of_tower_HE");
337  meEnergyHcalTower_HE = ibooker.book1D(histo, histo, 1100, -200, 2000);
338 
339  sprintf(histo, "CaloTowersTask_energy_HcalPlusEcalPlusHO_HE");
340  meTotEnergy_HE = ibooker.book1D(histo, histo, 400, 0., 2000.);
341 
342  sprintf(histo, "CaloTowersTask_map_energy_HE");
344  sprintf(histo, "CaloTowersTask_map_energy_HCAL_HE");
346  ibooker.book2D(histo, histo, ieta_bins_, ieta_min_, ieta_max_, iphi_bins_, iphi_min_, iphi_max_);
347  sprintf(histo, "CaloTowersTask_map_energy_ECAL_HE");
349  ibooker.book2D(histo, histo, ieta_bins_, ieta_min_, ieta_max_, iphi_bins_, iphi_min_, iphi_max_);
350 
351  sprintf(histo, "CaloTowersTask_phi_MET_HE");
352  phiMET_HE = ibooker.book1D(histo, histo, 72, -3.1415926535898, 3.1415926535898);
353  }
354  }
355 
356  if (isub == 3 || isub == 0) {
357  // All cell histos are used
358  sprintf(histo, "number_of_bad_cells_Hcal_HF");
359  numBadCellsHcal_HF = ibooker.book1D(histo, histo, 5, 0, 5);
360  sprintf(histo, "number_of_recovered_cells_Hcal_HF");
361  numRcvCellsHcal_HF = ibooker.book1D(histo, histo, 5, 0, 5);
362  sprintf(histo, "number_of_problematic_cells_Hcal_HF");
363  numPrbCellsHcal_HF = ibooker.book1D(histo, histo, 5, 0, 5);
364 
365  // These are the five oldest CaloTower histos used: NTowers, E in HCAL/ECAL,
366  // MET and SET
367  //-------------------------------------------------------------------------------------------
368  sprintf(histo, "CaloTowersTask_energy_HCAL_HF");
369  meEnergyHcal_HF = ibooker.book1D(histo, histo, 6040, -200, 30000);
370 
371  sprintf(histo, "CaloTowersTask_energy_ECAL_HF");
372  meEnergyEcal_HF = ibooker.book1D(histo, histo, 2440, -200, 12000);
373 
374  sprintf(histo, "CaloTowersTask_number_of_fired_towers_HF");
375  meNumFiredTowers_HF = ibooker.book1D(histo, histo, 1000, 0, 2000);
376 
377  sprintf(histo, "CaloTowersTask_MET_HF");
378  MET_HF = ibooker.book1D(histo, histo, 500, 0., 500.);
379 
380  sprintf(histo, "CaloTowersTask_SET_HF");
381  SET_HF = ibooker.book1D(histo, histo, 2000, 0., 2000.);
382  //-------------------------------------------------------------------------------------------
383 
384  // Timing histos and profiles -- all six are necessary
385  //-------------------------------------------------------------------------------------------
386  sprintf(histo, "CaloTowersTask_EM_Timing_HF");
387  emTiming_HF = ibooker.book1D(histo, histo, 110, -120., 100.);
388 
389  sprintf(histo, "CaloTowersTask_HAD_Timing_HF");
390  hadTiming_HF = ibooker.book1D(histo, histo, 70, -48., 92.);
391 
392  // EM
393  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_HF");
394  emEnergyTiming_HF = ibooker.book2D(histo, histo, 150, 0., 300., 110, -120., 100.);
395 
396  sprintf(histo, "CaloTowersTask_EM_Energy_Timing_profile_HF");
397  emEnergyTiming_profile_HF = ibooker.bookProfile(histo, histo, 150, 0., 300., 110, -120., 100.);
398 
399  // HAD (requires two different sets of histograms to lower RAM usage)
400  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_Low_HF");
401  hadEnergyTiming_Low_HF = ibooker.book2D(histo, histo, 40, 0., 40., 70, -48., 92.);
402 
403  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_HF");
404  hadEnergyTiming_HF = ibooker.book2D(histo, histo, 200, 0., 600., 70, -48., 92.);
405 
406  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_profile_Low_HF");
407  hadEnergyTiming_profile_Low_HF = ibooker.bookProfile(histo, histo, 40, 0., 40., 70, -48., 92.);
408 
409  sprintf(histo, "CaloTowersTask_HAD_Energy_Timing_profile_HF");
410  hadEnergyTiming_profile_HF = ibooker.bookProfile(histo, histo, 200, 0., 600., 70, -48., 92.);
411  //-------------------------------------------------------------------------------------------
412 
413  sprintf(histo, "CaloTowersTask_Iphi_tower_HFP");
414  meIphiCaloTower_HFP = ibooker.book1D(histo, histo, iphi_bins_, iphi_min_, iphi_max_);
415  sprintf(histo, "CaloTowersTask_Iphi_tower_HFM");
416  meIphiCaloTower_HFM = ibooker.book1D(histo, histo, iphi_bins_, iphi_min_, iphi_max_);
417 
418  //-------------------------------------------------------------------------------------------
419 
420  // Everything else is not drawn
421  if (useAllHistos_) {
422  sprintf(histo, "CaloTowersTask_sum_of_energy_HCAL_vs_ECAL_HF");
423  meEnergyHcalvsEcal_HF = ibooker.book2D(histo, histo, 500, 0., 500., 500, 0., 500.);
424 
425  sprintf(histo, "CaloTowersTask_energy_OUTER_HF");
426  meEnergyHO_HF = ibooker.book1D(histo, histo, 440, -200, 2000);
427 
428  sprintf(histo, "CaloTowersTask_energy_of_ECAL_component_of_tower_HF");
429  meEnergyEcalTower_HF = ibooker.book1D(histo, histo, 440, -200, 2000);
430 
431  sprintf(histo, "CaloTowersTask_energy_of_HCAL_component_of_tower_HF");
432  meEnergyHcalTower_HF = ibooker.book1D(histo, histo, 440, -200, 2000);
433 
434  sprintf(histo, "CaloTowersTask_energy_HcalPlusEcalPlusHO_HF");
435  meTotEnergy_HF = ibooker.book1D(histo, histo, 400, 0., 2000.);
436 
437  sprintf(histo, "CaloTowersTask_map_energy_HF");
439  sprintf(histo, "CaloTowersTask_map_energy_HCAL_HF");
441  ibooker.book2D(histo, histo, ieta_bins_, ieta_min_, ieta_max_, iphi_bins_, iphi_min_, iphi_max_);
442  sprintf(histo, "CaloTowersTask_map_energy_ECAL_HF");
444  ibooker.book2D(histo, histo, ieta_bins_, ieta_min_, ieta_max_, iphi_bins_, iphi_min_, iphi_max_);
445 
446  sprintf(histo, "CaloTowersTask_phi_MET_HF");
447  phiMET_HF = ibooker.book1D(histo, histo, 72, -3.1415926535898, 3.1415926535898);
448  }
449  }
450 }
451 
453 
455 
457 
459  nevent++;
460 
462  event.getByToken(tok_towers_, towers);
464 
465  double met;
466  double phimet;
467 
468  // ieta scan
469  // double partR = 0.3;
470  // double Rmin = 9999.;
471  // double Econe = 0.;
472  // double Hcone = 0.;
473  // double Ee1 = 0.;
474  // double Eh1 = 0.;
475  double ieta_MC = 9999;
476  double iphi_MC = 9999;
477 
478  // HB
479  double sumEnergyHcal_HB = 0.;
480  double sumEnergyEcal_HB = 0.;
481  double sumEnergyHO_HB = 0.;
482  Int_t numFiredTowers_HB = 0;
483  double metx_HB = 0.;
484  double mety_HB = 0.;
485  double metz_HB = 0.;
486  double sEt_HB = 0.;
487  // HE
488  double sumEnergyHcal_HE = 0.;
489  double sumEnergyEcal_HE = 0.;
490  double sumEnergyHO_HE = 0.;
491  Int_t numFiredTowers_HE = 0;
492  double metx_HE = 0.;
493  double mety_HE = 0.;
494  double metz_HE = 0.;
495  double sEt_HE = 0.;
496  // HF
497  double sumEnergyHcal_HF = 0.;
498  double sumEnergyEcal_HF = 0.;
499  double sumEnergyHO_HF = 0.;
500  Int_t numFiredTowers_HF = 0;
501  double metx_HF = 0.;
502  double mety_HF = 0.;
503  double metz_HF = 0.;
504  double sEt_HF = 0.;
505 
506  for (cal = towers->begin(); cal != towers->end(); ++cal) {
507  double eE = cal->emEnergy();
508  double eH = cal->hadEnergy();
509  double eHO = cal->outerEnergy();
510  double etaT = cal->eta();
511  // double phiT = cal->phi();
512  double en = cal->energy();
513  double etT = cal->et();
514  double had_tm = cal->hcalTime();
515  double em_tm = cal->ecalTime();
516 
517  int numBadEcalCells = cal->numBadEcalCells();
518  int numRcvEcalCells = cal->numRecoveredEcalCells();
519  int numPrbEcalCells = cal->numProblematicEcalCells();
520 
521  int numBadHcalCells = cal->numBadHcalCells();
522  int numRcvHcalCells = cal->numRecoveredHcalCells();
523  int numPrbHcalCells = cal->numProblematicHcalCells();
524 
525  math::RhoEtaPhiVector mom(cal->et(), cal->eta(), cal->phi());
526  // Vector mom = cal->momentum();
527 
528  // cell properties
529  CaloTowerDetId idT = cal->id();
530  int ieta = idT.ieta();
531  int iphi = idT.iphi();
532 
533  // ecal: 0 EcalBarrel 1 EcalEndcap
534  // hcal: 0 hcalBarrel 1 HcalEndcap 2 HcalForward
535  std::vector<int> inEcals(2), inHcals(3);
536  unsigned int constitSize = cal->constituentsSize();
537  for (unsigned int ic = 0; ic < constitSize; ic++) {
538  DetId detId = cal->constituent(ic);
539  if (detId.det() == DetId::Ecal) {
540  if (detId.subdetId() == EcalBarrel)
541  inEcals[0] = 1;
542  else if (detId.subdetId() == EcalEndcap)
543  inEcals[1] = 1;
544  }
545  if (detId.det() == DetId::Hcal) {
546  if (HcalDetId(detId).subdet() == HcalBarrel)
547  inHcals[0] = 1;
548  else if (HcalDetId(detId).subdet() == HcalEndcap)
549  inHcals[1] = 1;
550  else if (HcalDetId(detId).subdet() == HcalForward)
551  inHcals[2] = 1;
552  }
553  }
554  // All cell histos are used
555  if (inEcals[0]) {
556  numBadCellsEcal_EB->Fill(numBadEcalCells);
557  numRcvCellsEcal_EB->Fill(numRcvEcalCells);
558  numPrbCellsEcal_EB->Fill(numPrbEcalCells);
559  }
560  if (inEcals[1]) {
561  numBadCellsEcal_EE->Fill(numBadEcalCells);
562  numRcvCellsEcal_EE->Fill(numRcvEcalCells);
563  numPrbCellsEcal_EE->Fill(numPrbEcalCells);
564  }
565 
566  // Ntowers is used in EndJob, occupancy_map is used for occupancy vs ieta
567  Ntowers_vs_ieta->Fill(double(ieta), 1.);
568  occupancy_map->Fill(double(ieta), double(iphi));
569 
570  if ((isub == 0 || isub == 1) && (fabs(etaT) < etaMax[0] && fabs(etaT) >= etaMin[0])) {
571  // All cell histos are used
572  numBadCellsHcal_HB->Fill(numBadHcalCells);
573  numRcvCellsHcal_HB->Fill(numRcvHcalCells);
574  numPrbCellsHcal_HB->Fill(numPrbHcalCells);
575 
576  // Map energy histos are not used
577  if (useAllHistos_) {
578  mapEnergy_HB->Fill(double(ieta), double(iphi), en);
579  mapEnergyHcal_HB->Fill(double(ieta), double(iphi), eH);
580  mapEnergyEcal_HB->Fill(double(ieta), double(iphi), eE);
581  }
582  // std::cout << " e_ecal = " << eE << std::endl;
583 
584  if (eH > 0.) { // iphi of HCAL component of calotower
585  if (ieta > 0)
586  meIphiHcalTower_HBP->Fill(double(iphi));
587  else
588  meIphiHcalTower_HBM->Fill(double(iphi));
589  }
590 
591  // simple sums
592  sumEnergyHcal_HB += eH;
593  sumEnergyEcal_HB += eE;
594  sumEnergyHO_HB += eHO;
595 
596  numFiredTowers_HB++;
597 
598  // Not used
599  if (useAllHistos_) {
602  }
603 
604  // MET, SET & phimet
605  // double etT = cal->et();
606  metx_HB += mom.x();
607  mety_HB += mom.y(); // etT * sin(phiT);
608  sEt_HB += etT;
609 
610  // Timing (all histos are used)
611  emTiming_HB->Fill(em_tm);
612  hadTiming_HB->Fill(had_tm);
613 
614  emEnergyTiming_Low_HB->Fill(eE, em_tm);
615  emEnergyTiming_HB->Fill(eE, em_tm);
616  emEnergyTiming_High_HB->Fill(eE, em_tm);
618  emEnergyTiming_profile_HB->Fill(eE, em_tm);
620 
621  hadEnergyTiming_Low_HB->Fill(eH, had_tm);
622  hadEnergyTiming_HB->Fill(eH, had_tm);
623  hadEnergyTiming_High_HB->Fill(eH, had_tm);
625  hadEnergyTiming_profile_HB->Fill(eH, had_tm);
627  }
628 
629  if ((isub == 0 || isub == 2) && (fabs(etaT) < etaMax[1] && fabs(etaT) >= etaMin[1])) {
630  // All cell histos are used
631  numBadCellsHcal_HE->Fill(numBadHcalCells);
632  numRcvCellsHcal_HE->Fill(numRcvHcalCells);
633  numPrbCellsHcal_HE->Fill(numPrbHcalCells);
634 
635  // Map energy histos are not used
636  if (useAllHistos_) {
637  mapEnergy_HE->Fill(double(ieta), double(iphi), en);
638  mapEnergyHcal_HE->Fill(double(ieta), double(iphi), eH);
639  mapEnergyEcal_HE->Fill(double(ieta), double(iphi), eE);
640  }
641  // std::cout << " e_ecal = " << eE << std::endl;
642 
643  if (eH > 0.) { // iphi of HCAL component of calotower
644  if (ieta > 0)
645  meIphiHcalTower_HEP->Fill(double(iphi));
646  else
647  meIphiHcalTower_HEM->Fill(double(iphi));
648  }
649 
650  // simple sums
651  sumEnergyHcal_HE += eH;
652  sumEnergyEcal_HE += eE;
653  sumEnergyHO_HE += eHO;
654 
655  numFiredTowers_HE++;
656 
657  // Not used
658  if (useAllHistos_) {
661  }
662  // MET, SET & phimet
663  // double etT = cal->et();
664  metx_HE += mom.x();
665  mety_HE += mom.y(); // etT * sin(phiT);
666  sEt_HE += etT;
667 
668  // Timing (all histos are used)
669  emTiming_HE->Fill(em_tm);
670  hadTiming_HE->Fill(had_tm);
671 
672  emEnergyTiming_Low_HE->Fill(eE, em_tm);
673  emEnergyTiming_HE->Fill(eE, em_tm);
675  emEnergyTiming_profile_HE->Fill(eE, em_tm);
676 
677  hadEnergyTiming_Low_HE->Fill(eH, had_tm);
678  hadEnergyTiming_HE->Fill(eH, had_tm);
680  hadEnergyTiming_profile_HE->Fill(eH, had_tm);
681  }
682 
683  if ((isub == 0 || isub == 3) && (fabs(etaT) < etaMax[2] && fabs(etaT) >= etaMin[2])) {
684  // All cell histos are used
685  numBadCellsHcal_HF->Fill(numBadHcalCells);
686  numRcvCellsHcal_HF->Fill(numRcvHcalCells);
687  numPrbCellsHcal_HF->Fill(numPrbHcalCells);
688 
689  // Map energy histos are not used
690  if (useAllHistos_) {
691  mapEnergy_HF->Fill(double(ieta), double(iphi), en);
692  mapEnergyHcal_HF->Fill(double(ieta), double(iphi), eH);
693  mapEnergyEcal_HF->Fill(double(ieta), double(iphi), eE);
694  }
695  // std::cout << " e_ecal = " << eE << std::endl;
696 
697  if (ieta > 0)
698  meIphiCaloTower_HFP->Fill(double(iphi));
699  else
700  meIphiCaloTower_HFM->Fill(double(iphi));
701 
702  // simple sums
703  sumEnergyHcal_HF += eH;
704  sumEnergyEcal_HF += eE;
705  sumEnergyHO_HF += eHO;
706 
707  numFiredTowers_HF++;
708 
709  // Not used
710  if (useAllHistos_) {
713  }
714  // MET, SET & phimet
715  // double etT = cal->et();
716  metx_HF += mom.x();
717  mety_HF += mom.y(); // etT * sin(phiT);
718  sEt_HF += etT;
719 
720  // Timing (all histos are used)
721  emTiming_HF->Fill(em_tm);
722  hadTiming_HF->Fill(had_tm);
723  emEnergyTiming_HF->Fill(eE, em_tm);
724  emEnergyTiming_profile_HF->Fill(eE, em_tm);
725 
726  hadEnergyTiming_Low_HF->Fill(eH, had_tm);
727  hadEnergyTiming_HF->Fill(eH, had_tm);
729  hadEnergyTiming_profile_HF->Fill(eH, had_tm);
730  }
731 
732  } // end of Towers cycle
733 
734  // These are the six single pion histos; only the second set is used
735 
736  mapEnergy_N->Fill(double(ieta_MC), double(iphi_MC), 1.);
737 
738  if (isub == 0 || isub == 1) {
739  met = sqrt(metx_HB * metx_HB + mety_HB * mety_HB);
740  Vector metv(metx_HB, mety_HB, metz_HB);
741  phimet = metv.phi();
742 
743  // Five oldest drawn histos first; the rest are not used
744  meEnergyHcal_HB->Fill(sumEnergyHcal_HB);
745  meEnergyEcal_HB->Fill(sumEnergyEcal_HB);
746  meNumFiredTowers_HB->Fill(numFiredTowers_HB);
747  MET_HB->Fill(met);
748  SET_HB->Fill(sEt_HB);
749 
750  if (useAllHistos_) {
751  meEnergyHcalvsEcal_HB->Fill(sumEnergyEcal_HB, sumEnergyHcal_HB);
752  meEnergyHO_HB->Fill(sumEnergyHO_HB);
753  meTotEnergy_HB->Fill(sumEnergyHcal_HB + sumEnergyEcal_HB + sumEnergyHO_HB);
754  phiMET_HB->Fill(phimet);
755  }
756  }
757 
758  if (isub == 0 || isub == 2) {
759  met = sqrt(metx_HE * metx_HE + mety_HE * mety_HE);
760  Vector metv(metx_HE, mety_HE, metz_HE);
761  phimet = metv.phi();
762 
763  // Five oldest drawn histos first; the rest are not used
764  meEnergyHcal_HE->Fill(sumEnergyHcal_HE);
765  meEnergyEcal_HE->Fill(sumEnergyEcal_HE);
766  meNumFiredTowers_HE->Fill(numFiredTowers_HE);
767  MET_HE->Fill(met);
768  SET_HE->Fill(sEt_HE);
769 
770  if (useAllHistos_) {
771  meEnergyHcalvsEcal_HE->Fill(sumEnergyEcal_HE, sumEnergyHcal_HE);
772  meEnergyHO_HE->Fill(sumEnergyHO_HE);
773  meTotEnergy_HE->Fill(sumEnergyHcal_HE + sumEnergyEcal_HE + sumEnergyHO_HE);
774  phiMET_HE->Fill(phimet);
775  }
776  }
777 
778  if (isub == 0 || isub == 3) {
779  met = sqrt(metx_HF * metx_HF + mety_HF * mety_HF);
780  Vector metv(metx_HF, mety_HF, metz_HF);
781  phimet = metv.phi();
782 
783  // Five oldest drawn histos first; the rest are not used
784  meEnergyHcal_HF->Fill(sumEnergyHcal_HF);
785  meEnergyEcal_HF->Fill(sumEnergyEcal_HF);
786  meNumFiredTowers_HF->Fill(numFiredTowers_HF);
787  MET_HF->Fill(met);
788  SET_HF->Fill(sEt_HF);
789 
790  if (useAllHistos_) {
791  meEnergyHcalvsEcal_HF->Fill(sumEnergyEcal_HF, sumEnergyHcal_HF);
792  meEnergyHO_HF->Fill(sumEnergyHO_HF);
793  meTotEnergy_HF->Fill(sumEnergyHcal_HF + sumEnergyEcal_HF + sumEnergyHO_HF);
794  phiMET_HF->Fill(phimet);
795  }
796  }
797 }
798 
799 double CaloTowersAnalyzer::dR(double eta1, double phi1, double eta2, double phi2) {
800  double PI = 3.1415926535898;
801  double deltaphi = phi1 - phi2;
802  if (phi2 > phi1) {
803  deltaphi = phi2 - phi1;
804  }
805  if (deltaphi > PI) {
806  deltaphi = 2. * PI - deltaphi;
807  }
808  double deltaeta = eta2 - eta1;
809  double tmp = sqrt(deltaeta * deltaeta + deltaphi * deltaphi);
810  return tmp;
811 }
812 
MonitorElement * emean_vs_ieta_EH1
MonitorElement * mapEnergyEcal_HF
void dqmBeginRun(const edm::Run &run, const edm::EventSetup &c) override
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * meNumFiredTowers_HF
void endJob() override
MonitorElement * hadEnergyTiming_profile_High_HB
MonitorElement * hadEnergyTiming_HF
MonitorElement * meEnergyHcalTower_HF
MonitorElement * meEnergyHcalvsEcal_HE
HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:146
MonitorElement * hadEnergyTiming_Low_HE
MonitorElement * meEnergyHcalTower_HE
MonitorElement * numRcvCellsHcal_HF
MonitorElement * MET_HE
MonitorElement * phiMET_HF
MonitorElement * emEnergyTiming_profile_Low_HB
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:113
MonitorElement * phiMET_HE
MonitorElement * meEnergyEcalTower_HF
MonitorElement * hadEnergyTiming_profile_Low_HE
CaloTowersAnalyzer(edm::ParameterSet const &conf)
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * emEnergyTiming_Low_HB
MonitorElement * emTiming_HE
MonitorElement * meEnergyEcalTower_HE
MonitorElement * numRcvCellsEcal_EB
std::vector< CaloTower >::const_iterator const_iterator
MonitorElement * meEnergyHcalTower_HB
MonitorElement * emEnergyTiming_profile_Low_HE
MonitorElement * meIphiHcalTower_HEM
MonitorElement * numRcvCellsEcal_EE
MonitorElement * meIphiHcalTower_HEP
MonitorElement * SET_HF
MonitorElement * meEnergyHcal_HF
MonitorElement * meEnergyHcal_HB
MonitorElement * meEnergyHO_HB
MonitorElement * emTiming_HB
MonitorElement * MET_HF
MonitorElement * occupancy_map
MonitorElement * emEnergyTiming_HE
MonitorElement * hadEnergyTiming_Low_HB
MonitorElement * hadEnergyTiming_profile_Low_HB
MonitorElement * emean_vs_ieta_H
RhoEtaPhiVectorD RhoEtaPhiVector
spatial vector with cylindrical internal representation using pseudorapidity
Definition: Vector3D.h:32
std::pair< int, int > getEtaRange(const int &i) const
MonitorElement * hadTiming_HE
MonitorElement * SET_HB
void Fill(long long x)
MonitorElement * mapEnergyEcal_HB
MonitorElement * meEnergyHO_HF
MonitorElement * occupancy_vs_ieta
MonitorElement * mapEnergy_EH
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MonitorElement * phiMET_HB
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:268
MonitorElement * meEnergyEcal_HE
MonitorElement * hadEnergyTiming_profile_HB
MonitorElement * meEnergyEcal_HB
MonitorElement * numBadCellsHcal_HE
MonitorElement * meTotEnergy_HE
MonitorElement * mapEnergy_E
MonitorElement * hadEnergyTiming_Low_HF
MonitorElement * SET_HE
T sqrt(T t)
Definition: SSEVec.h:18
MonitorElement * numRcvCellsHcal_HB
MonitorElement * meNumFiredTowers_HB
MonitorElement * MET_HB
MonitorElement * numPrbCellsHcal_HB
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
MonitorElement * mapEnergyHcal_HF
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:106
MonitorElement * meEnergyHcal_HE
void analyze(edm::Event const &e, edm::EventSetup const &c) override
MonitorElement * hadTiming_HB
edm::EDGetTokenT< CaloTowerCollection > tok_towers_
MonitorElement * numBadCellsEcal_EE
MonitorElement * numPrbCellsEcal_EE
MonitorElement * mapEnergy_HE
MonitorElement * mapEnergy_HF
MonitorElement * mapEnergy_HB
MonitorElement * meEnergyEcalTower_HB
MonitorElement * meIphiHcalTower_HBP
MonitorElement * emean_vs_ieta_H1
MonitorElement * emEnergyTiming_High_HB
math::RhoEtaPhiVector Vector
MonitorElement * numRcvCellsHcal_HE
#define PI
Definition: QcdUeDQM.h:36
MonitorElement * emEnergyTiming_profile_HF
MonitorElement * hadEnergyTiming_HE
MonitorElement * numPrbCellsHcal_HE
MonitorElement * emEnergyTiming_profile_High_HB
MonitorElement * meTotEnergy_HB
MonitorElement * meTotEnergy_HF
MonitorElement * hadEnergyTiming_High_HB
MonitorElement * mapEnergyHcal_HE
const_iterator end() const
MonitorElement * hadEnergyTiming_HB
MonitorElement * numPrbCellsHcal_HF
Definition: DetId.h:18
MonitorElement * hadEnergyTiming_profile_HF
MonitorElement * numBadCellsHcal_HB
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:109
met
===> hadronic RAZOR
MonitorElement * Ntowers_vs_ieta
MonitorElement * emEnergyTiming_HB
MonitorElement * meEnergyHO_HE
MonitorElement * hadEnergyTiming_profile_HE
MonitorElement * emEnergyTiming_Low_HE
MonitorElement * emean_vs_ieta_E
MonitorElement * numPrbCellsEcal_EB
MonitorElement * emean_vs_ieta_EH
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
MonitorElement * numBadCellsHcal_HF
void beginJob() override
double dR(double eta1, double phi1, double eta2, double phi2)
MonitorElement * hadTiming_HF
MonitorElement * numBadCellsEcal_EB
T get() const
Definition: EventSetup.h:71
MonitorElement * mapEnergyEcal_HE
MonitorElement * emTiming_HF
MonitorElement * meIphiCaloTower_HFM
const HcalDDDRecConstants * hcons
MonitorElement * emEnergyTiming_profile_HE
MonitorElement * mapEnergy_N
int ieta() const
get the tower ieta
MonitorElement * meEnergyHcalvsEcal_HB
MonitorElement * mapEnergyHcal_HB
MonitorElement * emEnergyTiming_profile_HB
MonitorElement * meEnergyHcalvsEcal_HF
MonitorElement * emean_vs_ieta_E1
MonitorElement * meNumFiredTowers_HE
const_iterator begin() const
MonitorElement * emEnergyTiming_HF
Definition: event.py:1
Definition: Run.h:45
MonitorElement * hadEnergyTiming_profile_Low_HF
MonitorElement * mapEnergy_H
MonitorElement * meIphiCaloTower_HFP
int getNPhi(const int &type) const
MonitorElement * meIphiHcalTower_HBM
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39
MonitorElement * meEnergyEcal_HF