CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Static Private Member Functions | Private Attributes
EleTkIsolFromCands Class Reference

#include <EleTkIsolFromCands.h>

Classes

struct  TrkCuts
 

Public Types

enum  PIDVeto { PIDVeto::NONE = 0, PIDVeto::ELES, PIDVeto::NONELES }
 

Public Member Functions

std::pair< int, double > calIsol (const reco::TrackBase &trk, const pat::PackedCandidateCollection &cands, const PIDVeto=PIDVeto::NONE) const
 
std::pair< int, double > calIsol (const double eleEta, const double elePhi, const double eleVZ, const pat::PackedCandidateCollection &cands, const PIDVeto=PIDVeto::NONE) const
 
std::pair< int, double > calIsol (const reco::TrackBase &trk, const reco::TrackCollection &tracks) const
 
std::pair< int, double > calIsol (const double eleEta, const double elePhi, const double eleVZ, const reco::TrackCollection &tracks) const
 
template<typename... Args>
double calIsolPt (Args &&...args) const
 
 EleTkIsolFromCands (const edm::ParameterSet &para)
 
 EleTkIsolFromCands (const EleTkIsolFromCands &)=default
 
EleTkIsolFromCandsoperator= (const EleTkIsolFromCands &)=default
 
 ~EleTkIsolFromCands ()=default
 

Static Public Member Functions

static bool passPIDVeto (const int pdgId, const EleTkIsolFromCands::PIDVeto pidVeto)
 
static PIDVeto pidVetoFromStr (const std::string &vetoStr)
 
static edm::ParameterSetDescription pSetDescript ()
 

Static Private Member Functions

static bool passAlgo (const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackAlgorithm > &algosToRej)
 
static bool passQual (const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackQuality > &quals)
 
static bool passTrkSel (const reco::TrackBase &trk, const double trkPt, const TrkCuts &cuts, const double eleEta, const double elePhi, const double eleVZ)
 

Private Attributes

TrkCuts barrelCuts_
 
TrkCuts endcapCuts_
 

Detailed Description

Definition at line 44 of file EleTkIsolFromCands.h.

Member Enumeration Documentation

Enumerator
NONE 
ELES 
NONELES 

Definition at line 46 of file EleTkIsolFromCands.h.

46  {
47  NONE = 0,
48  ELES,
49  NONELES,
50  };

Constructor & Destructor Documentation

EleTkIsolFromCands::EleTkIsolFromCands ( const edm::ParameterSet para)
explicit

Definition at line 43 of file EleTkIsolFromCands.cc.

44  : barrelCuts_(para.getParameter<edm::ParameterSet>("barrelCuts")),
45  endcapCuts_(para.getParameter<edm::ParameterSet>("endcapCuts")) {}
T getParameter(std::string const &) const
EleTkIsolFromCands::EleTkIsolFromCands ( const EleTkIsolFromCands )
default
EleTkIsolFromCands::~EleTkIsolFromCands ( )
default

Member Function Documentation

std::pair< int, double > EleTkIsolFromCands::calIsol ( const reco::TrackBase trk,
const pat::PackedCandidateCollection cands,
const PIDVeto  pidVeto = PIDVeto::NONE 
) const

Definition at line 54 of file EleTkIsolFromCands.cc.

References HLT_2018_cff::cands, reco::TrackBase::eta(), reco::TrackBase::phi(), and reco::TrackBase::vz().

Referenced by calIsol(), and calIsolPt().

56  {
57  return calIsol(eleTrk.eta(), eleTrk.phi(), eleTrk.vz(), cands, pidVeto);
58 }
std::pair< int, double > calIsol(const reco::TrackBase &trk, const pat::PackedCandidateCollection &cands, const PIDVeto=PIDVeto::NONE) const
std::pair< int, double > EleTkIsolFromCands::calIsol ( const double  eleEta,
const double  elePhi,
const double  eleVZ,
const pat::PackedCandidateCollection cands,
const PIDVeto  pidVeto = PIDVeto::NONE 
) const

Definition at line 60 of file EleTkIsolFromCands.cc.

References funct::abs(), barrelCuts_, L1TMuonDQMOffline_cfi::cuts, endcapCuts_, passPIDVeto(), passTrkSel(), and reco::TrackBase::pt().

64  {
65  double ptSum = 0.;
66  int nrTrks = 0;
67 
68  const TrkCuts& cuts = std::abs(eleEta) < 1.5 ? barrelCuts_ : endcapCuts_;
69 
70  for (auto& cand : cands) {
71  if (cand.hasTrackDetails() && cand.charge() != 0 && passPIDVeto(cand.pdgId(), pidVeto)) {
72  const reco::Track& trk = cand.pseudoTrack();
73  if (passTrkSel(trk, trk.pt(), cuts, eleEta, elePhi, eleVZ)) {
74  ptSum += trk.pt();
75  nrTrks++;
76  }
77  }
78  }
79  return {nrTrks, ptSum};
80 }
double pt() const
track transverse momentum
Definition: TrackBase.h:602
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool passTrkSel(const reco::TrackBase &trk, const double trkPt, const TrkCuts &cuts, const double eleEta, const double elePhi, const double eleVZ)
static bool passPIDVeto(const int pdgId, const EleTkIsolFromCands::PIDVeto pidVeto)
std::pair< int, double > EleTkIsolFromCands::calIsol ( const reco::TrackBase trk,
const reco::TrackCollection tracks 
) const

Definition at line 82 of file EleTkIsolFromCands.cc.

References calIsol(), reco::TrackBase::eta(), reco::TrackBase::phi(), PDWG_EXOHSCP_cff::tracks, and reco::TrackBase::vz().

83  {
84  return calIsol(eleTrk.eta(), eleTrk.phi(), eleTrk.vz(), tracks);
85 }
std::pair< int, double > calIsol(const reco::TrackBase &trk, const pat::PackedCandidateCollection &cands, const PIDVeto=PIDVeto::NONE) const
std::pair< int, double > EleTkIsolFromCands::calIsol ( const double  eleEta,
const double  elePhi,
const double  eleVZ,
const reco::TrackCollection tracks 
) const

Definition at line 87 of file EleTkIsolFromCands.cc.

References funct::abs(), barrelCuts_, L1TMuonDQMOffline_cfi::cuts, endcapCuts_, and passTrkSel().

90  {
91  double ptSum = 0.;
92  int nrTrks = 0;
93 
94  const TrkCuts& cuts = std::abs(eleEta) < 1.5 ? barrelCuts_ : endcapCuts_;
95 
96  for (auto& trk : tracks) {
97  if (passTrkSel(trk, trk.pt(), cuts, eleEta, elePhi, eleVZ)) {
98  ptSum += trk.pt();
99  nrTrks++;
100  }
101  }
102  return {nrTrks, ptSum};
103 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool passTrkSel(const reco::TrackBase &trk, const double trkPt, const TrkCuts &cuts, const double eleEta, const double elePhi, const double eleVZ)
template<typename... Args>
double EleTkIsolFromCands::calIsolPt ( Args &&...  args) const
inline

Definition at line 95 of file EleTkIsolFromCands.h.

References writedatasetfile::args, calIsol(), L1TMuonDQMOffline_cfi::cuts, passAlgo(), passPIDVeto(), passQual(), passTrkSel(), EgammaValidation_cff::pdgId, pidVetoFromStr(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by ElectronHEEPIDValueMapProducer::calTrkIso(), and GsfElectronAlgo::createElectron().

95  {
96  return calIsol(std::forward<Args>(args)...).second;
97  }
std::pair< int, double > calIsol(const reco::TrackBase &trk, const pat::PackedCandidateCollection &cands, const PIDVeto=PIDVeto::NONE) const
EleTkIsolFromCands& EleTkIsolFromCands::operator= ( const EleTkIsolFromCands )
default
bool EleTkIsolFromCands::passAlgo ( const reco::TrackBase trk,
const std::vector< reco::TrackBase::TrackAlgorithm > &  algosToRej 
)
staticprivate

Definition at line 167 of file EleTkIsolFromCands.cc.

References reco::TrackBase::algo().

Referenced by calIsolPt(), and passTrkSel().

168  {
169  return algosToRej.empty() || !std::binary_search(algosToRej.begin(), algosToRej.end(), trk.algo());
170 }
TrackAlgorithm algo() const
Definition: TrackBase.h:526
bool EleTkIsolFromCands::passPIDVeto ( const int  pdgId,
const EleTkIsolFromCands::PIDVeto  pidVeto 
)
static

Definition at line 105 of file EleTkIsolFromCands.cc.

References funct::abs(), ELES, Exception, NONE, NONELES, and PbPb_ZMuSkimMuonDPG_cff::veto.

Referenced by calIsol(), and calIsolPt().

105  {
106  int pidAbs = std::abs(pdgId);
107  switch (veto) {
108  case PIDVeto::NONE:
109  return true;
110  case PIDVeto::ELES:
111  if (pidAbs == 11)
112  return false;
113  else
114  return true;
115  case PIDVeto::NONELES:
116  if (pidAbs == 11)
117  return true;
118  else
119  return false;
120  }
121  throw cms::Exception("CodeError") << "invalid PIDVeto " << static_cast<int>(veto) << ", "
122  << "this is likely due to some static casting of invalid ints somewhere";
123 }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
bool EleTkIsolFromCands::passQual ( const reco::TrackBase trk,
const std::vector< reco::TrackBase::TrackQuality > &  quals 
)
staticprivate

Definition at line 155 of file EleTkIsolFromCands.cc.

References reco::TrackBase::quality().

Referenced by calIsolPt(), and passTrkSel().

155  {
156  if (quals.empty())
157  return true;
158 
159  for (auto qual : quals) {
160  if (trk.quality(qual))
161  return true;
162  }
163 
164  return false;
165 }
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:531
bool EleTkIsolFromCands::passTrkSel ( const reco::TrackBase trk,
const double  trkPt,
const TrkCuts cuts,
const double  eleEta,
const double  elePhi,
const double  eleVZ 
)
staticprivate

Definition at line 138 of file EleTkIsolFromCands.cc.

References funct::abs(), EleTkIsolFromCands::TrkCuts::algosToReject, EleTkIsolFromCands::TrkCuts::allowedQualities, reco::deltaR2(), HLT_2018_cff::dEta, reco::TrackBase::eta(), reco::TrackBase::hitPattern(), EleTkIsolFromCands::TrkCuts::maxDPtPt, EleTkIsolFromCands::TrkCuts::maxDR2, EleTkIsolFromCands::TrkCuts::maxDZ, EleTkIsolFromCands::TrkCuts::minDEta, EleTkIsolFromCands::TrkCuts::minDR2, EleTkIsolFromCands::TrkCuts::minHits, EleTkIsolFromCands::TrkCuts::minPixelHits, EleTkIsolFromCands::TrkCuts::minPt, reco::HitPattern::numberOfValidHits(), reco::HitPattern::numberOfValidPixelHits(), passAlgo(), passQual(), reco::TrackBase::phi(), reco::TrackBase::ptError(), and reco::TrackBase::vz().

Referenced by calIsol(), and calIsolPt().

143  {
144  const float dR2 = reco::deltaR2(eleEta, elePhi, trk.eta(), trk.phi());
145  const float dEta = trk.eta() - eleEta;
146  const float dZ = eleVZ - trk.vz();
147 
148  return dR2 >= cuts.minDR2 && dR2 <= cuts.maxDR2 && std::abs(dEta) >= cuts.minDEta && std::abs(dZ) < cuts.maxDZ &&
149  trk.hitPattern().numberOfValidHits() >= cuts.minHits &&
150  trk.hitPattern().numberOfValidPixelHits() >= cuts.minPixelHits &&
151  (trk.ptError() / trkPt < cuts.maxDPtPt || cuts.maxDPtPt < 0) && passQual(trk, cuts.allowedQualities) &&
152  passAlgo(trk, cuts.algosToReject) && trkPt > cuts.minPt;
153 }
int numberOfValidHits() const
Definition: HitPattern.h:787
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:614
static bool passAlgo(const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackAlgorithm > &algosToRej)
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:617
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:696
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static bool passQual(const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackQuality > &quals)
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:626
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:483
int numberOfValidPixelHits() const
Definition: HitPattern.h:801
EleTkIsolFromCands::PIDVeto EleTkIsolFromCands::pidVetoFromStr ( const std::string &  vetoStr)
static

Definition at line 125 of file EleTkIsolFromCands.cc.

References ELES, Exception, NONE, and NONELES.

Referenced by calIsolPt(), and ElectronHEEPIDValueMapProducer::ElectronHEEPIDValueMapProducer().

125  {
126  if (vetoStr == "NONE")
127  return PIDVeto::NONE;
128  else if (vetoStr == "ELES")
129  return PIDVeto::ELES;
130  else if (vetoStr == "NONELES")
131  return PIDVeto::NONELES;
132  else {
133  throw cms::Exception("CodeError") << "unrecognised string " << vetoStr
134  << ", either a typo or this function needs to be updated";
135  }
136 }
edm::ParameterSetDescription EleTkIsolFromCands::pSetDescript ( )
static

Definition at line 47 of file EleTkIsolFromCands.cc.

References edm::ParameterSetDescription::add(), and EleTkIsolFromCands::TrkCuts::pSetDescript().

Referenced by GsfElectronBaseProducer::fillDescriptions(), and ElectronHEEPIDValueMapProducer::fillDescriptions().

47  {
49  desc.add("barrelCuts", TrkCuts::pSetDescript());
50  desc.add("endcapCuts", TrkCuts::pSetDescript());
51  return desc;
52 }
static edm::ParameterSetDescription pSetDescript()
ParameterDescriptionBase * add(U const &iLabel, T const &value)

Member Data Documentation

TrkCuts EleTkIsolFromCands::barrelCuts_
private

Definition at line 68 of file EleTkIsolFromCands.h.

Referenced by calIsol().

TrkCuts EleTkIsolFromCands::endcapCuts_
private

Definition at line 68 of file EleTkIsolFromCands.h.

Referenced by calIsol().