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