CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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, reco::TrackCollection const &tracks)
 
 EleTkIsolFromCands (Configuration const &cfg, pat::PackedCandidateCollection const &cands, PIDVeto pidVeto=PIDVeto::NONE)
 
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

Definition at line 106 of file EleTkIsolFromCands.h.

Member Enumeration Documentation

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::EleTkIsolFromCands ( Configuration const &  cfg,
reco::TrackCollection const &  tracks 
)
inlineexplicit

Definition at line 77 of file EleTkIsolFromCands.h.

78  : cfg_{cfg}, tracks_{&tracks} {}
tuple cfg
Definition: looper.py:296
reco::TrackCollection const * tracks_
auto const & tracks
cannot be loose
Configuration const & cfg_
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} {}
tuple cfg
Definition: looper.py:296
Configuration const & cfg_
pat::PackedCandidateCollection const * cands_

Member Function Documentation

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

Definition at line 186 of file EleTkIsolFromCands.cc.

References EleTkIsolFromCands::Configuration::barrelCuts, cands_, cfg_, cuts, EleTkIsolFromCands::Configuration::endcapCuts, pidVeto_, preselectedTracksWithBarrelCuts_, preselectedTracksWithEndcapCuts_, preselectTracks(), preselectTracksFromCands(), tracks_, tracksCachedForBarrelCuts_, and tracksCachedForEndcapCuts_.

Referenced by operator()().

186  {
187  auto const& cuts = isBarrel ? cfg_.barrelCuts : cfg_.endcapCuts;
190 
191  if (!tracksCached) {
193  tracksCached = true;
194  }
195 
196  return preselectedTracks;
197 }
reco::TrackCollection const * tracks_
static TrackTable preselectTracks(reco::TrackCollection const &tracks, TrkCuts const &cuts)
TkSoA const *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
TrackTable preselectedTracksWithBarrelCuts_
static TrackTable preselectTracksFromCands(pat::PackedCandidateCollection const &cands, TrkCuts const &cuts, PIDVeto=PIDVeto::NONE)
Configuration const & cfg_
pat::PackedCandidateCollection const * cands_
TrackTable preselectedTracksWithEndcapCuts_
EleTkIsolFromCands::Output EleTkIsolFromCands::operator() ( const reco::TrackBase electronTrack)

Definition at line 102 of file EleTkIsolFromCands.cc.

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

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 }
TkSoA const *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
Configuration const & cfg_
int col
Definition: cuy.py:1009
TrackTable const & getPreselectedTracks(bool isBarrel)
bool EleTkIsolFromCands::passAlgo ( const reco::TrackBase trk,
const std::vector< reco::TrackBase::TrackAlgorithm > &  algosToRej 
)
staticprivate

Definition at line 181 of file EleTkIsolFromCands.cc.

References reco::TrackBase::algo().

Referenced by passTrackPreselection().

182  {
183  return algosToRej.empty() || !std::binary_search(algosToRej.begin(), algosToRej.end(), trk.algo());
184 }
TrackAlgorithm algo() const
Definition: TrackBase.h:547
bool EleTkIsolFromCands::passPIDVeto ( const int  pdgId,
const EleTkIsolFromCands::PIDVeto  pidVeto 
)
staticprivate

Definition at line 130 of file EleTkIsolFromCands.cc.

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

Referenced by preselectTracksFromCands().

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 }
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 169 of file EleTkIsolFromCands.cc.

References reco::TrackBase::quality().

Referenced by passTrackPreselection().

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 }
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:552
bool EleTkIsolFromCands::passTrackPreselection ( const reco::TrackBase trk,
float  trkPt,
const TrkCuts cuts 
)
staticprivate

Definition at line 163 of file EleTkIsolFromCands.cc.

References EleTkIsolFromCands::TrkCuts::algosToReject, EleTkIsolFromCands::TrkCuts::allowedQualities, reco::TrackBase::hitPattern(), EleTkIsolFromCands::TrkCuts::maxDPtPt, EleTkIsolFromCands::TrkCuts::minHits, EleTkIsolFromCands::TrkCuts::minPixelHits, EleTkIsolFromCands::TrkCuts::minPt, reco::TrackBase::numberOfValidHits(), reco::HitPattern::numberOfValidPixelHits(), passAlgo(), passQual(), and reco::TrackBase::ptError().

Referenced by preselectTracks(), and preselectTracksFromCands().

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 }
tuple trackPt
Definition: listHistos.py:120
static bool passAlgo(const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackAlgorithm > &algosToRej)
TkSoA const *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:754
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:798
static bool passQual(const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackQuality > &quals)
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:504
int numberOfValidPixelHits() const
Definition: HitPattern.h:825
EleTkIsolFromCands::PIDVeto EleTkIsolFromCands::pidVetoFromStr ( const std::string &  vetoStr)
static

Definition at line 150 of file EleTkIsolFromCands.cc.

References ELES, Exception, NONE, and NONELES.

Referenced by ElectronHEEPIDValueMapProducer::ElectronHEEPIDValueMapProducer().

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 }
EleTkIsolFromCands::TrackTable EleTkIsolFromCands::preselectTracks ( reco::TrackCollection const &  tracks,
TrkCuts const &  cuts 
)
staticprivate

Definition at line 50 of file EleTkIsolFromCands.cc.

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

Referenced by getPreselectedTracks().

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 }
static bool passTrackPreselection(const reco::TrackBase &trk, float trkPt, const TrkCuts &cuts)
auto const & tracks
cannot be loose
TkSoA const *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
def move
Definition: eostools.py:511
EleTkIsolFromCands::TrackTable EleTkIsolFromCands::preselectTracksFromCands ( pat::PackedCandidateCollection const &  cands,
TrkCuts const &  cuts,
PIDVeto  pidVeto = PIDVeto::NONE 
)
staticprivate

Definition at line 74 of file EleTkIsolFromCands.cc.

References 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().

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 }
static bool passTrackPreselection(const reco::TrackBase &trk, float trkPt, const TrkCuts &cuts)
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
TkSoA const *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
double pt() const
track transverse momentum
Definition: TrackBase.h:637
def move
Definition: eostools.py:511
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:661
static bool passPIDVeto(const int pdgId, const EleTkIsolFromCands::PIDVeto pidVeto)
edm::ParameterSetDescription EleTkIsolFromCands::pSetDescript ( )
static

Member Data Documentation

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

Definition at line 127 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

Configuration const& EleTkIsolFromCands::cfg_
private

Definition at line 123 of file EleTkIsolFromCands.h.

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

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

Definition at line 128 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

TrackTable EleTkIsolFromCands::preselectedTracksWithBarrelCuts_
private

Definition at line 129 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

TrackTable EleTkIsolFromCands::preselectedTracksWithEndcapCuts_
private

Definition at line 130 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

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

Definition at line 126 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

bool EleTkIsolFromCands::tracksCachedForBarrelCuts_ = false
private

Definition at line 131 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().

bool EleTkIsolFromCands::tracksCachedForEndcapCuts_ = false
private

Definition at line 132 of file EleTkIsolFromCands.h.

Referenced by getPreselectedTracks().