CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
AcceptJet.cc
Go to the documentation of this file.
5 
6 #include <iostream>
7 
8 using namespace std;
9 
11  const double& etaMax_,
12  const double& ptMin_,
13  const double& ptMax_,
14  const double& pMin_,
15  const double& pMax_,
16  const double& ratioMin_,
17  const double& ratioMax_,
18  const bool& doJetID_)
19  : etaMin(etaMin_),
20  etaMax(etaMax_),
21  ptRecJetMin(ptMin_),
22  ptRecJetMax(ptMax_),
23  pRecJetMin(pMin_),
24  pRecJetMax(pMax_),
25  ratioMin(ratioMin_),
26  ratioMax(ratioMax_),
27  doJetID(doJetID_) {}
28 
30  const int& jetFlavour,
32  const double jec) const {
33  // temporary fudge to correct for double loop error
34  // jetPartonMomentum /= 2.0;
35 
36  if (fabs(jet.eta()) < etaMin || fabs(jet.eta()) > etaMax)
37  return false;
38 
39  // if ( jetFlavour.underlyingParton4Vec().P() < pPartonMin ||
40  // jetFlavour.underlyingParton4Vec().P() > pPartonMax ) accept = false;
41  //
42  // if ( jetFlavour.underlyingParton4Vec().Pt() < ptPartonMin ||
43  // jetFlavour.underlyingParton4Vec().Pt() > ptPartonMax ) accept = false;
44 
45  if (jet.pt() * jec < ptRecJetMin || jet.pt() * jec > ptRecJetMax)
46  return false;
47 
48  if (jet.p() * jec < pRecJetMin || jet.p() * jec > pRecJetMax)
49  return false;
50 
51  if (!infos.isValid()) {
52  LogDebug("infos not valid") << "A valid SoftLeptonTagInfoCollection was not found!"
53  << " Skipping ratio check.";
54  } else {
55  double pToEratio = ratio(jet, infos);
56  if (pToEratio / jec < ratioMin || pToEratio / jec > ratioMax)
57  return false;
58  }
59 
60  if (doJetID) {
61  const reco::PFJet* pfjet = dynamic_cast<const reco::PFJet*>(&jet);
62  if (pfjet) {
63  double neutralHadronEnergyFraction = pfjet->neutralHadronEnergy() / (jet.energy() * jec);
64  double neutralEmEnergyFraction = pfjet->neutralEmEnergy() / (jet.energy() * jec);
65  int nConstituents = pfjet->getPFConstituents().size();
66  double chargedHadronEnergyFraction = pfjet->chargedHadronEnergy() / (jet.energy() * jec);
67  int chargedMultiplicity = pfjet->chargedMultiplicity();
68  double chargedEmEnergyFraction = pfjet->chargedEmEnergy() / (jet.energy() * jec);
69  if (!(neutralHadronEnergyFraction < 0.99 && neutralEmEnergyFraction < 0.99 && nConstituents > 1 &&
70  chargedHadronEnergyFraction > 0.0 && chargedMultiplicity > 0.0 && chargedEmEnergyFraction < 0.99))
71  return false; //2012 values
72  }
73  //Looks to not work -> to be fixed
74  //else std::cout<<"Jets are not PF jets, put 'doJetID' to False."<<std::endl;
75  }
76 
77  return true;
78 }
79 
81  double jetRatio = 0.0;
82  reco::SoftLeptonTagInfoCollection::const_iterator infoiter = infos->begin();
83  for (; infoiter != infos->end(); ++infoiter) {
84  if (reco::deltaR(jet.eta(), jet.phi(), infoiter->jet()->eta(), infoiter->jet()->phi()) > 1e-4)
85  continue;
86 
87  if (infoiter->leptons() == 0)
88  break;
89 
90  for (unsigned int k = 0; k != infoiter->leptons(); ++k) {
91  double tempRatio = infoiter->properties(k).ratio;
92  if (tempRatio > jetRatio)
93  jetRatio = tempRatio;
94  }
95  }
96 
97  return jetRatio;
98 }
double pRecJetMax
Definition: AcceptJet.h:68
double etaMax
Definition: AcceptJet.h:53
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:139
double pt() const final
transverse momentum
double ptRecJetMin
Definition: AcceptJet.h:64
double ptRecJetMax
Definition: AcceptJet.h:65
bool doJetID
Definition: AcceptJet.h:74
double etaMin
Definition: AcceptJet.h:52
Base class for all types of Jets.
Definition: Jet.h:20
double pRecJetMin
Definition: AcceptJet.h:67
tuple etaMin
Definition: Puppi_cff.py:46
etaMax_(conf.getParameter< double >("etaMax"))
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:152
double ratioMax
Definition: AcceptJet.h:71
Jets made from PFObjects.
Definition: PFJet.h:20
float neutralEmEnergy() const
neutralEmEnergy
Definition: PFJet.h:147
ptMin_(conf.getParameter< double >("ptMin"))
double p() const final
magnitude of momentum vector
pMin_(conf.getParameter< double >("pMin"))
AcceptJet(const double &etaMin_, const double &etaMax_, const double &ptMin_, const double &ptMax_, const double &pMin_, const double &pMax_, const double &ratioMin_, const double &ratioMax_, const bool &doJetID_)
Definition: AcceptJet.cc:10
double ratio(const reco::Jet &jet, const edm::Handle< reco::SoftLeptonTagInfoCollection > &infos) const
Finds the ratio of the momentum of any leptons in the jet to jet energy.
Definition: AcceptJet.cc:80
bool isValid() const
Definition: HandleBase.h:70
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:41
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:99
bool operator()(const reco::Jet &jet, const int &jetFlavour, const edm::Handle< reco::SoftLeptonTagInfoCollection > &infos, const double jec) const
Returns true if jet and associated parton satisfy kinematic cuts.
Definition: AcceptJet.cc:29
tuple etaMax
Definition: Puppi_cff.py:47
double phi() const final
momentum azimuthal angle
etaMin_(conf.getParameter< double >("etaMin"))
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: PFJet.h:95
#define LogDebug(id)
double energy() const final
energy
double eta() const final
momentum pseudorapidity