CMS 3D CMS Logo

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

#include <EleTkIsolFromCands.h>

Classes

struct  Configuration
 
struct  Output
 
struct  TrkCuts
 

Public Types

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

Public Member Functions

 EleTkIsolFromCands (Configuration const &cfg, pat::PackedCandidateCollection const &cands, PIDVeto pidVeto=PIDVeto::NONE)
 
 EleTkIsolFromCands (Configuration const &cfg, reco::TrackCollection const &tracks)
 
Output operator() (const reco::TrackBase &electronTrack)
 

Static Public Member Functions

static PIDVeto pidVetoFromStr (const std::string &vetoStr)
 
static edm::ParameterSetDescription pSetDescript ()
 

Private Types

using TrackTable = edm::soa::Table< edm::soa::col::Pt, edm::soa::col::Eta, edm::soa::col::Phi, edm::soa::col::Vz >
 

Private Member Functions

TrackTable const & getPreselectedTracks (bool isBarrel)
 

Static Private Member Functions

static bool passAlgo (const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackAlgorithm > &algosToRej)
 
static bool passPIDVeto (const int pdgId, const EleTkIsolFromCands::PIDVeto pidVeto)
 
static bool passQual (const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackQuality > &quals)
 
static bool passTrackPreselection (const reco::TrackBase &trk, float trkPt, const TrkCuts &cuts)
 
static TrackTable preselectTracks (reco::TrackCollection const &tracks, TrkCuts const &cuts)
 
static TrackTable preselectTracksFromCands (pat::PackedCandidateCollection const &cands, TrkCuts const &cuts, PIDVeto=PIDVeto::NONE)
 

Private Attributes

pat::PackedCandidateCollection const * cands_ = nullptr
 
Configuration const & cfg_
 
const PIDVeto pidVeto_ = PIDVeto::NONE
 
TrackTable preselectedTracksWithBarrelCuts_
 
TrackTable preselectedTracksWithEndcapCuts_
 
reco::TrackCollection const * tracks_ = nullptr
 
bool tracksCachedForBarrelCuts_ = false
 
bool tracksCachedForEndcapCuts_ = false
 

Detailed Description

Definition at line 46 of file EleTkIsolFromCands.h.

Member Typedef Documentation

◆ TrackTable

Definition at line 106 of file EleTkIsolFromCands.h.

Member Enumeration Documentation

◆ PIDVeto

Enumerator
NONE 
ELES 
NONELES 

Definition at line 71 of file EleTkIsolFromCands.h.

71  {
72  NONE = 0,
73  ELES,
74  NONELES,
75  };

Constructor & Destructor Documentation

◆ EleTkIsolFromCands() [1/2]

EleTkIsolFromCands::EleTkIsolFromCands ( Configuration const &  cfg,
reco::TrackCollection const &  tracks 
)
inlineexplicit

Definition at line 77 of file EleTkIsolFromCands.h.

78  : cfg_{cfg}, tracks_{&tracks} {}

References looper::cfg.

◆ EleTkIsolFromCands() [2/2]

EleTkIsolFromCands::EleTkIsolFromCands ( Configuration const &  cfg,
pat::PackedCandidateCollection const &  cands,
PIDVeto  pidVeto = PIDVeto::NONE 
)
inlineexplicit

Definition at line 79 of file EleTkIsolFromCands.h.

82  : cfg_{cfg}, cands_{&cands}, pidVeto_{pidVeto} {}

References looper::cfg.

Member Function Documentation

◆ getPreselectedTracks()

EleTkIsolFromCands::TrackTable const & EleTkIsolFromCands::getPreselectedTracks ( bool  isBarrel)
private

◆ operator()()

EleTkIsolFromCands::Output EleTkIsolFromCands::operator() ( const reco::TrackBase electronTrack)

Definition at line 102 of file EleTkIsolFromCands.cc.

102  {
103  using namespace edm::soa::col;
104 
105  float ptSum = 0.;
106  int nrTrks = 0;
107 
108  const float eleEta = eleTrk.eta();
109  const float elePhi = eleTrk.phi();
110  const float eleVz = eleTrk.vz();
111 
112  const bool isBarrelElectron = std::abs(eleEta) < 1.5;
113 
114  auto const& preselectedTracks = getPreselectedTracks(isBarrelElectron);
115  auto const& cuts = isBarrelElectron ? cfg_.barrelCuts : cfg_.endcapCuts;
116 
117  for (auto const& trk : preselectedTracks) {
118  const float dR2 = reco::deltaR2(eleEta, elePhi, trk.get<Eta>(), trk.get<Phi>());
119  const float dEta = trk.get<Eta>() - eleEta;
120  const float dZ = eleVz - trk.get<Vz>();
121 
122  if (dR2 >= cuts.minDR2 && dR2 <= cuts.maxDR2 && std::abs(dEta) >= cuts.minDEta && std::abs(dZ) < cuts.maxDZ) {
123  ptSum += trk.get<Pt>();
124  nrTrks++;
125  }
126  }
127  return {nrTrks, ptSum};
128 }

References funct::abs(), EleTkIsolFromCands::Configuration::barrelCuts, cfg_, cuts, reco::deltaR2(), HLT_FULL_cff::dEta, EleTkIsolFromCands::Configuration::endcapCuts, reco::TrackBase::eta(), getPreselectedTracks(), reco::TrackBase::phi(), and reco::TrackBase::vz().

◆ passAlgo()

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

Definition at line 181 of file EleTkIsolFromCands.cc.

182  {
183  return algosToRej.empty() || !std::binary_search(algosToRej.begin(), algosToRej.end(), trk.algo());
184 }

References reco::TrackBase::algo().

Referenced by passTrackPreselection().

◆ passPIDVeto()

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

Definition at line 130 of file EleTkIsolFromCands.cc.

130  {
131  int pidAbs = std::abs(pdgId);
132  switch (veto) {
133  case PIDVeto::NONE:
134  return true;
135  case PIDVeto::ELES:
136  if (pidAbs == 11)
137  return false;
138  else
139  return true;
140  case PIDVeto::NONELES:
141  if (pidAbs == 11)
142  return true;
143  else
144  return false;
145  }
146  throw cms::Exception("CodeError") << "invalid PIDVeto " << static_cast<int>(veto) << ", "
147  << "this is likely due to some static casting of invalid ints somewhere";
148 }

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

Referenced by preselectTracksFromCands().

◆ passQual()

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

Definition at line 169 of file EleTkIsolFromCands.cc.

169  {
170  if (quals.empty())
171  return true;
172 
173  for (auto qual : quals) {
174  if (trk.quality(qual))
175  return true;
176  }
177 
178  return false;
179 }

References reco::TrackBase::quality().

Referenced by passTrackPreselection().

◆ passTrackPreselection()

bool EleTkIsolFromCands::passTrackPreselection ( const reco::TrackBase trk,
float  trkPt,
const TrkCuts cuts 
)
staticprivate

Definition at line 163 of file EleTkIsolFromCands.cc.

163  {
164  return trackPt > cuts.minPt && trk.numberOfValidHits() >= cuts.minHits &&
165  trk.hitPattern().numberOfValidPixelHits() >= cuts.minPixelHits && passQual(trk, cuts.allowedQualities) &&
166  passAlgo(trk, cuts.algosToReject) && (cuts.maxDPtPt < 0 || trk.ptError() / trackPt < cuts.maxDPtPt);
167 }

References cuts, reco::TrackBase::hitPattern(), reco::TrackBase::numberOfValidHits(), reco::HitPattern::numberOfValidPixelHits(), passAlgo(), passQual(), reco::TrackBase::ptError(), and listHistos::trackPt.

Referenced by preselectTracks(), and preselectTracksFromCands().

◆ pidVetoFromStr()

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

Definition at line 150 of file EleTkIsolFromCands.cc.

150  {
151  if (vetoStr == "NONE")
152  return PIDVeto::NONE;
153  else if (vetoStr == "ELES")
154  return PIDVeto::ELES;
155  else if (vetoStr == "NONELES")
156  return PIDVeto::NONELES;
157  else {
158  throw cms::Exception("CodeError") << "unrecognised string " << vetoStr
159  << ", either a typo or this function needs to be updated";
160  }
161 }

References ELES, Exception, NONE, and NONELES.

Referenced by ElectronHEEPIDValueMapProducer::ElectronHEEPIDValueMapProducer().

◆ preselectTracks()

EleTkIsolFromCands::TrackTable EleTkIsolFromCands::preselectTracks ( reco::TrackCollection const &  tracks,
TrkCuts const &  cuts 
)
staticprivate

Definition at line 50 of file EleTkIsolFromCands.cc.

51  {
52  std::vector<float> pt;
53  std::vector<float> eta;
54  std::vector<float> phi;
55  std::vector<float> vz;
56  pt.reserve(tracks.size());
57  eta.reserve(tracks.size());
58  phi.reserve(tracks.size());
59  vz.reserve(tracks.size());
60 
61  for (auto const& trk : tracks) {
62  auto trkPt = trk.pt();
63  if (passTrackPreselection(trk, trkPt, cuts)) {
64  pt.emplace_back(trkPt);
65  eta.emplace_back(trk.eta());
66  phi.emplace_back(trk.phi());
67  vz.emplace_back(trk.vz());
68  }
69  }
70 
71  return {pt, std::move(eta), std::move(phi), std::move(vz)};
72 }

References cuts, PVValHelper::eta, eostools::move(), passTrackPreselection(), phi, DiDispStaMuonMonitor_cfi::pt, and tracks.

Referenced by getPreselectedTracks().

◆ preselectTracksFromCands()

EleTkIsolFromCands::TrackTable EleTkIsolFromCands::preselectTracksFromCands ( pat::PackedCandidateCollection const &  cands,
TrkCuts const &  cuts,
PIDVeto  pidVeto = PIDVeto::NONE 
)
staticprivate

Definition at line 74 of file EleTkIsolFromCands.cc.

76  {
77  std::vector<float> pt;
78  std::vector<float> eta;
79  std::vector<float> phi;
80  std::vector<float> vz;
81  pt.reserve(cands.size());
82  eta.reserve(cands.size());
83  phi.reserve(cands.size());
84  vz.reserve(cands.size());
85 
86  for (auto const& cand : cands) {
87  if (cand.hasTrackDetails() && cand.charge() != 0 && passPIDVeto(cand.pdgId(), pidVeto)) {
88  const reco::Track& trk = cand.pseudoTrack();
89  float trkPt = trk.pt();
90  if (passTrackPreselection(trk, trkPt, cuts)) {
91  pt.emplace_back(trkPt);
92  eta.emplace_back(trk.eta());
93  phi.emplace_back(trk.phi());
94  vz.emplace_back(trk.vz());
95  }
96  }
97  }
98 
99  return {pt, std::move(eta), std::move(phi), std::move(vz)};
100 }

References HLT_FULL_cff::cands, cuts, PVValHelper::eta, reco::TrackBase::eta(), eostools::move(), passPIDVeto(), passTrackPreselection(), phi, reco::TrackBase::phi(), DiDispStaMuonMonitor_cfi::pt, reco::TrackBase::pt(), and reco::TrackBase::vz().

Referenced by getPreselectedTracks().

◆ pSetDescript()

edm::ParameterSetDescription EleTkIsolFromCands::pSetDescript ( )
static

Member Data Documentation

◆ cands_

pat::PackedCandidateCollection const* EleTkIsolFromCands::cands_ = nullptr
private

Definition at line 127 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

◆ cfg_

Configuration const& EleTkIsolFromCands::cfg_
private

Definition at line 123 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks(), and operator()().

◆ pidVeto_

const PIDVeto EleTkIsolFromCands::pidVeto_ = PIDVeto::NONE
private

Definition at line 128 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

◆ preselectedTracksWithBarrelCuts_

TrackTable EleTkIsolFromCands::preselectedTracksWithBarrelCuts_
private

Definition at line 129 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

◆ preselectedTracksWithEndcapCuts_

TrackTable EleTkIsolFromCands::preselectedTracksWithEndcapCuts_
private

Definition at line 130 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

◆ tracks_

reco::TrackCollection const* EleTkIsolFromCands::tracks_ = nullptr
private

Definition at line 126 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

◆ tracksCachedForBarrelCuts_

bool EleTkIsolFromCands::tracksCachedForBarrelCuts_ = false
private

Definition at line 131 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

◆ tracksCachedForEndcapCuts_

bool EleTkIsolFromCands::tracksCachedForEndcapCuts_ = false
private

Definition at line 132 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

EleTkIsolFromCands::passTrackPreselection
static bool passTrackPreselection(const reco::TrackBase &trk, float trkPt, const TrkCuts &cuts)
Definition: EleTkIsolFromCands.cc:163
edm::soa::col::Vz
Definition: KinematicColumns.h:14
reco::TrackBase::ptError
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:754
cuts
const TkSoA *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
Definition: CAHitNtupletGeneratorKernelsImpl.h:338
EleTkIsolFromCands::passPIDVeto
static bool passPIDVeto(const int pdgId, const EleTkIsolFromCands::PIDVeto pidVeto)
Definition: EleTkIsolFromCands.cc:130
EleTkIsolFromCands::preselectTracks
static TrackTable preselectTracks(reco::TrackCollection const &tracks, TrkCuts const &cuts)
Definition: EleTkIsolFromCands.cc:50
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
EleTkIsolFromCands::PIDVeto::NONE
EleTkIsolFromCands::TrkCuts::pSetDescript
static edm::ParameterSetDescription pSetDescript()
Definition: EleTkIsolFromCands.cc:28
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
EleTkIsolFromCands::PIDVeto::NONELES
reco::TrackBase::numberOfValidHits
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:798
EleTkIsolFromCands::PIDVeto::ELES
reco::TrackBase::pt
double pt() const
track transverse momentum
Definition: TrackBase.h:637
edm::soa::col
Definition: KinematicColumns.h:8
reco::TrackBase::vz
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:661
EleTkIsolFromCands::preselectTracksFromCands
static TrackTable preselectTracksFromCands(pat::PackedCandidateCollection const &cands, TrkCuts const &cuts, PIDVeto=PIDVeto::NONE)
Definition: EleTkIsolFromCands.cc:74
PVValHelper::eta
Definition: PVValidationHelpers.h:70
reco::Track
Definition: Track.h:27
EleTkIsolFromCands::getPreselectedTracks
TrackTable const & getPreselectedTracks(bool isBarrel)
Definition: EleTkIsolFromCands.cc:186
reco::TrackBase::phi
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
PixelPluginsPhase0_cfi.isBarrel
isBarrel
Definition: PixelPluginsPhase0_cfi.py:17
HLT_FULL_cff.cands
cands
Definition: HLT_FULL_cff.py:15144
EleTkIsolFromCands::passQual
static bool passQual(const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackQuality > &quals)
Definition: EleTkIsolFromCands.cc:169
EleTkIsolFromCands::cfg_
Configuration const & cfg_
Definition: EleTkIsolFromCands.h:123
EleTkIsolFromCands::tracksCachedForBarrelCuts_
bool tracksCachedForBarrelCuts_
Definition: EleTkIsolFromCands.h:131
tracks
const uint32_t *__restrict__ const HitContainer *__restrict__ TkSoA *__restrict__ tracks
Definition: CAHitNtupletGeneratorKernelsImpl.h:159
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
EleTkIsolFromCands::Configuration::barrelCuts
const TrkCuts barrelCuts
Definition: EleTkIsolFromCands.h:67
reco::TrackBase::eta
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
edm::soa::col::Eta
Definition: KinematicColumns.h:10
cand
Definition: decayParser.h:32
EleTkIsolFromCands::passAlgo
static bool passAlgo(const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackAlgorithm > &algosToRej)
Definition: EleTkIsolFromCands.cc:181
EgammaValidation_cff.pdgId
pdgId
Definition: EgammaValidation_cff.py:118
EleTkIsolFromCands::Configuration::endcapCuts
const TrkCuts endcapCuts
Definition: EleTkIsolFromCands.h:68
looper.cfg
cfg
Definition: looper.py:297
reco::TrackBase::algo
TrackAlgorithm algo() const
Definition: TrackBase.h:547
DDAxes::phi
EleTkIsolFromCands::cands_
pat::PackedCandidateCollection const * cands_
Definition: EleTkIsolFromCands.h:127
reco::TrackBase::hitPattern
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:504
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
eostools.move
def move(src, dest)
Definition: eostools.py:511
HLT_FULL_cff.dEta
dEta
Definition: HLT_FULL_cff.py:13702
Exception
Definition: hltDiff.cc:245
EleTkIsolFromCands::preselectedTracksWithBarrelCuts_
TrackTable preselectedTracksWithBarrelCuts_
Definition: EleTkIsolFromCands.h:129
NONE
Definition: TkAlStyle.cc:47
edm::soa::col::Pt
Definition: KinematicColumns.h:19
reco::HitPattern::numberOfValidPixelHits
int numberOfValidPixelHits() const
Definition: HitPattern.h:800
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EleTkIsolFromCands::preselectedTracksWithEndcapCuts_
TrackTable preselectedTracksWithEndcapCuts_
Definition: EleTkIsolFromCands.h:130
PbPb_ZMuSkimMuonDPG_cff.veto
veto
Definition: PbPb_ZMuSkimMuonDPG_cff.py:61
listHistos.trackPt
trackPt
Definition: listHistos.py:120
reco::TrackBase::quality
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:552
edm::soa::col::Phi
Definition: KinematicColumns.h:11
EleTkIsolFromCands::tracks_
reco::TrackCollection const * tracks_
Definition: EleTkIsolFromCands.h:126
EleTkIsolFromCands::tracksCachedForEndcapCuts_
bool tracksCachedForEndcapCuts_
Definition: EleTkIsolFromCands.h:132
EleTkIsolFromCands::pidVeto_
const PIDVeto pidVeto_
Definition: EleTkIsolFromCands.h:128