CMS 3D CMS Logo

L1JetRecoTreeProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: L1Trigger/L1TNtuples
4 // Class: L1JetRecoTreeProducer
5 //
13 // system include files
14 #include <memory>
15 
16 // framework
25 
26 // cond formats
30 
31 // data formats
43 
44 // ROOT output stuff
47 #include "TH1.h"
48 #include "TTree.h"
49 #include "TF1.h"
50 #include <TVector2.h>
51 
52 //local data formats
55 
56 //
57 // class declaration
58 //
59 
60 class L1JetRecoTreeProducer : public edm::one::EDAnalyzer<edm::one::SharedResources> {
61 public:
63  ~L1JetRecoTreeProducer() override;
64 
65 private:
66  void beginJob(void) override;
67  void analyze(const edm::Event&, const edm::EventSetup&) override;
68  void endJob() override;
69 
73  void doCorrPUPPIJets(edm::Handle<std::vector<pat::Jet> > corrPuppiJets);
78 
82 
83  void doZPt(edm::Handle<reco::MuonCollection> muons, edm::Handle<std::vector<pat::Jet> > corrPuppiJets);
84 
85  bool pfJetID(const reco::PFJet& jet);
86  bool puppiJetID(const pat::Jet& jet);
87  bool caloJetID(const reco::CaloJet& jet);
88 
89 public:
92 
93 private:
94  // tree
95  TTree* tree_;
96 
97  // EDM input tags
105 
110 
112 
113  // debug stuff
118  double jetetaMax_;
119  unsigned int maxCl_;
120  unsigned int maxJet_;
121  unsigned int maxVtx_;
122  unsigned int maxTrk_;
123 
133 };
134 
136  : pfJetsMissing_(false),
137  puppiJetsMissing_(false),
138  corrPuppiJetsMissing_(false),
139  pfJetCorrMissing_(false),
140  caloJetCorrMissing_(false),
141  caloJetsMissing_(false),
142  caloJetIDMissing_(false),
143  pfMetMissing_(false),
144  puppiMetMissing_(false),
145  caloMetMissing_(false),
146  caloMetBEMissing_(false),
147  muonsMissing_(false) {
148  caloJetToken_ =
149  consumes<reco::CaloJetCollection>(iConfig.getUntrackedParameter("caloJetToken", edm::InputTag("ak4CaloJets")));
150  pfJetToken_ =
151  consumes<reco::PFJetCollection>(iConfig.getUntrackedParameter("pfJetToken", edm::InputTag("ak4PFJetsCHS")));
152  puppiJetToken_ = consumes<reco::PFJetCollection>(iConfig.getParameter<edm::InputTag>("puppiJetToken"));
153  corrPuppiJetToken_ = consumes<std::vector<pat::Jet> >(
154  iConfig.getUntrackedParameter("corrPuppiJetToken", edm::InputTag("patJetsCorrectedPuppiJets")));
156  consumes<edm::ValueMap<reco::JetID> >(iConfig.getUntrackedParameter("caloJetIDToken", edm::InputTag("ak4JetID")));
157  pfJECToken_ = consumes<reco::JetCorrector>(
158  iConfig.getUntrackedParameter<edm::InputTag>("pfJECToken", edm::InputTag("ak4PFCHSL1FastL2L3ResidualCorrector")));
159  caloJECToken_ = consumes<reco::JetCorrector>(iConfig.getUntrackedParameter<edm::InputTag>(
160  "caloJECToken", edm::InputTag("ak4CaloL1FastL2L3ResidualCorrector")));
161 
162  pfMetToken_ = consumes<reco::PFMETCollection>(iConfig.getUntrackedParameter("pfMetToken", edm::InputTag("pfMetT1")));
164  consumes<reco::PFMETCollection>(iConfig.getUntrackedParameter("puppiMetToken", edm::InputTag("pfMetPuppi")));
165  caloMetToken_ =
166  consumes<reco::CaloMETCollection>(iConfig.getUntrackedParameter("caloMetToken", edm::InputTag("caloMet")));
168  consumes<reco::CaloMETCollection>(iConfig.getUntrackedParameter("caloMetBEToken", edm::InputTag("caloMetBE")));
169 
170  muonToken_ = consumes<reco::MuonCollection>(iConfig.getUntrackedParameter("muonToken", edm::InputTag("muons")));
171 
172  usesResource(TFileService::kSharedResource);
173 
174  jetptThreshold_ = iConfig.getParameter<double>("jetptThreshold");
175  jetetaMax_ = iConfig.getParameter<double>("jetetaMax");
176  maxJet_ = iConfig.getParameter<unsigned int>("maxJet");
177 
180 
181  // set up output
183  tree_ = fs_->make<TTree>("JetRecoTree", "JetRecoTree");
184  tree_->Branch("Jet", "L1Analysis::L1AnalysisRecoJetDataFormat", &jet_data, 32000, 3);
185  tree_->Branch("Sums", "L1Analysis::L1AnalysisRecoMetDataFormat", &met_data, 32000, 3);
186 }
187 
189  // do anything here that needs to be done at desctruction time
190  // (e.g. close files, deallocate resources etc.)
191 }
192 
193 //
194 // member functions
195 //
196 
197 // ------------ method called to for each event ------------
199  jet_data->Reset();
200  met_data->Reset();
201 
202  // get jets
204  iEvent.getByToken(pfJetToken_, pfJets);
205 
206  // get puppi jets
208  iEvent.getByToken(puppiJetToken_, puppiJets);
209 
210  // get corrected puppi jets
211  edm::Handle<std::vector<pat::Jet> > corrPuppiJets;
212  iEvent.getByToken(corrPuppiJetToken_, corrPuppiJets);
213 
214  // get calo jets
216  iEvent.getByToken(caloJetToken_, caloJets);
217 
218  //get sums
220  iEvent.getByToken(pfMetToken_, pfMet);
221 
222  //get sums
224  iEvent.getByToken(puppiMetToken_, puppiMet);
225 
226  // get jet ID
228  iEvent.getByToken(caloJetIDToken_, jetsID);
229 
231  iEvent.getByToken(pfJECToken_, pfJetCorr);
232 
234  iEvent.getByToken(caloJECToken_, caloJetCorr);
235 
237  iEvent.getByToken(caloMetToken_, caloMet);
238 
240  iEvent.getByToken(caloMetBEToken_, caloMetBE);
241 
242  // get muons
244  iEvent.getByToken(muonToken_, muons);
245 
246  if (pfJets.isValid()) {
247  jet_data->nJets = 0;
248 
249  doPFJets(pfJets);
250 
251  } else {
252  if (!pfJetsMissing_) {
253  edm::LogWarning("MissingProduct") << "PFJets not found. Branch will not be filled" << std::endl;
254  }
255  pfJetsMissing_ = true;
256  }
257 
258  if (pfJetCorr.isValid()) {
259  doPFJetCorr(pfJets, pfJetCorr);
260 
261  } else {
262  if (!pfJetCorrMissing_) {
263  edm::LogWarning("MissingProduct") << "PF Jet Corrector not found. Branch will not be filled" << std::endl;
264  }
265  pfJetCorrMissing_ = true;
266  }
267 
268  if (puppiJets.isValid()) {
270 
271  doPUPPIJets(puppiJets);
272 
273  } else {
274  if (!puppiJetsMissing_) {
275  edm::LogWarning("MissingProduct") << "PUPPIJets not found. Branch will not be filled" << std::endl;
276  }
277  puppiJetsMissing_ = true;
278  }
279 
280  if (corrPuppiJets.isValid()) {
281  jet_data->puppi_nJets = 0;
282 
283  doCorrPUPPIJets(corrPuppiJets);
284 
285  } else {
286  if (!corrPuppiJetsMissing_) {
287  edm::LogWarning("MissingProduct") << "Corrected PUPPIJets not found. Branch will not be filled" << std::endl;
288  }
289  corrPuppiJetsMissing_ = true;
290  }
291 
292  if (caloJets.isValid()) {
293  jet_data->nCaloJets = 0;
294 
296 
297  } else {
298  if (!caloJetsMissing_) {
299  edm::LogWarning("MissingProduct") << "Calo Jets not found. Branch will not be filled" << std::endl;
300  }
301  caloJetsMissing_ = true;
302  }
303 
304  if (caloJetCorr.isValid()) {
305  doCaloJetCorr(caloJets, caloJetCorr);
306 
307  } else {
308  if (!caloJetCorrMissing_) {
309  edm::LogWarning("MissingProduct") << "Calo Jet Corrector not found. Branch will not be filled" << std::endl;
310  }
311  caloJetCorrMissing_ = true;
312  }
313 
314  if (!jetsID.isValid()) {
315  if (!caloJetIDMissing_) {
316  edm::LogWarning("MissingProduct") << "Calo Jet ID not found. Branch will not be filled" << std::endl;
317  }
318  caloJetIDMissing_ = true;
319  }
320 
321  if (pfMet.isValid()) {
322  doPFMet(pfMet);
323 
324  if (muons.isValid()) {
326 
327  } else {
328  if (!muonsMissing_) {
329  edm::LogWarning("MissingProduct") << "Muons not found. PFMetNoMu branch will not be filled" << std::endl;
330  }
331  muonsMissing_ = true;
332  }
333  } else {
334  if (!pfMetMissing_) {
335  edm::LogWarning("MissingProduct") << "PFMet not found. Branch will not be filled" << std::endl;
336  }
337  pfMetMissing_ = true;
338  }
339 
340  if (puppiMet.isValid()) {
341  if (muons.isValid()) {
342  doPUPPIMetNoMu(puppiMet, muons);
343 
344  } else {
345  if (!muonsMissing_) {
346  edm::LogWarning("MissingProduct") << "Muons not found. PUPPIMetNoMu branch will not be filled" << std::endl;
347  }
348  muonsMissing_ = true;
349  }
350  } else {
351  if (!puppiMetMissing_) {
352  edm::LogWarning("MissingProduct") << "PUPPIMet not found. Branch will not be filled" << std::endl;
353  }
354  puppiMetMissing_ = true;
355  }
356 
357  if (caloMet.isValid()) {
359 
360  } else {
361  if (!caloMetMissing_) {
362  edm::LogWarning("MissingProduct") << "CaloMet not found. Branch will not be filled" << std::endl;
363  }
364  caloMetMissing_ = true;
365  }
366 
367  if (caloMetBE.isValid()) {
369 
370  } else {
371  if (!caloMetBEMissing_) {
372  edm::LogWarning("MissingProduct") << "CaloMetBE not found. Branch will not be filled" << std::endl;
373  }
374  caloMetBEMissing_ = true;
375  }
376 
377  if (muons.isValid()) {
378  if (puppiJets.isValid()) {
379  doZPt(muons, corrPuppiJets);
380 
381  } else {
382  if (!puppiJetsMissing_) {
383  edm::LogWarning("MissingProduct") << "PUPPIJets not found. Branch will not be filled" << std::endl;
384  }
385  puppiJetsMissing_ = true;
386  }
387  } else {
388  if (!muonsMissing_) {
389  edm::LogWarning("MissingProduct") << "Muons not found. ZPt branch will not be filled" << std::endl;
390  }
391  muonsMissing_ = true;
392  }
393 
394  tree_->Fill();
395 }
396 
398  for (auto it = caloJets->begin(); it != caloJets->end() && jet_data->nCaloJets < maxJet_; ++it) {
399  if (!caloJetIDMissing_)
400  if (!caloJetID(*it))
401  continue;
402 
403  jet_data->caloEt.push_back(it->et());
404  jet_data->caloEta.push_back(it->eta());
405  jet_data->caloPhi.push_back(it->phi());
406  jet_data->caloE.push_back(it->energy());
407 
408  jet_data->eEMF.push_back(it->emEnergyFraction());
409  jet_data->eEmEB.push_back(it->emEnergyInEB());
410  jet_data->eEmEE.push_back(it->emEnergyInEE());
411  jet_data->eEmHF.push_back(it->emEnergyInHF());
412  jet_data->eHadHB.push_back(it->hadEnergyInHB());
413  jet_data->eHadHE.push_back(it->hadEnergyInHE());
414  jet_data->eHadHO.push_back(it->hadEnergyInHO());
415  jet_data->eHadHF.push_back(it->hadEnergyInHF());
416  jet_data->eMaxEcalTow.push_back(it->maxEInEmTowers());
417  jet_data->eMaxHcalTow.push_back(it->maxEInHadTowers());
418  jet_data->towerArea.push_back(it->towersArea());
419  jet_data->n60.push_back(it->n60());
420 
421  jet_data->nCaloJets++;
422  }
423 }
424 
426  for (auto it = pfJets->begin(); it != pfJets->end() && jet_data->nJets < maxJet_; ++it) {
427  if (!pfJetID(*it))
428  continue;
429 
430  jet_data->et.push_back(it->et());
431  jet_data->eta.push_back(it->eta());
432  jet_data->phi.push_back(it->phi());
433  jet_data->e.push_back(it->energy());
434 
435  jet_data->chef.push_back(it->chargedHadronEnergyFraction());
436  jet_data->nhef.push_back(it->neutralHadronEnergyFraction());
437  jet_data->pef.push_back(it->photonEnergyFraction());
438  jet_data->eef.push_back(it->electronEnergyFraction());
439  jet_data->mef.push_back(it->muonEnergyFraction());
440  jet_data->hfhef.push_back(it->HFHadronEnergyFraction());
441  jet_data->hfemef.push_back(it->HFEMEnergyFraction());
442  jet_data->chMult.push_back(it->chargedHadronMultiplicity());
443  jet_data->nhMult.push_back(it->neutralHadronMultiplicity());
444  jet_data->phMult.push_back(it->photonMultiplicity());
445  jet_data->elMult.push_back(it->electronMultiplicity());
446  jet_data->muMult.push_back(it->muonMultiplicity());
447  jet_data->hfhMult.push_back(it->HFHadronMultiplicity());
448  jet_data->hfemMult.push_back(it->HFEMMultiplicity());
449 
450  jet_data->cemef.push_back(it->chargedEmEnergyFraction());
451  jet_data->cmef.push_back(it->chargedMuEnergyFraction());
452  jet_data->nemef.push_back(it->neutralEmEnergyFraction());
453  jet_data->cMult.push_back(it->chargedMultiplicity());
454  jet_data->nMult.push_back(it->neutralMultiplicity());
455 
456  jet_data->nJets++;
457  }
458 }
459 
462  float corrFactor = 1.;
463  unsigned int nJets = 0;
464 
465  float mHx = 0;
466  float mHy = 0;
467 
468  met_data->Ht = 0;
469  met_data->mHt = -999.;
470  met_data->mHtPhi = -999.;
471 
472  for (auto it = pfJets->begin(); it != pfJets->end() && nJets < maxJet_; ++it) {
473  if (!pfJetID(*it))
474  continue;
475 
476  corrFactor = pfJetCorr.product()->correction(*it);
477 
478  jet_data->etCorr.push_back(it->et() * corrFactor);
479  jet_data->corrFactor.push_back(corrFactor);
480 
481  nJets++;
482 
483  if (it->pt() * corrFactor > jetptThreshold_ && std::abs(it->eta()) < jetetaMax_) {
484  mHx += -1. * it->px() * corrFactor;
485  mHy += -1. * it->py() * corrFactor;
486  met_data->Ht += it->pt() * corrFactor;
487  }
488  }
489 
490  TVector2 tv2 = TVector2(mHx, mHy);
491  met_data->mHt = tv2.Mod();
492  met_data->mHtPhi = tv2.Phi();
493 }
494 
496  for (auto it = puppiJets->begin(); it != puppiJets->end() && jet_data->puppi_nUncorrJets < maxJet_; ++it) {
497  if (!puppiJetID(*it))
498  continue;
499  jet_data->puppi_et.push_back(it->et());
501  }
502 }
503 
504 void L1JetRecoTreeProducer::doCorrPUPPIJets(edm::Handle<std::vector<pat::Jet> > corrPuppiJets) {
505  float mHx = 0;
506  float mHy = 0;
507 
508  met_data->puppi_Ht = 0;
509  met_data->puppi_mHt = -999.;
510  met_data->puppi_mHtPhi = -999.;
511 
512  for (auto it = corrPuppiJets->begin(); it != corrPuppiJets->end() && jet_data->puppi_nJets < maxJet_; ++it) {
513  if (!puppiJetID(*it))
514  continue;
515 
516  jet_data->puppi_etCorr.push_back(it->et());
517  jet_data->puppi_eta.push_back(it->eta());
518  jet_data->puppi_phi.push_back(it->phi());
519  jet_data->puppi_e.push_back(it->energy());
520 
521  jet_data->puppi_chef.push_back(it->chargedHadronEnergyFraction());
522  jet_data->puppi_nhef.push_back(it->neutralHadronEnergyFraction());
523  jet_data->puppi_pef.push_back(it->photonEnergyFraction());
524  jet_data->puppi_eef.push_back(it->electronEnergyFraction());
525  jet_data->puppi_mef.push_back(it->muonEnergyFraction());
526  jet_data->puppi_hfhef.push_back(it->HFHadronEnergyFraction());
527  jet_data->puppi_hfemef.push_back(it->HFEMEnergyFraction());
528  jet_data->puppi_chMult.push_back(it->chargedHadronMultiplicity());
529  jet_data->puppi_nhMult.push_back(it->neutralHadronMultiplicity());
530  jet_data->puppi_phMult.push_back(it->photonMultiplicity());
531  jet_data->puppi_elMult.push_back(it->electronMultiplicity());
532  jet_data->puppi_muMult.push_back(it->muonMultiplicity());
533  jet_data->puppi_hfhMult.push_back(it->HFHadronMultiplicity());
534  jet_data->puppi_hfemMult.push_back(it->HFEMMultiplicity());
535 
536  jet_data->puppi_cemef.push_back(it->chargedEmEnergyFraction());
537  jet_data->puppi_cmef.push_back(it->chargedMuEnergyFraction());
538  jet_data->puppi_nemef.push_back(it->neutralEmEnergyFraction());
539  jet_data->puppi_cMult.push_back(it->chargedMultiplicity());
540  jet_data->puppi_nMult.push_back(it->neutralMultiplicity());
541 
543 
544  if (it->pt() > jetptThreshold_ && std::abs(it->eta()) < jetetaMax_) {
545  mHx += -1. * it->px();
546  mHy += -1. * it->py();
547  met_data->puppi_Ht += it->pt();
548  }
549  }
550 
551  TVector2 tv2 = TVector2(mHx, mHy);
552  met_data->puppi_mHt = tv2.Mod();
553  met_data->puppi_mHtPhi = tv2.Phi();
554 }
555 
557  edm::Handle<reco::JetCorrector> caloJetCorr) {
558  float caloCorrFactor = 1.;
559  unsigned int nCaloJets = 0;
560 
561  met_data->caloHt = 0;
562 
563  for (auto it = caloJets->begin(); it != caloJets->end() && nCaloJets < maxJet_; ++it) {
564  if (!caloJetIDMissing_)
565  if (!caloJetID(*it))
566  continue;
567 
568  caloCorrFactor = caloJetCorr.product()->correction(*it);
569 
570  jet_data->caloEtCorr.push_back(it->et() * caloCorrFactor);
571  jet_data->caloCorrFactor.push_back(caloCorrFactor);
572 
573  nCaloJets++;
574 
575  if (it->pt() * caloCorrFactor > jetptThreshold_ && std::abs(it->eta()) < jetetaMax_) {
576  met_data->caloHt += it->pt() * caloCorrFactor;
577  }
578  }
579 }
580 
582  const reco::PFMETCollection* metCol = pfMet.product();
583  const reco::PFMET theMet = metCol->front();
584 
585  met_data->met = theMet.et();
586  met_data->metPhi = theMet.phi();
587  met_data->sumEt = theMet.sumEt();
588  met_data->metPx = theMet.px();
589  met_data->metPy = theMet.py();
590 }
591 
594  const reco::PFMETCollection* metCol = pfMet.product();
595  const reco::PFMET theMet = metCol->front();
596  reco::PFMET thePFMetNoMu = metCol->front();
597 
598  double pfMetNoMuPx = theMet.px();
599  double pfMetNoMuPy = theMet.py();
600 
601  double muPx(0.), muPy(0.);
602 
603  for (auto it = muons->begin(); it != muons->end(); ++it) {
604  if (it->isPFMuon()) {
605  muPx += it->px();
606  muPy += it->py();
607  }
608  }
609 
610  pfMetNoMuPx += muPx;
611  pfMetNoMuPy += muPy;
612 
613  math::XYZTLorentzVector pfMetNoMuP4(pfMetNoMuPx, pfMetNoMuPy, 0, hypot(pfMetNoMuPx, pfMetNoMuPy));
614 
615  thePFMetNoMu.setP4(pfMetNoMuP4);
616 
617  met_data->pfMetNoMu = thePFMetNoMu.et();
618  met_data->pfMetNoMuPhi = thePFMetNoMu.phi();
619  met_data->pfMetNoMuPx = thePFMetNoMu.px();
620  met_data->pfMetNoMuPy = thePFMetNoMu.py();
621 }
622 
625  const reco::PFMETCollection* metCol = puppiMet.product();
626  const reco::PFMET theMet = metCol->front();
627  reco::PFMET thePUPPIMetNoMu = metCol->front();
628 
629  double puppiMetNoMuPx = theMet.px();
630  double puppiMetNoMuPy = theMet.py();
631 
632  double muPx(0.), muPy(0.);
633 
634  for (auto it = muons->begin(); it != muons->end(); ++it) {
635  if (it->isPFMuon()) {
636  muPx += it->px();
637  muPy += it->py();
638  }
639  }
640 
641  puppiMetNoMuPx += muPx;
642  puppiMetNoMuPy += muPy;
643 
644  math::XYZTLorentzVector puppiMetNoMuP4(puppiMetNoMuPx, puppiMetNoMuPy, 0, hypot(puppiMetNoMuPx, puppiMetNoMuPy));
645 
646  thePUPPIMetNoMu.setP4(puppiMetNoMuP4);
647 
648  met_data->puppi_metNoMu = thePUPPIMetNoMu.et();
649  met_data->puppi_metNoMuPhi = thePUPPIMetNoMu.phi();
650  met_data->puppi_metNoMuPx = thePUPPIMetNoMu.px();
651  met_data->puppi_metNoMuPy = thePUPPIMetNoMu.py();
652 }
653 
655  const reco::CaloMETCollection* metCol = caloMet.product();
656  const reco::CaloMET theMet = metCol->front();
657 
658  met_data->caloMet = theMet.et();
659  met_data->caloMetPhi = theMet.phi();
660  met_data->caloSumEt = theMet.sumEt();
661 }
662 
664  const reco::CaloMETCollection* metCol = caloMetBE.product();
665  const reco::CaloMET theMet = metCol->front();
666 
667  met_data->caloMetBE = theMet.et();
668  met_data->caloMetPhiBE = theMet.phi();
669  met_data->caloSumEtBE = theMet.sumEt();
670 }
671 
673  edm::Handle<std::vector<pat::Jet> > corrPuppiJets) {
674  bool passPuppiJetPtCut = false;
675 
676  for (auto it = corrPuppiJets->begin(); it != corrPuppiJets->end(); ++it) {
677  if (!puppiJetID(*it))
678  continue;
679  if (it->muonEnergyFraction() > 0.5 || it->chargedEmEnergyFraction() > 0.5)
680  continue;
681  if (it->pt() > 30)
682  passPuppiJetPtCut = true;
683  }
684 
685  if (!passPuppiJetPtCut || muons->size() < 2) {
686  met_data->zPt = -999;
687  return;
688  }
689 
690  reco::Muon muon1;
691  reco::Muon muon2;
692 
693  float zMass = 91.2;
694  float diMuMass = 0;
695  float closestDiff = 999.;
696  bool found2PFMuons = false;
697 
698  for (auto it1 = muons->begin(); it1 != muons->end(); ++it1) {
699  if (!it1->isPFMuon())
700  continue;
701  for (auto it2 = std::next(it1); it2 != muons->end(); ++it2) {
702  if (!it2->isPFMuon())
703  continue;
704  if (it1->charge() != (-1 * it2->charge()))
705  continue;
706 
707  found2PFMuons = true;
708  diMuMass = (it1->p4() + it2->p4()).M();
709  float diff = abs(diMuMass - zMass);
710  if (diff < closestDiff) {
711  closestDiff = diff;
712  muon1 = *it1;
713  muon2 = *it2;
714  }
715  }
716  }
717 
718  diMuMass = (muon1.p4() + muon2.p4()).M();
719  if (abs(diMuMass - zMass) > 30 || !found2PFMuons) {
720  met_data->zPt = -999;
721  return;
722  }
723 
724  float zPt = (muon1.p4() + muon2.p4()).pt();
725  met_data->zPt = zPt;
726 }
727 
729  bool tmp = true;
730  if (std::abs(jet.eta()) <= 2.6) {
731  tmp &= jet.neutralHadronEnergyFraction() < 0.9;
732  tmp &= jet.neutralEmEnergyFraction() < 0.9;
733  tmp &= (jet.chargedMultiplicity() + jet.neutralMultiplicity()) > 1;
734  tmp &= jet.muonEnergyFraction() < 0.8;
735  tmp &= jet.chargedHadronEnergyFraction() > 0.01;
736  tmp &= jet.chargedMultiplicity() > 0;
737  tmp &= jet.chargedEmEnergyFraction() < 0.8;
738  }
739  if (std::abs(jet.eta()) > 2.6 && std::abs(jet.eta()) <= 2.7) {
740  tmp &= jet.neutralHadronEnergyFraction() < 0.9;
741  tmp &= jet.neutralEmEnergyFraction() < 0.99;
742  tmp &= jet.muonEnergyFraction() < 0.8;
743  tmp &= jet.chargedMultiplicity() > 0;
744  tmp &= jet.chargedEmEnergyFraction() < 0.8;
745  }
746  if (std::abs(jet.eta()) > 2.7 && std::abs(jet.eta()) < 3.0) {
747  tmp &= jet.neutralEmEnergyFraction() < 0.99;
748  tmp &= jet.neutralMultiplicity() > 1;
749  }
750  if (std::abs(jet.eta()) > 3.0) {
751  tmp &= jet.neutralHadronEnergyFraction() > 0.2;
752  tmp &= jet.neutralEmEnergyFraction() < 0.9;
753  tmp &= jet.neutralMultiplicity() > 10;
754  }
755 
756  // our custom selection
757  //tmp &= jet.muonMultiplicity() == 0;
758  //tmp &= jet.electronMultiplicity() == 0;
759 
760  return tmp;
761 }
762 
763 //https://twiki.cern.ch/twiki/bin/view/CMS/JetID13p6TeV
765  bool tmp = true;
766  if (std::abs(jet.eta()) <= 2.6) {
767  tmp &= jet.neutralHadronEnergyFraction() < 0.9;
768  tmp &= jet.neutralEmEnergyFraction() < 0.9;
769  tmp &= (jet.chargedMultiplicity() + jet.neutralMultiplicity()) > 1;
770  tmp &= jet.muonEnergyFraction() < 0.8;
771  tmp &= jet.chargedHadronEnergyFraction() > 0.01;
772  tmp &= jet.chargedMultiplicity() > 0;
773  tmp &= jet.chargedEmEnergyFraction() < 0.8;
774  }
775  if (std::abs(jet.eta()) > 2.6 && std::abs(jet.eta()) <= 2.7) {
776  tmp &= jet.neutralHadronEnergyFraction() < 0.9;
777  tmp &= jet.neutralEmEnergyFraction() < 0.99;
778  tmp &= jet.muonEnergyFraction() < 0.8;
779  tmp &= jet.chargedEmEnergyFraction() < 0.8;
780  }
781  if (std::abs(jet.eta()) > 2.7 && std::abs(jet.eta()) <= 3.0) {
782  tmp &= jet.neutralHadronEnergyFraction() < 0.9999;
783  }
784  if (std::abs(jet.eta()) > 3.0) {
785  tmp &= jet.neutralEmEnergyFraction() < 0.9;
786  tmp &= jet.neutralMultiplicity() > 2;
787  }
788 
789  return tmp;
790 }
791 
793  bool tmp = true;
794 
795  return tmp;
796 }
797 
798 // ------------ method called once each job just before starting event loop ------------
800 
801 // ------------ method called once each job just after ending the event loop ------------
803 
804 //define this as a plug-in
static const std::string kSharedResource
Definition: TFileService.h:76
void doZPt(edm::Handle< reco::MuonCollection > muons, edm::Handle< std::vector< pat::Jet > > corrPuppiJets)
void doPFMet(edm::Handle< reco::PFMETCollection > pfMet)
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
MPlex< T, D1, D2, N > hypot(const MPlex< T, D1, D2, N > &a, const MPlex< T, D1, D2, N > &b)
Definition: Matriplex.h:436
bool pfJetID(const reco::PFJet &jet)
edm::EDGetTokenT< reco::PFMETCollection > puppiMetToken_
Jets made from CaloTowers.
Definition: CaloJet.h:27
L1Analysis::L1AnalysisRecoMetDataFormat * met_data
T const * product() const
Definition: Handle.h:70
bool puppiJetID(const pat::Jet &jet)
void doPFJetCorr(edm::Handle< reco::PFJetCollection > pfJets, edm::Handle< reco::JetCorrector > pfJetCorr)
edm::EDGetTokenT< reco::CaloMETCollection > caloMetToken_
void analyze(const edm::Event &, const edm::EventSetup &) override
void doPFJets(edm::Handle< reco::PFJetCollection > pfJets)
caloMetBE
____________________________________________________________________________||
Definition: CaloMET_cfi.py:19
double sumEt() const
Definition: MET.h:56
edm::EDGetTokenT< reco::JetCorrector > pfJECToken_
static constexpr int nJets
double correction(const LorentzVector &fJet) const
get correction using Jet information only
Definition: JetCorrector.h:46
void doCaloMetBE(edm::Handle< reco::CaloMETCollection > caloMetBE)
muons
the two sets of parameters below are mutually exclusive, depending if RECO or ALCARECO is used the us...
Definition: DiMuonV_cfg.py:214
Jets made from PFObjects.
Definition: PFJet.h:20
edm::EDGetTokenT< reco::PFJetCollection > puppiJetToken_
const LorentzVector & p4() const final
four-momentum Lorentz vector
T getUntrackedParameter(std::string const &, T const &) const
XYZTLorentzVectorD XYZTLorentzVector
Lorentz vector with cylindrical internal representation using pseudorapidity.
Definition: LorentzVector.h:29
L1Analysis::L1AnalysisRecoJetDataFormat * jet_data
double px() const final
x coordinate of momentum vector
int iEvent
Definition: GenABIO.cc:224
void beginJob(void) override
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::EDGetTokenT< edm::ValueMap< reco::JetID > > caloJetIDToken_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::EDGetTokenT< reco::PFJetCollection > pfJetToken_
void doCaloJetCorr(edm::Handle< reco::CaloJetCollection > caloJets, edm::Handle< reco::JetCorrector > caloJetCorr)
double py() const final
y coordinate of momentum vector
void doPFMetNoMu(edm::Handle< reco::PFMETCollection > pfMet, edm::Handle< reco::MuonCollection >)
void doCaloMet(edm::Handle< reco::CaloMETCollection > caloMet)
edm::EDGetTokenT< std::vector< pat::Jet > > corrPuppiJetToken_
edm::EDGetTokenT< reco::PFMETCollection > pfMetToken_
void doPUPPIMetNoMu(edm::Handle< reco::PFMETCollection > puppiMet, edm::Handle< reco::MuonCollection >)
std::vector< reco::CaloMET > CaloMETCollection
collection of CaloMET objects
L1JetRecoTreeProducer(const edm::ParameterSet &)
Analysis-level calorimeter jet class.
Definition: Jet.h:77
void doCaloJets(edm::Handle< reco::CaloJetCollection > caloJets)
bool caloJetID(const reco::CaloJet &jet)
bool isValid() const
Definition: HandleBase.h:70
void doPUPPIJets(edm::Handle< reco::PFJetCollection > puppiJets)
edm::EDGetTokenT< reco::MuonCollection > muonToken_
edm::EDGetTokenT< reco::JetCorrector > caloJECToken_
double et() const final
transverse energy
std::vector< reco::PFMET > PFMETCollection
collection of PFMET objects
edm::EDGetTokenT< reco::CaloJetCollection > caloJetToken_
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
Log< level::Warning, false > LogWarning
tmp
align.sh
Definition: createJobs.py:716
double phi() const final
momentum azimuthal angle
void setP4(const LorentzVector &p4) final
set 4-momentum
edm::EDGetTokenT< reco::CaloMETCollection > caloMetBEToken_
void doCorrPUPPIJets(edm::Handle< std::vector< pat::Jet > > corrPuppiJets)