CMS 3D CMS Logo

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