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 45 of file EleTkIsolFromCands.h.

Member Enumeration Documentation

Enumerator
NONE 
ELES 
NONELES 

Definition at line 47 of file EleTkIsolFromCands.h.

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

Constructor & Destructor Documentation

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

Definition at line 46 of file EleTkIsolFromCands.cc.

46  :
47  barrelCuts_(para.getParameter<edm::ParameterSet>("barrelCuts")),
48  endcapCuts_(para.getParameter<edm::ParameterSet>("endcapCuts"))
49 {
50 
51 
52 }
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 63 of file EleTkIsolFromCands.cc.

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

Referenced by calIsol(), and calIsolPt().

66 {
67  return calIsol(eleTrk.eta(),eleTrk.phi(),eleTrk.vz(),cands,pidVeto);
68 }
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 71 of file EleTkIsolFromCands.cc.

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

75 {
76  double ptSum=0.;
77  int nrTrks=0;
78 
79  const TrkCuts& cuts = std::abs(eleEta)<1.5 ? barrelCuts_ : endcapCuts_;
80 
81  for(auto& cand : cands){
82  if(cand.hasTrackDetails() && cand.charge()!=0 && passPIDVeto(cand.pdgId(),pidVeto)){
83  const reco::Track& trk = cand.pseudoTrack();
84  if(passTrkSel(trk,trk.pt(),cuts,eleEta,elePhi,eleVZ)){
85  ptSum+=trk.pt();
86  nrTrks++;
87  }
88  }
89  }
90  return {nrTrks,ptSum};
91 }
double pt() const
track transverse momentum
Definition: TrackBase.h:660
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 96 of file EleTkIsolFromCands.cc.

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

98 {
99  return calIsol(eleTrk.eta(),eleTrk.phi(),eleTrk.vz(),tracks);
100 }
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 103 of file EleTkIsolFromCands.cc.

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

106 {
107  double ptSum=0.;
108  int nrTrks=0;
109 
110  const TrkCuts& cuts = std::abs(eleEta)<1.5 ? barrelCuts_ : endcapCuts_;
111 
112  for(auto& trk : tracks){
113  if(passTrkSel(trk,trk.pt(),cuts,eleEta,elePhi,eleVZ)){
114  ptSum+=trk.pt();
115  nrTrks++;
116  }
117  }
118  return {nrTrks,ptSum};
119 }
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 90 of file EleTkIsolFromCands.h.

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

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

90 {return calIsol(std::forward<Args>(args)...).second;}
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 185 of file EleTkIsolFromCands.cc.

References reco::TrackBase::algo().

Referenced by calIsolPt(), passQual(), and passTrkSel().

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

Definition at line 121 of file EleTkIsolFromCands.cc.

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

Referenced by calIsol(), and calIsolPt().

122 {
123  int pidAbs = std::abs(pdgId);
124  switch (veto){
125  case PIDVeto::NONE:
126  return true;
127  case PIDVeto::ELES:
128  if(pidAbs==11) return false;
129  else return true;
130  case PIDVeto::NONELES:
131  if(pidAbs==11) return true;
132  else return false;
133  }
134  throw cms::Exception("CodeError") <<
135  "invalid PIDVeto "<<static_cast<int>(veto)<<", "<<
136  "this is likely due to some static casting of invalid ints somewhere";
137 }
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 172 of file EleTkIsolFromCands.cc.

References passAlgo(), and reco::TrackBase::quality().

Referenced by calIsolPt(), and passTrkSel().

174 {
175  if(quals.empty()) return true;
176 
177  for(auto qual : quals) {
178  if(trk.quality(qual)) return true;
179  }
180 
181  return false;
182 }
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:549
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 149 of file EleTkIsolFromCands.cc.

References funct::abs(), EleTkIsolFromCands::TrkCuts::algosToReject, EleTkIsolFromCands::TrkCuts::allowedQualities, reco::deltaR2(), particleFlow_cfi::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().

153 {
154  const float dR2 = reco::deltaR2(eleEta,elePhi,trk.eta(),trk.phi());
155  const float dEta = trk.eta()-eleEta;
156  const float dZ = eleVZ - trk.vz();
157 
158  return dR2>=cuts.minDR2 && dR2<=cuts.maxDR2 &&
159  std::abs(dEta)>=cuts.minDEta &&
160  std::abs(dZ)<cuts.maxDZ &&
161  trk.hitPattern().numberOfValidHits() >= cuts.minHits &&
162  trk.hitPattern().numberOfValidPixelHits() >=cuts.minPixelHits &&
163  (trk.ptError()/trkPt < cuts.maxDPtPt || cuts.maxDPtPt<0) &&
164  passQual(trk,cuts.allowedQualities) &&
165  passAlgo(trk,cuts.algosToReject) &&
166  trkPt > cuts.minPt;
167 }
int numberOfValidHits() const
Definition: HitPattern.h:896
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:684
static bool passAlgo(const reco::TrackBase &trk, const std::vector< reco::TrackBase::TrackAlgorithm > &algosToRej)
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:690
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:814
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:708
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:485
int numberOfValidPixelHits() const
Definition: HitPattern.h:916
EleTkIsolFromCands::PIDVeto EleTkIsolFromCands::pidVetoFromStr ( const std::string &  vetoStr)
static

Definition at line 139 of file EleTkIsolFromCands.cc.

References ELES, Exception, NONE, and NONELES.

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

140 {
141  if(vetoStr=="NONE") return PIDVeto::NONE;
142  else if(vetoStr=="ELES") return PIDVeto::ELES;
143  else if(vetoStr=="NONELES") return PIDVeto::NONELES;
144  else{
145  throw cms::Exception("CodeError") <<"unrecognised string "<<vetoStr<<", either a typo or this function needs to be updated";
146  }
147 }
edm::ParameterSetDescription EleTkIsolFromCands::pSetDescript ( )
static

Definition at line 54 of file EleTkIsolFromCands.cc.

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

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

55 {
57  desc.add("barrelCuts",TrkCuts::pSetDescript());
58  desc.add("endcapCuts",TrkCuts::pSetDescript());
59  return desc;
60 }
static edm::ParameterSetDescription pSetDescript()
ParameterDescriptionBase * add(U const &iLabel, T const &value)

Member Data Documentation

TrkCuts EleTkIsolFromCands::barrelCuts_
private

Definition at line 69 of file EleTkIsolFromCands.h.

Referenced by calIsol().

TrkCuts EleTkIsolFromCands::endcapCuts_
private

Definition at line 69 of file EleTkIsolFromCands.h.

Referenced by calIsol().