CMS 3D CMS Logo

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

#include <EleTkIsolFromCands.h>

Inheritance diagram for EleTkIsolFromCands:
SuperclusTkIsolFromCands

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

Protected Types

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

Protected Member Functions

TrackTable const & getPreselectedTracks (bool isBarrel)
 

Protected Attributes

Configuration const & cfg_
 

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
 
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 96 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  };
Definition: TkAlStyle.h:43

Constructor & Destructor Documentation

◆ EleTkIsolFromCands() [1/2]

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

Definition at line 77 of file EleTkIsolFromCands.h.

References looper::cfg.

78  : cfg_{cfg}, tracks_{&tracks} {}
reco::TrackCollection const * tracks_
Configuration const & 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.

References looper::cfg.

82  : cfg_{cfg}, cands_{&cands}, pidVeto_{pidVeto} {}
Configuration const & cfg_
pat::PackedCandidateCollection const * cands_

Member Function Documentation

◆ getPreselectedTracks()

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

Definition at line 190 of file EleTkIsolFromCands.cc.

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

Referenced by SuperclusTkIsolFromCands::operator()(), and operator()().

190  {
191  auto const& cuts = isBarrel ? cfg_.barrelCuts : cfg_.endcapCuts;
194 
195  if (!tracksCached) {
197  tracksCached = true;
198  }
199 
200  return preselectedTracks;
201 }
reco::TrackCollection const * tracks_
static TrackTable preselectTracks(reco::TrackCollection const &tracks, TrkCuts const &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_

◆ operator()()

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

Definition at line 102 of file EleTkIsolFromCands.cc.

References funct::abs(), EleTkIsolFromCands::Configuration::barrelCuts, cfg_, reco::deltaR2(), HLT_2024v14_cff::dEta, ALPAKA_ACCELERATOR_NAMESPACE::dR2(), l1ctLayer1_cff::dZ, EleTkIsolFromCands::Configuration::endcapCuts, reco::TrackBase::eta(), getPreselectedTracks(), reco::TrackBase::phi(), trk, 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 }
Trktree trk
Definition: Trktree.cc:2
ALPAKA_FN_ACC static ALPAKA_FN_INLINE float dR2(Position4 pos1, Position4 pos2)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TrackTable const & getPreselectedTracks(bool isBarrel)
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
Configuration const & cfg_

◆ passAlgo()

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

Definition at line 181 of file EleTkIsolFromCands.cc.

References ALPAKA_ACCELERATOR_NAMESPACE::lst::binary_search(), and trk.

Referenced by passTrackPreselection().

182  {
183  return algosToRej.empty() ||
184  //check also the originalAlgo in case the track is reconstructed by more than one
185  //reject only if both algo and originalAlgo are not acceptable
186  !(std::binary_search(algosToRej.begin(), algosToRej.end(), trk.algo()) &&
187  std::binary_search(algosToRej.begin(), algosToRej.end(), trk.originalAlgo()));
188 }
Trktree trk
Definition: Trktree.cc:2
ALPAKA_FN_HOST_ACC ALPAKA_FN_INLINE int binary_search(const unsigned int *data, unsigned int search_val, unsigned int ndata)
Definition: Hit.h:59

◆ passPIDVeto()

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, EgammaValidation_cff::pdgId, 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

◆ passQual()

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

Definition at line 169 of file EleTkIsolFromCands.cc.

References trk.

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 }
Trktree trk
Definition: Trktree.cc:2

◆ passTrackPreselection()

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

Definition at line 163 of file EleTkIsolFromCands.cc.

References passAlgo(), passQual(), listHistos::trackPt, and trk.

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 }
Trktree trk
Definition: Trktree.cc:2
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)

◆ pidVetoFromStr()

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(), and SuperclusValueMapProducer::SuperclusValueMapProducer().

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 }

◆ preselectTracks()

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, DiDispStaMuonMonitor_cfi::pt, DiMuonV_cfg::tracks, trk, run3scouting_cff::trkPt, and btvMC_cff::vz.

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();
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)
Trktree trk
Definition: Trktree.cc:2
def move(src, dest)
Definition: eostools.py:511

◆ 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.

References HLT_2024v14_cff::cands, PVValHelper::eta, eostools::move(), passPIDVeto(), passTrackPreselection(), phi, DiDispStaMuonMonitor_cfi::pt, trk, run3scouting_cff::trkPt, and btvMC_cff::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();
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)
Trktree trk
Definition: Trktree.cc:2
def move(src, dest)
Definition: eostools.py:511
static bool passPIDVeto(const int pdgId, const EleTkIsolFromCands::PIDVeto pidVeto)

◆ 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_
protected

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