CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
METAnalyzer.cc
Go to the documentation of this file.
1 
20 
22 
27 
29 
33 
34 #include <string>
35 
36 using namespace edm;
37 using namespace reco;
38 using namespace math;
39 
40 // ***********************************************************
42  parameters = pSet;
43 
44  outputMEsInRootFile = parameters.getParameter<bool>("OutputMEsInRootFile");
45  mOutputFile_ = parameters.getParameter<std::string>("OutputFile");
46 
47  LSBegin_ = pSet.getParameter<int>("LSBegin");
48  LSEnd_ = pSet.getParameter<int>("LSEnd");
49 
50  MetType_ = parameters.getUntrackedParameter<std::string>("METType");
51 
52  triggerResultsLabel_ = parameters.getParameter<edm::InputTag>("TriggerResultsLabel");
53  triggerResultsToken_= consumes<edm::TriggerResults>(edm::InputTag(triggerResultsLabel_));
54  jetCorrectionService_ = pSet.getParameter<std::string> ("JetCorrections");
55 
56  isCaloMet_ = (std::string("calo")==MetType_);
57  //isTCMet_ = (std::string("tc") ==MetType_);
58  isPFMet_ = (std::string("pf") ==MetType_);
59 
60  // MET information
61  metCollectionLabel_ = parameters.getParameter<edm::InputTag>("METCollectionLabel");
62 
63  if(/*isTCMet_ || */isCaloMet_){
64  inputJetIDValueMap = pSet.getParameter<edm::InputTag>("InputJetIDValueMap");
65  jetID_ValueMapToken_= consumes< edm::ValueMap<reco::JetID> >(inputJetIDValueMap);
67  }
68  if(isPFMet_){
70  }
71  ptThreshold_ = parameters.getParameter<double>("ptThreshold");
72 
73 
74  if(isPFMet_){
75  pfMetToken_= consumes<reco::PFMETCollection>(edm::InputTag(metCollectionLabel_));
76  }
77  if(isCaloMet_){
78  caloMetToken_= consumes<reco::CaloMETCollection>(edm::InputTag(metCollectionLabel_));
79  }
80  //if(isTCMet_){
81  // tcMetToken_= consumes<reco::METCollection>(edm::InputTag(metCollectionLabel_));
82  //}
83 
84  fill_met_high_level_histo = parameters.getParameter<bool>("fillMetHighLevel");
85 
86  hTriggerLabelsIsSet_ = false;
87  //jet cleanup parameters
88  cleaningParameters_ = pSet.getParameter<ParameterSet>("CleaningParameters");
89 
90  edm::ConsumesCollector iC = consumesCollector();
91  //DCS
92  DCSFilter_ = new JetMETDQMDCSFilter(parameters.getParameter<ParameterSet>("DCSFilter"), iC );
93 
94  //Vertex requirements
95  bypassAllPVChecks_ = cleaningParameters_.getParameter<bool>("bypassAllPVChecks");
96  bypassAllDCSChecks_ = cleaningParameters_.getParameter<bool>("bypassAllDCSChecks");
97  runcosmics_ = parameters.getUntrackedParameter<bool>("runcosmics");
98  vertexTag_ = cleaningParameters_.getParameter<edm::InputTag>("vertexCollection");
99  vertexToken_ = consumes<std::vector<reco::Vertex> >(edm::InputTag(vertexTag_));
100 
101  //Trigger parameters
102  gtTag_ = cleaningParameters_.getParameter<edm::InputTag>("gtLabel");
103  gtToken_= consumes<L1GlobalTriggerReadoutRecord>(edm::InputTag(gtTag_));
104 
105  //inputTrackLabel_ = parameters.getParameter<edm::InputTag>("InputTrackLabel");
106  //inputMuonLabel_ = parameters.getParameter<edm::InputTag>("InputMuonLabel");
107  //inputElectronLabel_ = parameters.getParameter<edm::InputTag>("InputElectronLabel");
108  //inputBeamSpotLabel_ = parameters.getParameter<edm::InputTag>("InputBeamSpotLabel");
109  //inputTCMETValueMap_ = parameters.getParameter<edm::InputTag>("InputTCMETValueMap");
110  //TrackToken_= consumes<edm::View <reco::Track> >(inputTrackLabel_);
111  //MuonToken_= consumes<reco::MuonCollection>(inputMuonLabel_);
112  //ElectronToken_= consumes<edm::View<reco::GsfElectron> >(inputElectronLabel_);
113  //BeamspotToken_= consumes<reco::BeamSpot>(inputBeamSpotLabel_);
114  //tcMETValueMapToken_= consumes< edm::ValueMap<reco::MuonMETCorrectionData> >(inputTCMETValueMap_);
115 
116  // Other data collections
117  jetCollectionLabel_ = parameters.getParameter<edm::InputTag>("JetCollectionLabel");
118  if (isCaloMet_) caloJetsToken_ = consumes<reco::CaloJetCollection>(jetCollectionLabel_);
119  //if (isTCMet_) jptJetsToken_ = consumes<reco::JPTJetCollection>(jetCollectionLabel_);
120  if (isPFMet_) pfJetsToken_ = consumes<reco::PFJetCollection>(jetCollectionLabel_);
121 
122  hcalNoiseRBXCollectionTag_ = parameters.getParameter<edm::InputTag>("HcalNoiseRBXCollection");
123  HcalNoiseRBXToken_ = consumes<reco::HcalNoiseRBXCollection>(hcalNoiseRBXCollectionTag_);
124 
125  beamHaloSummaryTag_ = parameters.getParameter<edm::InputTag>("BeamHaloSummaryLabel");
126  beamHaloSummaryToken_ = consumes<BeamHaloSummary>(beamHaloSummaryTag_);
127  hbheNoiseFilterResultTag_ = parameters.getParameter<edm::InputTag>("HBHENoiseFilterResultLabel");
128  hbheNoiseFilterResultToken_=consumes<bool>(hbheNoiseFilterResultTag_);
129 
130  //
131  nbinsPV_ = parameters.getParameter<int>("pVBin");
132  nPVMin_ = parameters.getParameter<double>("pVMin");
133  nPVMax_ = parameters.getParameter<double>("pVMax");
134 
135  triggerSelectedSubFolders_ = parameters.getParameter<edm::VParameterSet>("triggerSelectedSubFolders");
136  for (edm::VParameterSet::const_iterator it = triggerSelectedSubFolders_.begin(); it!= triggerSelectedSubFolders_.end(); it++) {
137  triggerFolderEventFlag_.push_back(new GenericTriggerEventFlag( *it, consumesCollector() ));
138  triggerFolderExpr_.push_back(it->getParameter<std::vector<std::string> >("hltPaths"));
139  triggerFolderLabels_.push_back(it->getParameter<std::string>("label"));
140  }
141 
142  cleaningParameters_ = parameters.getParameter<ParameterSet>("CleaningParameters");
143 
144  verbose_ = parameters.getParameter<int>("verbose");
145 
146  FolderName_ = parameters.getUntrackedParameter<std::string>("FolderName");
147 
148 }
149 
150 // ***********************************************************
152  for (std::vector<GenericTriggerEventFlag *>::const_iterator it = triggerFolderEventFlag_.begin(); it!= triggerFolderEventFlag_.end(); it++) {
153  delete *it;
154  }
155  delete DCSFilter_;
156 }
157 
158 
160  edm::Run const & iRun,
161  edm::EventSetup const &) {
162  std::string DirName = FolderName_+metCollectionLabel_.label();
163  ibooker.setCurrentFolder(DirName);
164 
165  folderNames_.push_back("Uncleaned");
166  folderNames_.push_back("Cleaned");
167  folderNames_.push_back("DiJet");
168 
169  for (std::vector<std::string>::const_iterator ic = folderNames_.begin();
170  ic != folderNames_.end(); ic++){
171  bookMESet(DirName+"/"+*ic, ibooker,map_dijet_MEs);
172  }
173 }
174 
175 
176 // ***********************************************************
177 void METAnalyzer::bookMESet(std::string DirName, DQMStore::IBooker & ibooker, std::map<std::string,MonitorElement*>& map_of_MEs)
178 {
179  bool bLumiSecPlot=fill_met_high_level_histo;
180  //if (DirName.find("Uncleaned")!=std::string::npos)bLumiSecPlot=true;//now defined on configlevel
181  bookMonitorElement(DirName,ibooker,map_of_MEs,bLumiSecPlot);
182 
183  if (DirName.find("Cleaned")!=std::string::npos) {
184  for (unsigned int i = 0; i<triggerFolderEventFlag_.size(); i++) {
185  if (triggerFolderEventFlag_[i]->on()) {
186  bookMonitorElement(DirName+"/"+triggerFolderLabels_[i],ibooker,map_of_MEs,false);
187  }
188  }
189  }
190 }
191 
192 // ***********************************************************
193 void METAnalyzer::bookMonitorElement(std::string DirName,DQMStore::IBooker & ibooker, std::map<std::string,MonitorElement*>& map_of_MEs, bool bLumiSecPlot=false)
194 {
195  if (verbose_) std::cout << "bookMonitorElement " << DirName << std::endl;
196 
197  ibooker.setCurrentFolder(DirName);
198 
199  hTrigger = ibooker.book1D("triggerResults", "triggerResults", 500, 0, 500);
200  hMEx = ibooker.book1D("MEx", "MEx", 200, -500, 500);
201  hMEy = ibooker.book1D("MEy", "MEy", 200, -500, 500);
202  hMET = ibooker.book1D("MET", "MET", 200, 0, 1000);
203  hSumET = ibooker.book1D("SumET", "SumET", 400, 0, 4000);
204  hMETSig = ibooker.book1D("METSig", "METSig", 51, 0, 51);
205  hMETPhi = ibooker.book1D("METPhi", "METPhi", 60, -3.2, 3.2);
206  hMET_logx = ibooker.book1D("MET_logx", "MET_logx", 40, -1, 7);
207  hSumET_logx = ibooker.book1D("SumET_logx", "SumET_logx", 40, -1, 7);
208 
209  hMEx ->setAxisTitle("MEx [GeV]", 1);
210  hMEy ->setAxisTitle("MEy [GeV]", 1);
211  hMET ->setAxisTitle("MET [GeV]", 1);
212  hSumET ->setAxisTitle("SumET [GeV]", 1);
213  hMETSig ->setAxisTitle("METSig", 1);
214  hMETPhi ->setAxisTitle("METPhi [rad]", 1);
215  hMET_logx ->setAxisTitle("log(MET) [GeV]", 1);
216  hSumET_logx->setAxisTitle("log(SumET) [GeV]", 1);
217 
218  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"triggerResults",hTrigger));
219  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"MEx",hMEx));
220  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"MEy",hMEy));
221  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"MET",hMET));
222  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"SumET",hSumET));
223  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"METSig",hMETSig));
224  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"METPhi",hMETPhi));
225  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"MET_logx",hMET_logx));
226  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"SumET_logx",hSumET_logx));
227 
228  // Book NPV profiles --> would some of these profiles be interesting for other MET types too
229  //----------------------------------------------------------------------------
230  meMEx_profile = ibooker.bookProfile("MEx_profile", "met.px()", nbinsPV_, nPVMin_, nPVMax_, 200, -500, 500);
231  meMEy_profile = ibooker.bookProfile("MEy_profile", "met.py()", nbinsPV_, nPVMin_, nPVMax_, 200, -500, 500);
232  meMET_profile = ibooker.bookProfile("MET_profile", "met.pt()", nbinsPV_, nPVMin_, nPVMax_, 200, 0, 1000);
233  meSumET_profile = ibooker.bookProfile("SumET_profile", "met.sumEt()", nbinsPV_, nPVMin_, nPVMax_, 400, 0, 4000);
234  // Set NPV profiles x-axis title
235  //----------------------------------------------------------------------------
236  meMEx_profile ->setAxisTitle("nvtx", 1);
237  meMEy_profile ->setAxisTitle("nvtx", 1);
238  meMET_profile ->setAxisTitle("nvtx", 1);
239  meSumET_profile->setAxisTitle("nvtx", 1);
240 
241  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"MEx_profile",meMEx_profile));
242  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"MEy_profile",meMEy_profile));
243  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"MET_profile",meMET_profile));
244  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"SumET_profile",meSumET_profile));
245 
246 
247  if(isCaloMet_){
248  hCaloMaxEtInEmTowers = ibooker.book1D("CaloMaxEtInEmTowers", "CaloMaxEtInEmTowers" ,100,0,2000);
249  hCaloMaxEtInEmTowers->setAxisTitle("Et(Max) in EM Tower [GeV]",1);
250  hCaloMaxEtInHadTowers = ibooker.book1D("CaloMaxEtInHadTowers", "CaloMaxEtInHadTowers" ,100,0,2000);
251  hCaloMaxEtInHadTowers->setAxisTitle("Et(Max) in Had Tower [GeV]",1);
252 
253  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloMaxEtInEmTowers",hCaloMaxEtInEmTowers));
254  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloMaxEtInHadTowers",hCaloMaxEtInHadTowers));
255 
256  hCaloHadEtInHB = ibooker.book1D("CaloHadEtInHB","CaloHadEtInHB",100,0,2000);
257  hCaloHadEtInHB->setAxisTitle("Had Et [GeV]",1);
258  hCaloHadEtInHO = ibooker.book1D("CaloHadEtInHO","CaloHadEtInHO",25,0,500);
259  hCaloHadEtInHO->setAxisTitle("Had Et [GeV]",1);
260  hCaloHadEtInHE = ibooker.book1D("CaloHadEtInHE","CaloHadEtInHE",100,0,2000);
261  hCaloHadEtInHE->setAxisTitle("Had Et [GeV]",1);
262  hCaloHadEtInHF = ibooker.book1D("CaloHadEtInHF","CaloHadEtInHF",50,0,1000);
263  hCaloHadEtInHF->setAxisTitle("Had Et [GeV]",1);
264  hCaloEmEtInHF = ibooker.book1D("CaloEmEtInHF" ,"CaloEmEtInHF" ,25,0,500);
265  hCaloEmEtInHF->setAxisTitle("EM Et [GeV]",1);
266  hCaloEmEtInEE = ibooker.book1D("CaloEmEtInEE" ,"CaloEmEtInEE" ,50,0,1000);
267  hCaloEmEtInEE->setAxisTitle("EM Et [GeV]",1);
268  hCaloEmEtInEB = ibooker.book1D("CaloEmEtInEB" ,"CaloEmEtInEB" ,100,0,2000);
269  hCaloEmEtInEB->setAxisTitle("EM Et [GeV]",1);
270 
271  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloHadEtInHO",hCaloHadEtInHO));
272  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloHadEtInHF",hCaloHadEtInHF));
273  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloHadEtInHE",hCaloHadEtInHE));
274  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloHadEtInHB",hCaloHadEtInHB));
275  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloEmEtInHF",hCaloEmEtInHF));
276  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloEmEtInEE",hCaloEmEtInEE));
277  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloEmEtInEB",hCaloEmEtInEB));
278 
279  hCaloMETPhi020 = ibooker.book1D("CaloMETPhi020", "CaloMETPhi020", 60, -3.2, 3.2);
280  hCaloMETPhi020 ->setAxisTitle("METPhi [rad] (MET>20 GeV)", 1);
281 
282  //hCaloMaxEtInEmTowers = ibooker.book1D("CaloMaxEtInEmTowers", "CaloMaxEtInEmTowers" ,100,0,2000);
283  //hCaloMaxEtInEmTowers->setAxisTitle("Et(Max) in EM Tower [GeV]",1);
284  //hCaloMaxEtInHadTowers = ibooker.book1D("CaloMaxEtInHadTowers", "CaloMaxEtInHadTowers" ,100,0,2000);
285  //hCaloMaxEtInHadTowers->setAxisTitle("Et(Max) in Had Tower [GeV]",1);
286  hCaloEtFractionHadronic = ibooker.book1D("CaloEtFractionHadronic","CaloEtFractionHadronic",100,0,1);
287  hCaloEtFractionHadronic->setAxisTitle("Hadronic Et Fraction",1);
288  hCaloEmEtFraction = ibooker.book1D("CaloEmEtFraction", "CaloEmEtFraction" ,100,0,1);
289  hCaloEmEtFraction->setAxisTitle("EM Et Fraction",1);
290 
291  //hCaloEmEtFraction002 = ibooker.book1D("CaloEmEtFraction002", "CaloEmEtFraction002" ,100,0,1);
292  //hCaloEmEtFraction002->setAxisTitle("EM Et Fraction (MET>2 GeV)",1);
293  //hCaloEmEtFraction010 = ibooker.book1D("CaloEmEtFraction010", "CaloEmEtFraction010" ,100,0,1);
294  //hCaloEmEtFraction010->setAxisTitle("EM Et Fraction (MET>10 GeV)",1);
295  hCaloEmEtFraction020 = ibooker.book1D("CaloEmEtFraction020", "CaloEmEtFraction020" ,100,0,1);
296  hCaloEmEtFraction020->setAxisTitle("EM Et Fraction (MET>20 GeV)",1);
297 
298  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloMETPhi020",hCaloMETPhi020));
299  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloEtFractionHadronic",hCaloEtFractionHadronic));
300  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloEmEtFraction", hCaloEmEtFraction));
301  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloEmEtFraction020",hCaloEmEtFraction020));
302 
303 
304 
305  //if (metCollectionLabel_.label() == "corMetGlobalMuons" ) {
306  //hCalomuPt = ibooker.book1D("CalomuonPt", "CalomuonPt", 50, 0, 500);
307  //hCalomuEta = ibooker.book1D("CalomuonEta", "CalomuonEta", 60, -3.0, 3.0);
308  //hCalomuNhits = ibooker.book1D("CalomuonNhits", "CalomuonNhits", 50, 0, 50);
309  //hCalomuChi2 = ibooker.book1D("CalomuonNormalizedChi2", "CalomuonNormalizedChi2", 20, 0, 20);
310  //hCalomuD0 = ibooker.book1D("CalomuonD0", "CalomuonD0", 50, -1, 1);
311  //hCaloMExCorrection = ibooker.book1D("CaloMExCorrection", "CaloMExCorrection", 100, -500.0,500.0);
312  //hCaloMEyCorrection = ibooker.book1D("CaloMEyCorrection", "CaloMEyCorrection", 100, -500.0,500.0);
313  //hCaloMuonCorrectionFlag = ibooker.book1D("CaloCorrectionFlag","CaloCorrectionFlag", 5, -0.5, 4.5);
314 
315  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CalomuonPt",hCalomuPt));
316  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CalomuonEta",hCalomuEta));
317  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CalomuonNhit",hCalomuNhits));
318  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CalomuonNormalizedChi2",hCalomuChi2));
319  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloMExCorrection",hCaloMExCorrection));
320  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloMEyCorrection",hCaloMEyCorrection));
321  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CaloCorrectionFlag",hCaloMuonCorrectionFlag));
322  //}
323 
324  }
325 
326  if(isPFMet_){
327  mePhotonEtFraction = ibooker.book1D("PfPhotonEtFraction", "pfmet.photonEtFraction()", 50, 0, 1);
328  mePhotonEt = ibooker.book1D("PfPhotonEt", "pfmet.photonEt()", 100, 0, 1000);
329  meNeutralHadronEtFraction = ibooker.book1D("PfNeutralHadronEtFraction", "pfmet.neutralHadronEtFraction()", 50, 0, 1);
330  meNeutralHadronEt = ibooker.book1D("PfNeutralHadronEt", "pfmet.neutralHadronEt()", 100, 0, 1000);
331  meElectronEtFraction = ibooker.book1D("PfElectronEtFraction", "pfmet.electronEtFraction()", 50, 0, 1);
332  meElectronEt = ibooker.book1D("PfElectronEt", "pfmet.electronEt()", 100, 0, 1000);
333  meChargedHadronEtFraction = ibooker.book1D("PfChargedHadronEtFraction", "pfmet.chargedHadronEtFraction()", 50, 0, 1);
334  meChargedHadronEt = ibooker.book1D("PfChargedHadronEt", "pfmet.chargedHadronEt()", 100, 0, 1000);
335  meMuonEtFraction = ibooker.book1D("PfMuonEtFraction", "pfmet.muonEtFraction()", 50, 0, 1);
336  meMuonEt = ibooker.book1D("PfMuonEt", "pfmet.muonEt()", 100, 0, 1000);
337  meHFHadronEtFraction = ibooker.book1D("PfHFHadronEtFraction", "pfmet.HFHadronEtFraction()", 50, 0, 1);
338  meHFHadronEt = ibooker.book1D("PfHFHadronEt", "pfmet.HFHadronEt()", 100, 0, 1000);
339  meHFEMEtFraction = ibooker.book1D("PfHFEMEtFraction", "pfmet.HFEMEtFraction()", 50, 0, 1);
340  meHFEMEt = ibooker.book1D("PfHFEMEt", "pfmet.HFEMEt()", 100, 0, 1000);
341 
342  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfPhotonEtFraction" ,mePhotonEtFraction));
343  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfPhotonEt" ,mePhotonEt));
344  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfNeutralHadronEtFraction",meNeutralHadronEtFraction));
345  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfNeutralHadronEt" ,meNeutralHadronEt));
346  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfElectronEtFraction" ,meElectronEtFraction));
347  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfElectronEt" ,meElectronEt));
348  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfChargedHadronEtFraction",meChargedHadronEtFraction));
349  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfChargedHadronEt" ,meChargedHadronEt));
350  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfMuonEtFraction" ,meMuonEtFraction));
351  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfMuonEt" ,meMuonEt));
352  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfHFHadronEtFraction" ,meHFHadronEtFraction));
353  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfHFHadronEt" ,meHFHadronEt));
354  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfHFEMEtFraction" ,meHFEMEtFraction));
355  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfHFEMEt" ,meHFEMEt));
356 
357  mePhotonEtFraction_profile = ibooker.bookProfile("PfPhotonEtFraction_profile", "pfmet.photonEtFraction()", nbinsPV_, nPVMin_, nPVMax_, 50, 0, 1);
358  mePhotonEt_profile = ibooker.bookProfile("PfPhotonEt_profile", "pfmet.photonEt()", nbinsPV_, nPVMin_, nPVMax_, 100, 0, 1000);
359  meNeutralHadronEtFraction_profile = ibooker.bookProfile("PfNeutralHadronEtFraction_profile", "pfmet.neutralHadronEtFraction()", nbinsPV_, nPVMin_, nPVMax_, 50, 0, 1);
360  meNeutralHadronEt_profile = ibooker.bookProfile("PfNeutralHadronEt_profile", "pfmet.neutralHadronEt()", nbinsPV_, nPVMin_, nPVMax_, 100, 0, 1000);
361  meElectronEtFraction_profile = ibooker.bookProfile("PfElectronEtFraction_profile", "pfmet.electronEtFraction()", nbinsPV_, nPVMin_, nPVMax_, 50, 0, 1);
362  meElectronEt_profile = ibooker.bookProfile("PfElectronEt_profile", "pfmet.electronEt()", nbinsPV_, nPVMin_, nPVMax_, 100, 0, 1000);
363  meChargedHadronEtFraction_profile = ibooker.bookProfile("PfChargedHadronEtFraction_profile", "pfmet.chargedHadronEtFraction()", nbinsPV_, nPVMin_, nPVMax_, 50, 0, 1);
364  meChargedHadronEt_profile = ibooker.bookProfile("PfChargedHadronEt_profile", "pfmet.chargedHadronEt()", nbinsPV_, nPVMin_, nPVMax_, 100, 0, 1000);
365  meMuonEtFraction_profile = ibooker.bookProfile("PfMuonEtFraction_profile", "pfmet.muonEtFraction()", nbinsPV_, nPVMin_, nPVMax_, 50, 0, 1);
366  meMuonEt_profile = ibooker.bookProfile("PfMuonEt_profile", "pfmet.muonEt()", nbinsPV_, nPVMin_, nPVMax_, 100, 0, 1000);
367  meHFHadronEtFraction_profile = ibooker.bookProfile("PfHFHadronEtFraction_profile", "pfmet.HFHadronEtFraction()", nbinsPV_, nPVMin_, nPVMax_, 50, 0, 1);
368  meHFHadronEt_profile = ibooker.bookProfile("PfHFHadronEt_profile", "pfmet.HFHadronEt()", nbinsPV_, nPVMin_, nPVMax_, 100, 0, 1000);
369  meHFEMEtFraction_profile = ibooker.bookProfile("PfHFEMEtFraction_profile", "pfmet.HFEMEtFraction()", nbinsPV_, nPVMin_, nPVMax_, 50, 0, 1);
370  meHFEMEt_profile = ibooker.bookProfile("PfHFEMEt_profile", "pfmet.HFEMEt()", nbinsPV_, nPVMin_, nPVMax_, 100, 0, 1000);
371 
372  mePhotonEtFraction_profile ->setAxisTitle("nvtx", 1);
373  mePhotonEt_profile ->setAxisTitle("nvtx", 1);
374  meNeutralHadronEtFraction_profile->setAxisTitle("nvtx", 1);
375  meNeutralHadronEt_profile ->setAxisTitle("nvtx", 1);
376  meElectronEtFraction_profile ->setAxisTitle("nvtx", 1);
377  meElectronEt_profile ->setAxisTitle("nvtx", 1);
378  meChargedHadronEtFraction_profile->setAxisTitle("nvtx", 1);
379  meChargedHadronEt_profile ->setAxisTitle("nvtx", 1);
380  meMuonEtFraction_profile ->setAxisTitle("nvtx", 1);
381  meMuonEt_profile ->setAxisTitle("nvtx", 1);
382  meHFHadronEtFraction_profile ->setAxisTitle("nvtx", 1);
383  meHFHadronEt_profile ->setAxisTitle("nvtx", 1);
384  meHFEMEtFraction_profile ->setAxisTitle("nvtx", 1);
385  meHFEMEt_profile ->setAxisTitle("nvtx", 1);
386 
387  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfPhotonEtFraction_profile" ,mePhotonEtFraction_profile));
388  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfPhotonEt_profile" ,mePhotonEt_profile));
389  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfNeutralHadronEtFraction_profile" ,meNeutralHadronEtFraction_profile));
390  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfNeutralHadronEt_profile" ,meNeutralHadronEt_profile));
391  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfElectronEtFraction_profile" ,meElectronEtFraction_profile));
392  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfElectronEt_profile" ,meElectronEt_profile));
393  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfChargedHadronEtFraction_profile" ,meChargedHadronEtFraction_profile));
394  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfChargedHadronEt_profile" ,meChargedHadronEt_profile));
395  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfMuonEtFraction_profile" ,meMuonEtFraction_profile));
396  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfMuonEt_profile" ,meMuonEt_profile));
397  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfHFHadronEtFraction_profile" ,meHFHadronEtFraction_profile));
398  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfHFHadronEt_profile" ,meHFHadronEt_profile));
399  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfHFEMEtFraction_profile" ,meHFEMEtFraction_profile));
400  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"PfHFEMEt_profile" ,meHFEMEt_profile));
401  }
402 
403  if (isCaloMet_){
404  if (fill_met_high_level_histo){//now configurable in python file
405  hMExLS = ibooker.book2D("MExLS","MEx_LS",200,-200,200,250,0.,2500.);
406  hMExLS->setAxisTitle("MEx [GeV]",1);
407  hMExLS->setAxisTitle("Lumi Section",2);
408  hMExLS->getTH2F()->SetOption("colz");
409  hMEyLS = ibooker.book2D("MEyLS","MEy_LS",200,-200,200,250,0.,2500.);
410  hMEyLS->setAxisTitle("MEy [GeV]",1);
411  hMEyLS->setAxisTitle("Lumi Section",2);
412  hMEyLS->getTH2F()->SetOption("colz");
413  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"MExLS",hMExLS));
414  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"MEyLS",hMEyLS));
415  }
416  }
417 
418  //if (isTCMet_) {
419  //htrkPt = ibooker.book1D("trackPt", "trackPt", 50, 0, 500);
420  //htrkEta = ibooker.book1D("trackEta", "trackEta", 60, -3.0, 3.0);
421  //htrkNhits = ibooker.book1D("trackNhits", "trackNhits", 50, 0, 50);
422  //htrkChi2 = ibooker.book1D("trackNormalizedChi2", "trackNormalizedChi2", 20, 0, 20);
423  //htrkD0 = ibooker.book1D("trackD0", "trackd0", 50, -1, 1);
424  //helePt = ibooker.book1D("electronPt", "electronPt", 50, 0, 500);
425  //heleEta = ibooker.book1D("electronEta", "electronEta", 60, -3.0, 3.0);
426  //heleHoE = ibooker.book1D("electronHoverE", "electronHoverE", 25, 0, 0.5);
427  //hmuPt = ibooker.book1D("muonPt", "muonPt", 50, 0, 500);
428  //hmuEta = ibooker.book1D("muonEta", "muonEta", 60, -3.0, 3.0);
429  //hmuNhits = ibooker.book1D("muonNhits", "muonNhits", 50, 0, 50);
430  //hmuChi2 = ibooker.book1D("muonNormalizedChi2", "muonNormalizedChi2", 20, 0, 20);
431  //hmuD0 = ibooker.book1D("muonD0", "muonD0", 50, -1, 1);
432 
433  //hMExCorrection = ibooker.book1D("MExCorrection", "MExCorrection", 100, -500.0,500.0);
434  //hMEyCorrection = ibooker.book1D("MEyCorrection", "MEyCorrection", 100, -500.0,500.0);
435  //hMuonCorrectionFlag = ibooker.book1D("CorrectionFlag","CorrectionFlag", 5, -0.5, 4.5);
436 
437  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"trackPt" ,htrkPt));
438  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"trackEta" ,htrkEta));
439  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"trackNhits",htrkNhits));
440  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"trackNormalizedChi2" ,htrkChi2));
441  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"trackD0" ,htrkD0));
442  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"electronPt" ,helePt));
443  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"electronEta" ,heleEta));
444  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"electronHoverE",heleHoE));
445  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"muonPt" ,hmuPt));
446  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"muonEta" ,hmuEta));
447  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"muonNhits",hmuNhits));
448  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"muonNormalizedChi2" ,hmuChi2));
449  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"muonD0" ,hmuD0));
450  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"MExCorrection" ,hMExCorrection));
451  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"MEyCorrection" ,hMEyCorrection));
452  //map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"CorrectionFlag" ,hMuonCorrectionFlag));
453  //}
454 
455  hMETRate = ibooker.book1D("METRate", "METRate", 200, 0, 1000);
456  map_of_MEs.insert(std::pair<std::string,MonitorElement*>(DirName+"/"+"METRate",hMETRate));
457 
458 
459  ibooker.setCurrentFolder("JetMET");
460  lumisecME = ibooker.book1D("lumisec", "lumisec", 2500, 0., 2500.);
461  map_of_MEs.insert(std::pair<std::string,MonitorElement*>("JetMET/lumisec",lumisecME));
462 
463 }
464 
465 // ***********************************************************
466 void METAnalyzer::dqmBeginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
467 {
468 
469 // std::cout << "Run " << iRun.run() << " hltconfig.init "
470 // << hltConfig_.init(iRun,iSetup,triggerResultsLabel_.process(),changed_) << " length: "<<hltConfig_.triggerNames().size()<<" changed "<<changed_<<std::endl;
471  bool changed(true);
472  if (hltConfig_.init(iRun,iSetup,triggerResultsLabel_.process(),changed)) {
473  if (changed) {
474  hltConfig_.dump("ProcessName");
475  hltConfig_.dump("GlobalTag");
476  hltConfig_.dump("TableName");
477 // hltConfig_.dump("Streams");
478 // hltConfig_.dump("Datasets");
479 // hltConfig_.dump("PrescaleTable");
480 // hltConfig_.dump("ProcessPSet");
481  }
482  } else {
483  if (verbose_) std::cout << "HLTEventAnalyzerAOD::analyze:"
484  << " config extraction failure with process name "
485  << triggerResultsLabel_.process() << std::endl;
486  }
487 
488  allTriggerNames_.clear();
489  for (unsigned i = 0; i<hltConfig_.size();i++) {
490  allTriggerNames_.push_back(hltConfig_.triggerName(i));
491  }
492 // std::cout<<"Length: "<<allTriggerNames_.size()<<std::endl;
493 
494  triggerSelectedSubFolders_ = parameters.getParameter<edm::VParameterSet>("triggerSelectedSubFolders");
495  for ( std::vector<GenericTriggerEventFlag *>::const_iterator it = triggerFolderEventFlag_.begin(); it!= triggerFolderEventFlag_.end(); it++) {
496  int pos = it - triggerFolderEventFlag_.begin();
497  if ((*it)->on()) {
498  (*it)->initRun( iRun, iSetup );
499  if (triggerSelectedSubFolders_[pos].exists(std::string("hltDBKey"))) {
500 // std::cout<<"Looking for hltDBKey for"<<triggerFolderLabels_[pos]<<std::endl;
501  if ((*it)->expressionsFromDB((*it)->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
502  triggerFolderExpr_[pos] = (*it)->expressionsFromDB((*it)->hltDBKey(), iSetup);
503  }
504 // for (unsigned j = 0; j<triggerFolderExpr_[pos].size(); j++) std::cout<<"pos "<<pos<<" "<<triggerFolderLabels_[pos]<<" triggerFolderExpr_"<<triggerFolderExpr_[pos][j]<<std::endl;
505  }
506  }
507 }
508 
509 // ***********************************************************
510 void METAnalyzer::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
511 {
512 
513  //
514  //--- Check the time length of the Run from the lumi section plots
515 
516 
517  TH1F* tlumisec;
518 
519  MonitorElement *meLumiSec = map_dijet_MEs["aaa"];
520  meLumiSec = map_dijet_MEs["JetMET/lumisec"];
521 
522  int totlsec=0;
523  int totlssecsum=0;
524  double totltime=0.;
525  if (meLumiSec && meLumiSec->getRootObject() ) {
526  tlumisec = meLumiSec->getTH1F();
527  //check overflow bin (if we have more than 2500 LS in a run)
528  //lumisec is filled every time the analyze section is processed
529  //we know an LS is present only once in a run: normalize how many events we had on average
530  //if lumi fluctuates strongly might be unreliable for overflow bin though
531  for (int i=0; i< (tlumisec->GetNbinsX()); i++){
532  if (tlumisec->GetBinContent(i)!=0){
533  totlsec+=1;
534  totlssecsum+=tlumisec->GetBinContent(i);
535  }
536  }
537  int num_per_ls=(double)totlssecsum/(double)totlsec;
538  totlsec=totlsec+tlumisec->GetBinContent(tlumisec->GetNbinsX()+1)/(double)num_per_ls;
539  totltime = double(totlsec*90); // one lumi sec ~ 90 (sec)
540  }
541 
542  if (totltime==0.) totltime=1.;
543 
544  std::string dirName = FolderName_+metCollectionLabel_.label()+"/";
545  //dbe_->setCurrentFolder(dirName);
546 
547 
548 
549  //below is the original METAnalyzer formulation
550 
551  for (std::vector<std::string>::const_iterator ic = folderNames_.begin(); ic != folderNames_.end(); ic++) {
553  DirName = dirName+*ic;
554  makeRatePlot(DirName,totltime);
555  for ( std::vector<GenericTriggerEventFlag *>::const_iterator it = triggerFolderEventFlag_.begin(); it!= triggerFolderEventFlag_.end(); it++) {
556  int pos = it - triggerFolderEventFlag_.begin();
557  if ((*it)->on()) {
558  makeRatePlot(DirName+"/"+triggerFolderLabels_[pos],totltime);
559  }
560  }
561  }
562 
563 }
564 
565 
566 // ***********************************************************
568 {
569 
570  //dbe_->setCurrentFolder(DirName);
571  MonitorElement *meMET = map_dijet_MEs[DirName+"/"+"MET"];
572  MonitorElement *mMETRate = map_dijet_MEs[DirName+"/"+"METRate"];
573 
574  TH1F* tMET;
575  TH1F* tMETRate;
576 
577  if ( meMET && mMETRate){
578  if ( meMET->getRootObject() && mMETRate->getRootObject()) {
579  tMET = meMET->getTH1F();
580 
581  // Integral plot & convert number of events to rate (hz)
582  tMETRate = (TH1F*) tMET->Clone("METRateHist");
583  for (int i = tMETRate->GetNbinsX()-1; i>=0; i--){
584  mMETRate->setBinContent(i+1,tMETRate->GetBinContent(i+2)+tMET->GetBinContent(i+1));
585  }
586  for (int i = 0; i<tMETRate->GetNbinsX(); i++){
587  mMETRate->setBinContent(i+1,tMETRate->GetBinContent(i+1)/double(totltime));
588  }
589  }
590  }
591 
592 }
593 
594 // ***********************************************************
596 
597 
598  // *** Fill lumisection ME
599  int myLuminosityBlock;
600  myLuminosityBlock = iEvent.luminosityBlock();
601  if(fill_met_high_level_histo){
602  lumisecME=map_dijet_MEs["JetMET/lumisec"]; if(lumisecME && lumisecME->getRootObject()) lumisecME->Fill(myLuminosityBlock);
603  }
604 
605  if (myLuminosityBlock<LSBegin_) return;
606  if (myLuminosityBlock>LSEnd_ && LSEnd_>0) return;
607 
608  if (verbose_) std::cout << "METAnalyzer analyze" << std::endl;
609 
610  std::string DirName = FolderName_+metCollectionLabel_.label();
611 
612 
613 
614 
615  // ==========================================================
616  // Trigger information
617  //
618 // trigJetMB_=0;
619 // trigHighPtJet_=0;
620 // trigLowPtJet_=0;
621 // trigMinBias_=0;
622 // trigHighMET_=0;
623 // // _trig_LowMET=0;
624 // trigEle_=0;
625 // trigMuon_=0;
626 // trigPhysDec_=0;
627  std::vector<int> triggerFolderDecisions;
628  triggerFolderDecisions_ = std::vector<int> (triggerFolderEventFlag_.size(), 0);
629  // **** Get the TriggerResults container
631  iEvent.getByToken(triggerResultsToken_, triggerResults);
632 
633  if( triggerResults.isValid()) {
635  // Check how many HLT triggers are in triggerResults
636  int ntrigs = (*triggerResults).size();
637  if (verbose_) std::cout << "ntrigs=" << ntrigs << std::endl;
638  // If index=ntrigs, this HLT trigger doesn't exist in the HLT table for this data.
639  for (std::vector<GenericTriggerEventFlag *>::const_iterator it = triggerFolderEventFlag_.begin(); it!=triggerFolderEventFlag_.end();it++) {
640  unsigned pos = it - triggerFolderEventFlag_.begin();
641  bool fd = (*it)->accept(iEvent, iSetup);
642  triggerFolderDecisions_[pos] = fd;
643  }
644  allTriggerDecisions_.clear();
645  for (unsigned i=0;i<allTriggerNames_.size();++i) {
646  allTriggerDecisions_.push_back((*triggerResults).accept(i));
647 // std::cout<<"TR "<<(*triggerResults).size()<<" "<<(*triggerResults).accept(i)<<" "<<allTriggerNames_[i]<<std::endl;
648  }
649  }
650 
651  // ==========================================================
652  // MET information
653 
654  // **** Get the MET container
658 
659  //if(isTCMet_){
660  //iEvent.getByToken(tcMetToken_, tcmetcoll);
661  //if(!tcmetcoll.isValid()) return;
662  //}
663  if(isCaloMet_){
664  iEvent.getByToken(caloMetToken_, calometcoll);
665  if(!calometcoll.isValid()) return;
666  }
667  if(isPFMet_){
668  iEvent.getByToken(pfMetToken_, pfmetcoll);
669  if(!pfmetcoll.isValid()) return;
670  }
671 
672  const MET *met=NULL;
673  const PFMET *pfmet=NULL;
674  const CaloMET *calomet=NULL;
675  //if(isTCMet_){
676  //met=&(tcmetcoll->front());
677  //}
678  if(isPFMet_){
679  met=&(pfmetcoll->front());
680  pfmet=&(pfmetcoll->front());
681  }
682  if(isCaloMet_){
683  met=&(calometcoll->front());
684  calomet=&(calometcoll->front());
685  }
686 
687  LogTrace(metname)<<"[METAnalyzer] Call to the MET analyzer";
688 
689  // ==========================================================
690  // TCMET
691 
692  //if (/*isTCMet_ || */(isCaloMet_ && metCollectionLabel_.label() == "corMetGlobalMuons")) {
693 
694  //iEvent.getByToken(MuonToken_, muonHandle_);
695  //iEvent.getByToken(TrackToken_, trackHandle_);
696  //iEvent.getByToken(ElectronToken_, electronHandle_);
697  //iEvent.getByToken(BeamspotToken_, beamSpotHandle_);
698  //iEvent.getByToken(tcMETValueMapToken_,tcMetValueMapHandle_);
699 
700  //if(!muonHandle_.isValid()) edm::LogInfo("OutputInfo") << "falied to retrieve muon data require by MET Task";
701  //if(!trackHandle_.isValid()) edm::LogInfo("OutputInfo") << "falied to retrieve track data require by MET Task";
702  //if(!electronHandle_.isValid()) edm::LogInfo("OutputInfo") << "falied to retrieve electron data require by MET Task";
703  //if(!beamSpotHandle_.isValid()) edm::LogInfo("OutputInfo") << "falied to retrieve beam spot data require by MET Task";
704 
705  //beamSpot_ = ( beamSpotHandle_.isValid() ) ? beamSpotHandle_->position() : math::XYZPoint(0, 0, 0);
706  //}
707 
708  // ==========================================================
709  //
710 
712  iEvent.getByToken(HcalNoiseRBXToken_,HRBXCollection);
713  if (!HRBXCollection.isValid()) {
714  LogDebug("") << "METAnalyzer: Could not find HcalNoiseRBX Collection" << std::endl;
715  if (verbose_) std::cout << "METAnalyzer: Could not find HcalNoiseRBX Collection" << std::endl;
716  }
717 
718  edm::Handle<bool> HBHENoiseFilterResultHandle;
719  iEvent.getByToken(hbheNoiseFilterResultToken_, HBHENoiseFilterResultHandle);
720  bool HBHENoiseFilterResult = *HBHENoiseFilterResultHandle;
721  if (!HBHENoiseFilterResultHandle.isValid()) {
722  LogDebug("") << "METAnalyzer: Could not find HBHENoiseFilterResult" << std::endl;
723  if (verbose_) std::cout << "METAnalyzer: Could not find HBHENoiseFilterResult" << std::endl;
724  }
725 
726  // ==========================================================
727  bool bJetID = false;
728  bool bDiJetID = false;
729  // Jet ID -------------------------------------------------------
730  //
731 
735 
736  int collsize=-1;
737 
738  if (isCaloMet_){
739  iEvent.getByToken(caloJetsToken_, caloJets);
740  if (!caloJets.isValid()) {
741  LogDebug("") << "METAnalyzer: Could not find calojet product" << std::endl;
742  if (verbose_) std::cout << "METAnalyzer: Could not find calojet product" << std::endl;
743  }
744  collsize=caloJets->size();
745  }
747  //if (isTCMet_){
748  //iEvent.getByToken(jptJetsToken_, jptJets);
749  //if (!jptJets.isValid()) {
750  // LogDebug("") << "METAnalyzer: Could not find jptjet product" << std::endl;
751  // if (verbose_) std::cout << "METAnalyzer: Could not find jptjet product" << std::endl;
752  //}
753  //collsize=jptJets->size();
754  //}*/
755 
756  edm::Handle< edm::ValueMap<reco::JetID> >jetID_ValueMap_Handle;
757  if(/*isTCMet_ || */isCaloMet_){
758  if(!runcosmics_){
759  iEvent.getByToken(jetID_ValueMapToken_,jetID_ValueMap_Handle);
760  }
761  }
762 
763  if (isPFMet_){ iEvent.getByToken(pfJetsToken_, pfJets);
764  if (!pfJets.isValid()) {
765  LogDebug("") << "METAnalyzer: Could not find pfjet product" << std::endl;
766  if (verbose_) std::cout << "METAnalyzer: Could not find pfjet product" << std::endl;
767  }
768  collsize=pfJets->size();
769  }
770 
771  unsigned int ind1=-1;
772  double pt1=-1;
773  bool pass_jetID1=false;
774  unsigned int ind2=-1;
775  double pt2=-1;
776  bool pass_jetID2=false;
777 
778  //do loose jet ID-> check threshold on corrected jets
779  for (int ijet=0; ijet<collsize; ijet++) {
780  double pt_jet=-10;
781  double scale=1.;
782  bool iscleaned=false;
783  if (!jetCorrectionService_.empty()) {
784  const JetCorrector* corrector = JetCorrector::getJetCorrector(jetCorrectionService_, iSetup);
785  if(isCaloMet_){
786  scale = corrector->correction((*caloJets)[ijet], iEvent, iSetup);
787  }
788  //if(isTCMet_){
789  //scale = corrector->correction((*jptJets)[ijet], iEvent, iSetup);
790  //}
791  if(isPFMet_){
792  scale = corrector->correction((*pfJets)[ijet], iEvent, iSetup);
793  }
794  }
795  if(isCaloMet_){
796  pt_jet=scale*(*caloJets)[ijet].pt();
797  if(pt_jet> ptThreshold_){
798  reco::CaloJetRef calojetref(caloJets, ijet);
799  if(!runcosmics_){
800  reco::JetID jetID = (*jetID_ValueMap_Handle)[calojetref];
801  iscleaned = jetIDFunctorLoose((*caloJets)[ijet], jetID);
802  }else{
803  iscleaned=true;
804  }
805  }
806  }
808  //if(isTCMet_){
809  //pt_jet=scale*(*jptJets)[ijet].pt();
810  //if(pt_jet> ptThreshold_){
811  // const edm::RefToBase<reco::Jet>& rawJet = (*jptJets)[ijet].getCaloJetRef();
812  // const reco::CaloJet *rawCaloJet = dynamic_cast<const reco::CaloJet*>(&*rawJet);
813  // reco::CaloJetRef const theCaloJetRef = (rawJet).castTo<reco::CaloJetRef>();
814  // if(!runcosmics_){
815  // reco::JetID jetID = (*jetID_ValueMap_Handle)[theCaloJetRef];
816  // iscleaned = jetIDFunctorLoose(*rawCaloJet, jetID);
817  // }else{
818  // iscleaned=true;
819  // }
820  //}
821  //}*/
822  if(isPFMet_){
823  pt_jet=scale*(*pfJets)[ijet].pt();
824  if(pt_jet> ptThreshold_){
825  iscleaned = pfjetIDFunctorLoose((*pfJets)[ijet]);
826  }
827  }
828  if(iscleaned){
829  bJetID=true;
830  }
831  if(pt_jet>pt1){
832  pt2=pt1;
833  ind2=ind1;
834  pass_jetID2=pass_jetID1;
835  pt1=pt_jet;
836  ind1=ijet;
837  pass_jetID1=iscleaned;
838  }else if (pt_jet>pt2){
839  pt2=pt_jet;
840  ind2=ijet;
841  pass_jetID2=iscleaned;
842  }
843  }
844  if(pass_jetID1 && pass_jetID2){
845  double dphi=-1.0;
846  if(isCaloMet_){
847  dphi=fabs((*caloJets)[ind1].phi()-(*caloJets)[ind2].phi());
848  }
850  //dphi=fabs((*jptJets)[ind1].phi()-(*jptJets)[ind2].phi());
851  //}*/
852  if(isPFMet_){
853  dphi=fabs((*pfJets)[ind1].phi()-(*pfJets)[ind2].phi());
854  }
855  if(dphi>acos(-1.)){
856  dphi=2*acos(-1.)-dphi;
857  }
858  if(dphi>2.7){
859  bDiJetID=true;
860  }
861  }
862 
863  // ==========================================================
864  // HCAL Noise filter
865 
866  bool bHBHENoiseFilter = HBHENoiseFilterResult;
867 
868  // ==========================================================
869  // Get BeamHaloSummary
870  edm::Handle<BeamHaloSummary> TheBeamHaloSummary ;
871  iEvent.getByToken(beamHaloSummaryToken_, TheBeamHaloSummary) ;
872 
873  if (!TheBeamHaloSummary.isValid()) {
874  if (verbose_) std::cout << "BeamHaloSummary doesn't exist" << std::endl;
875  }
876 
877  bool bBeamHaloID = true;
878 
879  if(!TheBeamHaloSummary.isValid()) {
880 
881  const BeamHaloSummary TheSummary = (*TheBeamHaloSummary.product() );
882 
883  if( !TheSummary.EcalTightHaloId() && !TheSummary.HcalTightHaloId() &&
884  !TheSummary.CSCTightHaloId() && !TheSummary.GlobalTightHaloId() )
885  bBeamHaloID = false;
886  }
887 
888  // ==========================================================
889  //Vertex information
890  Handle<VertexCollection> vertexHandle;
891  iEvent.getByToken(vertexToken_, vertexHandle);
892 
893  if (!vertexHandle.isValid()) {
894  LogDebug("") << "CaloMETAnalyzer: Could not find vertex collection" << std::endl;
895  if (verbose_) std::cout << "CaloMETAnalyzer: Could not find vertex collection" << std::endl;
896  }
897  numPV_ = 0;
898  if ( vertexHandle.isValid() ){
899  VertexCollection vertexCollection = *(vertexHandle.product());
900  numPV_ = vertexCollection.size();
901  }
902  bool bPrimaryVertex = (bypassAllPVChecks_ || (numPV_>0));
903  // ==========================================================
904 
906  iEvent.getByToken( gtToken_, gtReadoutRecord);
907 
908  if (!gtReadoutRecord.isValid()) {
909  LogDebug("") << "CaloMETAnalyzer: Could not find GT readout record" << std::endl;
910  if (verbose_) std::cout << "CaloMETAnalyzer: Could not find GT readout record product" << std::endl;
911  }
912  // DCS Filter
913  bool bDCSFilter = (bypassAllDCSChecks_ || DCSFilter_->filter(iEvent, iSetup));
914  // ==========================================================
915  // Reconstructed MET Information - fill MonitorElements
916 
917  for (std::vector<std::string>::const_iterator ic = folderNames_.begin();
918  ic != folderNames_.end(); ic++){
919  if ((*ic=="Uncleaned") &&(isCaloMet_ || bPrimaryVertex)) fillMESet(iEvent, DirName+"/"+*ic, *met,*pfmet,*calomet,map_dijet_MEs);
920  //take two lines out for first check
921  if ((*ic=="Cleaned") &&bDCSFilter&&bHBHENoiseFilter&&bPrimaryVertex&&bBeamHaloID&&bJetID) fillMESet(iEvent, DirName+"/"+*ic, *met,*pfmet,*calomet,map_dijet_MEs);
922  if ((*ic=="DiJet" ) &&bDCSFilter&&bHBHENoiseFilter&&bPrimaryVertex&&bBeamHaloID&&bDiJetID) fillMESet(iEvent, DirName+"/"+*ic, *met,*pfmet,*calomet,map_dijet_MEs);
923  }
924 }
925 
926 
927 // ***********************************************************
929  const reco::MET& met, const reco::PFMET& pfmet, const reco::CaloMET& calomet,std::map<std::string,MonitorElement*>& map_of_MEs)
930 {
931 
932  //dbe_->setCurrentFolder(DirName);
933 
934  bool bLumiSecPlot=fill_met_high_level_histo;
935  //if (DirName.find("Uncleaned")) bLumiSecPlot=true; //now done on configlevel
936  fillMonitorElement(iEvent, DirName, std::string(""), met, pfmet, calomet, map_of_MEs,bLumiSecPlot);
937  if (DirName.find("Cleaned")) {
938  for (unsigned i = 0; i<triggerFolderLabels_.size(); i++) {
939  if (triggerFolderDecisions_[i]) fillMonitorElement(iEvent, DirName, triggerFolderLabels_[i], met, pfmet, calomet, map_of_MEs, false);
940  }
941  }
942 
943  if (DirName.find("DiJet")) {
944  for (unsigned i = 0; i<triggerFolderLabels_.size(); i++) {
945  if (triggerFolderDecisions_[i]) fillMonitorElement(iEvent, DirName, triggerFolderLabels_[i], met, pfmet, calomet, map_of_MEs, false);
946  }
947  }
948 
949 
950 
951 
952 
953 
954 
955 // if (trigJetMB_)
956 // fillMonitorElement(iEvent,DirName,"",met,pfmet,calomet, bLumiSecPlot);
957 // if (trigHighPtJet_)
958 // fillMonitorElement(iEvent,DirName,"HighPtJet",met,pfmet,calomet,false);
959 // if (trigLowPtJet_)
960 // fillMonitorElement(iEvent,DirName,"LowPtJet",met,pfmet,calomet,false);
961 // if (trigMinBias_)
962 // fillMonitorElement(iEvent,DirName,"MinBias",met,pfmet,calomet,false);
963 // if (trigHighMET_)
964 // fillMonitorElement(iEvent,DirName,"HighMET",met,pfmet,calomet,false);
965 // // if (_trig_LowMET)
966 // // fillMonitorElement(iEvent,DirName,"LowMET",met,pfmet,calomet,false);
967 // if (trigEle_)
968 // fillMonitorElement(iEvent,DirName,"Ele",met,pfmet,calomet,false);
969 // if (trigMuon_)
970 // fillMonitorElement(iEvent,DirName,"Muon",met,pfmet,calomet,false);
971 }
972 
973 // ***********************************************************
975  std::string subFolderName,
976  const reco::MET& met, const reco::PFMET & pfmet, const reco::CaloMET &calomet, std::map<std::string,MonitorElement*>& map_of_MEs,bool bLumiSecPlot)
977 {
978 
979 // if (subFolderName=="HighPtJet") {
980 // if (!selectHighPtJetEvent(iEvent)) return;
981 // }
982 // else if (subFolderName=="LowPtJet") {
983 // if (!selectLowPtJetEvent(iEvent)) return;
984 // }
985 // else if (subFolderName=="HighMET") {
986 // if (met.pt()<highMETThreshold_) return;
987 // }
988 // // else if (subFolderName=="LowMET") {
989 // // if (met.pt()<_lowMETThreshold) return;
990 // // }
991 // else if (subFolderName=="Ele") {
992 // if (!selectWElectronEvent(iEvent)) return;
993 // }
994 // else if (subFolderName=="Muon") {
995 // if (!selectWMuonEvent(iEvent)) return;
996 // }
997 
998 // Reconstructed MET Information
999  double SumET = met.sumEt();
1000  double METSig = met.mEtSig();
1001  //double Ez = met.e_longitudinal();
1002  double MET = met.pt();
1003  double MEx = met.px();
1004  double MEy = met.py();
1005  double METPhi = met.phi();
1006  //
1007  int myLuminosityBlock;
1008  myLuminosityBlock = iEvent.luminosityBlock();
1009  //
1010 
1011  if (subFolderName!="") DirName = DirName +"/"+subFolderName;
1012 
1013 
1014  hTrigger = map_of_MEs[DirName+"/triggerResults"];
1015  // std::cout<<"Hello"<<c++<<":"<<hTrigger <<std::endl;//":"<< hTrigger->getRootObject()<<std::endl;
1016  if (hTrigger && hTrigger->getRootObject()) {
1017  // std::cout<<"Hello"<<c++<<std::endl;
1018  for (unsigned int i = 0; i<allTriggerDecisions_.size();i++){
1019  // std::cout<<"Hello"<<c++<<":"<<i<<":"<< allTriggerDecisions_[i]<<":"<<allTriggerDecisions_[i]<<std::endl;
1020  if(i<(unsigned int)hTrigger->getNbinsX()){
1021  hTrigger->Fill(i + .5, allTriggerDecisions_[i]);
1022  if (!hTriggerLabelsIsSet_) {
1023  hTrigger->setBinLabel(i+1, allTriggerNames_[i]);//Can't be done in beginJob (no trigger list). Can't be done in beginRun (would have to anticipate folder structure).FIXME doesn't work
1024  }
1025  }
1026  }
1027  if (!hTriggerLabelsIsSet_) for (int i = allTriggerDecisions_.size(); i<hTrigger->getNbinsX();i++){
1028  hTrigger->setBinLabel(i+1, "");//Can't be done in beginJob (no trigger list). Can't be done in beginRun (would have to anticipate folder structure).
1029  }
1030  hTriggerLabelsIsSet_ = true;
1031  // std::cout<<"Filling decision "<<allTriggerNames_[i]<<" "<<allTriggerDecisions_[i]<<std::endl;
1032  }
1033 
1034 
1035  hMEx = map_of_MEs[DirName+"/"+"MEx"]; if (hMEx && hMEx->getRootObject()) hMEx ->Fill(MEx);
1036  hMEy = map_of_MEs[DirName+"/"+"MEy"]; if (hMEy && hMEy->getRootObject()) hMEy ->Fill(MEy);
1037  hMET = map_of_MEs[DirName+"/"+"MET"]; if (hMET && hMET->getRootObject()) hMET ->Fill(MET);
1038  hMETPhi = map_of_MEs[DirName+"/"+"METPhi"]; if (hMETPhi && hMETPhi->getRootObject()) hMETPhi ->Fill(METPhi);
1039  hSumET = map_of_MEs[DirName+"/"+"SumET"]; if (hSumET && hSumET->getRootObject()) hSumET ->Fill(SumET);
1040  hMETSig = map_of_MEs[DirName+"/"+"METSig"]; if (hMETSig && hMETSig->getRootObject()) hMETSig ->Fill(METSig);
1041  hMET_logx = map_of_MEs[DirName+"/"+"MET_logx"]; if (hMET_logx && hMET_logx->getRootObject()) hMET_logx->Fill(log10(MET));
1042  hSumET_logx = map_of_MEs[DirName+"/"+"SumET_logx"]; if (hSumET_logx && hSumET_logx->getRootObject()) hSumET_logx->Fill(log10(SumET));
1043 
1044  // Fill NPV profiles
1045  //--------------------------------------------------------------------------
1046  meMEx_profile = map_of_MEs[DirName + "/MEx_profile"];
1047  meMEy_profile = map_of_MEs[DirName + "/MEy_profile"];
1048  meMET_profile = map_of_MEs[DirName + "/MET_profile"];
1049  meSumET_profile = map_of_MEs[DirName + "/SumET_profile"];
1050 
1051  if (meMEx_profile && meMEx_profile ->getRootObject()) meMEx_profile ->Fill(numPV_, MEx);
1052  if (meMEy_profile && meMEy_profile ->getRootObject()) meMEy_profile ->Fill(numPV_, MEy);
1053  if (meMET_profile && meMET_profile ->getRootObject()) meMET_profile ->Fill(numPV_, MET);
1054  if (meSumET_profile && meSumET_profile->getRootObject()) meSumET_profile->Fill(numPV_, SumET);
1055 
1056  if(isCaloMet_){
1057  //const reco::CaloMETCollection *calometcol = calometcoll.product();
1058  //const reco::CaloMET *calomet;
1059  //calomet = &(calometcol->front());
1060 
1061  double caloEtFractionHadronic = calomet.etFractionHadronic();
1062  double caloEmEtFraction = calomet.emEtFraction();
1063 
1064  double caloMaxEtInEMTowers = calomet.maxEtInEmTowers();
1065  double caloMaxEtInHadTowers = calomet.maxEtInHadTowers();
1066 
1067  double caloHadEtInHB = calomet.hadEtInHB();
1068  double caloHadEtInHO = calomet.hadEtInHO();
1069  double caloHadEtInHE = calomet.hadEtInHE();
1070  double caloHadEtInHF = calomet.hadEtInHF();
1071  double caloEmEtInEB = calomet.emEtInEB();
1072  double caloEmEtInEE = calomet.emEtInEE();
1073  double caloEmEtInHF = calomet.emEtInHF();
1074 
1075  hCaloMaxEtInEmTowers = map_of_MEs[DirName+"/"+"CaloMaxEtInEmTowers"]; if (hCaloMaxEtInEmTowers && hCaloMaxEtInEmTowers->getRootObject()) hCaloMaxEtInEmTowers->Fill(caloMaxEtInEMTowers);
1076  hCaloMaxEtInHadTowers = map_of_MEs[DirName+"/"+"CaloMaxEtInHadTowers"]; if (hCaloMaxEtInHadTowers && hCaloMaxEtInHadTowers->getRootObject()) hCaloMaxEtInHadTowers->Fill(caloMaxEtInHadTowers);
1077 
1078  hCaloHadEtInHB = map_of_MEs[DirName+"/"+"CaloHadEtInHB"]; if (hCaloHadEtInHB && hCaloHadEtInHB->getRootObject()) hCaloHadEtInHB->Fill(caloHadEtInHB);
1079  hCaloHadEtInHO = map_of_MEs[DirName+"/"+"CaloHadEtInHO"]; if (hCaloHadEtInHO && hCaloHadEtInHO->getRootObject()) hCaloHadEtInHO->Fill(caloHadEtInHO);
1080  hCaloHadEtInHE = map_of_MEs[DirName+"/"+"CaloHadEtInHE"]; if (hCaloHadEtInHE && hCaloHadEtInHE->getRootObject()) hCaloHadEtInHE->Fill(caloHadEtInHE);
1081  hCaloHadEtInHF = map_of_MEs[DirName+"/"+"CaloHadEtInHF"]; if (hCaloHadEtInHF && hCaloHadEtInHF->getRootObject()) hCaloHadEtInHF->Fill(caloHadEtInHF);
1082  hCaloEmEtInEB = map_of_MEs[DirName+"/"+"CaloEmEtInEB"]; if (hCaloEmEtInEB && hCaloEmEtInEB->getRootObject()) hCaloEmEtInEB->Fill(caloEmEtInEB);
1083  hCaloEmEtInEE = map_of_MEs[DirName+"/"+"CaloEmEtInEE"]; if (hCaloEmEtInEE && hCaloEmEtInEE->getRootObject()) hCaloEmEtInEE->Fill(caloEmEtInEE);
1084  hCaloEmEtInHF = map_of_MEs[DirName+"/"+"CaloEmEtInHF"]; if (hCaloEmEtInHF && hCaloEmEtInHF->getRootObject()) hCaloEmEtInHF->Fill(caloEmEtInHF);
1085 
1086  hCaloMETPhi020 = map_of_MEs[DirName+"/"+"CaloMETPhi020"]; if (MET> 20. && hCaloMETPhi020 && hCaloMETPhi020->getRootObject()) { hCaloMETPhi020->Fill(METPhi);}
1087 
1088 
1089  hCaloEtFractionHadronic = map_of_MEs[DirName+"/"+"CaloEtFractionHadronic"]; if (hCaloEtFractionHadronic && hCaloEtFractionHadronic->getRootObject()) hCaloEtFractionHadronic->Fill(caloEtFractionHadronic);
1090  hCaloEmEtFraction = map_of_MEs[DirName+"/"+"CaloEmEtFraction"]; if (hCaloEmEtFraction && hCaloEmEtFraction->getRootObject()) hCaloEmEtFraction->Fill(caloEmEtFraction);
1091  hCaloEmEtFraction020 = map_of_MEs[DirName+"/"+"CaloEmEtFraction020"]; if (MET> 20. && hCaloEmEtFraction020 && hCaloEmEtFraction020->getRootObject()) hCaloEmEtFraction020->Fill(caloEmEtFraction);
1092  //if (metCollectionLabel_.label() == "corMetGlobalMuons" ) {
1093 
1094  //for( reco::MuonCollection::const_iterator muonit = muonHandle_->begin(); muonit != muonHandle_->end(); muonit++ ) {
1095  // const reco::TrackRef siTrack = muonit->innerTrack();
1096  // hCalomuPt = map_of_MEs[DirName+"/"+"CalomuonPt"];
1097  // if (hCalomuPt && hCalomuPt->getRootObject()) hCalomuPt->Fill( muonit->p4().pt() );
1098  // hCalomuEta = map_of_MEs[DirName+"/"+"CalomuonEta"]; if (hCalomuEta && hCalomuEta->getRootObject()) hCalomuEta->Fill( muonit->p4().eta() );
1099  // hCalomuNhits = map_of_MEs[DirName+"/"+"CalomuonNhits"]; if (hCalomuNhits && hCalomuNhits->getRootObject()) hCalomuNhits->Fill( siTrack.isNonnull() ? siTrack->numberOfValidHits() : -999 );
1100  // hCalomuChi2 = map_of_MEs[DirName+"/"+"CalomuonNormalizedChi2"]; if (hCalomuChi2 && hCalomuChi2->getRootObject()) hCalomuChi2->Fill( siTrack.isNonnull() ? siTrack->chi2()/siTrack->ndof() : -999 );
1101  // double d0 = siTrack.isNonnull() ? -1 * siTrack->dxy( beamSpot_) : -999;
1102  // hCalomuD0 = map_of_MEs[DirName+"/"+"CalomuonD0"]; if (hCalomuD0 && hCalomuD0->getRootObject()) hCalomuD0->Fill( d0 );
1103  //}
1104 
1105  //const unsigned int nMuons = muonHandle_->size();
1106  //for( unsigned int mus = 0; mus < nMuons; mus++ ) {
1107  // reco::MuonRef muref( muonHandle_, mus);
1108  // reco::MuonMETCorrectionData muCorrData = (*tcMetValueMapHandle_)[muref];
1109  // hCaloMExCorrection = map_of_MEs[DirName+"/"+"CaloMExCorrection"]; if (hCaloMExCorrection && hCaloMExCorrection->getRootObject()) hCaloMExCorrection-> Fill(muCorrData.corrY());
1110  // hCaloMEyCorrection = map_of_MEs[DirName+"/"+"CaloMEyCorrection"]; if (hCaloMEyCorrection && hCaloMEyCorrection->getRootObject()) hCaloMEyCorrection-> Fill(muCorrData.corrX());
1111  // hCaloMuonCorrectionFlag = map_of_MEs[DirName+"/"+"CaloMuonCorrectionFlag"]; if (hCaloMuonCorrectionFlag && hCaloMuonCorrectionFlag->getRootObject()) hCaloMuonCorrectionFlag-> Fill(muCorrData.type());
1112  //}
1113  //}
1114  }
1115 
1116  if(isPFMet_){
1117  // **** Get the MET container
1118  //const PFMETCollection *pfmetcol = pfmetcoll.product();
1119  //const PFMET *pfmet;
1120  //pfmet = &(pfmetcol->front());
1121 
1122  // PFMET getters
1123  //----------------------------------------------------------------------------
1124  double pfPhotonEtFraction = pfmet.photonEtFraction();
1125  double pfPhotonEt = pfmet.photonEt();
1126  double pfNeutralHadronEtFraction = pfmet.neutralHadronEtFraction();
1127  double pfNeutralHadronEt = pfmet.neutralHadronEt();
1128  double pfElectronEtFraction = pfmet.electronEtFraction();
1129  double pfElectronEt = pfmet.electronEt();
1130  double pfChargedHadronEtFraction = pfmet.chargedHadronEtFraction();
1131  double pfChargedHadronEt = pfmet.chargedHadronEt();
1132  double pfMuonEtFraction = pfmet.muonEtFraction();
1133  double pfMuonEt = pfmet.muonEt();
1134  double pfHFHadronEtFraction = pfmet.HFHadronEtFraction();
1135  double pfHFHadronEt = pfmet.HFHadronEt();
1136  double pfHFEMEtFraction = pfmet.HFEMEtFraction();
1137  double pfHFEMEt = pfmet.HFEMEt();
1138 
1139  mePhotonEtFraction = map_of_MEs[DirName + "/PfPhotonEtFraction"];
1140  mePhotonEt = map_of_MEs[DirName + "/PfPhotonEt"];
1141  meNeutralHadronEtFraction = map_of_MEs[DirName + "/PfNeutralHadronEtFraction"];
1142  meNeutralHadronEt = map_of_MEs[DirName + "/PfNeutralHadronEt"];
1143  meElectronEtFraction = map_of_MEs[DirName + "/PfElectronEtFraction"];
1144  meElectronEt = map_of_MEs[DirName + "/PfElectronEt"];
1145  meChargedHadronEtFraction = map_of_MEs[DirName + "/PfChargedHadronEtFraction"];
1146  meChargedHadronEt = map_of_MEs[DirName + "/PfChargedHadronEt"];
1147  meMuonEtFraction = map_of_MEs[DirName + "/PfMuonEtFraction"];
1148  meMuonEt = map_of_MEs[DirName + "/PfMuonEt"];
1149  meHFHadronEtFraction = map_of_MEs[DirName + "/PfHFHadronEtFraction"];
1150  meHFHadronEt = map_of_MEs[DirName + "/PfHFHadronEt"];
1151  meHFEMEtFraction = map_of_MEs[DirName + "/PfHFEMEtFraction"];
1152  meHFEMEt = map_of_MEs[DirName + "/PfHFEMEt"];
1153 
1154  if (mePhotonEtFraction && mePhotonEtFraction ->getRootObject()) mePhotonEtFraction ->Fill(pfPhotonEtFraction);
1155  if (mePhotonEt && mePhotonEt ->getRootObject()) mePhotonEt ->Fill(pfPhotonEt);
1156  if (meNeutralHadronEtFraction && meNeutralHadronEtFraction->getRootObject()) meNeutralHadronEtFraction->Fill(pfNeutralHadronEtFraction);
1157  if (meNeutralHadronEt && meNeutralHadronEt ->getRootObject()) meNeutralHadronEt ->Fill(pfNeutralHadronEt);
1158  if (meElectronEtFraction && meElectronEtFraction ->getRootObject()) meElectronEtFraction ->Fill(pfElectronEtFraction);
1159  if (meElectronEt && meElectronEt ->getRootObject()) meElectronEt ->Fill(pfElectronEt);
1160  if (meChargedHadronEtFraction && meChargedHadronEtFraction->getRootObject()) meChargedHadronEtFraction->Fill(pfChargedHadronEtFraction);
1161  if (meChargedHadronEt && meChargedHadronEt ->getRootObject()) meChargedHadronEt ->Fill(pfChargedHadronEt);
1162  if (meMuonEtFraction && meMuonEtFraction ->getRootObject()) meMuonEtFraction ->Fill(pfMuonEtFraction);
1163  if (meMuonEt && meMuonEt ->getRootObject()) meMuonEt ->Fill(pfMuonEt);
1164  if (meHFHadronEtFraction && meHFHadronEtFraction ->getRootObject()) meHFHadronEtFraction ->Fill(pfHFHadronEtFraction);
1165  if (meHFHadronEt && meHFHadronEt ->getRootObject()) meHFHadronEt ->Fill(pfHFHadronEt);
1166  if (meHFEMEtFraction && meHFEMEtFraction ->getRootObject()) meHFEMEtFraction ->Fill(pfHFEMEtFraction);
1167  if (meHFEMEt && meHFEMEt ->getRootObject()) meHFEMEt ->Fill(pfHFEMEt);
1168 
1169  //NPV profiles
1170 
1171  mePhotonEtFraction_profile = map_of_MEs[DirName + "/PfPhotonEtFraction_profile"];
1172  mePhotonEt_profile = map_of_MEs[DirName + "/PfPhotonEt_profile"];
1173  meNeutralHadronEtFraction_profile = map_of_MEs[DirName + "/PfNeutralHadronEtFraction_profile"];
1174  meNeutralHadronEt_profile = map_of_MEs[DirName + "/PfNeutralHadronEt_profile"];
1175  meElectronEtFraction_profile = map_of_MEs[DirName + "/PfElectronEtFraction_profile"];
1176  meElectronEt_profile = map_of_MEs[DirName + "/PfElectronEt_profile"];
1177  meChargedHadronEtFraction_profile = map_of_MEs[DirName + "/PfChargedHadronEtFraction_profile"];
1178  meChargedHadronEt_profile = map_of_MEs[DirName + "/PfChargedHadronEt_profile"];
1179  meMuonEtFraction_profile = map_of_MEs[DirName + "/PfMuonEtFraction_profile"];
1180  meMuonEt_profile = map_of_MEs[DirName + "/PfMuonEt_profile"];
1181  meHFHadronEtFraction_profile = map_of_MEs[DirName + "/PfHFHadronEtFraction_profile"];
1182  meHFHadronEt_profile = map_of_MEs[DirName + "/PfHFHadronEt_profile"];
1183  meHFEMEtFraction_profile = map_of_MEs[DirName + "/PfHFEMEtFraction_profile"];
1184  meHFEMEt_profile = map_of_MEs[DirName + "/PfHFEMEt_profile"];
1185 
1186  if (mePhotonEtFraction_profile && mePhotonEtFraction_profile ->getRootObject()) mePhotonEtFraction_profile ->Fill(numPV_, pfPhotonEtFraction);
1187  if (mePhotonEt_profile && mePhotonEt_profile ->getRootObject()) mePhotonEt_profile ->Fill(numPV_, pfPhotonEt);
1188  if (meNeutralHadronEtFraction_profile && meNeutralHadronEtFraction_profile->getRootObject()) meNeutralHadronEtFraction_profile->Fill(numPV_, pfNeutralHadronEtFraction);
1189  if (meNeutralHadronEt_profile && meNeutralHadronEt_profile ->getRootObject()) meNeutralHadronEt_profile ->Fill(numPV_, pfNeutralHadronEt);
1190  if (meElectronEtFraction_profile && meElectronEtFraction_profile ->getRootObject()) meElectronEtFraction_profile ->Fill(numPV_, pfElectronEtFraction);
1191  if (meElectronEt_profile && meElectronEt_profile ->getRootObject()) meElectronEt_profile ->Fill(numPV_, pfElectronEt);
1192  if (meChargedHadronEtFraction_profile && meChargedHadronEtFraction_profile->getRootObject()) meChargedHadronEtFraction_profile->Fill(numPV_, pfChargedHadronEtFraction);
1193  if (meChargedHadronEt_profile && meChargedHadronEt_profile ->getRootObject()) meChargedHadronEt_profile ->Fill(numPV_, pfChargedHadronEt);
1194  if (meMuonEtFraction_profile && meMuonEtFraction_profile ->getRootObject()) meMuonEtFraction_profile ->Fill(numPV_, pfMuonEtFraction);
1195  if (meMuonEt_profile && meMuonEt_profile ->getRootObject()) meMuonEt_profile ->Fill(numPV_, pfMuonEt);
1196  if (meHFHadronEtFraction_profile && meHFHadronEtFraction_profile ->getRootObject()) meHFHadronEtFraction_profile ->Fill(numPV_, pfHFHadronEtFraction);
1197  if (meHFHadronEt_profile && meHFHadronEt_profile ->getRootObject()) meHFHadronEt_profile ->Fill(numPV_, pfHFHadronEt);
1198  if (meHFEMEtFraction_profile && meHFEMEtFraction_profile ->getRootObject()) meHFEMEtFraction_profile ->Fill(numPV_, pfHFEMEtFraction);
1199  if (meHFEMEt_profile && meHFEMEt_profile ->getRootObject()) meHFEMEt_profile ->Fill(numPV_, pfHFEMEt);
1200  }
1201 
1202  if (isCaloMet_){
1203  //if (bLumiSecPlot){//get from config level
1204  if (fill_met_high_level_histo){
1205  hMExLS = map_of_MEs[DirName+"/"+"MExLS"]; if (hMExLS && hMExLS->getRootObject()) hMExLS->Fill(MEx,myLuminosityBlock);
1206  hMEyLS = map_of_MEs[DirName+"/"+"MEyLS"]; if (hMEyLS && hMEyLS->getRootObject()) hMEyLS->Fill(MEy,myLuminosityBlock);
1207  }
1208  }
1209 
1212 
1213  //if(trackHandle_.isValid()) {
1214  // for( edm::View<reco::Track>::const_iterator trkit = trackHandle_->begin(); trkit != trackHandle_->end(); trkit++ ) {
1215  // htrkPt = map_of_MEs[DirName+"/"+"trackPt"]; if (htrkPt && htrkPt->getRootObject()) htrkPt->Fill( trkit->pt() );
1216  // htrkEta = map_of_MEs[DirName+"/"+"trackEta"]; if (htrkEta && htrkEta->getRootObject()) htrkEta->Fill( trkit->eta() );
1217  // htrkNhits = map_of_MEs[DirName+"/"+"trackNhits"]; if (htrkNhits && htrkNhits->getRootObject()) htrkNhits->Fill( trkit->numberOfValidHits() );
1218  // htrkChi2 = map_of_MEs[DirName+"/"+"trackNormalizedChi2"];
1219  // if (htrkChi2 && htrkChi2->getRootObject()) htrkChi2->Fill( trkit->chi2() / trkit->ndof() );
1220  // double d0 = -1 * trkit->dxy( beamSpot_ );
1221  // htrkD0 = map_of_MEs[DirName+"/"+"trackD0"]; if (htrkD0 && htrkD0->getRootObject()) htrkD0->Fill( d0 );
1222  // }
1223  //}else{if (verbose_) std::cout<<"tracks not valid"<<std::endl;}
1224 
1225  //if(electronHandle_.isValid()) {
1226  // for( edm::View<reco::GsfElectron>::const_iterator eleit = electronHandle_->begin(); eleit != electronHandle_->end(); eleit++ ) {
1227  // helePt = map_of_MEs[DirName+"/"+"electronPt"]; if (helePt && helePt->getRootObject()) helePt->Fill( eleit->p4().pt() );
1228  // heleEta = map_of_MEs[DirName+"/"+"electronEta"]; if (heleEta && heleEta->getRootObject()) heleEta->Fill( eleit->p4().eta() );
1229  // heleHoE = map_of_MEs[DirName+"/"+"electronHoverE"]; if (heleHoE && heleHoE->getRootObject()) heleHoE->Fill( eleit->hadronicOverEm() );
1230  // }
1231  //}else{
1232  // if (verbose_) std::cout<<"electrons not valid"<<std::endl;
1233  //}
1234 
1235  //if(muonHandle_.isValid()) {
1236  // for( reco::MuonCollection::const_iterator muonit = muonHandle_->begin(); muonit != muonHandle_->end(); muonit++ ) {
1237  // const reco::TrackRef siTrack = muonit->innerTrack();
1238  // hmuPt = map_of_MEs[DirName+"/"+"muonPt"]; if (hmuPt && hmuPt->getRootObject()) hmuPt ->Fill( muonit->p4().pt() );
1239  // hmuEta = map_of_MEs[DirName+"/"+"muonEta"]; if (hmuEta && hmuEta->getRootObject()) hmuEta ->Fill( muonit->p4().eta() );
1240  // hmuNhits = map_of_MEs[DirName+"/"+"muonNhits"]; if (hmuNhits && hmuNhits->getRootObject()) hmuNhits->Fill( siTrack.isNonnull() ? siTrack->numberOfValidHits() : -999 );
1241  // hmuChi2 = map_of_MEs[DirName+"/"+"muonNormalizedChi2"]; if (hmuChi2 && hmuChi2->getRootObject()) hmuChi2 ->Fill( siTrack.isNonnull() ? siTrack->chi2()/siTrack->ndof() : -999 );
1242  // double d0 = siTrack.isNonnull() ? -1 * siTrack->dxy( beamSpot_) : -999;
1243  // hmuD0 = map_of_MEs[DirName+"/"+"muonD0"]; if (hmuD0 && hmuD0->getRootObject()) hmuD0->Fill( d0 );
1244  // }
1245  // const unsigned int nMuons = muonHandle_->size();
1246  // for( unsigned int mus = 0; mus < nMuons; mus++ ) {
1247  // reco::MuonRef muref( muonHandle_, mus);
1248  // reco::MuonMETCorrectionData muCorrData = (*tcMetValueMapHandle_)[muref];
1249  // hMExCorrection = map_of_MEs[DirName+"/"+"MExCorrection"]; if (hMExCorrection && hMExCorrection->getRootObject()) hMExCorrection-> Fill(muCorrData.corrY());
1250  // hMEyCorrection = map_of_MEs[DirName+"/"+"MEyCorrection"]; if (hMEyCorrection && hMEyCorrection->getRootObject()) hMEyCorrection-> Fill(muCorrData.corrX());
1251  //hMuonCorrectionFlag = map_of_MEs[DirName+"/"+"CorrectionFlag"]; if (hMuonCorrectionFlag && hMuonCorrectionFlag->getRootObject()) hMuonCorrectionFlag-> Fill(muCorrData.type());
1252  // }
1253  // }else{
1254  //if (verbose_) std::cout<<"muons not valid"<<std::endl;
1255  // }
1256  // }*/
1257 }
1258 
1260 //bool METAnalyzer::selectHighPtJetEvent(const edm::Event& iEvent){
1261 //
1262 // bool return_value=false;
1263 //
1264 // if(isCaloMet_){
1265 // edm::Handle<reco::CaloJetCollection> caloJets;
1266 // iEvent.getByToken(caloJetsToken_, caloJets);
1267 // if (!caloJets.isValid()) {
1268 // LogDebug("") << "METAnalyzer: Could not find jet product" << std::endl;
1269 // if (verbose_) std::cout << "METAnalyzer: Could not find jet product" << std::endl;
1270 // }
1271 //
1272 // for (reco::CaloJetCollection::const_iterator cal = caloJets->begin();
1273 // cal!=caloJets->end(); ++cal){
1274 // if (cal->pt()>highPtJetThreshold_){
1275 // return_value=true;
1276 // }
1277 // }
1278 // }/*
1279 // if(isTCMet_){
1280 // edm::Handle<reco::JPTJetCollection> jptJets;
1281 // iEvent.getByToken(jptJetsToken_, jptJets);
1282 // if (!jptJets.isValid()) {
1283 // LogDebug("") << "METAnalyzer: Could not find jet product" << std::endl;
1284 // if (verbose_) std::cout << "METAnalyzer: Could not find jet product" << std::endl;
1285 // }
1286 //
1287 // for (reco::JPTJetCollection::const_iterator cal = jptJets->begin();
1288 // cal!=jptJets->end(); ++cal){
1289 // if (cal->pt()>highPtJetThreshold_){
1290 // return_value=true;
1291 // }
1292 // }
1293 // }*/
1294 // if(isPFMet_){
1295 // edm::Handle<reco::PFJetCollection> PFJets;
1296 // iEvent.getByToken(pfJetsToken_, PFJets);
1297 // if (!PFJets.isValid()) {
1298 // LogDebug("") << "METAnalyzer: Could not find jet product" << std::endl;
1299 // if (verbose_) std::cout << "METAnalyzer: Could not find jet product" << std::endl;
1300 // }
1301 // for (reco::PFJetCollection::const_iterator cal = PFJets->begin();
1302 // cal!=PFJets->end(); ++cal){
1303 // if (cal->pt()>highPtJetThreshold_){
1304 // return_value=true;
1305 // }
1306 // }
1307 // }
1308 //
1309 //
1310 // return return_value;
1311 //}
1312 //
1314 //bool METAnalyzer::selectLowPtJetEvent(const edm::Event& iEvent){
1315 //
1316 // bool return_value=false;
1317 // if(isCaloMet_){
1318 // edm::Handle<reco::CaloJetCollection> caloJets;
1319 // iEvent.getByToken(caloJetsToken_, caloJets);
1320 // if (!caloJets.isValid()) {
1321 // LogDebug("") << "METAnalyzer: Could not find jet product" << std::endl;
1322 // if (verbose_) std::cout << "METAnalyzer: Could not find jet product" << std::endl;
1323 // }
1324 //
1325 // for (reco::CaloJetCollection::const_iterator cal = caloJets->begin();
1326 // cal!=caloJets->end(); ++cal){
1327 // if (cal->pt()>lowPtJetThreshold_){
1328 // return_value=true;
1329 // }
1330 // }
1331 // }
1332 // if(isTCMet_){
1333 // edm::Handle<reco::JPTJetCollection> jptJets;
1334 // iEvent.getByToken(jptJetsToken_, jptJets);
1335 // if (!jptJets.isValid()) {
1336 // LogDebug("") << "METAnalyzer: Could not find jet product" << std::endl;
1337 // if (verbose_) std::cout << "METAnalyzer: Could not find jet product" << std::endl;
1338 // }
1339 //
1340 // for (reco::JPTJetCollection::const_iterator cal = jptJets->begin();
1341 // cal!=jptJets->end(); ++cal){
1342 // if (cal->pt()>lowPtJetThreshold_){
1343 // return_value=true;
1344 // }
1345 // }
1346 // }
1347 // if(isPFMet_){
1348 // edm::Handle<reco::PFJetCollection> PFJets;
1349 // iEvent.getByToken(pfJetsToken_, PFJets);
1350 // if (!PFJets.isValid()) {
1351 // LogDebug("") << "METAnalyzer: Could not find jet product" << std::endl;
1352 // if (verbose_) std::cout << "METAnalyzer: Could not find jet product" << std::endl;
1353 // }
1354 // for (reco::PFJetCollection::const_iterator cal = PFJets->begin();
1355 // cal!=PFJets->end(); ++cal){
1356 // if (cal->pt()>lowPtJetThreshold_){
1357 // return_value=true;
1358 // }
1359 // }
1360 // }
1361 // return return_value;
1362 //
1363 //}
1364 //
1365 //
1367 //bool METAnalyzer::selectWElectronEvent(const edm::Event& iEvent){
1368 //
1369 // bool return_value=true;
1370 //
1371 // /*
1372 // W-electron event selection comes here
1373 // */
1374 //
1375 // return return_value;
1376 //
1377 //}
1378 //
1380 //bool METAnalyzer::selectWMuonEvent(const edm::Event& iEvent){
1381 //
1382 // bool return_value=true;
1383 //
1384 // /*
1385 // W-muon event selection comes here
1386 // */
1387 //
1388 // return return_value;
1389 //
1390 //}
1391 
#define LogDebug(id)
const bool EcalTightHaloId() const
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
double hadEtInHE() const
Definition: CaloMET.h:51
void setBinContent(int binx, double content)
set content of bin (1-D)
tuple met
____________________________________________________________________________||
Definition: CaloMET_cfi.py:4
void fillMESet(const edm::Event &, std::string, const reco::MET &, const reco::PFMET &, const reco::CaloMET &, std::map< std::string, MonitorElement * > &)
Definition: METAnalyzer.cc:928
double HFEMEtFraction() const
Definition: PFMET.h:47
double hadEtInHF() const
Definition: CaloMET.h:53
const bool HcalTightHaloId() const
void bookMonitorElement(std::string, DQMStore::IBooker &, std::map< std::string, MonitorElement * > &, bool)
Definition: METAnalyzer.cc:193
MonitorElement * bookProfile(Args &&...args)
Definition: DQMStore.h:155
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
const std::string metname
virtual double correction(const LorentzVector &fJet) const =0
get correction using Jet information only
std::vector< ParameterSet > VParameterSet
Definition: ParameterSet.h:33
double maxEtInHadTowers() const
Definition: CaloMET.h:40
double neutralHadronEtFraction() const
Definition: PFMET.h:32
double muonEt() const
Definition: PFMET.h:42
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
#define NULL
Definition: scimark2.h:8
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
Provides a code based selection for trigger and DCS information in order to have no failing filters i...
const bool GlobalTightHaloId() const
double maxEtInEmTowers() const
Definition: CaloMET.h:38
Jet ID object.
Definition: JetID.h:16
tuple vertexCollection
virtual double py() const GCC11_FINAL
y coordinate of momentum vector
triggerResultsToken_(consumes< edm::TriggerResults >(edm::InputTag("TriggerResults")))
const bool CSCTightHaloId() const
virtual float phi() const GCC11_FINAL
momentum azimuthal angle
void makeRatePlot(std::string, double)
Definition: METAnalyzer.cc:567
double mEtSig() const
Definition: MET.h:55
double HFHadronEtFraction() const
Definition: PFMET.h:44
int iEvent
Definition: GenABIO.cc:230
double sumEt() const
Definition: MET.h:53
double muonEtFraction() const
Definition: PFMET.h:41
double HFHadronEt() const
Definition: PFMET.h:45
void bookMESet(std::string, DQMStore::IBooker &, std::map< std::string, MonitorElement * > &)
Definition: METAnalyzer.cc:177
void Fill(HcalDetId &id, double val, std::vector< TH2F > &depth)
Definition: MET.h:39
void endRun(const edm::Run &iRun, const edm::EventSetup &iSetup)
Finish up a run.
Definition: METAnalyzer.cc:510
double photonEtFraction() const
Definition: PFMET.h:29
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:113
virtual double px() const GCC11_FINAL
x coordinate of momentum vector
double emEtInEB() const
Definition: CaloMET.h:55
void dqmBeginRun(const edm::Run &, const edm::EventSetup &)
Initialize run-based parameters.
Definition: METAnalyzer.cc:466
bool isValid() const
Definition: HandleBase.h:76
#define LogTrace(id)
double HFEMEt() const
Definition: PFMET.h:48
PF Jet selector for pat::Jets.
double hadEtInHO() const
Definition: CaloMET.h:49
double electronEt() const
Definition: PFMET.h:36
Jet selector for pat::Jets and for CaloJets.
TObject * getRootObject(void) const
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
double etFractionHadronic() const
Definition: CaloMET.h:42
MonitorElement * book2D(Args &&...args)
Definition: DQMStore.h:131
double photonEt() const
Definition: PFMET.h:30
static std::string const triggerResults("TriggerResults")
static const JetCorrector * getJetCorrector(const std::string &fName, const edm::EventSetup &fSetup)
retrieve corrector from the event setup. troughs exception if something is missing ...
Definition: JetCorrector.cc:50
TH1F * getTH1F(void) const
T const * product() const
Definition: Handle.h:81
METAnalyzer(const edm::ParameterSet &)
Constructor.
Definition: METAnalyzer.cc:41
double emEtInEE() const
Definition: CaloMET.h:57
double electronEtFraction() const
Definition: PFMET.h:35
double chargedHadronEtFraction() const
Definition: PFMET.h:38
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
Inizialize parameters for histo binning.
Definition: METAnalyzer.cc:159
double emEtInHF() const
Definition: CaloMET.h:59
tuple cout
Definition: gather_cfg.py:121
double neutralHadronEt() const
Definition: PFMET.h:33
void analyze(const edm::Event &, const edm::EventSetup &)
Get the analysis.
Definition: METAnalyzer.cc:595
void fillMonitorElement(const edm::Event &, std::string, std::string, const reco::MET &, const reco::PFMET &, const reco::CaloMET &, std::map< std::string, MonitorElement * > &, bool)
Definition: METAnalyzer.cc:974
virtual ~METAnalyzer()
Destructor.
Definition: METAnalyzer.cc:151
virtual float pt() const GCC11_FINAL
transverse momentum
tuple pfJets
Definition: pfJets_cff.py:8
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
double hadEtInHB() const
Definition: CaloMET.h:47
double emEtFraction() const
Definition: CaloMET.h:45
double chargedHadronEt() const
Definition: PFMET.h:39
Definition: Run.h:41
Definition: DDAxes.h:10