CMS 3D CMS Logo

MuonIsolationDQM.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 // MuonIsolationDQM.cc
3 // Package: Muon Isolation DQM
4 // Class: MuonIsolationDQM
5 //
6 /*
7 
8  Description: Muon Isolation DQM class
9 
10  Implementation: This code will accept a data set and generate plots of
11  various quantities relevent to the Muon Isolation module. We will
12  be using the IsoDeposit class, *not* the MuonIsolation struct.
13 
14  The sequence of events is...
15  * initalize statics (which variables to plot, axis limtis, etc.)
16  * run over events
17  * for each event, run over the muons in that event
18  *record IsoDeposit data
19  * transfer data to histograms, profile plots
20  * save histograms to a root file
21 */
22 //#define DEBUG
23 
24 //Class header file
26 
27 //System included files
28 #include <memory>
29 #include <string>
30 #include <typeinfo>
31 #include <utility>
32 
33 //Root included files
34 #include "TH1.h"
35 #include "TH2.h"
36 #include "TProfile.h"
37 
38 //Event framework included files
42 
43 //Other included files
44 
45 //Using declarations
46 using std::pair;
47 using std::string;
48 using std::vector;
49 
50 using namespace std;
51 //
52 //-----------------Constructors---------------------
53 //
54 
56 #ifdef DEBUG
57  cout << " Initialise Constructor " << endl;
58 #endif
59  requireSTAMuon = iConfig.getUntrackedParameter<bool>("requireSTAMuon");
60  requireTRKMuon = iConfig.getUntrackedParameter<bool>("requireTRKMuon");
61  requireGLBMuon = iConfig.getUntrackedParameter<bool>("requireGLBMuon");
62  dirName = iConfig.getParameter<std::string>("directory");
63 
64  vtxBin_ = iConfig.getParameter<int>("vtxBin");
65  vtxMin_ = iConfig.getParameter<double>("vtxMin");
66  vtxMax_ = iConfig.getParameter<double>("vtxMax");
67 
68  //--------Initialize tags-------
69  theMuonCollectionLabel_ =
70  consumes<edm::View<reco::Muon> >(iConfig.getUntrackedParameter<edm::InputTag>("Global_Muon_Label"));
71  theVertexCollectionLabel_ =
72  consumes<reco::VertexCollection>(iConfig.getUntrackedParameter<edm::InputTag>("vertexLabel"));
73 
74  //-------Initialize Counterse----------------
75  nEvents = 0;
76  nSTAMuons = 0;
77  nTRKMuons = 0;
78  nGLBMuons = 0;
79 
80  InitStatics();
81 
82  //------"allocate" space for the data vectors-------
83  h_1D.resize(NUM_VARS);
84  h_2D.resize(NUM_VARS_2D);
85  h_1D_NVTX.resize(NUM_VARS_NVTX);
86 }
87 
88 //
89 //----------Destructor-----------------
90 //
92 #ifdef DEBUG
93  cout << "Calling destructor" << endl;
94 #endif
95  //Deallocate memory
96 }
97 
98 //
99 //------------Methods-----------------------
100 //
102 #ifdef DEBUG
103  cout << " InitStatistics() " << endl;
104 #endif
105  //-----------Initialize primitives-----------
106  S_BIN_WIDTH = 1.0; //in GeV
107  L_BIN_WIDTH = 2.0; //in GeV
108  LOG_BINNING_ENABLED = 1;
109  NUM_LOG_BINS = 15;
110  LOG_BINNING_RATIO = 1.1;
111  //ratio by which each bin is wider than the last for log binning
112  //i.e. bin widths are (x), (r*x), (r^2*x), ..., (r^(nbins)*x)
113 
114  //-------Initialize Titles---------
115  title_sam = ""; //"[Sample b-jet events] ";
116  title_cone = ""; //" [in R=0.3 IsoDeposit Cone]";
117  //The above two pieces of info will be printed on the title of the whole page,
118  //not for each individual histogram
119  // title_cd = "C.D. of ";
120 
121  //-------"Allocate" memory for vectors
122  main_titles.resize(NUM_VARS);
123  axis_titles.resize(NUM_VARS);
124  names.resize(NUM_VARS);
125  param.resize(NUM_VARS, vector<double>(3));
126  isContinuous.resize(NUM_VARS);
127 
128  titles_2D.resize(NUM_VARS_2D);
129  names_2D.resize(NUM_VARS_2D);
130 
131  main_titles_NVtxs.resize(NUM_VARS_NVTX);
132  axis_titles_NVtxs.resize(NUM_VARS_NVTX);
133  names_NVtxs.resize(NUM_VARS_NVTX);
134 
135 #ifdef DEBUG
136  cout << "InitStatistics(): vectors resized " << endl;
137 #endif
138  //-----Titles of the plots-----------
139  main_titles[0] = "Total Tracker Momentum, #Delta R = 0.3";
140  main_titles[1] = "Total EM Cal Energy, #Delta R = 0.3";
141  main_titles[2] = "Total Had Cal Energy, #Delta R = 0.3";
142  main_titles[3] = "Total HO Cal Energy, #Delta R = 0.3";
143  main_titles[4] = "Number of Tracker Tracks, #Delta R = 0.3";
144  main_titles[5] = "Number of Jets around Muon, #Delta R = 0.3";
145  main_titles[6] = "Tracker p_{T} within veto cone, #Delta R = 0.3";
146  main_titles[7] = "EM E_{T} within veto cone, #Delta R = 0.3";
147  main_titles[8] = "Had E_{T} within veto cone, #Delta R = 0.3";
148  main_titles[9] = "HO E_{T} within veto cone, #Delta R = 0.3";
149  main_titles[10] = "Average Momentum per Track, #Delta R = 0.3";
150  main_titles[11] = "Weighted Energy, #Delta R = 0.3";
151 
152  main_titles[12] = "Total Tracker Momentum, #Delta R = 0.5";
153  main_titles[13] = "Total EM Cal Energy, #Delta R = 0.5";
154  main_titles[14] = "Total Had Cal Energy, #Delta R = 0.5";
155  main_titles[15] = "Total HO Cal Energy, #Delta R = 0.5";
156  main_titles[16] = "Number of Tracker Tracks, #Delta R = 0.5";
157  main_titles[17] = "Number of Jets around Muon, #Delta R = 0.5";
158  main_titles[18] = "Tracker p_{T} within veto cone, #Delta R = 0.5";
159  main_titles[19] = "EM E_{T} within veto cone, #Delta R = 0.5";
160  main_titles[20] = "Had E_{T} within veto cone, #Delta R = 0.5";
161  main_titles[21] = "HO E_{T} within veto cone, #Delta R = 0.5";
162  main_titles[22] = "Average Momentum per Track, #Delta R = 0.5";
163  main_titles[23] = "Weighted Energy, #Delta R = 0.5";
164 
165  main_titles[24] = "Relative Detector-Based Isolation, #Delta R = 0.3";
166  main_titles[25] = "Relative Detector-Based Isolation, #Delta R = 0.5";
167 
168  //-----Titles of the plots-----------
169  main_titles[26] = "Sum PF Charged Hadron Pt, #Delta R = 0.3";
170  main_titles[27] = "Sum PF Neutral Hadron Pt, #Delta R = 0.3";
171  main_titles[28] = "Sum PF Photon Et, #Delta R = 0.3";
172  main_titles[29] = "Sum PF Neutral Hadron Pt (Higher Pt threshold), #Delta R = 0.3";
173  main_titles[30] = "Sum PF Photon Et (Higher Pt threshold), #Delta R = 0.3";
174  main_titles[31] = "Sum PF Charged Particles Pt not from PV (for Pu corrections), #Delta R = 0.3";
175 
176  //-----Titles of the plots-----------
177  main_titles[32] = "Sum PF Charged Hadron Pt, #Delta R = 0.4";
178  main_titles[33] = "Sum PF Neutral Hadron Pt, #Delta R = 0.4";
179  main_titles[34] = "Sum PF Photon Et, #Delta R = 0.4";
180  main_titles[35] = "Sum PF Neutral Hadron Pt (Higher Pt threshold), #Delta R = 0.4";
181  main_titles[36] = "Sum PF Photon Et (Higher Pt threshold), #Delta R = 0.4";
182  main_titles[37] = "Sum PF Charged Particles Pt not from PV (for Pu corrections), #Delta R = 0.4";
183 
184  main_titles[38] = "Relative PF Isolation, #Delta R = 0.3";
185  main_titles[39] = "Relative PF Isolation, #Delta R = 0.4";
186 
187  main_titles[40] = "Relative PF Isolation (Higher Pt threshold), #Delta R = 0.3";
188  main_titles[41] = "Relative PF Isolation (Higher Pt threshold), #Delta R = 0.4";
189 
190  main_titles[42] = "Sum DR Isolation Profile for Charged Hadron, #Delta R = 0.4";
191 
192  main_titles[43] = "Sum DR Isolation Profile for Neutral Hadron, #Delta R = 0.4";
193 
194  main_titles[44] = "Sum DR Isolation Profile for Photon, #Delta R = 0.4";
195 
196  main_titles[45] = "Mean DR Isolation Profile for Charged Hadron, #Delta R = 0.4";
197 
198  main_titles[46] = "Mean DR Isolation Profile for Neutral Hadron, #Delta R = 0.4";
199 
200  main_titles[47] = "Mean DR Isolation Profile for Photon, #Delta R = 0.4";
201 
202 #ifdef DEBUG
203  cout << "InitStatistics(): main titles 1D DONE " << endl;
204 #endif
205  titles_2D[0] = "Total Tracker Momentum, #Delta R = 0.3";
206  titles_2D[1] = "Total EM Cal Energy, #Delta R = 0.3";
207  titles_2D[2] = "Total Had Cal Energy, #Delta R = 0.3";
208  titles_2D[3] = "Total HO Cal Energy, #Delta R = 0.3";
209  titles_2D[4] = "Sum PF Charged Hadron Pt, #Delta R = 0.4";
210  titles_2D[5] = "Sum PF Neutral Hadron Pt, #Delta R = 0.4";
211  titles_2D[6] = "Sum PF Photon Et, #Delta R = 0.4";
212  titles_2D[7] = "Sum PF Charged Pt Not from PV, #Delta R = 0.4";
213  titles_2D[8] = "Relative Detector-Based Isolation, #Delta R = 0.4";
214  titles_2D[9] = "Relative PF Isolation, #Delta R = 0.4";
215 
216  main_titles_NVtxs[0] = "Sum PF Neutral Hadron Pt, #DeltaR = 0.4 ( 20 < N_{Vtx} < 50)";
217  main_titles_NVtxs[1] = "Sum PF Neutral Hadron Pt, #DeltaR = 0.4 (50 < N_{Vtx} < 80)";
218  main_titles_NVtxs[2] = "Sum PF Neutral Hadron Pt, #DeltaR = 0.4 (80 < N_{Vtx})";
219  main_titles_NVtxs[3] = "Sum PF Photon Et, #DeltaR = 0.4 ( 20 < N_{Vtx} < 50)";
220  main_titles_NVtxs[4] = "Sum PF Photon Et, #DeltaR = 0.4 (50 < N_{Vtx} < 80)";
221  main_titles_NVtxs[5] = "Sum PF Photon Et, #DeltaR = 0.4 (80 < N_{Vtx})";
222 
223 #ifdef DEBUG
224  cout << "InitStatistics(): main titles 2D DONE " << endl;
225 #endif
226 
227  //------Titles on the X or Y axis------------
228  axis_titles[0] = "#Sigma p_{T} (GeV)";
229  axis_titles[1] = "#Sigma E_{T}^{EM} (GeV)";
230  axis_titles[2] = "#Sigma E_{T}^{Had} (GeV)";
231  axis_titles[3] = "#Sigma E_{T}^{HO} (GeV)";
232  axis_titles[4] = "N_{Tracks}";
233  axis_titles[5] = "N_{Jets}";
234  axis_titles[6] = "#Sigma p_{T,veto} (GeV)";
235  axis_titles[7] = "#Sigma E_{T,veto}^{EM} (GeV)";
236  axis_titles[8] = "#Sigma E_{T,veto}^{Had} (GeV)";
237  axis_titles[9] = "#Sigma E_{T,veto}^{HO} (GeV)";
238  axis_titles[10] = "#Sigma p_{T} / N_{Tracks} (GeV)";
239  axis_titles[11] = "(1.5) X #Sigma E_{T}^{EM} + #Sigma E_{T}^{Had}";
240 
241  axis_titles[12] = "#Sigma p_{T} (GeV)";
242  axis_titles[13] = "#Sigma E_{T}^{EM} (GeV)";
243  axis_titles[14] = "#Sigma E_{T}^{Had} (GeV)";
244  axis_titles[15] = "#Sigma E_{T}^{HO} (GeV)";
245  axis_titles[16] = "N_{Tracks}";
246  axis_titles[17] = "N_{Jets}";
247  axis_titles[18] = "#Sigma p_{T,veto} (GeV)";
248  axis_titles[19] = "#Sigma E_{T,veto}^{EM} (GeV)";
249  axis_titles[20] = "#Sigma E_{T,veto}^{Had} (GeV)";
250  axis_titles[21] = "#Sigma E_{T,veto}^{HO} (GeV)";
251  axis_titles[22] = "#Sigma p_{T} / N_{Tracks} (GeV)";
252  axis_titles[23] = "(1.5) X #Sigma E_{T}^{EM} + #Sigma E_{T}^{Had}";
253 
254  axis_titles[24] = "(#Sigma Tk p_{T} + #Sigma ECAL p_{T} + #Sigma HCAL p_{T})/ Mu p_{T} (GeV)";
255  axis_titles[25] = "(#Sigma Tk p_{T} + #Sigma ECAL p_{T} + #Sigma HCAL p_{T})/ Mu p_{T} (GeV)";
256 
257  axis_titles[26] = "#Sigma PFCharged p_{T}";
258  axis_titles[27] = "#Sigma PFNeutral p_{T}";
259  axis_titles[28] = "#Sigma PFPhoton p_{T}";
260  axis_titles[29] = "#Sigma PFNeutral p_{T}";
261  axis_titles[30] = "#Sigma PFPhoton p_{T}";
262  axis_titles[31] = "#Sigma PFCharged p_{T}";
263 
264  axis_titles[32] = "#Sigma PFCharged p_{T}";
265  axis_titles[33] = "#Sigma PFNeutral p_{T}";
266  axis_titles[34] = "#Sigma PFPhoton p_{T}";
267  axis_titles[35] = "#Sigma PFNeutral p_{T}";
268  axis_titles[36] = "#Sigma PFPhoton p_{T}";
269  axis_titles[37] = "#Sigma PFCharged p_{T}";
270 
271  axis_titles[38] = "(#Sigma PFCharged p_{T} + #Sigma PFNeutral p_{T} + #Sigma PFPhoton p_{T}) Mu p_{T} (GeV)";
272  axis_titles[39] = "(#Sigma PFCharged p_{T} + #Sigma PFNeutral p_{T} + #Sigma PFPhoton p_{T}) Mu p_{T} (GeV)";
273  axis_titles[40] = "(#Sigma PFCharged p_{T} + #Sigma PFNeutral p_{T} + #Sigma PFPhoton p_{T}) Mu p_{T} (GeV)";
274  axis_titles[41] = "(#Sigma PFCharged p_{T} + #Sigma PFNeutral p_{T} + #Sigma PFPhoton p_{T}) Mu p_{T} (GeV)";
275 
276  axis_titles[42] = "#Sigma DR PFCharged";
277  axis_titles[43] = "#Sigma DR PFNeutral";
278  axis_titles[44] = "#Sigma DR PFPhoton";
279 
280  axis_titles[45] = "Mean DR PFCharged";
281  axis_titles[46] = "Mean DR PFNeutral";
282  axis_titles[47] = "Mean DR PFPhoton";
283 
284  axis_titles_NVtxs[0] = "#Sigma PFNeutral p_{T}";
285  axis_titles_NVtxs[1] = "#Sigma PFNeutral p_{T}";
286  axis_titles_NVtxs[2] = "#Sigma PFNeutral p_{T}";
287  axis_titles_NVtxs[3] = "#Sigma PFPhoton p_{T}";
288  axis_titles_NVtxs[4] = "#Sigma PFPhoton p_{T}";
289  axis_titles_NVtxs[5] = "#Sigma PFPhoton p_{T}";
290 
291 #ifdef DEBUG
292  cout << "InitStatistics(): main titles 1D DONE " << endl;
293 #endif
294 
295  //-----------Names given for the root file----------
296  names[0] = "sumPt_R03";
297  names[1] = "emEt_R03";
298  names[2] = "hadEt_R03";
299  names[3] = "hoEt_R03";
300  names[4] = "nTracks_R03";
301  names[5] = "nJets_R03";
302  names[6] = "trackerVetoPt_R03";
303  names[7] = "emVetoEt_R03";
304  names[8] = "hadVetoEt_R03";
305  names[9] = "hoVetoEt_R03";
306  names[10] = "avgPt_R03";
307  names[11] = "weightedEt_R03";
308 
309  names[12] = "sumPt_R05";
310  names[13] = "emEt_R05";
311  names[14] = "hadEt_R05";
312  names[15] = "hoEt_R05";
313  names[16] = "nTracks_R05";
314  names[17] = "nJets_R05";
315  names[18] = "trackerVetoPt_R05";
316  names[19] = "emVetoEt_R05";
317  names[20] = "hadVetoEt_R05";
318  names[21] = "hoVetoEt_R05";
319  names[22] = "avgPt_R05";
320  names[23] = "weightedEt_R05";
321 
322  names[24] = "relDetIso_R03";
323  names[25] = "relDetIso_R05";
324 
325  names[26] = "pfChargedPt_R03";
326  names[27] = "pfNeutralPt_R03";
327  names[28] = "pfPhotonPt_R03";
328  names[29] = "pfNeutralPt_HT_R03";
329  names[30] = "pfPhotonPt_HT_R03";
330  names[31] = "pfChargedPt_PU_R03";
331 
332  names[32] = "pfChargedPt_R04";
333  names[33] = "pfNeutralPt_R04";
334  names[34] = "pfPhotonPt_R04";
335  names[35] = "pfNeutralPt_HT_R04";
336  names[36] = "pfPhotonPt_HT_R04";
337  names[37] = "pfChargedPt_PU_R04";
338 
339  names[38] = "relPFIso_R03";
340  names[39] = "relPFIso_R04";
341 
342  names[40] = "relPFIso_HT_R03";
343  names[41] = "relPFIso_HT_R04";
344 
345  names[42] = "SumDR_PFCharged_R04";
346  names[43] = "SumDR_PFNeutral_R04";
347  names[44] = "SumDR_PFPhoton_R04";
348 
349  names[45] = "MeanDR_PFCharged_R04";
350  names[46] = "MeanDR_PFNeutral_R04";
351  names[47] = "MeanDR_PFPhoton_R04";
352 
353 #ifdef DEBUG
354  cout << "InitStatistics(): names 1D DONE " << endl;
355 #endif
356 
357  names_2D[0] = "SumPt_R03";
358  names_2D[1] = "emEt_R03";
359  names_2D[2] = "hadEt_R03";
360  names_2D[3] = "hoEt_R03";
361  names_2D[4] = "pfChargedPt_R04";
362  names_2D[5] = "pfNeutralPt_R04";
363  names_2D[6] = "pfPhotonPt_R04";
364  names_2D[7] = "pfChargedPUPt_R04";
365  names_2D[8] = "relDetIso_R03";
366  names_2D[9] = "relPFIso_R04";
367 
368 #ifdef DEBUG
369  cout << "InitStatistics(): names 2D DONE " << endl;
370 #endif
371 
372  names_NVtxs[0] = "pfNeutralPt_R04_PV20to50";
373  names_NVtxs[1] = "pfNeutralPt_R04_PV50to80";
374  names_NVtxs[2] = "pfNeutralPt_R04_PV80toInf";
375  names_NVtxs[3] = "pfPhotonPt_R04_PV20to50";
376  names_NVtxs[4] = "pfPhotonPt_R04_PV50to80";
377  names_NVtxs[5] = "pfPhotonPt_R04_PV80toInf";
378 
379  //----------Parameters for binning of histograms---------
380  //param[var][0] is the number of bins
381  //param[var][1] is the low edge of the low bin
382  //param[var][2] is the high edge of the high bin
383  //
384  // maximum value------,
385  // |
386  // V
387  param[0][0] = (int)(20.0 / S_BIN_WIDTH);
388  param[0][1] = 0.0;
389  param[0][2] = param[0][0] * S_BIN_WIDTH;
390  param[1][0] = (int)(20.0 / S_BIN_WIDTH);
391  param[1][1] = 0.0;
392  param[1][2] = param[1][0] * S_BIN_WIDTH;
393  param[2][0] = (int)(20.0 / S_BIN_WIDTH);
394  param[2][1] = 0.0;
395  param[2][2] = param[2][0] * S_BIN_WIDTH;
396  param[3][0] = 20;
397  param[3][1] = 0.0;
398  param[3][2] = 2.0;
399  param[4][0] = 16;
400  param[4][1] = -0.5;
401  param[4][2] = param[4][0] - 0.5;
402  param[5][0] = 4;
403  param[5][1] = -0.5;
404  param[5][2] = param[5][0] - 0.5;
405  param[6][0] = (int)(40.0 / S_BIN_WIDTH);
406  param[6][1] = 0.0;
407  param[6][2] = param[6][0] * S_BIN_WIDTH;
408  param[7][0] = 20;
409  param[7][1] = 0.0;
410  param[7][2] = 10.0;
411  param[8][0] = (int)(20.0 / S_BIN_WIDTH);
412  param[8][1] = 0.0;
413  param[8][2] = param[8][0] * S_BIN_WIDTH;
414  param[9][0] = 20;
415  param[9][1] = 0.0;
416  param[9][2] = 5.0;
417  param[10][0] = (int)(15.0 / S_BIN_WIDTH);
418  param[10][1] = 0.0;
419  param[10][2] = param[10][0] * S_BIN_WIDTH;
420  param[11][0] = (int)(20.0 / S_BIN_WIDTH);
421  param[11][1] = 0.0;
422  param[11][2] = param[11][0] * S_BIN_WIDTH;
423 
424  param[12][0] = (int)(20.0 / S_BIN_WIDTH);
425  param[12][1] = 0.0;
426  param[12][2] = param[12][0] * S_BIN_WIDTH;
427  param[13][0] = (int)(20.0 / S_BIN_WIDTH);
428  param[13][1] = 0.0;
429  param[13][2] = param[13][0] * S_BIN_WIDTH;
430  param[14][0] = (int)(20.0 / S_BIN_WIDTH);
431  param[14][1] = 0.0;
432  param[14][2] = param[14][0] * S_BIN_WIDTH;
433  param[15][0] = 20;
434  param[15][1] = 0.0;
435  param[15][2] = 2.0;
436  param[16][0] = 16;
437  param[16][1] = -0.5;
438  param[16][2] = param[16][0] - 0.5;
439  param[17][0] = 4;
440  param[17][1] = -0.5;
441  param[17][2] = param[17][0] - 0.5;
442  param[18][0] = (int)(40.0 / S_BIN_WIDTH);
443  param[18][1] = 0.0;
444  param[18][2] = param[18][0] * S_BIN_WIDTH;
445  param[19][0] = 20;
446  param[19][1] = 0.0;
447  param[19][2] = 10.0;
448  param[20][0] = (int)(20.0 / S_BIN_WIDTH);
449  param[20][1] = 0.0;
450  param[20][2] = param[20][0] * S_BIN_WIDTH;
451  param[21][0] = 20;
452  param[21][1] = 0.0;
453  param[21][2] = 5.0;
454  param[22][0] = (int)(15.0 / S_BIN_WIDTH);
455  param[22][1] = 0.0;
456  param[22][2] = param[22][0] * S_BIN_WIDTH;
457  param[23][0] = (int)(20.0 / S_BIN_WIDTH);
458  param[23][1] = 0.0;
459  param[23][2] = param[23][0] * S_BIN_WIDTH;
460 
461  param[24][0] = 50;
462  param[24][1] = 0.0;
463  param[24][2] = 1.0;
464  param[25][0] = 50;
465  param[25][1] = 0.0;
466  param[25][2] = 1.0;
467 
468  param[26][0] = (int)(20.0 / S_BIN_WIDTH);
469  param[26][1] = 0.0;
470  param[26][2] = param[26][0] * S_BIN_WIDTH;
471  param[27][0] = (int)(20.0 / S_BIN_WIDTH);
472  param[27][1] = 0.0;
473  param[27][2] = param[27][0] * S_BIN_WIDTH;
474  param[28][0] = (int)(20.0 / S_BIN_WIDTH);
475  param[28][1] = 0.0;
476  param[28][2] = param[28][0] * S_BIN_WIDTH;
477  param[29][0] = (int)(20.0 / S_BIN_WIDTH);
478  param[29][1] = 0.0;
479  param[29][2] = param[29][0] * S_BIN_WIDTH;
480  param[30][0] = (int)(20.0 / S_BIN_WIDTH);
481  param[30][1] = 0.0;
482  param[30][2] = param[30][0] * S_BIN_WIDTH;
483  param[31][0] = (int)(20.0 / S_BIN_WIDTH);
484  param[31][1] = 0.0;
485  param[31][2] = param[31][0] * S_BIN_WIDTH;
486 
487  param[32][0] = (int)(20.0 / S_BIN_WIDTH);
488  param[32][1] = 0.0;
489  param[32][2] = param[32][0] * S_BIN_WIDTH;
490  param[33][0] = (int)(20.0 / S_BIN_WIDTH);
491  param[33][1] = 0.0;
492  param[33][2] = param[33][0] * S_BIN_WIDTH;
493  param[34][0] = (int)(20.0 / S_BIN_WIDTH);
494  param[34][1] = 0.0;
495  param[34][2] = param[34][0] * S_BIN_WIDTH;
496  param[35][0] = (int)(20.0 / S_BIN_WIDTH);
497  param[35][1] = 0.0;
498  param[35][2] = param[35][0] * S_BIN_WIDTH;
499  param[36][0] = (int)(20.0 / S_BIN_WIDTH);
500  param[36][1] = 0.0;
501  param[36][2] = param[36][0] * S_BIN_WIDTH;
502  param[37][0] = (int)(20.0 / S_BIN_WIDTH);
503  param[37][1] = 0.0;
504  param[37][2] = param[37][0] * S_BIN_WIDTH;
505 
506  param[38][0] = 50;
507  param[38][1] = 0.0;
508  param[38][2] = 1.0;
509  param[39][0] = 50;
510  param[39][1] = 0.0;
511  param[39][2] = 1.0;
512 
513  param[40][0] = 50;
514  param[40][1] = 0.0;
515  param[40][2] = 1.0;
516  param[41][0] = 50;
517  param[41][1] = 0.0;
518  param[41][2] = 1.0;
519 
520  param[42][0] = 50;
521  param[42][1] = 0.0;
522  param[42][2] = 5;
523  param[43][0] = 50;
524  param[43][1] = 0.0;
525  param[43][2] = 5;
526  param[44][0] = 50;
527  param[44][1] = 0.0;
528  param[44][2] = 5;
529 
530  param[45][0] = 50;
531  param[45][1] = 0.0;
532  param[45][2] = 0.4;
533  param[46][0] = 50;
534  param[46][1] = 0.0;
535  param[46][2] = 0.4;
536  param[47][0] = 50;
537  param[47][1] = 0.0;
538  param[47][2] = 0.4;
539 
540  //--------------Is the variable continuous (i.e. non-integer)?-------------
541  //---------(Log binning will only be used for continuous variables)--------
542  isContinuous[0] = 1;
543  isContinuous[1] = 1;
544  isContinuous[2] = 1;
545  isContinuous[3] = 1;
546  isContinuous[4] = 0;
547  isContinuous[5] = 0;
548  isContinuous[6] = 1;
549  isContinuous[7] = 1;
550  isContinuous[8] = 1;
551  isContinuous[9] = 1;
552  isContinuous[10] = 1;
553  isContinuous[11] = 1;
554 
555  isContinuous[12] = 1;
556  isContinuous[13] = 1;
557  isContinuous[14] = 1;
558  isContinuous[15] = 1;
559  isContinuous[16] = 0;
560  isContinuous[17] = 0;
561  isContinuous[18] = 1;
562  isContinuous[19] = 1;
563  isContinuous[20] = 1;
564  isContinuous[21] = 1;
565  isContinuous[22] = 1;
566  isContinuous[23] = 1;
567 
568  isContinuous[24] = 1;
569  isContinuous[25] = 1;
570  isContinuous[26] = 1;
571  isContinuous[27] = 1;
572  isContinuous[28] = 1;
573  isContinuous[29] = 1;
574  isContinuous[30] = 1;
575  isContinuous[31] = 1;
576  isContinuous[32] = 1;
577  isContinuous[33] = 1;
578  isContinuous[34] = 1;
579  isContinuous[35] = 1;
580  isContinuous[36] = 1;
581  isContinuous[37] = 1;
582  isContinuous[38] = 1;
583  isContinuous[39] = 1;
584  isContinuous[40] = 1;
585  isContinuous[41] = 1;
586  isContinuous[42] = 1;
587  isContinuous[43] = 1;
588  isContinuous[44] = 1;
589  isContinuous[45] = 1;
590  isContinuous[46] = 1;
591  isContinuous[47] = 1;
592 
593 #ifdef DEBUG
594  cout << "InitStatistics(): DONE " << endl;
595 #endif
596 }
597 
598 // ------------ method called for each event ------------
600  ++nEvents;
601  edm::LogInfo("Tutorial") << "\nInvestigating event #" << nEvents << "\n";
602 #ifdef DEBUG
603  cout << "[MuonIsolationDQM]: analyze()" << endl;
604 #endif
605 
606  // Get Muon Collection
608  iEvent.getByToken(theMuonCollectionLabel_, muons);
609 
610 #ifdef DEBUG
611  cout << "[MuonIsolationDQM]: Number of muons -> " << muons->size() << endl;
612 #endif
613 
614  int theMuonData = muons->size();
615  h_nMuons->Fill(theMuonData);
616 #ifdef DEBUG
617  cout << "[MuonIsolationDQM]: Vertex is Valid" << endl;
618 #endif
619 
620  //Get Vertex Information
621  int _numPV = 0;
623  iEvent.getByToken(theVertexCollectionLabel_, vertexHandle);
624 
625  if (vertexHandle.isValid()) {
626  reco::VertexCollection vertex = *(vertexHandle.product());
627  for (reco::VertexCollection::const_iterator v = vertex.begin(); v != vertex.end(); ++v) {
628  if (v->isFake())
629  continue;
630  if (v->ndof() < 4)
631  continue;
632  if (fabs(v->z()) > 24.0)
633  continue;
634  ++_numPV;
635  }
636  }
637 
638 #ifdef DEBUG
639  cout << "[MuonIsolationDQM]: Vertex is Valid" << endl;
640 #endif
641  // Get Muon Collection
642 
643  //Fill historgams concerning muon isolation
644  for (edm::View<reco::Muon>::const_iterator muon = muons->begin(); muon != muons->end(); ++muon) {
645  if (requireSTAMuon && muon->isStandAloneMuon()) {
646  ++nSTAMuons;
647  RecordData(*muon);
648  FillHistos(_numPV);
649  } else if (requireTRKMuon && muon->isTrackerMuon()) {
650  ++nTRKMuons;
651  RecordData(*muon);
652  FillHistos(_numPV);
653  } else if (requireGLBMuon && muon->isGlobalMuon()) {
654  ++nGLBMuons;
655  RecordData(*muon);
656  FillHistos(_numPV);
657  FillNVtxHistos(_numPV);
658  }
659  }
660 }
661 
662 //---------------Record data for a signle muon's data---------------------
664 #ifdef DEBUG
665  std::cout << "RecordData()" << endl;
666 #endif
667  float MuPt = muon.pt();
668 
669  theData[0] = muon.isolationR03().sumPt;
670  theData[1] = muon.isolationR03().emEt;
671  theData[2] = muon.isolationR03().hadEt;
672  theData[3] = muon.isolationR03().hoEt;
673 
674  theData[4] = muon.isolationR03().nTracks;
675  theData[5] = muon.isolationR03().nJets;
676  theData[6] = muon.isolationR03().trackerVetoPt;
677  theData[7] = muon.isolationR03().emVetoEt;
678  theData[8] = muon.isolationR03().hadVetoEt;
679  theData[9] = muon.isolationR03().hoVetoEt;
680 
681  // make sure nTracks != 0 before filling this one
682  if (theData[4] != 0)
683  theData[10] = (double)theData[0] / (double)theData[4];
684  else
685  theData[10] = -99;
686 
687  theData[11] = 1.5 * theData[1] + theData[2];
688 
689  theData[12] = muon.isolationR05().sumPt;
690  theData[13] = muon.isolationR05().emEt;
691  theData[14] = muon.isolationR05().hadEt;
692  theData[15] = muon.isolationR05().hoEt;
693 
694  theData[16] = muon.isolationR05().nTracks;
695  theData[17] = muon.isolationR05().nJets;
696  theData[18] = muon.isolationR05().trackerVetoPt;
697  theData[19] = muon.isolationR05().emVetoEt;
698  theData[20] = muon.isolationR05().hadVetoEt;
699  theData[21] = muon.isolationR05().hoVetoEt;
700 
701  // make sure nTracks != 0 before filling this one
702  if (theData[16] != 0)
703  theData[22] = (double)theData[12] / (double)theData[16];
704  else
705  theData[22] = -99;
706 
707  theData[23] = 1.5 * theData[13] + theData[14];
708 
709  theData[24] = (theData[0] + theData[1] + theData[2]) / MuPt;
710  theData[25] = (theData[12] + theData[13] + theData[14]) / MuPt;
711 
712  theData[26] = muon.pfIsolationR03().sumChargedHadronPt;
713  theData[27] = muon.pfIsolationR03().sumNeutralHadronEt;
714  theData[28] = muon.pfIsolationR03().sumPhotonEt;
715  theData[29] = muon.pfIsolationR03().sumNeutralHadronEtHighThreshold;
716  theData[30] = muon.pfIsolationR03().sumPhotonEtHighThreshold;
717  theData[31] = muon.pfIsolationR03().sumPUPt;
718 
719  theData[32] = muon.pfIsolationR04().sumChargedHadronPt;
720  theData[33] = muon.pfIsolationR04().sumNeutralHadronEt;
721  theData[34] = muon.pfIsolationR04().sumPhotonEt;
722  theData[35] = muon.pfIsolationR04().sumNeutralHadronEtHighThreshold;
723  theData[36] = muon.pfIsolationR04().sumPhotonEtHighThreshold;
724  theData[37] = muon.pfIsolationR04().sumPUPt;
725 
726  theData[38] = (theData[26] + theData[27] + theData[28]) / MuPt;
727  theData[39] = (theData[32] + theData[33] + theData[34]) / MuPt;
728 
729  theData[40] = (theData[26] + theData[29] + theData[30]) / MuPt;
730  theData[41] = (theData[32] + theData[35] + theData[36]) / MuPt;
731 
732  theData[42] = muon.pfSumDRIsoProfileR04().sumChargedHadronPt;
733  theData[43] = muon.pfSumDRIsoProfileR04().sumNeutralHadronEt;
734  theData[44] = muon.pfSumDRIsoProfileR04().sumPhotonEt;
735  theData[45] = muon.pfMeanDRIsoProfileR04().sumChargedHadronPt;
736  theData[46] = muon.pfMeanDRIsoProfileR04().sumNeutralHadronEt;
737  theData[47] = muon.pfMeanDRIsoProfileR04().sumPhotonEt;
738 
739  //--------------Filling the 2D Histos Data -------- //
740  theData2D[0] = muon.isolationR03().sumPt;
741  theData2D[1] = muon.isolationR03().emEt;
742  theData2D[2] = muon.isolationR03().hadEt;
743  theData2D[3] = muon.isolationR03().hoEt;
744 
745  theData2D[4] = muon.pfIsolationR04().sumChargedHadronPt;
746  theData2D[5] = muon.pfIsolationR04().sumNeutralHadronEt;
747  theData2D[6] = muon.pfIsolationR04().sumPhotonEt;
748  theData2D[7] = muon.pfIsolationR04().sumPUPt;
749 
750  theData2D[8] = theData2D[0] + theData2D[1] + theData2D[2] + theData2D[3] / MuPt; //Det RelIso;
751  theData2D[9] = theData2D[4] + theData2D[5] + theData2D[6] / MuPt; //PF RelIso;
752 
753  //-----------Filling the NVTX 1D HISTOS DATA ------------- //
754  theDataNVtx[0] = muon.pfIsolationR04().sumNeutralHadronEt;
755  theDataNVtx[1] = theDataNVtx[0];
756  theDataNVtx[2] = theDataNVtx[0];
757 
758  theDataNVtx[3] = muon.pfIsolationR04().sumPhotonEt;
759  theDataNVtx[4] = theDataNVtx[3];
760  theDataNVtx[5] = theDataNVtx[3];
761 }
763  edm::Run const& /*iRun*/,
764  edm::EventSetup const& /* iSetup */) {
765  ibooker.cd();
766  ibooker.setCurrentFolder(dirName);
767 
768  ibooker.cd();
769  ibooker.setCurrentFolder(dirName);
770 
771  //---initialize number of muons histogram---
772  h_nMuons = ibooker.book1D("nMuons", title_sam + "Number of Muons", 20, 0., 20.);
773  h_nMuons->setAxisTitle("Number of Muons", XAXIS);
774  h_nMuons->setAxisTitle("Fraction of Events", YAXIS);
775 
776  //---Initialize 1D Histograms---
777  for (int var = 0; var < NUM_VARS; var++) {
778  h_1D[var] = ibooker.book1D(
779  names[var], title_sam + main_titles[var] + title_cone, (int)param[var][0], param[var][1], param[var][2]);
780  h_1D[var]->setAxisTitle(axis_titles[var], XAXIS);
781  // GetTH1FromMonitorElement(h_1D[var])->Sumw2();
782  } //Finish 1D
783 
784  //----Initialize 2D Histograms
785  for (int var = 0; var < NUM_VARS_2D; var++) {
786  h_2D[var] = ibooker.bookProfile(
787  names_2D[var] + "_VsPV", titles_2D[var] + " Vs PV", vtxBin_, vtxMin_, vtxMax_, 20, 0.0, 20.0);
788  h_2D[var]->setAxisTitle("Number of PV", XAXIS);
789  h_2D[var]->setAxisTitle(titles_2D[var] + " (GeV)", YAXIS);
790  // h_2D[var]->getTH1()->Sumw2();
791  }
792 
793  //-----Initialise PU-Binned histograms
794  for (int var = 0; var < NUM_VARS_NVTX; var++) {
795  h_1D_NVTX[var] = ibooker.book1D(names_NVtxs[var], main_titles_NVtxs[var], 50, 0.0, 10.0);
796  h_1D_NVTX[var]->setAxisTitle(axis_titles_NVtxs[var], XAXIS);
798  }
799 }
800 
802  for (int var = 0; var < NUM_VARS; var++) {
803  double entries = GetTH1FromMonitorElement(h_1D[var])->GetEntries();
804  GetTH1FromMonitorElement(h_1D[var])->Scale(1. / entries);
805  }
806 }
807 
809 #ifdef DEBUG
810  cout << "FillHistos( " << numPV << " )" << endl;
811 #endif
812 
813  //----------Fill 1D histograms---------------
814  for (int var = 0; var < NUM_VARS; var++) {
815  h_1D[var]->Fill(theData[var]);
816  // cd_plots[var]->Fill(theData[var]);//right now, this is a regular PDF (just like h_1D)
817  //OFBin if (theData[var] > param[var][2]) {
818  //OFBin // fill the overflow bin
819  //OFBin overFlowBin = (int) param[var][0] + 1;
820  //OFBin overFlow = GetTH1FromMonitorElement(h_1D[var])->GetBinContent(overFlowBin);
821  //OFBin GetTH1FromMonitorElement(h_1D[var])->SetBinContent(overFlowBin, overFlow + 1);
822  //OFBin }
823  } //Finish 1D
824 
825  for (int var = 0; var < NUM_VARS_2D; var++) {
826  h_2D[var]->Fill(numPV, theData2D[var]);
827  }
828 
829 #ifdef DEBUG
830  cout << "FillHistos( " << numPV << " ): DONE" << endl;
831 #endif
832 }
834  if (PV >= 20 && PV < 50) {
835  h_1D_NVTX[0]->Fill(theDataNVtx[0]);
836  h_1D_NVTX[3]->Fill(theDataNVtx[3]);
837  }
838  if (PV >= 50 && PV < 80) {
839  h_1D_NVTX[1]->Fill(theDataNVtx[1]);
840  h_1D_NVTX[4]->Fill(theDataNVtx[4]);
841  }
842  if (PV >= 80) {
843  h_1D_NVTX[2]->Fill(theDataNVtx[2]);
844  h_1D_NVTX[5]->Fill(theDataNVtx[5]);
845  }
846 }
847 
849 
850 //define this as a plug-in
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
MuonIsolationDQM(const edm::ParameterSet &)
T const * product() const
Definition: Handle.h:70
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:212
const std::string names[nVars_]
T getUntrackedParameter(std::string const &, T const &) const
int iEvent
Definition: GenABIO.cc:224
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
void RecordData(const reco::Muon &muon)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
~MuonIsolationDQM() override
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Log< level::Info, false > LogInfo
bool isValid() const
Definition: HandleBase.h:70
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:88
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
Definition: PV.py:1
Definition: Run.h:45
TH1 * GetTH1FromMonitorElement(MonitorElement *me)
void analyze(const edm::Event &, const edm::EventSetup &) override
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)