CMS 3D CMS Logo

AcceptJet.cc
Go to the documentation of this file.
5 
6 #include <iostream>
7 
8 using namespace std;
9 
10 AcceptJet::AcceptJet(const double& etaMin_,
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 }
reco::btau::chargedHadronEnergyFraction
Definition: TaggingVariable.h:103
ALCARECOTkAlBeamHalo_cff.etaMin
etaMin
GeV.
Definition: ALCARECOTkAlBeamHalo_cff.py:32
reco::btau::neutralHadronEnergyFraction
Definition: TaggingVariable.h:104
reco::Jet
Base class for all types of Jets.
Definition: Jet.h:20
AcceptJet::ptRecJetMax
double ptRecJetMax
Definition: AcceptJet.h:65
MessageLogger.h
bTagCommon_cff.doJetID
doJetID
Definition: bTagCommon_cff.py:44
reco::PFJet::getPFConstituents
virtual std::vector< reco::PFCandidatePtr > getPFConstituents() const
get all constituents
Definition: PFJet.cc:41
AcceptJet::operator()
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
AcceptJet::ptRecJetMin
double ptRecJetMin
Definition: AcceptJet.h:64
PFJet.h
AcceptJet::AcceptJet
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
edm::Handle
Definition: AssociativeIterator.h:50
reco::PFJet::chargedHadronEnergy
float chargedHadronEnergy() const
chargedHadronEnergy
Definition: PFJet.h:95
AcceptJet::pRecJetMin
double pRecJetMin
Definition: AcceptJet.h:67
reco::PFJet::chargedMultiplicity
int chargedMultiplicity() const
chargedMultiplicity
Definition: PFJet.h:152
reco::PFJet::chargedEmEnergy
float chargedEmEnergy() const
chargedEmEnergy
Definition: PFJet.h:139
dqmdumpme.k
k
Definition: dqmdumpme.py:60
AcceptJet::etaMax
double etaMax
Definition: AcceptJet.h:53
custom_jme_cff.nConstituents
nConstituents
Definition: custom_jme_cff.py:136
AcceptJet::ratioMax
double ratioMax
Definition: AcceptJet.h:71
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
bTagCommon_cff.ptRecJetMax
ptRecJetMax
Definition: bTagCommon_cff.py:28
bTagCommon_cff.ptRecJetMin
ptRecJetMin
Definition: bTagCommon_cff.py:27
deltaR.h
AcceptJet::pRecJetMax
double pRecJetMax
Definition: AcceptJet.h:68
AcceptJet::ratio
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
AcceptJet::doJetID
bool doJetID
Definition: AcceptJet.h:74
std
Definition: JetResolutionObject.h:76
reco::PFJet::neutralHadronEnergy
float neutralHadronEnergy() const
neutralHadronEnergy
Definition: PFJet.h:99
metsig::jet
Definition: SignAlgoResolutions.h:47
AcceptJet::etaMin
double etaMin
Definition: AcceptJet.h:52
reco::PFJet
Jets made from PFObjects.
Definition: PFJet.h:20
reco::PFJet::neutralEmEnergy
float neutralEmEnergy() const
neutralEmEnergy
Definition: PFJet.h:147
ALCARECOTkAlBeamHalo_cff.etaMax
etaMax
Definition: ALCARECOTkAlBeamHalo_cff.py:33
reco::deltaR
constexpr auto deltaR(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:30
jetMETDQMOfflineSource_cff.jec
jec
Definition: jetMETDQMOfflineSource_cff.py:27
AcceptJet.h
bTagCommon_cff.ratioMax
ratioMax
Definition: bTagCommon_cff.py:34
submitPVValidationJobs.infos
dictionary infos
Definition: submitPVValidationJobs.py:221
bTagCommon_cff.ratioMin
ratioMin
Definition: bTagCommon_cff.py:33
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37