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 double eleEta, const double elePhi, const double eleVZ, const pat::PackedCandidateCollection &cands, const PIDVeto=PIDVeto::NONE) const
 
std::pair< int, double > calIsol (const double eleEta, const double elePhi, const double eleVZ, const reco::TrackCollection &tracks) const
 
std::pair< int, double > calIsol (const reco::TrackBase &trk, const pat::PackedCandidateCollection &cands, const PIDVeto=PIDVeto::NONE) const
 
std::pair< int, double > calIsol (const reco::TrackBase &trk, 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

◆ PIDVeto

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() [1/2]

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")) {}

◆ EleTkIsolFromCands() [2/2]

EleTkIsolFromCands::EleTkIsolFromCands ( const EleTkIsolFromCands )
default

◆ ~EleTkIsolFromCands()

EleTkIsolFromCands::~EleTkIsolFromCands ( )
default

Member Function Documentation

◆ calIsol() [1/4]

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.

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 }

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

◆ calIsol() [2/4]

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.

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 }

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

◆ calIsol() [3/4]

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.

56  {
57  return calIsol(eleTrk.eta(), eleTrk.phi(), eleTrk.vz(), cands, pidVeto);
58 }

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

Referenced by calIsol(), and calIsolPt().

◆ calIsol() [4/4]

std::pair< int, double > EleTkIsolFromCands::calIsol ( const reco::TrackBase trk,
const reco::TrackCollection tracks 
) const

Definition at line 82 of file EleTkIsolFromCands.cc.

83  {
84  return calIsol(eleTrk.eta(), eleTrk.phi(), eleTrk.vz(), tracks);
85 }

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

◆ calIsolPt()

template<typename... Args>
double EleTkIsolFromCands::calIsolPt ( Args &&...  args) const
inline

Definition at line 95 of file EleTkIsolFromCands.h.

95  {
96  return calIsol(std::forward<Args>(args)...).second;
97  }

References writedatasetfile::args, and calIsol().

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

◆ operator=()

EleTkIsolFromCands& EleTkIsolFromCands::operator= ( const EleTkIsolFromCands )
default

◆ passAlgo()

bool EleTkIsolFromCands::passAlgo ( const reco::TrackBase trk,
const std::vector< reco::TrackBase::TrackAlgorithm > &  algosToRej 
)
staticprivate

Definition at line 167 of file EleTkIsolFromCands.cc.

168  {
169  return algosToRej.empty() || !std::binary_search(algosToRej.begin(), algosToRej.end(), trk.algo());
170 }

References reco::TrackBase::algo().

Referenced by passTrkSel().

◆ passPIDVeto()

bool EleTkIsolFromCands::passPIDVeto ( const int  pdgId,
const EleTkIsolFromCands::PIDVeto  pidVeto 
)
static

Definition at line 105 of file EleTkIsolFromCands.cc.

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 }

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

Referenced by calIsol().

◆ passQual()

bool EleTkIsolFromCands::passQual ( const reco::TrackBase trk,
const std::vector< reco::TrackBase::TrackQuality > &  quals 
)
staticprivate

Definition at line 155 of file EleTkIsolFromCands.cc.

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 }

References reco::TrackBase::quality().

Referenced by passTrkSel().

◆ passTrkSel()

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.

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 }

References funct::abs(), L1TMuonDQMOffline_cfi::cuts, reco::deltaR2(), HLT_2018_cff::dEta, reco::TrackBase::eta(), reco::TrackBase::hitPattern(), reco::HitPattern::numberOfValidHits(), reco::HitPattern::numberOfValidPixelHits(), passAlgo(), passQual(), reco::TrackBase::phi(), reco::TrackBase::ptError(), and reco::TrackBase::vz().

Referenced by calIsol().

◆ pidVetoFromStr()

EleTkIsolFromCands::PIDVeto EleTkIsolFromCands::pidVetoFromStr ( const std::string &  vetoStr)
static

Definition at line 125 of file EleTkIsolFromCands.cc.

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 }

References ELES, Exception, NONE, and NONELES.

Referenced by ElectronHEEPIDValueMapProducer::ElectronHEEPIDValueMapProducer().

◆ pSetDescript()

edm::ParameterSetDescription EleTkIsolFromCands::pSetDescript ( )
static

Member Data Documentation

◆ barrelCuts_

TrkCuts EleTkIsolFromCands::barrelCuts_
private

Definition at line 68 of file EleTkIsolFromCands.h.

Referenced by calIsol().

◆ endcapCuts_

TrkCuts EleTkIsolFromCands::endcapCuts_
private

Definition at line 68 of file EleTkIsolFromCands.h.

Referenced by calIsol().

writedatasetfile.args
args
Definition: writedatasetfile.py:18
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
reco::TrackBase::ptError
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:702
EleTkIsolFromCands::passPIDVeto
static bool passPIDVeto(const int pdgId, const EleTkIsolFromCands::PIDVeto pidVeto)
Definition: EleTkIsolFromCands.cc:105
EleTkIsolFromCands::barrelCuts_
TrkCuts barrelCuts_
Definition: EleTkIsolFromCands.h:68
EleTkIsolFromCands::PIDVeto::NONE
EleTkIsolFromCands::TrkCuts::pSetDescript
static edm::ParameterSetDescription pSetDescript()
Definition: EleTkIsolFromCands.cc:28
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EleTkIsolFromCands::PIDVeto::NONELES
EleTkIsolFromCands::calIsol
std::pair< int, double > calIsol(const reco::TrackBase &trk, const pat::PackedCandidateCollection &cands, const PIDVeto=PIDVeto::NONE) const
Definition: EleTkIsolFromCands.cc:54
EleTkIsolFromCands::PIDVeto::ELES
HLT_2018_cff.dEta
dEta
Definition: HLT_2018_cff.py:12289
reco::TrackBase::pt
double pt() const
track transverse momentum
Definition: TrackBase.h:608
reco::TrackBase::vz
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:632
reco::Track
Definition: Track.h:27
reco::TrackBase::phi
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:620
EleTkIsolFromCands::passQual
static bool passQual(const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackQuality > &quals)
Definition: EleTkIsolFromCands.cc:155
edm::ParameterSet
Definition: ParameterSet.h:36
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
reco::TrackBase::eta
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:623
cand
Definition: decayParser.h:34
EleTkIsolFromCands::passAlgo
static bool passAlgo(const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackAlgorithm > &algosToRej)
Definition: EleTkIsolFromCands.cc:167
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
reco::TrackBase::algo
TrackAlgorithm algo() const
Definition: TrackBase.h:532
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
reco::TrackBase::hitPattern
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:489
EleTkIsolFromCands::passTrkSel
static bool passTrkSel(const reco::TrackBase &trk, const double trkPt, const TrkCuts &cuts, const double eleEta, const double elePhi, const double eleVZ)
Definition: EleTkIsolFromCands.cc:138
Exception
Definition: hltDiff.cc:246
HLT_2018_cff.cands
cands
Definition: HLT_2018_cff.py:13762
NONE
Definition: TkAlStyle.cc:47
reco::HitPattern::numberOfValidPixelHits
int numberOfValidPixelHits() const
Definition: HitPattern.h:800
L1TMuonDQMOffline_cfi.cuts
cuts
Definition: L1TMuonDQMOffline_cfi.py:41
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
reco::HitPattern::numberOfValidHits
int numberOfValidHits() const
Definition: HitPattern.h:786
PbPb_ZMuSkimMuonDPG_cff.veto
veto
Definition: PbPb_ZMuSkimMuonDPG_cff.py:61
EleTkIsolFromCands::endcapCuts_
TrkCuts endcapCuts_
Definition: EleTkIsolFromCands.h:68
reco::TrackBase::quality
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:537