CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
JetMETAnalyzer.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author F. Chlebana - Fermilab
5  * K. Hatakeyama - Rockefeller University
6  */
7 
9 
13 
22 
25 
29 
30 #include <string>
31 using namespace edm;
32 
33 #define DEBUG 0
34 
35 // ***********************************************************
37 
38  parameters = pSet;
39 
40  // Jet Collection Label
41  theAKJetCollectionLabel = parameters.getParameter<edm::InputTag>("AKJetsCollectionLabel");
42  theSCJetCollectionLabel = parameters.getParameter<edm::InputTag>("SCJetsCollectionLabel");
43  theICJetCollectionLabel = parameters.getParameter<edm::InputTag>("ICJetsCollectionLabel");
44  theJPTJetCollectionLabel = parameters.getParameter<edm::InputTag>("JPTJetsCollectionLabel");
45  thePFJetCollectionLabel = parameters.getParameter<edm::InputTag>("PFJetsCollectionLabel");
46 
47  theTriggerResultsLabel = parameters.getParameter<edm::InputTag>("TriggerResultsLabel");
48 
49  theJetAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoJetAnalysis", true);
50  theJetCleaningFlag = parameters.getUntrackedParameter<bool>("DoJetCleaning", true);
51  theIConeJetAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoIterativeCone", false);
52  theSConeJetAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoSisCone", false);
53  theJetPtAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoJetPtAnalysis", false);
54  theJetPtCleaningFlag = parameters.getUntrackedParameter<bool>("DoJetPtCleaning", false);
55  theJPTJetAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoJPTJetAnalysis", false);
56  theJPTJetCleaningFlag = parameters.getUntrackedParameter<bool>("DoJPTJetCleaning", true);
57  thePFJetAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoPFJetAnalysis", false);
58  thePFJetCleaningFlag = parameters.getUntrackedParameter<bool>("DoPFJetCleaning", true);
59  //
60  theDiJetSelectionFlag = parameters.getUntrackedParameter<bool>("DoDiJetSelection", true);
61  //
62  theCaloMETAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoCaloMETAnalysis",true);
63  theTcMETAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoTcMETAnalysis", true);
64  theMuCorrMETAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoMuCorrMETAnalysis", true);
65  thePfMETAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoPfMETAnalysis", true);
66  theHTMHTAnalyzerFlag = parameters.getUntrackedParameter<bool>("DoHTMHTAnalysis", true);
67 
68  // ==========================================================
69  //DCS information
70  // ==========================================================
71  DCSFilterCalo = new JetMETDQMDCSFilter(parameters.getParameter<ParameterSet>("DCSFilterCalo"));
72  DCSFilterPF = new JetMETDQMDCSFilter(parameters.getParameter<ParameterSet>("DCSFilterPF"));
73  DCSFilterJPT = new JetMETDQMDCSFilter(parameters.getParameter<ParameterSet>("DCSFilterJPT"));
74  DCSFilterAll = new JetMETDQMDCSFilter(parameters.getParameter<ParameterSet>("DCSFilterAll"));
75  // Used for Jet DQM - For MET DQM, DCS selection applied in ***METAnalyzer
76 
77  // --- do the analysis on the Jets
78  if(theJetAnalyzerFlag) {
79  theAKJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("jetAnalysis"));
80  theAKJetAnalyzer->setSource("AntiKtJets");
81  if(theSConeJetAnalyzerFlag) {
82  theSCJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("jetAnalysis"));
83  theSCJetAnalyzer->setSource("SISConeJets");
84  }
85  if(theIConeJetAnalyzerFlag){
86  theICJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("jetAnalysis"));
87  theICJetAnalyzer->setSource("IterativeConeJets");
88  }
89  }
90 
91  if(theJetCleaningFlag) {
92  theCleanedAKJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("CleanedjetAnalysis"));
93  theCleanedAKJetAnalyzer->setSource("CleanedAntiKtJets");
94  if(theSConeJetAnalyzerFlag){
95  theCleanedSCJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("CleanedjetAnalysis"));
96  theCleanedSCJetAnalyzer->setSource("CleanedSISConeJets");
97  }
98  if(theIConeJetAnalyzerFlag){
99  theCleanedICJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("CleanedjetAnalysis"));
100  theCleanedICJetAnalyzer->setSource("CleanedIterativeConeJets");
101  }
102  }
103 
104  if(theDiJetSelectionFlag){
105  theDiJetAnalyzer = new JetAnalyzer(parameters.getParameter<ParameterSet>("DijetAnalysis"));
106  theDiJetAnalyzer->setSource("DiJets");
107  }
108 
109  // Do Pt analysis
110  if(theJetPtAnalyzerFlag ) {
111  thePtAKJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("PtAnalysis"));
112  thePtAKJetAnalyzer->setSource("PtAnalysisAntiKtJets");
113  if(theSConeJetAnalyzerFlag){
114  thePtSCJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("PtAnalysis"));
115  thePtSCJetAnalyzer->setSource("PtAnalysisSISConeJets");
116  }
117  if(theIConeJetAnalyzerFlag){
118  thePtICJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("PtAnalysis"));
119  thePtICJetAnalyzer->setSource("PtAnalysisIterativeConeJets");
120  }
121  }
122  // Do Cleaned Pt analysis
123  if(theJetPtCleaningFlag ) {
124  theCleanedPtAKJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("CleanedPtAnalysis"));
125  theCleanedPtAKJetAnalyzer->setSource("PtAnalysisCleanedAntiKtJets");
126  if(theSConeJetAnalyzerFlag){
127  theCleanedPtSCJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("CleanedPtAnalysis"));
128  theCleanedPtSCJetAnalyzer->setSource("PtAnalysisCleanedSISConeJets");
129  }
130  if(theIConeJetAnalyzerFlag){
131  theCleanedPtICJetAnalyzer = new JetPtAnalyzer(parameters.getParameter<ParameterSet>("CleanedPtAnalysis"));
132  theCleanedPtICJetAnalyzer->setSource("PtAnalysisCleanedIterativeConeJets");
133  }
134  }
135 
136  // --- do the analysis on JPT Jets
137  if(theJPTJetAnalyzerFlag) {
138  theJPTJetAnalyzer = new JPTJetAnalyzer(parameters.getParameter<ParameterSet>("JPTJetAnalysis"));
139  }
140  // --- do the analysis on JPT Cleaned Jets
141  if(theJPTJetCleaningFlag) {
142  theCleanedJPTJetAnalyzer = new JPTJetAnalyzer(parameters.getParameter<ParameterSet>("CleanedJPTJetAnalysis"));
143  }
144 
145  // --- do the analysis on the PFJets
146  if(thePFJetAnalyzerFlag){
147  thePFJetAnalyzer = new PFJetAnalyzer(parameters.getParameter<ParameterSet>("pfJetAnalysis"));
148  thePFJetAnalyzer->setSource("uncPFJets");
149  }
150  // --- do the analysis on the CleanedPFJets
151  if(thePFJetCleaningFlag) {
152  theCleanedPFJetAnalyzer = new PFJetAnalyzer(parameters.getParameter<ParameterSet>("CleanedpfJetAnalysis"));
153  theCleanedPFJetAnalyzer->setSource("PFJets");
154  }
155 
156  if(theDiJetSelectionFlag){
157  thePFDiJetAnalyzer = new PFJetAnalyzer(parameters.getParameter<ParameterSet>("PFDijetAnalysis"));
158  thePFDiJetAnalyzer->setSource("PFDiJets");
159  }
160  //Trigger selectoin
161  edm::ParameterSet highptjetparms = parameters.getParameter<edm::ParameterSet>("highPtJetTrigger");
162  edm::ParameterSet lowptjetparms = parameters.getParameter<edm::ParameterSet>("lowPtJetTrigger" );
163 
164  _HighPtJetEventFlag = new GenericTriggerEventFlag( highptjetparms, consumesCollector() );
165  _LowPtJetEventFlag = new GenericTriggerEventFlag( lowptjetparms , consumesCollector() );
166 
167  highPtJetExpr_ = highptjetparms.getParameter<std::vector<std::string> >("hltPaths");
168  lowPtJetExpr_ = lowptjetparms .getParameter<std::vector<std::string> >("hltPaths");
169 
170  // --- do the analysis on the MET
171  if(theCaloMETAnalyzerFlag){
172  theCaloMETAnalyzer = new CaloMETAnalyzer(parameters.getParameter<ParameterSet>("caloMETAnalysis"), consumesCollector());
173  //theCaloMETNoHFAnalyzer = new CaloMETAnalyzer(parameters.getParameter<ParameterSet>("caloMETNoHFAnalysis"), consumesCollector());
174  //theCaloMETHOAnalyzer = new CaloMETAnalyzer(parameters.getParameter<ParameterSet>("caloMETHOAnalysis"), consumesCollector());
175  //theCaloMETNoHFHOAnalyzer = new CaloMETAnalyzer(parameters.getParameter<ParameterSet>("caloMETNoHFHOAnalysis"), consumesCollector());
176  }
177  if(theTcMETAnalyzerFlag){
178  theTcMETAnalyzer = new METAnalyzer(parameters.getParameter<ParameterSet>("tcMETAnalysis"), consumesCollector());
179  }
180  if(theMuCorrMETAnalyzerFlag){
181  theMuCorrMETAnalyzer = new CaloMETAnalyzer(parameters.getParameter<ParameterSet>("mucorrMETAnalysis"), consumesCollector());
182  }
183  if(thePfMETAnalyzerFlag){
184  thePfMETAnalyzer = new PFMETAnalyzer(parameters.getParameter<ParameterSet>("pfMETAnalysis"), consumesCollector());
185  }
186  if(theHTMHTAnalyzerFlag){
187  theHTMHTAnalyzer = new HTMHTAnalyzer(parameters.getParameter<ParameterSet>("HTMHTAnalysis"));
188  }
189 
190  _LSBegin = parameters.getParameter<int>("LSBegin");
191  _LSEnd = parameters.getParameter<int>("LSEnd");
192 
193  processname_ = parameters.getParameter<std::string>("processname");
194 
195  //jet cleanup parameters
196  theCleaningParameters = parameters.getParameter<ParameterSet>("CleaningParameters"),
197 
198  _hlt_PhysDec = theCleaningParameters.getParameter<std::string>("HLT_PhysDec");
199 
200  _techTrigsAND = theCleaningParameters.getParameter<std::vector<unsigned > >("techTrigsAND");
201  _techTrigsOR = theCleaningParameters.getParameter<std::vector<unsigned > >("techTrigsOR");
202  _techTrigsNOT = theCleaningParameters.getParameter<std::vector<unsigned > >("techTrigsNOT");
203 
204  _doPVCheck = theCleaningParameters.getParameter<bool>("doPrimaryVertexCheck");
205  _doHLTPhysicsOn = theCleaningParameters.getParameter<bool>("doHLTPhysicsOn");
206 
207  _tightBHFiltering = theCleaningParameters.getParameter<bool>("tightBHFiltering");
208 
209  _theVertexLabel = theCleaningParameters.getParameter<edm::InputTag>("vertexLabel");
210  _theGTLabel = theCleaningParameters.getParameter<edm::InputTag>("gtLabel");
211 
212  //Vertex requirements
213  if (_doPVCheck) {
214  _nvtx_min = theCleaningParameters.getParameter<int>("nvtx_min");
215  _nvtxtrks_min = theCleaningParameters.getParameter<int>("nvtxtrks_min");
216  _vtxndof_min = theCleaningParameters.getParameter<int>("vtxndof_min");
217  _vtxchi2_max = theCleaningParameters.getParameter<double>("vtxchi2_max");
218  _vtxz_max = theCleaningParameters.getParameter<double>("vtxz_max");
219  }
220 
221 }
222 
223 // ***********************************************************
225 
226  if(theJetAnalyzerFlag) {
227  delete theAKJetAnalyzer;
228  if(theSConeJetAnalyzerFlag) delete theSCJetAnalyzer;
229  if(theIConeJetAnalyzerFlag) delete theICJetAnalyzer;
230  }
231  if(theJetCleaningFlag) {
232  delete theCleanedAKJetAnalyzer;
233  if(theSConeJetAnalyzerFlag) delete theCleanedSCJetAnalyzer;
234  if(theIConeJetAnalyzerFlag) delete theCleanedICJetAnalyzer;
235  }
236  if(theDiJetSelectionFlag) {
237  delete theDiJetAnalyzer;
238  }
239  if(theJetPtAnalyzerFlag) {
240  delete thePtAKJetAnalyzer;
241  if(theSConeJetAnalyzerFlag) delete thePtSCJetAnalyzer;
242  if(theIConeJetAnalyzerFlag) delete thePtICJetAnalyzer;
243  }
244 
245  if(theJetPtCleaningFlag) {
246  delete theCleanedPtAKJetAnalyzer;
247  if(theSConeJetAnalyzerFlag) delete theCleanedPtSCJetAnalyzer;
248  if(theIConeJetAnalyzerFlag) delete theCleanedPtICJetAnalyzer;
249  }
250 
251  if(theJPTJetAnalyzerFlag) delete theJPTJetAnalyzer;
252  if(theJPTJetCleaningFlag) delete theCleanedJPTJetAnalyzer;
253 
254  if(thePFJetAnalyzerFlag) delete thePFJetAnalyzer;
255  if(thePFJetCleaningFlag) delete theCleanedPFJetAnalyzer;
256  if(theDiJetSelectionFlag) delete thePFDiJetAnalyzer;
257 
258  delete _HighPtJetEventFlag;
259  delete _LowPtJetEventFlag;
260 
261  if(theCaloMETAnalyzerFlag){
262  delete theCaloMETAnalyzer;
263  //delete theCaloMETNoHFAnalyzer;
264  //delete theCaloMETHOAnalyzer;
265  //delete theCaloMETNoHFHOAnalyzer;
266  }
267  if(theTcMETAnalyzerFlag) delete theTcMETAnalyzer;
268  if(theMuCorrMETAnalyzerFlag) delete theMuCorrMETAnalyzer;
269  if(thePfMETAnalyzerFlag) delete thePfMETAnalyzer;
270  if(theHTMHTAnalyzerFlag) delete theHTMHTAnalyzer;
271 
272  delete DCSFilterCalo;
273  delete DCSFilterPF;
274  delete DCSFilterJPT;
275  delete DCSFilterAll;
276 
277 }
278 
279 // ***********************************************************
281 
282  metname = "JetMETAnalyzer";
283 
284  LogTrace(metname)<<"[JetMETAnalyzer] Parameters initialization";
285  dbe = edm::Service<DQMStore>().operator->();
286 
287  //
288  //--- Jet
289  if(theJetAnalyzerFlag) {
290  theAKJetAnalyzer->beginJob(dbe);
291  if(theSConeJetAnalyzerFlag) theSCJetAnalyzer->beginJob(dbe);
292  if(theIConeJetAnalyzerFlag) theICJetAnalyzer->beginJob(dbe);
293  }
294  if(theJetCleaningFlag) {
295  theCleanedAKJetAnalyzer->beginJob(dbe);
296  if(theSConeJetAnalyzerFlag) theCleanedSCJetAnalyzer->beginJob(dbe);
297  if(theIConeJetAnalyzerFlag) theCleanedICJetAnalyzer->beginJob(dbe);
298  }
299  if(theDiJetSelectionFlag) theDiJetAnalyzer->beginJob(dbe);
300  if(theJetPtAnalyzerFlag ) {
301  thePtAKJetAnalyzer->beginJob(dbe);
302  if(theSConeJetAnalyzerFlag) thePtSCJetAnalyzer->beginJob(dbe);
303  if(theIConeJetAnalyzerFlag) thePtICJetAnalyzer->beginJob(dbe);
304  }
305  if(theJetPtCleaningFlag ) {
306  theCleanedPtAKJetAnalyzer->beginJob(dbe);
307  if(theSConeJetAnalyzerFlag) theCleanedPtSCJetAnalyzer->beginJob(dbe);
308  if(theIConeJetAnalyzerFlag) theCleanedPtICJetAnalyzer->beginJob(dbe);
309  }
310 
311  if(theJPTJetAnalyzerFlag) theJPTJetAnalyzer->beginJob(dbe);
312  if(theJPTJetCleaningFlag) theCleanedJPTJetAnalyzer->beginJob(dbe);
313 
314  if(thePFJetAnalyzerFlag) thePFJetAnalyzer->beginJob(dbe);
315  if(thePFJetCleaningFlag) theCleanedPFJetAnalyzer->beginJob(dbe);
316  if(theDiJetSelectionFlag) thePFDiJetAnalyzer->beginJob(dbe);
317 
318  //
319  //--- MET
320  if(theCaloMETAnalyzerFlag){
321  theCaloMETAnalyzer->beginJob(dbe);
322  //theCaloMETNoHFAnalyzer->beginJob(dbe);
323  //theCaloMETHOAnalyzer->beginJob(dbe);
324  //theCaloMETNoHFHOAnalyzer->beginJob(dbe);
325  }
326  if(theTcMETAnalyzerFlag) theTcMETAnalyzer->beginJob(dbe);
327  if(theMuCorrMETAnalyzerFlag) theMuCorrMETAnalyzer->beginJob(dbe);
328  if(thePfMETAnalyzerFlag) thePfMETAnalyzer->beginJob(dbe);
329  if(theHTMHTAnalyzerFlag) theHTMHTAnalyzer->beginJob(dbe);
330 
331  dbe->setCurrentFolder("JetMET");
332  lumisecME = dbe->book1D("lumisec", "lumisec", 500, 0., 500.);
333  cleanupME = dbe->book1D("cleanup", "cleanup", 10, 0., 10.);
334  cleanupME->setBinLabel(1,"Primary Vertex");
335  cleanupME->setBinLabel(2,"DCS::Pixel");
336  cleanupME->setBinLabel(3,"DCS::SiStrip");
337  cleanupME->setBinLabel(4,"DCS::ECAL");
338  cleanupME->setBinLabel(5,"DCS::ES");
339  cleanupME->setBinLabel(6,"DCS::HBHE");
340  cleanupME->setBinLabel(7,"DCS::HF");
341  cleanupME->setBinLabel(8,"DCS::HO");
342  cleanupME->setBinLabel(9,"DCS::Muon");
343 
344  verticesME = dbe->book1D("vertices", "vertices", 50, 0, 50);
345 }
346 
347 // ***********************************************************
348 void JetMETAnalyzer::beginRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
349 {
350  //LogDebug("JetMETAnalyzer") << "beginRun, run " << run.id();
351  //
352 
353  if ( _HighPtJetEventFlag->on() ) _HighPtJetEventFlag->initRun( iRun, iSetup );
354  if ( _LowPtJetEventFlag ->on() ) _LowPtJetEventFlag ->initRun( iRun, iSetup );
355 
356  if (_HighPtJetEventFlag->on() && _HighPtJetEventFlag->expressionsFromDB(_HighPtJetEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
357  highPtJetExpr_ = _HighPtJetEventFlag->expressionsFromDB(_HighPtJetEventFlag->hltDBKey(), iSetup);
358  if (_LowPtJetEventFlag->on() && _LowPtJetEventFlag->expressionsFromDB(_LowPtJetEventFlag->hltDBKey(), iSetup)[0] != "CONFIG_ERROR")
359  lowPtJetExpr_ = _LowPtJetEventFlag->expressionsFromDB(_LowPtJetEventFlag->hltDBKey(), iSetup);
360 
361  //--- htlConfig_
362  //processname_="HLT";
363  bool changed(true);
364  _hlt_initialized = hltConfig_.init(iRun,iSetup,processname_,changed);
365  if (!_hlt_initialized) {
366  //if (!hltConfig_.init(iRun,iSetup,processname_,changed)) {
367  processname_ = "FU";
368  _hlt_initialized = hltConfig_.init(iRun,iSetup,processname_,changed);
369  if(!_hlt_initialized){
370  //if (!hltConfig_.init(iRun,iSetup,processname_,changed)){
371  LogDebug("JetMETAnalyzer") << "HLTConfigProvider failed to initialize.";
372  }
373  }
374 
375  /*
376  hltpathME = 0;
377  if (_hlt_initialized) {
378  //if (hltConfig_.init(iRun,iSetup,processname_,changed)) {
379  if (hltConfig_.size()){
380  dbe->setCurrentFolder("JetMET");
381  hltpathME = dbe->book1D("hltpath", "hltpath", 300, 0., 300.);
382  }
383 
384  for (unsigned int j=0; j!=hltConfig_.size(); ++j) {
385  if (hltpathME) hltpathME->setBinLabel(j+1,hltConfig_.triggerName(j));
386  // if (hltConfig_.triggerName(j)=="HLT_PhysicsDeclared")
387  }
388  }
389  */
390  //
391  //--- Jet
392 
393  //
394  //--- MET
395  if(theCaloMETAnalyzerFlag){
396  theCaloMETAnalyzer->beginRun(iRun, iSetup);
397  //theCaloMETNoHFAnalyzer->beginRun(iRun, iSetup);
398  //theCaloMETHOAnalyzer->beginRun(iRun, iSetup);
399  //theCaloMETNoHFHOAnalyzer->beginRun(iRun, iSetup);
400  }
401  if(theTcMETAnalyzerFlag) theTcMETAnalyzer->beginRun(iRun, iSetup);
402  if(theMuCorrMETAnalyzerFlag) theMuCorrMETAnalyzer->beginRun(iRun, iSetup);
403  if(thePfMETAnalyzerFlag) thePfMETAnalyzer->beginRun(iRun, iSetup);
404  //if(theHTMHTAnalyzerFlag) theHTMHTAnalyzer->beginRun(iRun, iSetup);
405 
406 }
407 
408 // ***********************************************************
409 void JetMETAnalyzer::endRun(const edm::Run& iRun, const edm::EventSetup& iSetup)
410 {
411  //
412  //--- Jet
413 
414  //
415  //--- MET
416  if(theCaloMETAnalyzerFlag){
417  theCaloMETAnalyzer->endRun(iRun, iSetup, dbe);
418  //theCaloMETNoHFAnalyzer->endRun(iRun, iSetup, dbe);
419  //theCaloMETHOAnalyzer->endRun(iRun, iSetup, dbe);
420  //theCaloMETNoHFHOAnalyzer->endRun(iRun, iSetup, dbe);
421  }
422  if(theTcMETAnalyzerFlag) theTcMETAnalyzer->endRun(iRun, iSetup, dbe);
423  if(theMuCorrMETAnalyzerFlag) theMuCorrMETAnalyzer->endRun(iRun, iSetup, dbe);
424  if(thePfMETAnalyzerFlag) thePfMETAnalyzer->endRun(iRun, iSetup, dbe);
425  //if(theHTMHTAnalyzerFlag) theHTMHTAnalyzer->endRun(iRun, iSetup, dbe);
426 
427 }
428 
429 // ***********************************************************
431 
432  LogTrace(metname)<<"[JetMETAnalyzer] Analysis of event # ";
433 
434  // *** Fill lumisection ME
435  int myLuminosityBlock;
436  myLuminosityBlock = iEvent.luminosityBlock();
437  lumisecME->Fill(myLuminosityBlock);
438 
439  if (myLuminosityBlock<_LSBegin) return;
440  if (myLuminosityBlock>_LSEnd && _LSEnd>0) return;
441 
442  // **** Get the TriggerResults container
444  iEvent.getByLabel(theTriggerResultsLabel, triggerResults);
445 
446  bool bPhysicsDeclared = false;
447  if(!_doHLTPhysicsOn) bPhysicsDeclared = true;
448 
449  Int_t JetLoPass = 0;
450  Int_t JetHiPass = 0;
451 
452  if (triggerResults.isValid()){
453  const edm::TriggerNames & triggerNames = iEvent.triggerNames(*triggerResults);
454 
455  if( triggerNames.triggerIndex("HLT_PhysicsDeclared") != triggerNames.size() )
456  if (triggerResults->accept(triggerNames.triggerIndex("HLT_PhysicsDeclared"))) {
457  if(_doHLTPhysicsOn) bPhysicsDeclared = true;
458  }
459 
460  /*
461  //sanity check
462  if (_hlt_initialized && hltConfig_.size() && triggerResults->size()==hltConfig_.size()){
463  //check the trigger results
464  for (unsigned int j=0; j!=hltConfig_.size(); ++j) {
465  if (triggerResults->accept(j)){
466  if (hltpathME) hltpathME->Fill(j);
467  }
468  }
469  }
470  */
471  const unsigned int nTrig(triggerNames.size());
472  for (unsigned int i=0;i<nTrig;++i)
473  {
474  if (triggerNames.triggerName(i).find(highPtJetExpr_[0].substr(0,highPtJetExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults->accept(i))
475  JetHiPass=1;
476  else if (triggerNames.triggerName(i).find(lowPtJetExpr_[0].substr(0,lowPtJetExpr_[0].rfind("_v")+2))!=std::string::npos && triggerResults->accept(i))
477  JetLoPass=1;
478  }
479 
480  }
481 
482  if (DEBUG) std::cout << "trigger label " << theTriggerResultsLabel << std::endl;
483 
484  /*
485  if ( _HighPtJetEventFlag->on() && _HighPtJetEventFlag->accept( iEvent, iSetup) )
486  JetHiPass=1;
487 
488  if ( _LowPtJetEventFlag->on() && _LowPtJetEventFlag->accept( iEvent, iSetup) )
489  JetLoPass=1;
490  */
491 
492  if (DEBUG) {
493  std::cout << ">>> Trigger Lo = " << JetLoPass
494  << " Hi = " << JetHiPass
495  << std::endl;
496  }
497 
498  // ==========================================================
499  //Vertex information
500 
501  int _numPV = 0;
502  bool bPrimaryVertex = true;
503  if(_doPVCheck){
504  bPrimaryVertex = false;
505  Handle<reco::VertexCollection> vertexHandle;
506 
507  iEvent.getByLabel(_theVertexLabel, vertexHandle);
508 
509  if (!vertexHandle.isValid()) {
510  LogInfo("JetMETAnalyzer") << "JetMETAnalyzer: Could not find vertex collection" << std::endl;
511  if (DEBUG) std::cout << "JetMETAnalyzer: Could not find vertex collection" << std::endl;
512  }
513 
514  if ( vertexHandle.isValid() ){
515  reco::VertexCollection vertexCollection = *(vertexHandle.product());
516  int vertex_number = vertexCollection.size();
517  reco::VertexCollection::const_iterator v = vertexCollection.begin();
518  for ( ; v != vertexCollection.end(); ++v) {
519  double vertex_chi2 = v->normalizedChi2();
520  double vertex_ndof = v->ndof();
521  bool fakeVtx = v->isFake();
522  double vertex_Z = v->z();
523 
524  if ( !fakeVtx
525  && vertex_number>=_nvtx_min
526  && vertex_ndof >_vtxndof_min
527  && vertex_chi2 <_vtxchi2_max
528  && fabs(vertex_Z)<_vtxz_max ) {
529  bPrimaryVertex = true;
530  ++_numPV;
531  }
532  }
533  }
534  }
535  verticesME->Fill(_numPV);
536  // ==========================================================
537 
539  iEvent.getByLabel( _theGTLabel, gtReadoutRecord);
540 
541  if (!gtReadoutRecord.isValid()) {
542  LogInfo("JetMETAnalyzer") << "JetMETAnalyzer: Could not find GT readout record" << std::endl;
543  if (DEBUG) std::cout << "JetMETAnalyzer: Could not find GT readout record product" << std::endl;
544  }
545 
546  bool bTechTriggers = true;
547  bool bTechTriggersAND = true;
548  bool bTechTriggersOR = false;
549  bool bTechTriggersNOT = false;
550 
551  if (gtReadoutRecord.isValid()) {
552  const TechnicalTriggerWord& technicalTriggerWordBeforeMask = gtReadoutRecord->technicalTriggerWord();
553 
554  if (_techTrigsAND.size() == 0)
555  bTechTriggersAND = true;
556  else
557  for (unsigned ttr = 0; ttr != _techTrigsAND.size(); ttr++) {
558  bTechTriggersAND = bTechTriggersAND && technicalTriggerWordBeforeMask.at(_techTrigsAND.at(ttr));
559  }
560 
561  if (_techTrigsAND.size() == 0)
562  bTechTriggersOR = true;
563  else
564  for (unsigned ttr = 0; ttr != _techTrigsOR.size(); ttr++) {
565  bTechTriggersOR = bTechTriggersOR || technicalTriggerWordBeforeMask.at(_techTrigsOR.at(ttr));
566  }
567  if (_techTrigsNOT.size() == 0)
568  bTechTriggersNOT = false;
569  else
570  for (unsigned ttr = 0; ttr != _techTrigsNOT.size(); ttr++) {
571  bTechTriggersNOT = bTechTriggersNOT || technicalTriggerWordBeforeMask.at(_techTrigsNOT.at(ttr));
572  }
573  }
574  else
575  {
576  bTechTriggersAND = true;
577  bTechTriggersOR = true;
578  bTechTriggersNOT = false;
579  }
580 
581  if (_techTrigsAND.size()==0)
582  bTechTriggersAND = true;
583  if (_techTrigsOR.size()==0)
584  bTechTriggersOR = true;
585  if (_techTrigsNOT.size()==0)
586  bTechTriggersNOT = false;
587 
588  bTechTriggers = bTechTriggersAND && bTechTriggersOR && !bTechTriggersNOT;
589 
590  bool bJetCleanup = bTechTriggers && bPrimaryVertex && bPhysicsDeclared;
591 
592  DCSFilterAll->filter(iEvent, iSetup);
593  if (bPrimaryVertex) cleanupME->Fill(0.5);
594  if ( DCSFilterAll->passPIX ) cleanupME->Fill(1.5);
595  if ( DCSFilterAll->passSiStrip ) cleanupME->Fill(2.5);
596  if ( DCSFilterAll->passECAL ) cleanupME->Fill(3.5);
597  if ( DCSFilterAll->passES ) cleanupME->Fill(4.5);
598  if ( DCSFilterAll->passHBHE ) cleanupME->Fill(5.5);
599  if ( DCSFilterAll->passHF ) cleanupME->Fill(6.5);
600  if ( DCSFilterAll->passHO ) cleanupME->Fill(7.5);
601  if ( DCSFilterAll->passMuon ) cleanupME->Fill(8.5);
602 
603  // **** Get the Calo Jet container
605 
606 
607  // **** Get the AntiKt Jet container
608  iEvent.getByLabel(theAKJetCollectionLabel, caloJets);
609  if(caloJets.isValid()) {
610 
611  if(theJetAnalyzerFlag){
612  theAKJetAnalyzer->setJetHiPass(JetHiPass);
613  theAKJetAnalyzer->setJetLoPass(JetLoPass);
614  theAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
615  }
616  if(theJetPtAnalyzerFlag){
617  LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt anti-Kt analyzer";
618  thePtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
619  }
620 
621  }
622 
623  if(caloJets.isValid() && bJetCleanup) {
624  if(DCSFilterCalo->filter(iEvent, iSetup)){
625  if(theJetCleaningFlag){
626  theCleanedAKJetAnalyzer->setJetHiPass(JetHiPass);
627  theCleanedAKJetAnalyzer->setJetLoPass(JetLoPass);
628  theCleanedAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
629  }
630  if(theJetPtCleaningFlag){
631  LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt anti-Kt analyzer";
632  theCleanedPtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
633  }
634  } // DCS
635  } // caloJets.isValid()
636 
637  if(caloJets.isValid() && bJetCleanup){
638  if(DCSFilterCalo->filter(iEvent, iSetup)){
639  if(theDiJetSelectionFlag){
640  theDiJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
641  }
642  } // DCS
643  } // caloJets.isValid()
644 
645 
646  if(caloJets.isValid()){
647  if(theJetPtAnalyzerFlag){
648  LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt anti-Kt analyzer";
649  thePtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
650  }
651  }
652 
653  if(caloJets.isValid() && bJetCleanup){
654  if(DCSFilterCalo->filter(iEvent, iSetup)){
655  if(theJetPtCleaningFlag){
656  LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt anti-Kt analyzer";
657  theCleanedPtAKJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
658  }
659  } // DCS
660  } // caloJets.isValid()
661 
662  // **** Get the SISCone Jet container
663  iEvent.getByLabel(theSCJetCollectionLabel, caloJets);
664  if(theSConeJetAnalyzerFlag){
665  if(caloJets.isValid()){
666  if(theJetAnalyzerFlag){
667  theSCJetAnalyzer->setJetHiPass(JetHiPass);
668  theSCJetAnalyzer->setJetLoPass(JetLoPass);
669  theSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
670  }
671  if(theJetPtAnalyzerFlag){
672  LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt SisCone analyzer";
673  thePtSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
674  }
675  }
676 
677  if(caloJets.isValid() && bJetCleanup){
678  if(DCSFilterCalo->filter(iEvent, iSetup)){
679  if(theJetCleaningFlag){
680  theCleanedSCJetAnalyzer->setJetHiPass(JetHiPass);
681  theCleanedSCJetAnalyzer->setJetLoPass(JetLoPass);
682  theCleanedSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
683  }
684  if(theJetPtCleaningFlag){
685  LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt SisCone analyzer";
686  theCleanedPtSCJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
687  }
688  } // DCS
689  } // caloJets.isValid()
690  }
691  // **** Get the Iterative Cone Jet container
692  iEvent.getByLabel(theICJetCollectionLabel, caloJets);
693  if(theIConeJetAnalyzerFlag) {
694  if(caloJets.isValid()){
695  if(theJetAnalyzerFlag){
696  theICJetAnalyzer->setJetHiPass(JetHiPass);
697  theICJetAnalyzer->setJetLoPass(JetLoPass);
698  theICJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
699  }
700  if(theJetPtAnalyzerFlag){
701  LogTrace(metname)<<"[JetMETAnalyzer] Call to the Jet Pt ICone analyzer";
702  thePtICJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
703  }
704  }
705 
706  if(caloJets.isValid() && bJetCleanup){
707  if(DCSFilterCalo->filter(iEvent, iSetup)){
708  if(theJetCleaningFlag){
709  theCleanedICJetAnalyzer->setJetHiPass(JetHiPass);
710  theCleanedICJetAnalyzer->setJetLoPass(JetLoPass);
711  theCleanedICJetAnalyzer->analyze(iEvent, iSetup, *caloJets, _numPV);
712  }
713  if(theJetPtCleaningFlag){
714  LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned Jet Pt ICone analyzer";
715  theCleanedPtICJetAnalyzer->analyze(iEvent, iSetup, *caloJets);
716  }
717  } // DCS
718  } // isValid
719  }
720 
721  // **** Get the JPT Jet container
723  iEvent.getByLabel(theJPTJetCollectionLabel, jptJets);
724  if(jptJets.isValid() && theJPTJetAnalyzerFlag){
725  //theJPTJetAnalyzer->setJetHiPass(JetHiPass);
726  //theJPTJetAnalyzer->setJetLoPass(JetLoPass);
727  theJPTJetAnalyzer->analyze(iEvent, iSetup, *jptJets, _numPV);
728  }
729 
730  if(jptJets.isValid() && bJetCleanup && theJPTJetCleaningFlag){
731  if(DCSFilterJPT->filter(iEvent, iSetup)){
732  //theCleanedJPTJetAnalyzer->setJetHiPass(JetHiPass);
733  //theCleanedJPTJetAnalyzer->setJetLoPass(JetLoPass);
734  theCleanedJPTJetAnalyzer->analyze(iEvent, iSetup, *jptJets, _numPV);
735  }
736  }
737 
738  // **** Get the PFlow Jet container
740  iEvent.getByLabel(thePFJetCollectionLabel, pfJets);
741 
742  if(pfJets.isValid()){
743  if(thePFJetAnalyzerFlag){
744  thePFJetAnalyzer->setJetHiPass(JetHiPass);
745  thePFJetAnalyzer->setJetLoPass(JetLoPass);
746  LogTrace(metname)<<"[JetMETAnalyzer] Call to the PFJet analyzer";
747  thePFJetAnalyzer->analyze(iEvent, iSetup, *pfJets, _numPV);
748  }
749  if(thePFJetCleaningFlag){
750  if(DCSFilterPF->filter(iEvent, iSetup)){
751  theCleanedPFJetAnalyzer->setJetHiPass(JetHiPass);
752  theCleanedPFJetAnalyzer->setJetLoPass(JetLoPass);
753  LogTrace(metname)<<"[JetMETAnalyzer] Call to the Cleaned PFJet analyzer";
754  theCleanedPFJetAnalyzer->analyze(iEvent, iSetup, *pfJets, _numPV);
755  if(theDiJetSelectionFlag){
756  thePFDiJetAnalyzer->analyze(iEvent, iSetup, *pfJets, _numPV);
757  }
758  } // DCS
759  }
760  } else {
761  if (DEBUG) LogTrace(metname)<<"[JetMETAnalyzer] pfjets NOT VALID!!";
762  }
763 
764  //
765  // **** CaloMETAnalyzer **** //
766  //
767  if(theCaloMETAnalyzerFlag){
768 
769  theCaloMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
770  //theCaloMETNoHFAnalyzer->analyze(iEvent, iSetup, *triggerResults);
771  //theCaloMETHOAnalyzer->analyze(iEvent, iSetup, *triggerResults);
772  //theCaloMETNoHFHOAnalyzer->analyze(iEvent, iSetup, *triggerResults);
773  }
774 
775  //
776  // **** TcMETAnalyzer **** //
777  //
778  if(theTcMETAnalyzerFlag){
779 
780  theTcMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
781 
782  }
783 
784  //
785  // **** MuCorrMETAnalyzer **** //
786  //
787  if(theMuCorrMETAnalyzerFlag){
788 
789  theMuCorrMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
790 
791  }
792 
793  //
794  // **** PfMETAnalyzer **** //
795  //
796  if(thePfMETAnalyzerFlag){
797 
798  thePfMETAnalyzer->analyze(iEvent, iSetup, *triggerResults);
799 
800  }
801 
802  //
803  // **** HTMHTAnalyzer **** //
804  //
805  if(theHTMHTAnalyzerFlag){
806 
807  theHTMHTAnalyzer->analyze(iEvent, iSetup, *triggerResults);
808 
809  }
810 
811 }
812 
813 // ***********************************************************
815  LogTrace(metname)<<"[JetMETAnalyzer] Saving the histos";
816  bool outputMEsInRootFile = parameters.getParameter<bool>("OutputMEsInRootFile");
817  std::string outputFileName = parameters.getParameter<std::string>("OutputFileName");
818 
819 
820  //--- MET
821  if(theCaloMETAnalyzerFlag){
822  theCaloMETAnalyzer->endJob();
823  //theCaloMETNoHFAnalyzer->endJob();
824  //theCaloMETHOAnalyzer->endJob();
825  //theCaloMETNoHFHOAnalyzer->endJob();
826  }
827  if(theTcMETAnalyzerFlag) theTcMETAnalyzer->endJob();
828  if(theMuCorrMETAnalyzerFlag) theMuCorrMETAnalyzer->endJob();
829  if(thePfMETAnalyzerFlag) thePfMETAnalyzer->endJob();
830  //if(theHTMHTAnalyzerFlag) theHTMHTAnalyzer->endJob();
831 
832  //--- Jet
833  if(theJetAnalyzerFlag) {
834  theAKJetAnalyzer->endJob();
835  if(theSConeJetAnalyzerFlag) theSCJetAnalyzer->endJob();
836  if(theIConeJetAnalyzerFlag) theICJetAnalyzer->endJob();
837  }
838 
839  if(theJetCleaningFlag) {
840  theCleanedAKJetAnalyzer->endJob();
841  if(theSConeJetAnalyzerFlag) theCleanedSCJetAnalyzer->endJob();
842  if(theIConeJetAnalyzerFlag) theCleanedICJetAnalyzer->endJob();
843  }
844 
845  if(theDiJetSelectionFlag) theDiJetAnalyzer->endJob();
846 
847  if(theJetPtAnalyzerFlag ) {
848  thePtAKJetAnalyzer->endJob();
849  if(theSConeJetAnalyzerFlag) thePtSCJetAnalyzer->endJob();
850  if(theIConeJetAnalyzerFlag) thePtICJetAnalyzer->endJob();
851  }
852 
853  if(theJetPtCleaningFlag ) {
854  theCleanedPtAKJetAnalyzer->endJob();
855  if(theSConeJetAnalyzerFlag) theCleanedPtSCJetAnalyzer->endJob();
856  if(theIConeJetAnalyzerFlag) theCleanedPtICJetAnalyzer->endJob();
857  }
858 
859  if(theJPTJetAnalyzerFlag) theJPTJetAnalyzer->endJob();
860  if(theJPTJetCleaningFlag) theCleanedJPTJetAnalyzer->endJob();
861 
862  if(thePFJetAnalyzerFlag) thePFJetAnalyzer->endJob();
863  if(thePFJetCleaningFlag) theCleanedPFJetAnalyzer->endJob();
864  if(theDiJetSelectionFlag) thePFDiJetAnalyzer->endJob();
865 
866  if(outputMEsInRootFile){
867  dbe->save(outputFileName);
868  }
869 
870 }
871 
872 
#define LogDebug(id)
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
dictionary parameters
Definition: Parameters.py:2
virtual edm::TriggerNames const & triggerNames(edm::TriggerResults const &triggerResults) const
Definition: Event.cc:204
void endJob(void)
Save the histos.
const std::string metname
JetMETAnalyzer(const edm::ParameterSet &)
Constructor.
void endRun(const edm::Run &, const edm::EventSetup &)
Finish up a run.
edm::LuminosityBlockNumber_t luminosityBlock() const
Definition: EventBase.h:59
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...
Strings::size_type size() const
Definition: TriggerNames.cc:39
void beginRun(const edm::Run &, const edm::EventSetup &)
Initialize run-based parameters.
tuple vertexCollection
int iEvent
Definition: GenABIO.cc:243
unsigned int triggerIndex(std::string const &name) const
Definition: TriggerNames.cc:32
std::vector< bool > TechnicalTriggerWord
technical trigger bits (64 bits)
void beginJob(void)
Inizialize parameters for histo binning.
bool isValid() const
Definition: HandleBase.h:76
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
#define LogTrace(id)
#define DEBUG
std::string const & triggerName(unsigned int index) const
Definition: TriggerNames.cc:27
static std::string const triggerResults("TriggerResults")
T const * product() const
Definition: Handle.h:81
JPT jet analyzer class definition.
tuple cout
Definition: gather_cfg.py:121
virtual ~JetMETAnalyzer()
Destructor.
tuple pfJets
Definition: pfJets_cff.py:8
Definition: Run.h:41
void analyze(const edm::Event &, const edm::EventSetup &)
Get the analysis.