CMS 3D CMS Logo

CaloTowersAnalyzer.cc
Go to the documentation of this file.
6 
8  : hcalDDDRecConstantsToken_{esConsumes<HcalDDDRecConstants, HcalRecNumberingRecord, edm::Transition::BeginRun>()} {
9  tok_towers_ = consumes<CaloTowerCollection>(conf.getUntrackedParameter<edm::InputTag>("CaloTowerCollectionLabel"));
10  // DQM ROOT output
11 
12  outputFile_ = conf.getUntrackedParameter<std::string>("outputFile", "myfile.root");
13 
14  hcalselector_ = conf.getUntrackedParameter<std::string>("hcalselector", "all");
15 
16  useAllHistos_ = conf.getUntrackedParameter<bool>("useAllHistos", false);
17 }
18 
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");
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");
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");
218  sprintf(histo, "CaloTowersTask_Iphi_HCAL_component_of_tower_HBM");
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");
245  sprintf(histo, "CaloTowersTask_map_energy_ECAL_HB");
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");
320  sprintf(histo, "CaloTowersTask_Iphi_HCAL_component_of_tower_HEM");
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");
347  sprintf(histo, "CaloTowersTask_map_energy_ECAL_HE");
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, 5001, -20., 1000000.);
370 
371  sprintf(histo, "CaloTowersTask_energy_ECAL_HF");
372  meEnergyEcal_HF = ibooker.book1D(histo, histo, 3501, -20., 70000.);
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, 500, 0., 5000.);
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");
415  sprintf(histo, "CaloTowersTask_Iphi_tower_HFM");
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");
442  sprintf(histo, "CaloTowersTask_map_energy_ECAL_HF");
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  nevent++;
456 
458  event.getByToken(tok_towers_, towers);
460 
461  double met;
462  double phimet;
463 
464  // ieta scan
465  // double partR = 0.3;
466  // double Rmin = 9999.;
467  // double Econe = 0.;
468  // double Hcone = 0.;
469  // double Ee1 = 0.;
470  // double Eh1 = 0.;
471  double ieta_MC = 9999;
472  double iphi_MC = 9999;
473 
474  // HB
475  double sumEnergyHcal_HB = 0.;
476  double sumEnergyEcal_HB = 0.;
477  double sumEnergyHO_HB = 0.;
478  Int_t numFiredTowers_HB = 0;
479  double metx_HB = 0.;
480  double mety_HB = 0.;
481  double metz_HB = 0.;
482  double sEt_HB = 0.;
483  // HE
484  double sumEnergyHcal_HE = 0.;
485  double sumEnergyEcal_HE = 0.;
486  double sumEnergyHO_HE = 0.;
487  Int_t numFiredTowers_HE = 0;
488  double metx_HE = 0.;
489  double mety_HE = 0.;
490  double metz_HE = 0.;
491  double sEt_HE = 0.;
492  // HF
493  double sumEnergyHcal_HF = 0.;
494  double sumEnergyEcal_HF = 0.;
495  double sumEnergyHO_HF = 0.;
496  Int_t numFiredTowers_HF = 0;
497  double metx_HF = 0.;
498  double mety_HF = 0.;
499  double metz_HF = 0.;
500  double sEt_HF = 0.;
501 
502  for (cal = towers->begin(); cal != towers->end(); ++cal) {
503  double eE = cal->emEnergy();
504  double eH = cal->hadEnergy();
505  double eHO = cal->outerEnergy();
506  double etaT = cal->eta();
507  // double phiT = cal->phi();
508  double en = cal->energy();
509  double etT = cal->et();
510  double had_tm = cal->hcalTime();
511  double em_tm = cal->ecalTime();
512 
513  int numBadEcalCells = cal->numBadEcalCells();
514  int numRcvEcalCells = cal->numRecoveredEcalCells();
515  int numPrbEcalCells = cal->numProblematicEcalCells();
516 
517  int numBadHcalCells = cal->numBadHcalCells();
518  int numRcvHcalCells = cal->numRecoveredHcalCells();
519  int numPrbHcalCells = cal->numProblematicHcalCells();
520 
521  math::RhoEtaPhiVector mom(cal->et(), cal->eta(), cal->phi());
522  // Vector mom = cal->momentum();
523 
524  // cell properties
525  CaloTowerDetId idT = cal->id();
526  int ieta = idT.ieta();
527  int iphi = idT.iphi();
528 
529  // ecal: 0 EcalBarrel 1 EcalEndcap
530  // hcal: 0 hcalBarrel 1 HcalEndcap 2 HcalForward
531  std::vector<int> inEcals(2), inHcals(3);
532  unsigned int constitSize = cal->constituentsSize();
533  for (unsigned int ic = 0; ic < constitSize; ic++) {
534  DetId detId = cal->constituent(ic);
535  if (detId.det() == DetId::Ecal) {
536  if (detId.subdetId() == EcalBarrel)
537  inEcals[0] = 1;
538  else if (detId.subdetId() == EcalEndcap)
539  inEcals[1] = 1;
540  }
541  if (detId.det() == DetId::Hcal) {
542  if (HcalDetId(detId).subdet() == HcalBarrel)
543  inHcals[0] = 1;
544  else if (HcalDetId(detId).subdet() == HcalEndcap)
545  inHcals[1] = 1;
546  else if (HcalDetId(detId).subdet() == HcalForward)
547  inHcals[2] = 1;
548  }
549  }
550  // All cell histos are used
551  if (inEcals[0]) {
552  numBadCellsEcal_EB->Fill(numBadEcalCells);
553  numRcvCellsEcal_EB->Fill(numRcvEcalCells);
554  numPrbCellsEcal_EB->Fill(numPrbEcalCells);
555  }
556  if (inEcals[1]) {
557  numBadCellsEcal_EE->Fill(numBadEcalCells);
558  numRcvCellsEcal_EE->Fill(numRcvEcalCells);
559  numPrbCellsEcal_EE->Fill(numPrbEcalCells);
560  }
561 
562  // Ntowers is used in EndJob, occupancy_map is used for occupancy vs ieta
563  Ntowers_vs_ieta->Fill(double(ieta), 1.);
564  occupancy_map->Fill(double(ieta), double(iphi));
565 
566  if ((isub == 0 || isub == 1) && (fabs(etaT) < etaMax[0] && fabs(etaT) >= etaMin[0])) {
567  // All cell histos are used
568  numBadCellsHcal_HB->Fill(numBadHcalCells);
569  numRcvCellsHcal_HB->Fill(numRcvHcalCells);
570  numPrbCellsHcal_HB->Fill(numPrbHcalCells);
571 
572  // Map energy histos are not used
573  if (useAllHistos_) {
574  mapEnergy_HB->Fill(double(ieta), double(iphi), en);
575  mapEnergyHcal_HB->Fill(double(ieta), double(iphi), eH);
576  mapEnergyEcal_HB->Fill(double(ieta), double(iphi), eE);
577  }
578  // std::cout << " e_ecal = " << eE << std::endl;
579 
580  if (eH > 0.) { // iphi of HCAL component of calotower
581  if (ieta > 0)
582  meIphiHcalTower_HBP->Fill(double(iphi));
583  else
584  meIphiHcalTower_HBM->Fill(double(iphi));
585  }
586 
587  // simple sums
588  sumEnergyHcal_HB += eH;
589  sumEnergyEcal_HB += eE;
590  sumEnergyHO_HB += eHO;
591 
592  numFiredTowers_HB++;
593 
594  // Not used
595  if (useAllHistos_) {
598  }
599 
600  // MET, SET & phimet
601  // double etT = cal->et();
602  metx_HB += mom.x();
603  mety_HB += mom.y(); // etT * sin(phiT);
604  sEt_HB += etT;
605 
606  // Timing (all histos are used)
607  emTiming_HB->Fill(em_tm);
608  hadTiming_HB->Fill(had_tm);
609 
610  emEnergyTiming_Low_HB->Fill(eE, em_tm);
611  emEnergyTiming_HB->Fill(eE, em_tm);
612  emEnergyTiming_High_HB->Fill(eE, em_tm);
614  emEnergyTiming_profile_HB->Fill(eE, em_tm);
616 
617  hadEnergyTiming_Low_HB->Fill(eH, had_tm);
618  hadEnergyTiming_HB->Fill(eH, had_tm);
619  hadEnergyTiming_High_HB->Fill(eH, had_tm);
621  hadEnergyTiming_profile_HB->Fill(eH, had_tm);
623  }
624 
625  if ((isub == 0 || isub == 2) && (fabs(etaT) < etaMax[1] && fabs(etaT) >= etaMin[1])) {
626  // All cell histos are used
627  numBadCellsHcal_HE->Fill(numBadHcalCells);
628  numRcvCellsHcal_HE->Fill(numRcvHcalCells);
629  numPrbCellsHcal_HE->Fill(numPrbHcalCells);
630 
631  // Map energy histos are not used
632  if (useAllHistos_) {
633  mapEnergy_HE->Fill(double(ieta), double(iphi), en);
634  mapEnergyHcal_HE->Fill(double(ieta), double(iphi), eH);
635  mapEnergyEcal_HE->Fill(double(ieta), double(iphi), eE);
636  }
637  // std::cout << " e_ecal = " << eE << std::endl;
638 
639  if (eH > 0.) { // iphi of HCAL component of calotower
640  if (ieta > 0)
641  meIphiHcalTower_HEP->Fill(double(iphi));
642  else
643  meIphiHcalTower_HEM->Fill(double(iphi));
644  }
645 
646  // simple sums
647  sumEnergyHcal_HE += eH;
648  sumEnergyEcal_HE += eE;
649  sumEnergyHO_HE += eHO;
650 
651  numFiredTowers_HE++;
652 
653  // Not used
654  if (useAllHistos_) {
657  }
658  // MET, SET & phimet
659  // double etT = cal->et();
660  metx_HE += mom.x();
661  mety_HE += mom.y(); // etT * sin(phiT);
662  sEt_HE += etT;
663 
664  // Timing (all histos are used)
665  emTiming_HE->Fill(em_tm);
666  hadTiming_HE->Fill(had_tm);
667 
668  emEnergyTiming_Low_HE->Fill(eE, em_tm);
669  emEnergyTiming_HE->Fill(eE, em_tm);
671  emEnergyTiming_profile_HE->Fill(eE, em_tm);
672 
673  hadEnergyTiming_Low_HE->Fill(eH, had_tm);
674  hadEnergyTiming_HE->Fill(eH, had_tm);
676  hadEnergyTiming_profile_HE->Fill(eH, had_tm);
677  }
678 
679  if ((isub == 0 || isub == 3) && (fabs(etaT) < etaMax[2] && fabs(etaT) >= etaMin[2])) {
680  // All cell histos are used
681  numBadCellsHcal_HF->Fill(numBadHcalCells);
682  numRcvCellsHcal_HF->Fill(numRcvHcalCells);
683  numPrbCellsHcal_HF->Fill(numPrbHcalCells);
684 
685  // Map energy histos are not used
686  if (useAllHistos_) {
687  mapEnergy_HF->Fill(double(ieta), double(iphi), en);
688  mapEnergyHcal_HF->Fill(double(ieta), double(iphi), eH);
689  mapEnergyEcal_HF->Fill(double(ieta), double(iphi), eE);
690  }
691  // std::cout << " e_ecal = " << eE << std::endl;
692 
693  if (ieta > 0)
694  meIphiCaloTower_HFP->Fill(double(iphi));
695  else
696  meIphiCaloTower_HFM->Fill(double(iphi));
697 
698  // simple sums
699  sumEnergyHcal_HF += eH;
700  sumEnergyEcal_HF += eE;
701  sumEnergyHO_HF += eHO;
702 
703  numFiredTowers_HF++;
704 
705  // Not used
706  if (useAllHistos_) {
709  }
710  // MET, SET & phimet
711  // double etT = cal->et();
712  metx_HF += mom.x();
713  mety_HF += mom.y(); // etT * sin(phiT);
714  sEt_HF += etT;
715 
716  // Timing (all histos are used)
717  emTiming_HF->Fill(em_tm);
718  hadTiming_HF->Fill(had_tm);
719  emEnergyTiming_HF->Fill(eE, em_tm);
720  emEnergyTiming_profile_HF->Fill(eE, em_tm);
721 
722  hadEnergyTiming_Low_HF->Fill(eH, had_tm);
723  hadEnergyTiming_HF->Fill(eH, had_tm);
725  hadEnergyTiming_profile_HF->Fill(eH, had_tm);
726  }
727 
728  } // end of Towers cycle
729 
730  // These are the six single pion histos; only the second set is used
731 
732  mapEnergy_N->Fill(double(ieta_MC), double(iphi_MC), 1.);
733 
734  if (isub == 0 || isub == 1) {
735  met = sqrt(metx_HB * metx_HB + mety_HB * mety_HB);
736  Vector metv(metx_HB, mety_HB, metz_HB);
737  phimet = metv.phi();
738 
739  // Five oldest drawn histos first; the rest are not used
740  meEnergyHcal_HB->Fill(sumEnergyHcal_HB);
741  meEnergyEcal_HB->Fill(sumEnergyEcal_HB);
742  meNumFiredTowers_HB->Fill(numFiredTowers_HB);
743  MET_HB->Fill(met);
744  SET_HB->Fill(sEt_HB);
745 
746  if (useAllHistos_) {
747  meEnergyHcalvsEcal_HB->Fill(sumEnergyEcal_HB, sumEnergyHcal_HB);
748  meEnergyHO_HB->Fill(sumEnergyHO_HB);
749  meTotEnergy_HB->Fill(sumEnergyHcal_HB + sumEnergyEcal_HB + sumEnergyHO_HB);
750  phiMET_HB->Fill(phimet);
751  }
752  }
753 
754  if (isub == 0 || isub == 2) {
755  met = sqrt(metx_HE * metx_HE + mety_HE * mety_HE);
756  Vector metv(metx_HE, mety_HE, metz_HE);
757  phimet = metv.phi();
758 
759  // Five oldest drawn histos first; the rest are not used
760  meEnergyHcal_HE->Fill(sumEnergyHcal_HE);
761  meEnergyEcal_HE->Fill(sumEnergyEcal_HE);
762  meNumFiredTowers_HE->Fill(numFiredTowers_HE);
763  MET_HE->Fill(met);
764  SET_HE->Fill(sEt_HE);
765 
766  if (useAllHistos_) {
767  meEnergyHcalvsEcal_HE->Fill(sumEnergyEcal_HE, sumEnergyHcal_HE);
768  meEnergyHO_HE->Fill(sumEnergyHO_HE);
769  meTotEnergy_HE->Fill(sumEnergyHcal_HE + sumEnergyEcal_HE + sumEnergyHO_HE);
770  phiMET_HE->Fill(phimet);
771  }
772  }
773 
774  if (isub == 0 || isub == 3) {
775  met = sqrt(metx_HF * metx_HF + mety_HF * mety_HF);
776  Vector metv(metx_HF, mety_HF, metz_HF);
777  phimet = metv.phi();
778 
779  // Five oldest drawn histos first; the rest are not used
780  meEnergyHcal_HF->Fill(sumEnergyHcal_HF);
781  meEnergyEcal_HF->Fill(sumEnergyEcal_HF);
782  meNumFiredTowers_HF->Fill(numFiredTowers_HF);
783  MET_HF->Fill(met);
784  SET_HF->Fill(sEt_HF);
785 
786  if (useAllHistos_) {
787  meEnergyHcalvsEcal_HF->Fill(sumEnergyEcal_HF, sumEnergyHcal_HF);
788  meEnergyHO_HF->Fill(sumEnergyHO_HF);
789  meTotEnergy_HF->Fill(sumEnergyHcal_HF + sumEnergyEcal_HF + sumEnergyHO_HF);
790  phiMET_HF->Fill(phimet);
791  }
792  }
793 }
794 
795 double CaloTowersAnalyzer::dR(double eta1, double phi1, double eta2, double phi2) {
796  double PI = 3.1415926535898;
797  double deltaphi = phi1 - phi2;
798  if (phi2 > phi1) {
799  deltaphi = phi2 - phi1;
800  }
801  if (deltaphi > PI) {
802  deltaphi = 2. * PI - deltaphi;
803  }
804  double deltaeta = eta2 - eta1;
805  double tmp = sqrt(deltaeta * deltaeta + deltaphi * deltaphi);
806  return tmp;
807 }
808 
MonitorElement * emean_vs_ieta_EH1
MonitorElement * mapEnergyEcal_HF
std::pair< int, int > getEtaRange(const int &i) const
MonitorElement * meNumFiredTowers_HF
MonitorElement * hadEnergyTiming_profile_High_HB
MonitorElement * hadEnergyTiming_HF
T const & getData(const ESGetToken< T, R > &iToken) const noexcept(false)
Definition: EventSetup.h:119
MonitorElement * meEnergyHcalTower_HF
MonitorElement * meEnergyHcalvsEcal_HE
MonitorElement * hadEnergyTiming_Low_HE
MonitorElement * meEnergyHcalTower_HE
MonitorElement * numRcvCellsHcal_HF
MonitorElement * MET_HE
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
MonitorElement * phiMET_HF
MonitorElement * emEnergyTiming_profile_Low_HB
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
int getNPhi(const int &type) const
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:33
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:46
MonitorElement * hadTiming_HE
MonitorElement * SET_HB
MonitorElement * mapEnergyEcal_HB
void dqmBeginRun(const edm::Run &, const edm::EventSetup &) override
void Fill(long long x)
MonitorElement * meEnergyHO_HF
MonitorElement * occupancy_vs_ieta
constexpr HcalSubdetector subdet() const
get the subdetector
Definition: HcalDetId.h:138
MonitorElement * mapEnergy_EH
MonitorElement * phiMET_HB
MonitorElement * meEnergyEcal_HE
MonitorElement * hadEnergyTiming_profile_HB
MonitorElement * meEnergyEcal_HB
MonitorElement * bookProfile(TString const &name, TString const &title, int nchX, double lowX, double highX, int, double lowY, double highY, char const *option="s", FUNC onbooking=NOOP())
Definition: DQMStore.h:399
MonitorElement * numBadCellsHcal_HE
MonitorElement * meTotEnergy_HE
MonitorElement * mapEnergy_E
MonitorElement * hadEnergyTiming_Low_HF
MonitorElement * SET_HE
T sqrt(T t)
Definition: SSEVec.h:19
MonitorElement * numRcvCellsHcal_HB
MonitorElement * meNumFiredTowers_HB
MonitorElement * MET_HB
MonitorElement * numPrbCellsHcal_HB
MonitorElement * mapEnergyHcal_HF
MonitorElement * meEnergyHcal_HE
MonitorElement * hadTiming_HB
edm::EDGetTokenT< CaloTowerCollection > tok_towers_
MonitorElement * numBadCellsEcal_EE
MonitorElement * numPrbCellsEcal_EE
MonitorElement * mapEnergy_HE
MonitorElement * mapEnergy_HF
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:48
MonitorElement * mapEnergy_HB
MonitorElement * meEnergyEcalTower_HB
MonitorElement * meIphiHcalTower_HBP
MonitorElement * emean_vs_ieta_H1
MonitorElement * emEnergyTiming_High_HB
math::RhoEtaPhiVector Vector
MonitorElement * numRcvCellsHcal_HE
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
Log< level::Info, false > LogInfo
MonitorElement * hadEnergyTiming_HB
MonitorElement * numPrbCellsHcal_HF
Definition: DetId.h:17
MonitorElement * hadEnergyTiming_profile_HF
MonitorElement * numBadCellsHcal_HB
MonitorElement * Ntowers_vs_ieta
MonitorElement * emEnergyTiming_HB
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
Definition: DQMStore.h:212
edm::ESGetToken< HcalDDDRecConstants, HcalRecNumberingRecord > hcalDDDRecConstantsToken_
MonitorElement * meEnergyHO_HE
MonitorElement * hadEnergyTiming_profile_HE
MonitorElement * emEnergyTiming_Low_HE
MonitorElement * emean_vs_ieta_E
MonitorElement * numPrbCellsEcal_EB
MonitorElement * emean_vs_ieta_EH
MonitorElement * numBadCellsHcal_HF
double dR(double eta1, double phi1, double eta2, double phi2)
MonitorElement * hadTiming_HF
MonitorElement * numBadCellsEcal_EB
MonitorElement * mapEnergyEcal_HE
MonitorElement * emTiming_HF
MonitorElement * meIphiCaloTower_HFM
MonitorElement * emEnergyTiming_profile_HE
MonitorElement * mapEnergy_N
MonitorElement * meEnergyHcalvsEcal_HB
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
tmp
align.sh
Definition: createJobs.py:716
void analyze(edm::Event const &, edm::EventSetup const &) override
MonitorElement * mapEnergyHcal_HB
MonitorElement * emEnergyTiming_profile_HB
MonitorElement * meEnergyHcalvsEcal_HF
MonitorElement * emean_vs_ieta_E1
MonitorElement * meNumFiredTowers_HE
MonitorElement * emEnergyTiming_HF
Definition: event.py:1
Definition: Run.h:45
MonitorElement * hadEnergyTiming_profile_Low_HF
MonitorElement * mapEnergy_H
MonitorElement * meIphiCaloTower_HFP
MonitorElement * meIphiHcalTower_HBM
MonitorElement * meEnergyEcal_HF