CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
METTester.cc
Go to the documentation of this file.
2 // author: Mike Schmitt, University of Florida
3 // first version 8/24/2006
4 // modification: Bobby Scurlock
5 // date: 03.11.2006
6 // note: added RMS(METx) vs SumET capability
7 // modification: Rick Cavanaugh
8 // date: 05.11.2006
9 // note: cleaned up constructor and beginJob, removed int conv. warning
10 // added configuration params
11 // modification: Mike Schmitt
12 // date: 02.28.2007
13 // note: code rewrite. Now uses STL map for monitoring element container.
14 // modification: Bobby Scurlock
15 // date: 04.03.2007
16 // note: Eliminated automated resolution fitting. This is now done in a ROOT script.
17 
18 // date: 02.04.2009
19 // note: Added option to use fine binning or course binning for histos
20 //
21 // modification: Samantha Hewamanage, Florida International University
22 // date: 01.30.2012
23 // note: Added few hists for various nvtx ranges to study PU effects.
24 // Cleaned up the code by making it readable and const'ing the
25 // variables that should be changed.
26 // Changed the number of bins from odd to even. Odd number of bins
27 // makes it impossible to rebin a hist.
28 
31 
34 
38 
57 
58 #include <vector>
59 #include <utility>
60 #include <ostream>
61 #include <fstream>
62 #include <iostream>
63 #include <algorithm>
64 #include <cmath>
65 #include <memory>
67 #include "TMath.h"
68 
70 {
71  METType_ = iConfig.getUntrackedParameter<std::string>("METType");
72  inputMETLabel_ = iConfig.getParameter<edm::InputTag>("InputMETLabel");
73  if(METType_ == "TCMET") {
74  inputCaloMETLabel_ = iConfig.getParameter<edm::InputTag>("InputCaloMETLabel");
75  inputTrackLabel_ = iConfig.getParameter<edm::InputTag>("InputTrackLabel");
76  inputMuonLabel_ = iConfig.getParameter<edm::InputTag>("InputMuonLabel");
77  inputElectronLabel_ = iConfig.getParameter<edm::InputTag>("InputElectronLabel");
78  inputBeamSpotLabel_ = iConfig.getParameter<edm::InputTag>("InputBeamSpotLabel");
79  minhits_ = iConfig.getParameter<int>("minhits");
80  maxd0_ = iConfig.getParameter<double>("maxd0");
81  maxchi2_ = iConfig.getParameter<double>("maxchi2");
82  maxeta_ = iConfig.getParameter<double>("maxeta");
83  maxpt_ = iConfig.getParameter<double>("maxpt");
84  maxPtErr_ = iConfig.getParameter<double>("maxPtErr");
85  trkQuality_ = iConfig.getParameter<std::vector<int> >("trkQuality");
86  trkAlgos_ = iConfig.getParameter<std::vector<int> >("trkAlgos");
87  sample_ = iConfig.getUntrackedParameter<std::string>("sample");
88  }
89  finebinning_ = iConfig.getUntrackedParameter<bool>("FineBinning");
90  FolderName_ = iConfig.getUntrackedParameter<std::string>("FolderName");
91 }
92 
93 
94 void METTester::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
95 {
96  // get ahold of back-end interface
98 
99  if (dbe_) {
100  // TString dirName = "RecoMETV/METTask/MET/";
101  //TString dirName = "JetMET/EventInfo/CertificationSummary/MET_Global/";
102  // TString dirName = "RecoMETV/MET_Global/";
103  TString dirName(FolderName_.c_str());
104  TString label(inputMETLabel_.label());
105  dirName += label;
106  dbe_->setCurrentFolder((std::string)dirName);
107 
108  if (METType_ == "CaloMET")
109  {
110  // CaloMET Histograms
111  if(!finebinning_)
112  {
113  me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
114  me["hNvertex"] = dbe_->book1D("METTask_Nvertex","METTask_Nvertex",80,0,80);
115  me["hCaloMEx"] = dbe_->book1D("METTask_CaloMEx","METTask_CaloMEx",500,-1000,500);
116  me["hCaloMEy"] = dbe_->book1D("METTask_CaloMEy","METTask_CaloMEy",500,-1000,500);
117  // me["hCaloEz"] = dbe_->book1D("METTask_CaloEz","METTask_CaloEz",2000,-500,501);
118  me["hCaloMETSig"] = dbe_->book1D("METTask_CaloMETSig","METTask_CaloMETSig",25,0,24.5);
119  me["hCaloMET"] = dbe_->book1D("METTask_CaloMET" , "METTask_CaloMET" , 1000,0,2000);
120  me["hCaloMET_Nvtx0to5"] = dbe_->book1D("METTask_CaloMET_Nvtx0to5" , "METTask_CaloMET_Nvtx0to5" , 1000,0,2000);
121  me["hCaloMET_Nvtx6to10"] = dbe_->book1D("METTask_CaloMET_Nvtx6to10" , "METTask_CaloMET_Nvtx6to10" , 1000,0,2000);
122  me["hCaloMET_Nvtx11to15"] = dbe_->book1D("METTask_CaloMET_Nvtx11to15" , "METTask_CaloMET_Nvtx11to15" , 1000,0,2000);
123  me["hCaloMET_Nvtx16to20"] = dbe_->book1D("METTask_CaloMET_Nvtx16to20" , "METTask_CaloMET_Nvtx16to20" , 1000,0,2000);
124  me["hCaloMET_Nvtx21to30"] = dbe_->book1D("METTask_CaloMET_Nvtx21to30" , "METTask_CaloMET_Nvtx21to30" , 1000,0,2000);
125  me["hCaloMET_Nvtx30toInf"] = dbe_->book1D("METTask_CaloMET_Nvtx30toInf", "METTask_CaloMET_Nvtx30toInf", 1000,0,2000);
126  me["hCaloMETPhi"] = dbe_->book1D("METTask_CaloMETPhi","METTask_CaloMETPhi",40,-4,4);
127  me["hCaloSumET"] = dbe_->book1D("METTask_CaloSumET" , "METTask_CaloSumET" , 800,0,8000); //10GeV
128  me["hCaloSumET_Nvtx0to5"] = dbe_->book1D("METTask_CaloSumET_Nvtx0to5" , "METTask_CaloSumET_Nvtx0to5" , 800,0,8000);
129  me["hCaloSumET_Nvtx6to10"] = dbe_->book1D("METTask_CaloSumET_Nvtx6to10" , "METTask_CaloSumET_Nvtx6to10" , 800,0,8000);
130  me["hCaloSumET_Nvtx11to15"] = dbe_->book1D("METTask_CaloSumET_Nvtx11to15" , "METTask_CaloSumET_Nvtx11to15" , 800,0,8000);
131  me["hCaloSumET_Nvtx16to20"] = dbe_->book1D("METTask_CaloSumET_Nvtx16to20" , "METTask_CaloSumET_Nvtx16to20" , 800,0,8000);
132  me["hCaloSumET_Nvtx21to30"] = dbe_->book1D("METTask_CaloSumET_Nvtx21to30" , "METTask_CaloSumET_Nvtx21to30" , 800,0,8000);
133  me["hCaloSumET_Nvtx30toInf"] = dbe_->book1D("METTask_CaloSumET_Nvtx30toInf", "METTask_CaloSumET_Nvtx30toInf", 800,0,8000);
134 
135  me["hCaloMaxEtInEmTowers"] = dbe_->book1D("METTask_CaloMaxEtInEmTowers","METTask_CaloMaxEtInEmTowers",600,0,3000); //5GeV
136  me["hCaloMaxEtInHadTowers"] = dbe_->book1D("METTask_CaloMaxEtInHadTowers","METTask_CaloMaxEtInHadTowers",600,0,3000); //5GeV
137  me["hCaloEtFractionHadronic"] = dbe_->book1D("METTask_CaloEtFractionHadronic","METTask_CaloEtFractionHadronic",100,0,1);
138  me["hCaloEmEtFraction"] = dbe_->book1D("METTask_CaloEmEtFraction","METTask_CaloEmEtFraction",100,0,1);
139  me["hCaloHadEtInHB"] = dbe_->book1D("METTask_CaloHadEtInHB","METTask_CaloHadEtInHB",1000, 0, 5000); //5GeV
140  me["hCaloHadEtInHO"] = dbe_->book1D("METTask_CaloHadEtInHO","METTask_CaloHadEtInHO", 250, 0, 500); //5GeV
141  me["hCaloHadEtInHE"] = dbe_->book1D("METTask_CaloHadEtInHE","METTask_CaloHadEtInHE", 200, 0, 400); //5GeV
142  me["hCaloHadEtInHF"] = dbe_->book1D("METTask_CaloHadEtInHF","METTask_CaloHadEtInHF", 100, 0, 200); //5GeV
143  me["hCaloEmEtInHF"] = dbe_->book1D("METTask_CaloEmEtInHF","METTask_CaloEmEtInHF",100, 0, 100); //5GeV
144  me["hCaloSETInpHF"] = dbe_->book1D("METTask_CaloSETInpHF","METTask_CaloSETInpHF",500, 0, 1000);
145  me["hCaloSETInmHF"] = dbe_->book1D("METTask_CaloSETInmHF","METTask_CaloSETInmHF",500, 0, 1000);
146  me["hCaloEmEtInEE"] = dbe_->book1D("METTask_CaloEmEtInEE","METTask_CaloEmEtInEE",100, 0, 200); //5GeV
147  me["hCaloEmEtInEB"] = dbe_->book1D("METTask_CaloEmEtInEB","METTask_CaloEmEtInEB",1200, 0, 6000); //5GeV
148 
149  me["hCaloMETResolution_GenMETTrue"] = dbe_->book1D("METTask_CaloMETResolution_GenMETTrue","METTask_CaloMETResolution_GenMETTrue", 500,-500,500);
150  me["hCaloMETResolution_GenMETCalo"] = dbe_->book1D("METTask_CaloMETResolution_GenMETCalo","METTask_CaloMETResolution_GenMETCalo", 500,-500,500);
151 
152  me["hCaloMETPhiResolution_GenMETTrue"] = dbe_->book1D("METTask_CaloMETPhiResolution_GenMETTrue","METTask_CaloMETPhiResolution_GenMETTrue", 80,0,4);
153  me["hCaloMETPhiResolution_GenMETCalo"] = dbe_->book1D("METTask_CaloMETPhiResolution_GenMETCalo","METTask_CaloMETPhiResolution_GenMETCalo", 80,0,4);
154 
155  } else
156  {
157 
158  //FineBinnning
159  me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
160  me["hNvertex"] = dbe_->book1D("METTask_Nvertex","METTask_Nvertex",80,0,80);
161  me["hCaloMEx"] = dbe_->book1D("METTask_CaloMEx","METTask_CaloMEx",4000,-1000,1000);
162  me["hCaloMEy"] = dbe_->book1D("METTask_CaloMEy","METTask_CaloMEy",4000,-1000,1000);
163  //me["hCaloEz"] = dbe_->book1D("METTask_CaloEz","METTask_CaloEz",2000,-500,501);
164  me["hCaloMETSig"] = dbe_->book1D("METTask_CaloMETSig","METTask_CaloMETSig",50,0,50);
165  me["hCaloMET"] = dbe_->book1D("METTask_CaloMET","METTask_CaloMET",2000,0,2000);
166  me["hCaloMET_Nvtx0to5"] = dbe_->book1D("METTask_CaloMET_Nvtx0to5" , "METTask_CaloMET_Nvtx0to5" , 2000,0,2000);
167  me["hCaloMET_Nvtx6to10"] = dbe_->book1D("METTask_CaloMET_Nvtx6to10" , "METTask_CaloMET_Nvtx6to10" , 2000,0,2000);
168  me["hCaloMET_Nvtx11to15"] = dbe_->book1D("METTask_CaloMET_Nvtx11to15" , "METTask_CaloMET_Nvtx11to15" , 2000,0,2000);
169  me["hCaloMET_Nvtx16to20"] = dbe_->book1D("METTask_CaloMET_Nvtx16to20" , "METTask_CaloMET_Nvtx16to20" , 2000,0,2000);
170  me["hCaloMET_Nvtx21to30"] = dbe_->book1D("METTask_CaloMET_Nvtx21to30" , "METTask_CaloMET_Nvtx21to30" , 2000,0,2000);
171  me["hCaloMET_Nvtx30toInf"] = dbe_->book1D("METTask_CaloMET_Nvtx30toInf", "METTask_CaloMET_Nvtx30toInf", 2000,0,2000);
172  me["hCaloMETPhi"] = dbe_->book1D("METTask_CaloMETPhi","METTask_CaloMETPhi",40,-4,4);
173  me["hCaloSumET"] = dbe_->book1D("METTask_CaloSumET","METTask_CaloSumET",10000,0,10000);
174  me["hCaloSumET_Nvtx0to5"] = dbe_->book1D("METTask_CaloSumET_Nvtx0to5" , "METTask_CaloSumET_Nvtx0to5" , 10000,0,10000);
175  me["hCaloSumET_Nvtx6to10"] = dbe_->book1D("METTask_CaloSumET_Nvtx6to10" , "METTask_CaloSumET_Nvtx6to10" , 10000,0,10000);
176  me["hCaloSumET_Nvtx11to15"] = dbe_->book1D("METTask_CaloSumET_Nvtx11to15" , "METTask_CaloSumET_Nvtx11to15" , 10000,0,10000);
177  me["hCaloSumET_Nvtx16to20"] = dbe_->book1D("METTask_CaloSumET_Nvtx16to20" , "METTask_CaloSumET_Nvtx16to20" , 10000,0,10000);
178  me["hCaloSumET_Nvtx21to30"] = dbe_->book1D("METTask_CaloSumET_Nvtx21to30" , "METTask_CaloSumET_Nvtx21to30" , 10000,0,10000);
179  me["hCaloSumET_Nvtx30toInf"] = dbe_->book1D("METTask_CaloSumET_Nvtx30toInf", "METTask_CaloSumET_Nvtx30toInf", 10000,0,10000);
180  me["hCaloMaxEtInEmTowers"] = dbe_->book1D("METTask_CaloMaxEtInEmTowers","METTask_CaloMaxEtInEmTowers",4000,0,4000);
181  me["hCaloMaxEtInHadTowers"] = dbe_->book1D("METTask_CaloMaxEtInHadTowers","METTask_CaloMaxEtInHadTowers",4000,0,4000);
182  me["hCaloEtFractionHadronic"] = dbe_->book1D("METTask_CaloEtFractionHadronic","METTask_CaloEtFractionHadronic",100,0,1);
183  me["hCaloEmEtFraction"] = dbe_->book1D("METTask_CaloEmEtFraction","METTask_CaloEmEtFraction",100,0,1);
184  me["hCaloHadEtInHB"] = dbe_->book1D("METTask_CaloHadEtInHB","METTask_CaloHadEtInHB",8000,0,8000);
185  me["hCaloHadEtInHO"] = dbe_->book1D("METTask_CaloHadEtInHO","METTask_CaloHadEtInHO",4000,0,4000);
186  me["hCaloHadEtInHE"] = dbe_->book1D("METTask_CaloHadEtInHE","METTask_CaloHadEtInHE",4000,0,4000);
187  me["hCaloHadEtInHF"] = dbe_->book1D("METTask_CaloHadEtInHF","METTask_CaloHadEtInHF",4000,0,4000);
188  me["hCaloHadEtInEB"] = dbe_->book1D("METTask_CaloHadEtInEB","METTask_CaloHadEtInEB",8000,0,8000);
189  me["hCaloHadEtInEE"] = dbe_->book1D("METTask_CaloHadEtInEE","METTask_CaloHadEtInEE",4000,0,4000);
190  me["hCaloEmEtInHF"] = dbe_->book1D("METTask_CaloEmEtInHF","METTask_CaloEmEtInHF",4000,0,4000);
191  me["hCaloSETInpHF"] = dbe_->book1D("METTask_CaloSETInpHF","METTask_CaloSETInpHF",4000,0,4000);
192  me["hCaloSETInmHF"] = dbe_->book1D("METTask_CaloSETInmHF","METTask_CaloSETInmHF",4000,0,4000);
193  me["hCaloEmEtInEE"] = dbe_->book1D("METTask_CaloEmEtInEE","METTask_CaloEmEtInEE",4000,0,4000);
194  me["hCaloEmEtInEB"] = dbe_->book1D("METTask_CaloEmEtInEB","METTask_CaloEmEtInEB",8000,0,8000);
195 
196  me["hCaloMETResolution_GenMETTrue"] = dbe_->book1D("METTask_CaloMETResolution_GenMETTrue","METTask_CaloMETResolution_GenMETTrue", 2000,-1000,1000);
197  me["hCaloMETResolution_GenMETCalo"] = dbe_->book1D("METTask_CaloMETResolution_GenMETCalo","METTask_CaloMETResolution_GenMETCalo", 2000,-1000,1000);
198 
199  me["hCaloMETPhiResolution_GenMETTrue"] = dbe_->book1D("METTask_CaloMETPhiResolution_GenMETTrue","METTask_CaloMETPhiResolution_GenMETTrue", 80,0,4);
200  me["hCaloMETPhiResolution_GenMETCalo"] = dbe_->book1D("METTask_CaloMETPhiResolution_GenMETCalo","METTask_CaloMETPhiResolution_GenMETCalo", 80,0,4);
201  }
202 
203 
204  } else if (METType_ == "GenMET")
205  {
206 
207  // GenMET Histograms
208 
209  if(!finebinning_)
210  {
211  me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
212  me["hGenMEx"] = dbe_->book1D("METTask_GenMEx","METTask_GenMEx",1000,-999.5,999.5);
213  me["hGenMEy"] = dbe_->book1D("METTask_GenMEy","METTask_GenMEy",1000,-999.5,999.5);
214  // me["hGenEz"] = dbe_->book1D("METTask_GenEz","METTask_GenEz",2000,-500,501);
215  me["hGenMETSig"] = dbe_->book1D("METTask_GenMETSig","METTask_GenMETSig",51,0,51);
216  me["hGenMET"] = dbe_->book1D("METTask_GenMET","METTask_GenMET", 2000,-0.5,1999.5);
217  me["hGenMETPhi"] = dbe_->book1D("METTask_GenMETPhi","METTask_GenMETPhi",40,-4,4);
218  me["hGenSumET"] = dbe_->book1D("METTask_GenSumET","METTask_GenSumET",1000,-0.5,9999.5);
219 
220  me["hNeutralEMEtFraction"] = dbe_->book1D("METTask_GenNeutralEMEtFraction", "METTask_GenNeutralEMEtFraction", 120, 0.0, 1.2 );
221  me["hNeutralHadEtFraction"] = dbe_->book1D("METTask_GenNeutralHadEtFraction", "METTask_GenNeutralHadEtFraction", 120, 0.0, 1.2 );
222  me["hChargedEMEtFraction"] = dbe_->book1D("METTask_GenChargedEMEtFraction", "METTask_GenChargedEMEtFraction", 120, 0.0, 1.2);
223  me["hChargedHadEtFraction"] = dbe_->book1D("METTask_GenChargedHadEtFraction", "METTask_GenChargedHadEtFraction", 120, 0.0,1.2);
224  me["hMuonEtFraction"] = dbe_->book1D("METTask_GenMuonEtFraction", "METTask_GenMuonEtFraction", 120, 0.0, 1.2 );
225  me["hInvisibleEtFraction"] = dbe_->book1D("METTask_GenInvisibleEtFraction", "METTask_GenInvisibleEtFraction", 120, 0.0, 1.2 );
226 
227  } else
228  {
229  me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
230  me["hGenMEx"] = dbe_->book1D("METTask_GenMEx","METTask_GenMEx",4000,-1000,1000);
231  me["hGenMEy"] = dbe_->book1D("METTask_GenMEy","METTask_GenMEy",4000,-1000,1000);
232  //me["hGenEz"] = dbe_->book1D("METTask_GenEz","METTask_GenEz",2000,-500,500);
233  me["hGenMETSig"] = dbe_->book1D("METTask_GenMETSig","METTask_GenMETSig",51,0,51);
234  me["hGenMET"] = dbe_->book1D("METTask_GenMET","METTask_GenMET",2000,0,2000);
235  me["hGenMETPhi"] = dbe_->book1D("METTask_GenMETPhi","METTask_GenMETPhi",40,-4,4);
236  me["hGenSumET"] = dbe_->book1D("METTask_GenSumET","METTask_GenSumET",10000,0,10000);
237  me["hNeutralEMEtFraction"] = dbe_->book1D("METTask_GenNeutralEMEtFraction", "METTask_GenNeutralEMEtFraction", 120, 0.0, 1.2 );
238  me["hNeutralHadEtFraction"] = dbe_->book1D("METTask_GenNeutralHadEtFraction", "METTask_GenNeutralHadEtFraction", 120, 0.0, 1.2 );
239  me["hChargedEMEtFraction"] = dbe_->book1D("METTask_GenChargedEMEtFraction", "METTask_GenChargedEMEtFraction", 120, 0.0, 1.2);
240  me["hChargedHadEtFraction"] = dbe_->book1D("METTask_GenChargedHadEtFraction", "METTask_GenChargedHadEtFraction", 120, 0.0,1.2);
241  me["hMuonEtFraction"] = dbe_->book1D("METTask_GenMuonEtFraction", "METTask_GenMuonEtFraction", 120, 0.0, 1.2 );
242  me["hInvisibleEtFraction"] = dbe_->book1D("METTask_GenInvisibleEtFraction", "METTask_GenInvisibleEtFraction", 120, 0.0, 1.2 );
243 
244  }
245 
246  } else if (METType_ == "MET")
247  {
248 
249  // MET Histograms
250  if(!finebinning_)
251  {
252  me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
253  me["hMEx"] = dbe_->book1D("METTask_MEx","METTask_MEx",1000,-999.5,999.5);
254  me["hMEy"] = dbe_->book1D("METTask_MEy","METTask_MEy",1000,-999.5,999.5);
255  //me["hEz"] = dbe_->book1D("METTask_Ez","METTask_Ez",1000,-999.5,999.5);
256  me["hMETSig"] = dbe_->book1D("METTask_METSig","METTask_METSig",50,-0.5,49.5);
257  me["hMET"] = dbe_->book1D("METTask_MET","METTask_MET",1000,-0.5,1999.5);
258  me["hMETPhi"] = dbe_->book1D("METTask_METPhi","METTask_METPhi",40,-4,4);
259  me["hSumET"] = dbe_->book1D("METTask_SumET","METTask_SumET",1000,0,9999.5);
260 
261  } else
262  {
263  me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
264  me["hMEx"] = dbe_->book1D("METTask_MEx","METTask_MEx",2000,-500,500);
265  me["hMEy"] = dbe_->book1D("METTask_MEy","METTask_MEy",2000,-500,500);
266  //me["hEz"] = dbe_->book1D("METTask_Ez","METTask_Ez",2000,-500,500);
267  me["hMETSig"] = dbe_->book1D("METTask_METSig","METTask_METSig",51,0,51);
268  me["hMET"] = dbe_->book1D("METTask_MET","METTask_MET",2000,0,2000);
269  me["hMETPhi"] = dbe_->book1D("METTask_METPhi","METTask_METPhi",40,-4,4);
270  me["hSumET"] = dbe_->book1D("METTask_SumET","METTask_SumET",4000,0,4000);
271 
272  }
273 
274  } else if (METType_ == "PFMET")
275  {
276  // PFMET Histograms
277  if(!finebinning_)
278  {
279  me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
280  me["hNvertex"] = dbe_->book1D("METTask_Nvertex","METTask_Nvertex",80,0,80);
281  me["hMEx"] = dbe_->book1D("METTask_MEx","METTask_MEx",1000,-1000,1000);
282  me["hMEy"] = dbe_->book1D("METTask_MEy","METTask_MEy",1000,-1000,1000);
283  // me["hEz"] = dbe_->book1D("METTask_Ez","METTask_Ez",2000,-500,500);
284  me["hMETSig"] = dbe_->book1D("METTask_METSig","METTask_METSig",51,0,51);
285  me["hMET"] = dbe_->book1D("METTask_MET","METTask_MET",1000,0,2000);
286  me["hMET_Nvtx0to5"] = dbe_->book1D("METTask_MET_Nvtx0to5" , "METTask_MET_Nvtx0to5" , 1000,0,2000);
287  me["hMET_Nvtx6to10"] = dbe_->book1D("METTask_MET_Nvtx6to10" , "METTask_MET_Nvtx6to10" , 1000,0,2000);
288  me["hMET_Nvtx11to15"] = dbe_->book1D("METTask_MET_Nvtx11to15" , "METTask_MET_Nvtx11to15" , 1000,0,2000);
289  me["hMET_Nvtx16to20"] = dbe_->book1D("METTask_MET_Nvtx16to20" , "METTask_MET_Nvtx16to20" , 1000,0,2000);
290  me["hMET_Nvtx21to30"] = dbe_->book1D("METTask_MET_Nvtx21to30" , "METTask_MET_Nvtx21to30" , 1000,0,2000);
291  me["hMET_Nvtx30toInf"] = dbe_->book1D("METTask_MET_Nvtx30toInf", "METTask_MET_Nvtx30toInf", 1000,0,2000);
292  me["hMETPhi"] = dbe_->book1D("METTask_METPhi","METTask_METPhi",40,-4,4);
293  me["hSumET"] = dbe_->book1D("METTask_SumET","METTask_SumET",1000,0,10000);
294  me["hSumET_Nvtx0to5"] = dbe_->book1D("METTask_SumET_Nvtx0to5" , "METTask_SumET_Nvtx0to5" , 1000,0,2000);
295  me["hSumET_Nvtx6to10"] = dbe_->book1D("METTask_SumET_Nvtx6to10" , "METTask_SumET_Nvtx6to10" , 1000,0,2000);
296  me["hSumET_Nvtx11to15"] = dbe_->book1D("METTask_SumET_Nvtx11to15" , "METTask_SumET_Nvtx11to15" , 1000,0,2000);
297  me["hSumET_Nvtx16to20"] = dbe_->book1D("METTask_SumET_Nvtx16to20" , "METTask_SumET_Nvtx16to20" , 1000,0,2000);
298  me["hSumET_Nvtx21to30"] = dbe_->book1D("METTask_SumET_Nvtx21to30" , "METTask_SumET_Nvtx21to30" , 1000,0,2000);
299  me["hSumET_Nvtx30toInf"] = dbe_->book1D("METTask_SumET_Nvtx30toInf", "METTask_SumET_Nvtx30toInf", 1000,0,2000);
300 
301 
302  me["hMETResolution_GenMETTrue"] = dbe_->book1D("METTask_METResolution_GenMETTrue","METTask_METResolution_GenMETTrue", 500,-500,500);
303  me["hMETResolution_GenMETCalo"] = dbe_->book1D("METTask_METResolution_GenMETCalo","METTask_METResolution_GenMETCalo", 500,-500,500);
304 
305  me["hMETPhiResolution_GenMETTrue"] = dbe_->book1D("METTask_METPhiResolution_GenMETTrue","METTask_METPhiResolution_GenMETTrue", 80,0,4);
306  me["hMETPhiResolution_GenMETCalo"] = dbe_->book1D("METTask_METPhiResolution_GenMETCalo","METTask_METPhiResolution_GenMETCalo", 80,0,4);
307 
308 
309  me["hMETResolution_GenMETTrue_MET0to20"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET0to20" , "METTask_METResolution_GenMETTrue_MET0to20" , 500,-500,500);
310  me["hMETResolution_GenMETTrue_MET20to40"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET20to40" , "METTask_METResolution_GenMETTrue_MET20to40" , 500,-500,500);
311  me["hMETResolution_GenMETTrue_MET40to60"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET40to60" , "METTask_METResolution_GenMETTrue_MET40to60" , 500,-500,500);
312  me["hMETResolution_GenMETTrue_MET60to80"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET60to80" , "METTask_METResolution_GenMETTrue_MET60to80" , 500,-500,500);
313  me["hMETResolution_GenMETTrue_MET80to100"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET80to100" , "METTask_METResolution_GenMETTrue_MET80to100" , 500,-500,500);
314  me["hMETResolution_GenMETTrue_MET100to150"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET100to150", "METTask_METResolution_GenMETTrue_MET100to150", 500,-500,500);
315  me["hMETResolution_GenMETTrue_MET150to200"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET150to200", "METTask_METResolution_GenMETTrue_MET150to200", 500,-500,500);
316  me["hMETResolution_GenMETTrue_MET200to300"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET200to300", "METTask_METResolution_GenMETTrue_MET200to300", 500,-500,500);
317  me["hMETResolution_GenMETTrue_MET300to400"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET300to400", "METTask_METResolution_GenMETTrue_MET300to400", 500,-500,500);
318  me["hMETResolution_GenMETTrue_MET400to500"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET400to500", "METTask_METResolution_GenMETTrue_MET400to500", 500,-500,500);
319  //this will be filled at the end of the job using info from above hists
320  int nBins = 10;
321  float bins[] = {0.,20.,40.,60.,80.,100.,150.,200.,300.,400.,500.};
322  me["hMETResolution_GenMETTrue_METResolution"] = dbe_->book1D("METTask_METResolution_GenMETTrue_InMETBins","METTask_METResolution_GenMETTrue_InMETBins",nBins, bins);
323 
324 
325  } else
326  {
327 
328  //FineBin
329  me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
330  me["hNvertex"] = dbe_->book1D("METTask_Nvertex","METTask_Nvertex",80,0,80);
331  me["hMEx"] = dbe_->book1D("METTask_MEx","METTask_MEx",2000,-500,500);
332  me["hMEy"] = dbe_->book1D("METTask_MEy","METTask_MEy",2000,-500,500);
333  //me["hEz"] = dbe_->book1D("METTask_Ez","METTask_Ez",2000,-500,500);
334  me["hMETSig"] = dbe_->book1D("METTask_METSig","METTask_METSig",51,0,51);
335  me["hMET"] = dbe_->book1D("METTask_MET","METTask_MET", 2000,0,2000);
336  me["hMET_Nvtx0to5"] = dbe_->book1D("METTask_MET_Nvtx0to5" , "METTask_MET_Nvtx0to5" , 2000,0,2000);
337  me["hMET_Nvtx6to10"] = dbe_->book1D("METTask_MET_Nvtx6to10" , "METTask_MET_Nvtx6to10" , 2000,0,2000);
338  me["hMET_Nvtx11to15"] = dbe_->book1D("METTask_MET_Nvtx11to15" , "METTask_MET_Nvtx11to15" , 2000,0,2000);
339  me["hMET_Nvtx16to20"] = dbe_->book1D("METTask_MET_Nvtx16to20" , "METTask_MET_Nvtx16to20" , 2000,0,2000);
340  me["hMET_Nvtx21to30"] = dbe_->book1D("METTask_MET_Nvtx21to30" , "METTask_MET_Nvtx21to30" , 2000,0,2000);
341  me["hMET_Nvtx30toInf"] = dbe_->book1D("METTask_MET_Nvtx30toInf", "METTask_MET_Nvtx30toInf", 2000,0,2000);
342  me["hMETPhi"] = dbe_->book1D("METTask_METPhi","METTask_METPhi",40,-4,4);
343  me["hSumET"] = dbe_->book1D("METTask_SumET","METTask_SumET",4000,0,4000);
344  me["hSumET_Nvtx0to5"] = dbe_->book1D("METTask_SumET_Nvtx0to5" , "METTask_SumET_Nvtx0to5" , 4000,0,4000);
345  me["hSumET_Nvtx6to10"] = dbe_->book1D("METTask_SumET_Nvtx6to10" , "METTask_SumET_Nvtx6to10" , 4000,0,4000);
346  me["hSumET_Nvtx11to15"] = dbe_->book1D("METTask_SumET_Nvtx11to15" , "METTask_SumET_Nvtx11to15" , 4000,0,4000);
347  me["hSumET_Nvtx16to20"] = dbe_->book1D("METTask_SumET_Nvtx16to20" , "METTask_SumET_Nvtx16to20" , 4000,0,4000);
348  me["hSumET_Nvtx21to30"] = dbe_->book1D("METTask_SumET_Nvtx21to30" , "METTask_SumET_Nvtx21to30" , 4000,0,4000);
349  me["hSumET_Nvtx30toInf"] = dbe_->book1D("METTask_SumET_Nvtx30toInf", "METTask_SumET_Nvtx30toInf", 4000,0,4000);
350 
351  me["hMETResolution_GenMETTrue"] = dbe_->book1D("METTask_METResolution_GenMETTrue","METTask_METResolution_GenMETTrue",2000,-1000,1000);
352  me["hMETResolution_GenMETCalo"] = dbe_->book1D("METTask_METResolution_GenMETCalo","METTask_METResolution_GenMETCalo",2000,-1000,1000);
353 
354  me["hMETPhiResolution_GenMETTrue"] = dbe_->book1D("METTask_METPhiResolution_GenMETTrue","METTask_METPhiResolution_GenMETTrue", 80,0,4);
355  me["hMETPhiResolution_GenMETCalo"] = dbe_->book1D("METTask_METPhiResolution_GenMETCalo","METTask_METPhiResolution_GenMETCalo", 80,0,4);
356 
357 
358  me["hMETResolution_GenMETTrue_MET0to20"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET0to20","METTask_METResolution_GenMETTrue_MET0to20" , 2000,-1000,1000);
359  me["hMETResolution_GenMETTrue_MET20to40"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET20to40","METTask_METResolution_GenMETTrue_MET20to40" , 2000,-1000,1000);
360  me["hMETResolution_GenMETTrue_MET40to60"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET40to60","METTask_METResolution_GenMETTrue_MET40to60" , 2000,-1000,1000);
361  me["hMETResolution_GenMETTrue_MET60to80"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET60to80","METTask_METResolution_GenMETTrue_MET60to80" , 2000,-1000,1000);
362  me["hMETResolution_GenMETTrue_MET80to100"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET80to100","METTask_METResolution_GenMETTrue_MET80to100" , 2000,-1000,1000);
363  me["hMETResolution_GenMETTrue_MET100to150"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET100to150","METTask_METResolution_GenMETTrue_MET100to150", 2000,-1000,1000);
364  me["hMETResolution_GenMETTrue_MET150to200"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET150to200","METTask_METResolution_GenMETTrue_MET150to200", 2000,-1000,1000);
365  me["hMETResolution_GenMETTrue_MET200to300"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET200to300","METTask_METResolution_GenMETTrue_MET200to300", 2000,-1000,1000);
366  me["hMETResolution_GenMETTrue_MET300to400"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET300to400","METTask_METResolution_GenMETTrue_MET300to400", 2000,-1000,1000);
367  me["hMETResolution_GenMETTrue_MET400to500"] = dbe_->book1D("METTask_METResolution_GenMETTrue_MET400to500","METTask_METResolution_GenMETTrue_MET400to500", 2000,-1000,1000);
368 
369  //this will be filled at the end of the job using info from above hists
370  int nBins = 10;
371  float bins[] = {0.,20.,40.,60.,80.,100.,150.,200.,300.,400.,500.};
372  me["hMETResolution_GenMETTrue_METResolution"] = dbe_->book1D("METTask_METResolution_GenMETTrue_InMETBins","METTask_METResolution_GenMETTrue_InMETBins",nBins, bins);
373  }
374 
375  } else if (METType_ == "TCMET" || inputMETLabel_.label() == "corMetGlobalMuons")
376  {
377  //TCMET or MuonCorrectedCaloMET Histograms
378  if(!finebinning_)
379  {
380  me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
381  me["hMEx"] = dbe_->book1D("METTask_MEx","METTask_MEx",1000,-999.5,999.5);
382  me["hMEy"] = dbe_->book1D("METTask_MEy","METTask_MEy",1000,-999.5,999.5);
383  me["hMETSig"] = dbe_->book1D("METTask_METSig","METTask_METSig",51,0,51);
384  me["hMET"] = dbe_->book1D("METTask_MET","METTask_MET",1000,-0.5,1999.5);
385  me["hMETPhi"] = dbe_->book1D("METTask_METPhi","METTask_METPhi",40,-4,4);
386  me["hSumET"] = dbe_->book1D("METTask_SumET","METTask_SumET",1000,-0.50,9999.5);
387 
388  me["hMExCorrection"] = dbe_->book1D("METTask_MExCorrection","METTask_MExCorrection", 1000, -500.0,500.0);
389  me["hMEyCorrection"] = dbe_->book1D("METTask_MEyCorrection","METTask_MEyCorrection", 1000, -500.0,500.0);
390  me["hMuonCorrectionFlag"] = dbe_->book1D("METTask_CorrectionFlag", "METTask_CorrectionFlag", 6, -0.5, 5.5);
391 
392  me["hMETResolution_GenMETTrue"] = dbe_->book1D("METTask_METResolution_GenMETTrue","METTask_METResolution_GenMETTrue", 500,-500,500);
393  me["hMETResolution_GenMETCalo"] = dbe_->book1D("METTask_METResolution_GenMETCalo","METTask_METResolution_GenMETCalo", 500,-500,500);
394 
395  me["hMETPhiResolution_GenMETTrue"] = dbe_->book1D("METTask_METPhiResolution_GenMETTrue","METTask_METPhiResolution_GenMETTrue", 80,0,4);
396  me["hMETPhiResolution_GenMETCalo"] = dbe_->book1D("METTask_METPhiResolution_GenMETCalo","METTask_METPhiResolution_GenMETCalo", 80,0,4);
397 
398  if( METType_ == "TCMET" ) {
399  me["htrkPt"] = dbe_->book1D("METTask_trackPt", "METTask_trackPt", 50, 0, 500);
400  me["htrkEta"] = dbe_->book1D("METTask_trackEta", "METTask_trackEta", 50, -2.5, 2.5);
401  me["htrkNhits"] = dbe_->book1D("METTask_trackNhits", "METTask_trackNhits", 50, 0, 50);
402  me["htrkChi2"] = dbe_->book1D("METTask_trackNormalizedChi2", "METTask_trackNormalizedChi2", 20, 0, 20);
403  me["htrkD0"] = dbe_->book1D("METTask_trackD0", "METTask_trackd0", 50, -1, 1);
404  me["htrkQuality"] = dbe_->book1D("METTask_trackQuality", "METTask_trackQuality", 30, -0.5, 29.5);
405  me["htrkAlgo"] = dbe_->book1D("METTask_trackAlgo", "METTask_trackAlgo", 6, 3.5, 9.5);
406  me["htrkPtErr"] = dbe_->book1D("METTask_trackPtErr", "METTask_trackPtErr", 200, 0, 2);
407  me["helePt"] = dbe_->book1D("METTask_electronPt", "METTask_electronPt", 50, 0, 500);
408  me["heleEta"] = dbe_->book1D("METTask_electronEta", "METTask_electronEta", 50, -2.5, 2.5);
409  me["heleHoE"] = dbe_->book1D("METTask_electronHoverE", "METTask_electronHoverE", 25, 0, 0.5);
410  me["hmuPt"] = dbe_->book1D("METTask_muonPt", "METTask_muonPt", 50, 0, 500);
411  me["hmuEta"] = dbe_->book1D("METTask_muonEta", "METTask_muonEta", 50, -2.5, 2.5);
412  me["hmuNhits"] = dbe_->book1D("METTask_muonNhits", "METTask_muonNhits", 50, 0, 50);
413  me["hmuChi2"] = dbe_->book1D("METTask_muonNormalizedChi2", "METTask_muonNormalizedChi2", 20, 0, 20);
414  me["hmuD0"] = dbe_->book1D("METTask_muonD0", "METTask_muonD0", 50, -1, 1);
415  me["hnMus"] = dbe_->book1D("METTask_nMus", "METTask_nMus", 5, -0.5, 4.5);
416  me["hnMusPis"] = dbe_->book1D("METTask_nMusAsPis", "METTask_nMusAsPis", 5, -0.5, 4.5);
417  me["hmuSAhits"] = dbe_->book1D("METTask_muonSAhits", "METTask_muonSAhits", 51, -0.5, 50.5);
418  me["hnEls"] = dbe_->book1D("METTask_nEls", "METTask_nEls", 5, -0.5, 4.5);
419  me["hfracTrks"] = dbe_->book1D("METTask_fracTracks", "METTask_fracTracks", 100, 0, 1);
420  me["hdMETx"] = dbe_->book1D("METTask_dMETx", "METTask_dMETx", 500, -250, 250);
421  me["hdMETy"] = dbe_->book1D("METTask_dMETy", "METTask_dMETy", 500, -250, 250);
422  me["hdMET"] = dbe_->book1D("METTask_dMET", "METTask_dMET", 500, -250, 250);
423  me["hdMUx"] = dbe_->book1D("METTask_dMUx", "METTask_dMUx", 500, -250, 250);
424  me["hdMUy"] = dbe_->book1D("METTask_dMUy", "METTask_dMUy", 500, -250, 250);
425  }
426  else if( inputMETLabel_.label() == "corMetGlobalMuons" ) {
427  me["hmuPt"] = dbe_->book1D("METTask_muonPt", "METTask_muonPt", 50, 0, 500);
428  me["hmuEta"] = dbe_->book1D("METTask_muonEta", "METTask_muonEta", 50, -2.5, 2.5);
429  me["hmuNhits"] = dbe_->book1D("METTask_muonNhits", "METTask_muonNhits", 50, 0, 50);
430  me["hmuChi2"] = dbe_->book1D("METTask_muonNormalizedChi2", "METTask_muonNormalizedChi2", 20, 0, 20);
431  me["hmuD0"] = dbe_->book1D("METTask_muonD0", "METTask_muonD0", 50, -1, 1);
432  me["hmuSAhits"] = dbe_->book1D("METTask_muonSAhits", "METTask_muonSAhits", 51, -0.5, 50.5);
433  }
434  }
435  else
436  {
437  //FineBin
438  me["hNevents"] = dbe_->book1D("METTask_Nevents","METTask_Nevents",1,0,1);
439  me["hMEx"] = dbe_->book1D("METTask_MEx","METTask_MEx",2000,-500,500);
440  me["hMEy"] = dbe_->book1D("METTask_MEy","METTask_MEy",2000,-500,500);
441  me["hMETSig"] = dbe_->book1D("METTask_METSig","METTask_METSig",51,0,51);
442  me["hMET"] = dbe_->book1D("METTask_MET","METTask_MET",2000,0,2002);
443  me["hMETPhi"] = dbe_->book1D("METTask_METPhi","METTask_METPhi",40,-4,4);
444  me["hSumET"] = dbe_->book1D("METTask_SumET","METTask_SumET",4000,0,4000);
445  me["hMExCorrection"] = dbe_->book1D("METTask_MExCorrection","METTask_MExCorrection", 2000, -500.0,500.0);
446  me["hMEyCorrection"] = dbe_->book1D("METTask_MEyCorrection","METTask_MEyCorrection", 2000, -500.0,500.0);
447  me["hMuonCorrectionFlag"] = dbe_->book1D("METTask_CorrectionFlag", "METTask_CorrectionFlag", 6, -0.5, 5.5);
448 
449  me["hMETResolution_GenMETTrue"] = dbe_->book1D("METTask_METResolution_GenMETTrue","METTask_METResolution_GenMETTrue",2000,-1000,1000);
450  me["hMETResolution_GenMETCalo"] = dbe_->book1D("METTask_METResolution_GenMETCalo","METTask_METResolution_GenMETCalo",2000,-1000,1000);
451 
452  me["hMETPhiResolution_GenMETTrue"] = dbe_->book1D("METTask_METPhiResolution_GenMETTrue","METTask_METPhiResolution_GenMETTrue", 80,0,4);
453  me["hMETPhiResolution_GenMETCalo"] = dbe_->book1D("METTask_METPhiResolution_GenMETCalo","METTask_METPhiResolution_GenMETCalo", 80,0,4);
454 
455  if( METType_ == "TCMET" ) {
456  me["htrkPt"] = dbe_->book1D("METTask_trackPt", "METTask_trackPt", 250, 0, 500);
457  me["htrkEta"] = dbe_->book1D("METTask_trackEta", "METTask_trackEta", 250, -2.5, 2.5);
458  me["htrkNhits"] = dbe_->book1D("METTask_trackNhits", "METTask_trackNhits", 50, 0, 50);
459  me["htrkChi2"] = dbe_->book1D("METTask_trackNormalizedChi2", "METTask_trackNormalizedChi2", 100, 0, 20);
460  me["htrkD0"] = dbe_->book1D("METTask_trackD0", "METTask_trackd0", 200, -1, 1);
461  me["htrkQuality"] = dbe_->book1D("METTask_trackQuality", "METTask_trackQuality", 30, -0.5, 29.5);
462  me["htrkAlgo"] = dbe_->book1D("METTask_trackAlgo", "METTask_trackAlgo", 6, 3.5, 9.5);
463  me["htrkPtErr"] = dbe_->book1D("METTask_trackPtErr", "METTask_trackPtErr", 200, 0, 2);
464  me["helePt"] = dbe_->book1D("METTask_electronPt", "METTask_electronPt", 250, 0, 500);
465  me["heleEta"] = dbe_->book1D("METTask_electronEta", "METTask_electronEta", 250, -2.5, 2.5);
466  me["heleHoE"] = dbe_->book1D("METTask_electronHoverE", "METTask_electronHoverE", 100, 0, 0.5);
467  me["hmuPt"] = dbe_->book1D("METTask_muonPt", "METTask_muonPt", 250, 0, 500);
468  me["hmuEta"] = dbe_->book1D("METTask_muonEta", "METTask_muonEta", 250, -2.5, 2.5);
469  me["hmuNhits"] = dbe_->book1D("METTask_muonNhits", "METTask_muonNhits", 50, 0, 50);
470  me["hmuChi2"] = dbe_->book1D("METTask_muonNormalizedChi2", "METTask_muonNormalizedChi2", 100, 0, 20);
471  me["hmuD0"] = dbe_->book1D("METTask_muonD0", "METTask_muonD0", 200, -1, 1);
472  me["hnMus"] = dbe_->book1D("METTask_nMus", "METTask_nMus", 5, -0.5, 4.5);
473  me["hnMusPis"] = dbe_->book1D("METTask_nMusAsPis", "METTask_nMusAsPis", 5, -0.5, 4.5);
474  me["hmuSAhits"] = dbe_->book1D("METTask_muonSAhits", "METTask_muonSAhits", 51, -0.5, 50.5);
475  me["hnEls"] = dbe_->book1D("METTask_nEls", "METTask_nEls", 5, -0.5, 4.5);
476  me["hfracTrks"] = dbe_->book1D("METTask_fracTracks", "METTask_fracTracks", 100, 0, 1);
477  me["hdMETx"] = dbe_->book1D("METTask_dMETx", "METTask_dMETx", 500, -250, 250);
478  me["hdMETy"] = dbe_->book1D("METTask_dMETy", "METTask_dMETy", 500, -250, 250);
479  me["hdMET"] = dbe_->book1D("METTask_dMET", "METTask_dMET", 500, -250, 250);
480  me["hdMUx"] = dbe_->book1D("METTask_dMUx", "METTask_dMUx", 500, -250, 250);
481  me["hdMUy"] = dbe_->book1D("METTask_dMUy", "METTask_dMUy", 500, -250, 250);
482  }
483  else if( inputMETLabel_.label() == "corMetGlobalMuons" ) {
484  me["hmuPt"] = dbe_->book1D("METTask_muonPt", "METTask_muonPt", 250, 0, 500);
485  me["hmuEta"] = dbe_->book1D("METTask_muonEta", "METTask_muonEta", 250, -2.5, 2.5);
486  me["hmuNhits"] = dbe_->book1D("METTask_muonNhits", "METTask_muonNhits", 50, 0, 50);
487  me["hmuChi2"] = dbe_->book1D("METTask_muonNormalizedChi2", "METTask_muonNormalizedChi2", 100, 0, 20);
488  me["hmuD0"] = dbe_->book1D("METTask_muonD0", "METTask_muonD0", 200, -1, 1);
489  me["hmuSAhits"] = dbe_->book1D("METTask_muonSAhits", "METTask_muonSAhits", 51, -0.5, 50.5);
490  }
491  }
492 
493  if(METType_ == "TCMET")
494  {
495  me["hMuonCorrectionFlag"]->setBinLabel(1,"Not Corrected");
496  me["hMuonCorrectionFlag"]->setBinLabel(2,"Global Fit");
497  me["hMuonCorrectionFlag"]->setBinLabel(3,"Tracker Fit");
498  me["hMuonCorrectionFlag"]->setBinLabel(4,"SA Fit");
499  me["hMuonCorrectionFlag"]->setBinLabel(5,"Treated as Pion");
500  me["hMuonCorrectionFlag"]->setBinLabel(6,"Default fit");
501  }
502  else if( inputMETLabel_.label() == "corMetGlobalMuons")
503  {
504  me["hMuonCorrectionFlag"]->setBinLabel(1,"Not Corrected");
505  me["hMuonCorrectionFlag"]->setBinLabel(2,"Global Fit");
506  me["hMuonCorrectionFlag"]->setBinLabel(3,"Tracker Fit");
507  me["hMuonCorrectionFlag"]->setBinLabel(4,"SA Fit");
508  me["hMuonCorrectionFlag"]->setBinLabel(5,"Treated as Pion");
509  me["hMuonCorrectionFlag"]->setBinLabel(6,"Default fit");
510  }
511  }
512  else
513  {
514  edm::LogInfo("OutputInfo") << " METType not correctly specified!'";// << outputFile_.c_str();
515  }
516  }
517 }
518 
520 {
521 
523  iEvent.getByLabel("offlinePrimaryVertices", vertexHandle);
524  if (! vertexHandle.isValid())
525  {
526  std::cout << __FUNCTION__ << ":" << __LINE__ << ":vertexHandle handle not found!" << std::endl;
527  assert(false);
528  }
529  const int nvtx = vertexHandle->size();
530 
531  using namespace reco;
532  if (METType_ == "CaloMET")
533  {
534  const CaloMET *calomet;
535  // Get CaloMET
537  iEvent.getByLabel(inputMETLabel_, calo);
538  if (!calo.isValid()) {
539  edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task";
540  edm::LogInfo("OutputInfo") << " MET Task cannot continue...!";
541  return;
542  } else {
543  const CaloMETCollection *calometcol = calo.product();
544  calomet = &(calometcol->front());
545  }
546 
547 
548  // ==========================================================
549  // Reconstructed MET Information
550  const double caloSumET = calomet->sumEt();
551  const double caloMETSig = calomet->mEtSig();
552  const double caloMET = calomet->pt();
553  const double caloMEx = calomet->px();
554  const double caloMEy = calomet->py();
555  const double caloMETPhi = calomet->phi();
556  const double caloMaxEtInEMTowers = calomet->maxEtInEmTowers();
557  const double caloMaxEtInHadTowers = calomet->maxEtInHadTowers();
558  const double caloEtFractionHadronic = calomet->etFractionHadronic();
559  const double caloEmEtFraction = calomet->emEtFraction();
560  const double caloHadEtInHB = calomet->hadEtInHB();
561  const double caloHadEtInHO = calomet->hadEtInHO();
562  const double caloHadEtInHE = calomet->hadEtInHE();
563  const double caloHadEtInHF = calomet->hadEtInHF();
564  const double caloEmEtInEB = calomet->emEtInEB();
565  const double caloEmEtInEE = calomet->emEtInEE();
566  const double caloEmEtInHF = calomet->emEtInHF();
567  const double caloSETInpHF = calomet->CaloSETInpHF();
568  const double caloSETInmHF = calomet->CaloSETInmHF();
569 
570  edm::LogInfo("OutputInfo") << caloMET << " " << caloSumET << std::endl;
571  me["hNevents"]->Fill(0.5);
572  me["hCaloMEx"]->Fill(caloMEx);
573  me["hCaloMEy"]->Fill(caloMEy);
574  me["hCaloMET"]->Fill(caloMET);
575  me["hCaloMETPhi"]->Fill(caloMETPhi);
576  me["hCaloSumET"]->Fill(caloSumET);
577  me["hCaloMETSig"]->Fill(caloMETSig);
578  me["hCaloMaxEtInEmTowers"]->Fill(caloMaxEtInEMTowers);
579  me["hCaloMaxEtInHadTowers"]->Fill(caloMaxEtInHadTowers);
580  me["hCaloEtFractionHadronic"]->Fill(caloEtFractionHadronic);
581  me["hCaloEmEtFraction"]->Fill(caloEmEtFraction);
582  me["hCaloHadEtInHB"]->Fill(caloHadEtInHB);
583  me["hCaloHadEtInHO"]->Fill(caloHadEtInHO);
584  me["hCaloHadEtInHE"]->Fill(caloHadEtInHE);
585  me["hCaloHadEtInHF"]->Fill(caloHadEtInHF);
586  me["hCaloEmEtInEB"]->Fill(caloEmEtInEB);
587  me["hCaloEmEtInEE"]->Fill(caloEmEtInEE);
588  me["hCaloEmEtInHF"]->Fill(caloEmEtInHF);
589  me["hCaloSETInpHF"]->Fill(caloSETInpHF);
590  me["hCaloSETInmHF"]->Fill(caloSETInmHF);
591 
592  /******************************************
593  * For PU Studies
594  * ****************************************/
595  me["hNvertex"]->Fill(nvtx);
596 
597  if (nvtx <= 5)
598  {
599  me["hCaloMET_Nvtx0to5"]->Fill(caloMET);
600  me["hCaloSumET_Nvtx0to5"]->Fill(caloSumET);
601  } else if (nvtx >= 6 && nvtx <= 10)
602  {
603  me["hCaloMET_Nvtx6to10"]->Fill(caloMET);
604  me["hCaloSumET_Nvtx6to10"]->Fill(caloSumET);
605  } else if (nvtx >= 11 && nvtx <= 15)
606  {
607  me["hCaloMET_Nvtx11to15"]->Fill(caloMET);
608  me["hCaloSumET_Nvtx11to15"]->Fill(caloSumET);
609  } else if (nvtx >= 16 && nvtx <= 20)
610  {
611  me["hCaloMET_Nvtx16to20"]->Fill(caloMET);
612  me["hCaloSumET_Nvtx16to20"]->Fill(caloSumET);
613  } else if (nvtx >= 21 && nvtx <= 30)
614  {
615  me["hCaloMET_Nvtx21to30"]->Fill(caloMET);
616  me["hCaloSumET_Nvtx21to30"]->Fill(caloSumET);
617  } else if (nvtx >= 31)
618  {
619  me["hCaloMET_Nvtx30toInf"]->Fill(caloMET);
620  me["hCaloSumET_Nvtx30toInf"]->Fill(caloSumET);
621  }
622 
623 
624  // Get Generated MET for Resolution plots
625 
627  iEvent.getByLabel("genMetTrue", genTrue);
628  if (genTrue.isValid()) {
629  const GenMETCollection *genmetcol = genTrue.product();
630  const GenMET *genMetTrue = &(genmetcol->front());
631  double genMET = genMetTrue->pt();
632  double genMETPhi = genMetTrue->phi();
633 
634  me["hCaloMETResolution_GenMETTrue"]->Fill( caloMET - genMET );
635  me["hCaloMETPhiResolution_GenMETTrue"]->Fill( TMath::ACos( TMath::Cos( caloMETPhi - genMETPhi ) ) );
636  } else {
637  edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task: genMetTrue";
638  }
639 
640 
642  iEvent.getByLabel("genMetCalo", genCalo);
643  if (genCalo.isValid()) {
644  const GenMETCollection *genmetcol = genCalo.product();
645  const GenMET *genMetCalo = &(genmetcol->front());
646  const double genMET = genMetCalo->pt();
647  const double genMETPhi = genMetCalo->phi();
648 
649  me["hCaloMETResolution_GenMETCalo"]->Fill( caloMET - genMET );
650  me["hCaloMETPhiResolution_GenMETCalo"]->Fill( TMath::ACos( TMath::Cos( caloMETPhi - genMETPhi ) ) );
651  } else {
652  edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task: genMetCalo";
653  }
654 
655 
656  } else if (METType_ == "GenMET")
657  {
658  const GenMET *genmet;
659  // Get Generated MET
661  iEvent.getByLabel(inputMETLabel_, gen);
662  if (!gen.isValid()) {
663  edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task";
664  edm::LogInfo("OutputInfo") << " MET Task cannot continue...!";
665  return;
666  } else {
667  const GenMETCollection *genmetcol = gen.product();
668  genmet = &(genmetcol->front());
669  }
670 
671  // ==========================================================
672  // Genenerated MET Information
673  const double genSumET = genmet->sumEt();
674  const double genMET = genmet->pt();
675  const double genMEx = genmet->px();
676  const double genMEy = genmet->py();
677  const double genMETPhi = genmet->phi();
678  const double genMETSig = genmet->mEtSig();
679  /*
680  double genEmEnergy = genmet->emEnergy();
681  double genHadEnergy = genmet->hadEnergy();
682  double genInvisibleEnergy= genmet->invisibleEnergy();
683  double genAuxiliaryEnergy= genmet->auxiliaryEnergy();
684  */
685 
686  const double NeutralEMEtFraction = genmet->NeutralEMEtFraction() ;
687  const double NeutralHadEtFraction = genmet->NeutralHadEtFraction() ;
688  const double ChargedEMEtFraction = genmet->ChargedEMEtFraction () ;
689  const double ChargedHadEtFraction = genmet->ChargedHadEtFraction();
690  const double MuonEtFraction = genmet->MuonEtFraction() ;
691  const double InvisibleEtFraction = genmet->InvisibleEtFraction() ;
692 
693  me["hNevents"]->Fill(0);
694  me["hGenMEx"]->Fill(genMEx);
695  me["hGenMEy"]->Fill(genMEy);
696  me["hGenMET"]->Fill(genMET);
697  me["hGenMETPhi"]->Fill(genMETPhi);
698  me["hGenSumET"]->Fill(genSumET);
699  me["hGenMETSig"]->Fill(genMETSig);
700  //me["hGenEz"]->Fill(genEz);
701 
702  me["hNeutralEMEtFraction"]->Fill( NeutralEMEtFraction );
703  me["hNeutralHadEtFraction"]->Fill( NeutralHadEtFraction );
704  me["hChargedEMEtFraction"]->Fill( ChargedEMEtFraction );
705  me["hChargedHadEtFraction"]->Fill( ChargedHadEtFraction );
706  me["hMuonEtFraction"]->Fill( MuonEtFraction );
707  me["hInvisibleEtFraction"]->Fill( InvisibleEtFraction );
708 
709  me["hNevents"]->Fill(0.5);
710 
711  } else if( METType_ == "PFMET")
712  {
713  const PFMET *pfmet;
715  iEvent.getByLabel(inputMETLabel_,hpfmetcol);
716  if (!hpfmetcol.isValid()){
717  edm::LogInfo("OutputInfo") << "falied to retrieve data require by MET Task";
718  edm::LogInfo("OutputInfo") << "MET Taks cannot continue...!";
719  return;
720  } else
721  {
722  const PFMETCollection *pfmetcol = hpfmetcol.product();
723  pfmet = &(pfmetcol->front());
724  }
725  // Reconstructed MET Information
726  const double SumET = pfmet->sumEt();
727  const double MET = pfmet->pt();
728  const double MEx = pfmet->px();
729  const double MEy = pfmet->py();
730  const double METPhi = pfmet->phi();
731  const double METSig = pfmet->mEtSig();
732  me["hMEx"]->Fill(MEx);
733  me["hMEy"]->Fill(MEy);
734  me["hMET"]->Fill(MET);
735  me["hMETPhi"]->Fill(METPhi);
736  me["hSumET"]->Fill(SumET);
737  me["hMETSig"]->Fill(METSig);
738  me["hNevents"]->Fill(0.5);
739 
740  /******************************************
741  * For PU Studies
742  * ****************************************/
743 
744  me["hNvertex"]->Fill(nvtx);
745  if (nvtx <= 5)
746  {
747  me["hMET_Nvtx0to5"]->Fill(MET);
748  me["hSumET_Nvtx0to5"]->Fill(SumET);
749  } else if (nvtx >= 6 && nvtx <= 10)
750  {
751  me["hMET_Nvtx6to10"]->Fill(MET);
752  me["hSumET_Nvtx6to10"]->Fill(SumET);
753  } else if (nvtx >= 11 && nvtx <= 15)
754  {
755  me["hMET_Nvtx11to15"]->Fill(MET);
756  me["hSumET_Nvtx11to15"]->Fill(SumET);
757  } else if (nvtx >= 16 && nvtx <= 20)
758  {
759  me["hMET_Nvtx16to20"]->Fill(MET);
760  me["hSumET_Nvtx16to20"]->Fill(SumET);
761  } else if (nvtx >= 21 && nvtx <= 30)
762  {
763  me["hMET_Nvtx21to30"]->Fill(MET);
764  me["hSumET_Nvtx21to30"]->Fill(SumET);
765  } else if (nvtx >= 31)
766  {
767  me["hMET_Nvtx30toInf"]->Fill(MET);
768  me["hSumET_Nvtx30toInf"]->Fill(SumET);
769  }
770 
771 
773  iEvent.getByLabel("genMetTrue", genTrue);
774  if (genTrue.isValid()) {
775  const GenMETCollection *genmetcol = genTrue.product();
776  const GenMET *genMetTrue = &(genmetcol->front());
777  const double genMET = genMetTrue->pt();
778  const double genMETPhi = genMetTrue->phi();
779 
780  me["hMETResolution_GenMETTrue"]->Fill( MET - genMET );
781  me["hMETPhiResolution_GenMETTrue"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
782 
783  //pfMET resolution in pfMET bins : Sam, Feb, 2012
784 
785  if (MET > 0 && MET < 20) me["hMETResolution_GenMETTrue_MET0to20"]->Fill( MET - genMET );
786  else if (MET > 20 && MET < 40) me["hMETResolution_GenMETTrue_MET20to40"]->Fill( MET - genMET );
787  else if (MET > 40 && MET < 60) me["hMETResolution_GenMETTrue_MET40to60"]->Fill( MET - genMET );
788  else if (MET > 60 && MET < 80) me["hMETResolution_GenMETTrue_MET60to80"]->Fill( MET - genMET );
789  else if (MET > 80 && MET <100) me["hMETResolution_GenMETTrue_MET80to100"]->Fill( MET - genMET );
790  else if (MET >100 && MET <150) me["hMETResolution_GenMETTrue_MET100to150"]->Fill( MET - genMET );
791  else if (MET >150 && MET <200) me["hMETResolution_GenMETTrue_MET150to200"]->Fill( MET - genMET );
792  else if (MET >200 && MET <300) me["hMETResolution_GenMETTrue_MET200to300"]->Fill( MET - genMET );
793  else if (MET >300 && MET <400) me["hMETResolution_GenMETTrue_MET300to400"]->Fill( MET - genMET );
794  else if (MET >400 && MET <500) me["hMETResolution_GenMETTrue_MET400to500"]->Fill( MET - genMET );
795 
796  //This is an ugly hack I had to do.
797  //I wanted to fill just one histogram at the endo the job. I tried
798  //to do this in endjob() but it seems the file is closed before this
799  //step.
800  FillpfMETRes();
801 
802  } else {
803  edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task: genMetTrue";
804  }
805 
806 
808  iEvent.getByLabel("genMetCalo", genCalo);
809  if (genCalo.isValid()) {
810  const GenMETCollection *genmetcol = genCalo.product();
811  const GenMET *genMetCalo = &(genmetcol->front());
812  const double genMET = genMetCalo->pt();
813  const double genMETPhi = genMetCalo->phi();
814 
815  me["hMETResolution_GenMETCalo"]->Fill( MET - genMET );
816  me["hMETPhiResolution_GenMETCalo"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
817  } else {
818  edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task: genMetCalo";
819  }
820 
821 
822 
823  } else if (METType_ == "MET")
824  {
825  const MET *met;
826  // Get Generated MET
828  iEvent.getByLabel(inputMETLabel_, hmetcol);
829  if (!hmetcol.isValid()) {
830  edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task";
831  edm::LogInfo("OutputInfo") << " MET Task cannot continue...!";
832  return;
833  } else {
834  const METCollection *metcol = hmetcol.product();
835  met = &(metcol->front());
836  }
837 
838  // Reconstructed MET Information
839  const double SumET = met->sumEt();
840  const double MET = met->pt();
841  const double MEx = met->px();
842  const double MEy = met->py();
843  const double METPhi = met->phi();
844  const double METSig = met->mEtSig();
845 
846  me["hMEx"]->Fill(MEx);
847  me["hMEy"]->Fill(MEy);
848  me["hMET"]->Fill(MET);
849  me["hMETPhi"]->Fill(METPhi);
850  me["hSumET"]->Fill(SumET);
851  me["hMETSig"]->Fill(METSig);
852  me["hNevents"]->Fill(0.5);
853 
854  } else if( METType_ == "TCMET" )
855  {
856  const MET *tcMet;
857  edm::Handle<METCollection> htcMetcol;
858  iEvent.getByLabel(inputMETLabel_, htcMetcol);
859 
860  const CaloMET *caloMet;
861  edm::Handle<CaloMETCollection> hcaloMetcol;
862  iEvent.getByLabel(inputCaloMETLabel_, hcaloMetcol);
863 
865  iEvent.getByLabel(inputMuonLabel_, muon_h);
866 
867  // edm::Handle< edm::View<reco::Track> > track_h;
869  iEvent.getByLabel(inputTrackLabel_, track_h);
870 
872  iEvent.getByLabel(inputElectronLabel_, electron_h);
873 
875  iEvent.getByLabel(inputBeamSpotLabel_, beamSpot_h);
876 
877  if(!htcMetcol.isValid()){
878  edm::LogInfo("OutputInfo") << "falied to retrieve data require by MET Task";
879  edm::LogInfo("OutputInfo") << "MET Taks cannot continue...!";
880  return;
881  }
882  else
883  {
884  const METCollection *tcMetcol = htcMetcol.product();
885  tcMet = &(tcMetcol->front());
886  }
887 
888  if(!hcaloMetcol.isValid()){
889  edm::LogInfo("OutputInfo") << "falied to retrieve data require by MET Task";
890  edm::LogInfo("OutputInfo") << "MET Taks cannot continue...!";
891  return;
892  }
893  else
894  {
895  const CaloMETCollection *caloMetcol = hcaloMetcol.product();
896  caloMet = &(caloMetcol->front());
897  }
898 
899  if(!muon_h.isValid()){
900  edm::LogInfo("OutputInfo") << "falied to retrieve muon data require by MET Task";
901  edm::LogInfo("OutputInfo") << "MET Taks cannot continue...!";
902  return;
903  }
904 
905  if(!track_h.isValid()){
906  edm::LogInfo("OutputInfo") << "falied to retrieve track data require by MET Task";
907  edm::LogInfo("OutputInfo") << "MET Taks cannot continue...!";
908  return;
909  }
910 
911  if(!electron_h.isValid()){
912  edm::LogInfo("OutputInfo") << "falied to retrieve electron data require by MET Task";
913  edm::LogInfo("OutputInfo") << "MET Taks cannot continue...!";
914  return;
915  }
916 
917  if(!beamSpot_h.isValid()){
918  edm::LogInfo("OutputInfo") << "falied to retrieve beam spot data require by MET Task";
919  edm::LogInfo("OutputInfo") << "MET Taks cannot continue...!";
920  return;
921  }
922 
923  math::XYZPoint bspot = ( beamSpot_h.isValid() ) ? beamSpot_h->position() : math::XYZPoint(0, 0, 0);
924 
925  //Event selection-----------------------------------------------------------------------
926 
928  iEvent.getByLabel("muonTCMETValueMapProducer" , "muCorrData", tcMet_ValueMap_Handle);
929 
930  //count muons
931  int nM = 0;
932 
933  for( unsigned int mus = 0; mus < muon_h->size() ; mus++ ) {
934 
935  reco::MuonRef muref( muon_h, mus);
936  if( muref->pt() < 20 ) continue;
937 
938  reco::MuonMETCorrectionData muCorrData = (*tcMet_ValueMap_Handle)[muref];
939  int type = muCorrData.type();
940 
941  if( type == 1 || type == 2 || type == 5 ) ++nM;
942  }
943 
944  //count electrons
945  int nE = 0;
946 
947  for( edm::View<reco::GsfElectron>::const_iterator eleit = electron_h->begin(); eleit != electron_h->end(); eleit++ ) {
948  if( eleit->p4().pt() < 20 ) continue;
949  ++nE;
950  }
951 
952  if( strcmp( sample_.c_str() , "zmm" ) == 0 && nM != 2 ) return;
953 
954  if( strcmp( sample_.c_str() , "zee" ) == 0 && nE != 2 ) return;
955 
956  if( strcmp( sample_.c_str() , "ttbar" ) == 0 && ( nE + nM ) == 0 ) return;
957 
958  // Reconstructed TCMET Information
959  const double SumET = tcMet->sumEt();
960  const double MET = tcMet->pt();
961  const double MEx = tcMet->px();
962  const double MEy = tcMet->py();
963  const double METPhi = tcMet->phi();
964  const double METSig = tcMet->mEtSig();
965 
966  me["hMEx"]->Fill(MEx);
967  me["hMEy"]->Fill(MEy);
968  me["hMET"]->Fill(MET);
969  me["hMETPhi"]->Fill(METPhi);
970  me["hSumET"]->Fill(SumET);
971  me["hMETSig"]->Fill(METSig);
972  me["hNevents"]->Fill(0.5);
973 
974  const double caloMET = caloMet->pt();
975  const double caloMEx = caloMet->px();
976  const double caloMEy = caloMet->py();
977 
978  me["hdMETx"]->Fill(caloMEx-MEx);
979  me["hdMETy"]->Fill(caloMEy-MEy);
980  me["hdMET"]->Fill(caloMET-MET);
981 
982  const unsigned int nTracks = track_h->size();
983  unsigned int nCorrTracks = 0;
984  unsigned int trackCount = 0;
985  for( reco::TrackCollection::const_iterator trkit = track_h->begin(); trkit != track_h->end(); trkit++ ) {
986  me["htrkPt"]->Fill( trkit->pt() );
987  me["htrkEta"]->Fill( trkit->eta() );
988  me["htrkNhits"]->Fill( trkit->numberOfValidHits() );
989  me["htrkChi2"]->Fill( trkit->chi2() / trkit->ndof() );
990 
991  double d0 = -1 * trkit->dxy( bspot );
992 
993  me["htrkD0"]->Fill( d0 );
994 
995  me["htrkQuality"]->Fill( trkit->qualityMask() );
996  me["htrkAlgo"]->Fill( trkit->algo() );
997  me["htrkPtErr"]->Fill( trkit->ptError() / trkit->pt() );
998 
999  reco::TrackRef trkref( track_h, trackCount );
1000 
1001  if( isGoodTrack( trkref, d0) ) ++nCorrTracks;
1002  ++trackCount;
1003  }
1004 
1005  const float frac = (float)nCorrTracks / (float)nTracks;
1006  me["hfracTrks"]->Fill(frac);
1007 
1008  int nEls = 0;
1009  for( edm::View<reco::GsfElectron>::const_iterator eleit = electron_h->begin(); eleit != electron_h->end(); eleit++ ) {
1010  me["helePt"]->Fill( eleit->p4().pt() );
1011  me["heleEta"]->Fill( eleit->p4().eta() );
1012  me["heleHoE"]->Fill( eleit->hadronicOverEm() );
1013 
1014  reco::TrackRef el_track = eleit->closestCtfTrackRef();
1015 
1016  unsigned int ele_idx = el_track.isNonnull() ? el_track.key() : 99999;
1017 
1018  if( eleit->hadronicOverEm() < 0.1 && ele_idx < nTracks )
1019  ++nEls;
1020  }
1021 
1022  me["hnEls"]->Fill(nEls);
1023 
1024  for( reco::MuonCollection::const_iterator muonit = muon_h->begin(); muonit != muon_h->end(); muonit++ ) {
1025 
1026  const reco::TrackRef siTrack = muonit->innerTrack();
1027 
1028  me["hmuPt"]->Fill( muonit->p4().pt() );
1029  me["hmuEta"]->Fill( muonit->p4().eta() );
1030  me["hmuNhits"]->Fill( siTrack.isNonnull() ? siTrack->numberOfValidHits() : -999 );
1031  me["hmuChi2"]->Fill( siTrack.isNonnull() ? siTrack->chi2()/siTrack->ndof() : -999 );
1032 
1033  double d0 = siTrack.isNonnull() ? -1 * siTrack->dxy( bspot) : -999;
1034 
1035  me["hmuD0"]->Fill( d0 );
1036  }
1037 
1038  //edm::Handle< edm::ValueMap<reco::MuonMETCorrectionData> > tcMet_ValueMap_Handle;
1039  //iEvent.getByLabel("muonTCMETValueMapProducer" , "muCorrData", tcMet_ValueMap_Handle);
1040 
1042  iEvent.getByLabel("muonMETValueMapProducer" , "muCorrData", muon_ValueMap_Handle);
1043 
1044  const unsigned int nMuons = muon_h->size();
1045 
1046  int nMus = 0;
1047  int nMusPis = 0;
1048  double muDx = 0;
1049  double muDy = 0;
1050  for( unsigned int mus = 0; mus < nMuons; mus++ )
1051  {
1052  reco::MuonRef muref( muon_h, mus);
1053  reco::MuonMETCorrectionData muCorrData = (*tcMet_ValueMap_Handle)[muref];
1054  reco::MuonMETCorrectionData muonCorrData = (*muon_ValueMap_Handle)[muref];
1055 
1056  me["hMExCorrection"] -> Fill(muCorrData.corrX());
1057  me["hMEyCorrection"] -> Fill(muCorrData.corrY());
1058 
1059  int type = muCorrData.type();
1060  me["hMuonCorrectionFlag"]-> Fill(type);
1061 
1062  if( type == 1 || type == 2 || type == 5 ) {
1063  ++nMus;
1064 
1065  if( type == 1 ) {
1066  muDx += muonCorrData.corrX() - muref->globalTrack()->px();
1067  muDy += muonCorrData.corrY() - muref->globalTrack()->py();
1068  }
1069  else if( type == 2 ) {
1070  muDx += muonCorrData.corrX() - muref->innerTrack()->px();
1071  muDy += muonCorrData.corrY() - muref->innerTrack()->py();
1072  }
1073  else if( type == 5 ) {
1074  muDx += muonCorrData.corrX() - muref->px();
1075  muDy += muonCorrData.corrY() - muref->py();
1076  }
1077  }
1078  else if( type == 4 )
1079  ++nMusPis;
1080  }
1081 
1082  me["hnMus"]->Fill(nMus);
1083  me["hnMusPis"]->Fill(nMusPis);
1084  me["hdMUx"]->Fill(muDx);
1085  me["hdMUy"]->Fill(muDy);
1086 
1088  iEvent.getByLabel("genMetTrue", genTrue);
1089  if (genTrue.isValid()) {
1090  const GenMETCollection *genmetcol = genTrue.product();
1091  const GenMET *genMetTrue = &(genmetcol->front());
1092  const double genMET = genMetTrue->pt();
1093  const double genMETPhi = genMetTrue->phi();
1094 
1095  me["hMETResolution_GenMETTrue"]->Fill( MET - genMET );
1096  me["hMETPhiResolution_GenMETTrue"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
1097  } else {
1098  edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task: genMetTrue";
1099  }
1100 
1101 
1103  iEvent.getByLabel("genMetCalo", genCalo);
1104  if (genCalo.isValid()) {
1105  const GenMETCollection *genmetcol = genCalo.product();
1106  const GenMET *genMetCalo = &(genmetcol->front());
1107  const double genMET = genMetCalo->pt();
1108  const double genMETPhi = genMetCalo->phi();
1109 
1110  me["hMETResolution_GenMETCalo"]->Fill( MET - genMET );
1111  me["hMETPhiResolution_GenMETCalo"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
1112  } else {
1113  edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task: genMetCalo";
1114  }
1115  }
1116  else if( inputMETLabel_.label() == "corMetGlobalMuons" )
1117  {
1118  const CaloMET *corMetGlobalMuons = 0;
1119  edm::Handle<CaloMETCollection> hcorMetGlobalMuonscol;
1120  iEvent.getByLabel(inputMETLabel_, hcorMetGlobalMuonscol );
1121  if(! hcorMetGlobalMuonscol.isValid()){
1122  edm::LogInfo("OutputInfo") << "hcorMetGlobalMuonscol is NOT Valid";
1123  edm::LogInfo("OutputInfo") << "MET Taks continues anyway...!";
1124  }
1125  else
1126  {
1127  const CaloMETCollection *corMetGlobalMuonscol = hcorMetGlobalMuonscol.product();
1128  corMetGlobalMuons = &(corMetGlobalMuonscol->front());
1129  }
1130 
1131  // Reconstructed TCMET Information
1132  const double SumET = corMetGlobalMuons->sumEt();
1133  const double MET = corMetGlobalMuons->pt();
1134  const double MEx = corMetGlobalMuons->px();
1135  const double MEy = corMetGlobalMuons->py();
1136  const double METPhi = corMetGlobalMuons->phi();
1137  const double METSig = corMetGlobalMuons->mEtSig();
1138  me["hMEx"]->Fill(MEx);
1139  me["hMEy"]->Fill(MEy);
1140  me["hMET"]->Fill(MET);
1141  me["hMETPhi"]->Fill(METPhi);
1142  me["hSumET"]->Fill(SumET);
1143  me["hMETSig"]->Fill(METSig);
1144  me["hNevents"]->Fill(0.5);
1145 
1146  edm::Handle< edm::ValueMap<reco::MuonMETCorrectionData> > corMetGlobalMuons_ValueMap_Handle;
1147  iEvent.getByLabel("muonMETValueMapProducer" , "muCorrData", corMetGlobalMuons_ValueMap_Handle);
1148 
1150  iEvent.getByLabel("muons", muon_Handle);
1151 
1152  edm::Handle< reco::BeamSpot > beamSpot_h;
1153  iEvent.getByLabel(inputBeamSpotLabel_, beamSpot_h);
1154 
1155  if(!beamSpot_h.isValid()){
1156  edm::LogInfo("OutputInfo") << "beamSpot is NOT Valid";
1157  edm::LogInfo("OutputInfo") << "MET Taks continues anyway...!";
1158  }
1159 
1160  math::XYZPoint bspot = ( beamSpot_h.isValid() ) ? beamSpot_h->position() : math::XYZPoint(0, 0, 0);
1161 
1162  for( reco::MuonCollection::const_iterator muonit = muon_Handle->begin(); muonit != muon_Handle->end(); muonit++ ) {
1163 
1164  const reco::TrackRef siTrack = muonit->innerTrack();
1165  const reco::TrackRef globalTrack = muonit->globalTrack();
1166 
1167  me["hmuPt"]->Fill( muonit->p4().pt() );
1168  me["hmuEta"]->Fill( muonit->p4().eta() );
1169  me["hmuNhits"]->Fill( siTrack.isNonnull() ? siTrack->numberOfValidHits() : -999 );
1170  me["hmuChi2"]->Fill( siTrack.isNonnull() ? siTrack->chi2()/siTrack->ndof() : -999 );
1171 
1172  double d0 = siTrack.isNonnull() ? -1 * siTrack->dxy( bspot) : -999;
1173 
1174  me["hmuD0"]->Fill( d0 );
1175 
1176  int nHits = globalTrack.isNonnull() ? globalTrack->hitPattern().numberOfValidMuonHits() : -999;
1177 
1178  me["hmuSAhits"]->Fill( nHits );
1179  }
1180 
1181  const unsigned int nMuons = muon_Handle->size();
1182  for( unsigned int mus = 0; mus < nMuons; mus++ )
1183  {
1184  reco::MuonRef muref( muon_Handle, mus);
1185  reco::MuonMETCorrectionData muCorrData = (*corMetGlobalMuons_ValueMap_Handle)[muref];
1186 
1187  me["hMExCorrection"] -> Fill(muCorrData.corrY());
1188  me["hMEyCorrection"] -> Fill(muCorrData.corrX());
1189  me["hMuonCorrectionFlag"]-> Fill(muCorrData.type());
1190  }
1191 
1193  iEvent.getByLabel("genMetTrue", genTrue);
1194  if (genTrue.isValid()) {
1195  const GenMETCollection *genmetcol = genTrue.product();
1196  const GenMET *genMetTrue = &(genmetcol->front());
1197  const double genMET = genMetTrue->pt();
1198  const double genMETPhi = genMetTrue->phi();
1199 
1200  me["hMETResolution_GenMETTrue"]->Fill( MET - genMET );
1201  me["hMETPhiResolution_GenMETTrue"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
1202  } else {
1203  edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task: genMetTrue";
1204  }
1205 
1206 
1208  iEvent.getByLabel("genMetCalo", genCalo);
1209  if (genCalo.isValid()) {
1210  const GenMETCollection *genmetcol = genCalo.product();
1211  const GenMET *genMetCalo = &(genmetcol->front());
1212  const double genMET = genMetCalo->pt();
1213  const double genMETPhi = genMetCalo->phi();
1214 
1215  me["hMETResolution_GenMETCalo"]->Fill( MET - genMET );
1216  me["hMETPhiResolution_GenMETCalo"]->Fill( TMath::ACos( TMath::Cos( METPhi - genMETPhi ) ) );
1217  } else {
1218  edm::LogInfo("OutputInfo") << " failed to retrieve data required by MET Task: genMetCalo";
1219  }
1220 
1221  }
1222 
1223 }
1224 
1226 {
1227 }
1228 
1229 //void METTester::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
1231 {
1232  me["hMETResolution_GenMETTrue_METResolution"]->setBinContent(1, me["hMETResolution_GenMETTrue_MET0to20"]->getMean());
1233  me["hMETResolution_GenMETTrue_METResolution"]->setBinContent(2, me["hMETResolution_GenMETTrue_MET20to40"]->getMean());
1234  me["hMETResolution_GenMETTrue_METResolution"]->setBinContent(3, me["hMETResolution_GenMETTrue_MET40to60"]->getMean());
1235  me["hMETResolution_GenMETTrue_METResolution"]->setBinContent(4, me["hMETResolution_GenMETTrue_MET60to80"]->getMean());
1236  me["hMETResolution_GenMETTrue_METResolution"]->setBinContent(5, me["hMETResolution_GenMETTrue_MET80to100"]->getMean());
1237  me["hMETResolution_GenMETTrue_METResolution"]->setBinContent(6, me["hMETResolution_GenMETTrue_MET100to150"]->getMean());
1238  me["hMETResolution_GenMETTrue_METResolution"]->setBinContent(7, me["hMETResolution_GenMETTrue_MET150to200"]->getMean());
1239  me["hMETResolution_GenMETTrue_METResolution"]->setBinContent(8, me["hMETResolution_GenMETTrue_MET200to300"]->getMean());
1240  me["hMETResolution_GenMETTrue_METResolution"]->setBinContent(9, me["hMETResolution_GenMETTrue_MET300to400"]->getMean());
1241  me["hMETResolution_GenMETTrue_METResolution"]->setBinContent(10, me["hMETResolution_GenMETTrue_MET400to500"]->getMean());
1242  me["hMETResolution_GenMETTrue_METResolution"]->setBinError(1, me["hMETResolution_GenMETTrue_MET0to20"]->getRMS());
1243  me["hMETResolution_GenMETTrue_METResolution"]->setBinError(2, me["hMETResolution_GenMETTrue_MET20to40"]->getRMS());
1244  me["hMETResolution_GenMETTrue_METResolution"]->setBinError(3, me["hMETResolution_GenMETTrue_MET40to60"]->getRMS());
1245  me["hMETResolution_GenMETTrue_METResolution"]->setBinError(4, me["hMETResolution_GenMETTrue_MET60to80"]->getRMS());
1246  me["hMETResolution_GenMETTrue_METResolution"]->setBinError(5, me["hMETResolution_GenMETTrue_MET80to100"]->getRMS());
1247  me["hMETResolution_GenMETTrue_METResolution"]->setBinError(6, me["hMETResolution_GenMETTrue_MET100to150"]->getRMS());
1248  me["hMETResolution_GenMETTrue_METResolution"]->setBinError(7, me["hMETResolution_GenMETTrue_MET150to200"]->getRMS());
1249  me["hMETResolution_GenMETTrue_METResolution"]->setBinError(8, me["hMETResolution_GenMETTrue_MET200to300"]->getRMS());
1250  me["hMETResolution_GenMETTrue_METResolution"]->setBinError(9, me["hMETResolution_GenMETTrue_MET300to400"]->getRMS());
1251  me["hMETResolution_GenMETTrue_METResolution"]->setBinError(10, me["hMETResolution_GenMETTrue_MET400to500"]->getRMS());
1252 
1253 }
1254 
1255 //determines if track is "good" - i.e. passes quality and kinematic cuts
1256 bool METTester::isGoodTrack( const reco::TrackRef track, float d0corr ) {
1257 
1258  if( fabs( d0corr ) > maxd0_ ) return false;
1259  if( track->numberOfValidHits() < minhits_ ) return false;
1260  if( track->normalizedChi2() > maxchi2_ ) return false;
1261  if( fabs( track->eta() ) > maxeta_ ) return false;
1262  if( track->pt() > maxpt_ ) return false;
1263  if( (track->ptError() / track->pt()) > maxPtErr_ ) return false;
1264 
1265  int cut = 0;
1266  for( unsigned int i = 0; i < trkQuality_.size(); i++ ) {
1267 
1268  cut |= (1 << trkQuality_.at(i));
1269  }
1270 
1271  if( !( ( track->qualityMask() & cut ) == cut ) ) return false;
1272 
1273  bool isGoodAlgo = false;
1274  if( trkAlgos_.size() == 0 ) isGoodAlgo = true;
1275  for( unsigned int i = 0; i < trkAlgos_.size(); i++ ) {
1276 
1277  if( track->algo() == trkAlgos_.at(i) ) isGoodAlgo = true;
1278  }
1279 
1280  if( !isGoodAlgo ) return false;
1281 
1282  return true;
1283 }
type
Definition: HCALResponse.h:22
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
int i
Definition: DBlmapReader.cc:9
edm::InputTag inputCaloMETLabel_
Definition: METTester.h:54
double hadEtInHE() const
Definition: CaloMET.h:51
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:81
Collection of Gen MET.
double maxchi2_
Definition: METTester.h:65
edm::InputTag inputTrackLabel_
Definition: METTester.h:55
std::string FolderName_
Definition: METTester.h:51
double hadEtInHF() const
Definition: CaloMET.h:53
virtual void analyze(const edm::Event &, const edm::EventSetup &)
Definition: METTester.cc:519
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:717
double CaloSETInmHF() const
Definition: CaloMET.h:65
double maxEtInHadTowers() const
Definition: CaloMET.h:40
virtual void beginRun(const edm::Run &, const edm::EventSetup &)
Definition: METTester.cc:94
double MuonEtFraction() const
Definition: GenMET.h:57
double maxEtInEmTowers() const
Definition: CaloMET.h:38
std::string METType_
Definition: METTester.h:50
std::vector< int > trkQuality_
Definition: METTester.h:69
DQMStore * dbe_
Definition: METTester.h:46
edm::InputTag inputElectronLabel_
Definition: METTester.h:57
std::vector< int > trkAlgos_
Definition: METTester.h:70
std::string sample_
Definition: METTester.h:52
Collection of Calo MET.
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:250
void FillpfMETRes()
Definition: METTester.cc:1230
double mEtSig() const
Definition: MET.h:50
int iEvent
Definition: GenABIO.cc:243
double sumEt() const
Definition: MET.h:48
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: MET.h:32
edm::InputTag inputBeamSpotLabel_
Definition: METTester.h:58
double ChargedEMEtFraction() const
Definition: GenMET.h:39
double maxPtErr_
Definition: METTester.h:68
double emEtInEB() const
Definition: CaloMET.h:55
Collection of MET.
bool isValid() const
Definition: HandleBase.h:76
double CaloSETInpHF() const
Definition: CaloMET.h:63
edm::InputTag inputMuonLabel_
Definition: METTester.h:56
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double InvisibleEtFraction() const
Definition: GenMET.h:63
bool finebinning_
Definition: METTester.h:59
double hadEtInHO() const
Definition: CaloMET.h:49
double maxpt_
Definition: METTester.h:67
double etFractionHadronic() const
Definition: CaloMET.h:42
virtual double px() const
x coordinate of momentum vector
virtual double pt() const
transverse momentum
XYZPointD XYZPoint
point in space with cartesian internal representation
Definition: Point3D.h:13
tuple tcMet
Definition: TCMET_cfi.py:9
key_type key() const
Accessor for product key.
Definition: Ref.h:266
std::map< std::string, MonitorElement * > me
Definition: METTester.h:47
T const * product() const
Definition: Handle.h:74
std::string const & label() const
Definition: InputTag.h:25
double NeutralEMEtFraction() const
Definition: GenMET.h:33
double emEtInEE() const
Definition: CaloMET.h:57
int minhits_
Definition: METTester.h:63
virtual void endJob()
Definition: METTester.cc:1225
METTester(const edm::ParameterSet &)
Definition: METTester.cc:69
double NeutralHadEtFraction() const
Definition: GenMET.h:45
bool isGoodTrack(const reco::TrackRef, float d0corr)
Definition: METTester.cc:1256
double maxeta_
Definition: METTester.h:66
double emEtInHF() const
Definition: CaloMET.h:59
tuple cout
Definition: gather_cfg.py:121
edm::InputTag inputMETLabel_
Definition: METTester.h:53
double ChargedHadEtFraction() const
Definition: GenMET.h:51
double maxd0_
Definition: METTester.h:64
virtual double phi() const
momentum azimuthal angle
double hadEtInHB() const
Definition: CaloMET.h:47
virtual double py() const
y coordinate of momentum vector
double emEtFraction() const
Definition: CaloMET.h:45
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33
Collection of PF MET.