CMS 3D CMS Logo

EgammaL1TkIsolation.cc
Go to the documentation of this file.
4 
5 #include <algorithm>
6 
8  : useAbsEta_(para.getParameter<bool>("useAbsEta")),
9  etaBoundaries_(para.getParameter<std::vector<double>>("etaBoundaries")) {
10  const auto& trkCutParams = para.getParameter<std::vector<edm::ParameterSet>>("trkCuts");
11  for (const auto& params : trkCutParams) {
12  trkCuts_.emplace_back(TrkCuts(params));
13  }
14  if (etaBoundaries_.size() + 1 != trkCuts_.size()) {
15  throw cms::Exception("ConfigError") << "EgammaL1TkIsolation: etaBoundaries parameters size ("
16  << etaBoundaries_.size()
17  << ") should be one less than the size of trkCuts VPSet (" << trkCuts_.size()
18  << ")";
19  }
20  if (!std::is_sorted(etaBoundaries_.begin(), etaBoundaries_.end())) {
21  throw cms::Exception("ConfigError")
22  << "EgammaL1TkIsolation: etaBoundaries parameter's entries should be in increasing value";
23  }
24 }
25 
27  desc.add("useAbsEta", true);
28  desc.add("etaBoundaries", std::vector{1.5});
30 }
31 
32 std::pair<int, double> EgammaL1TkIsolation::calIsol(const reco::TrackBase& trk, const L1TrackCollection& tracks) const {
33  return calIsol(trk.eta(), trk.phi(), trk.vz(), tracks);
34 }
35 
36 std::pair<int, double> EgammaL1TkIsolation::calIsol(const double objEta,
37  const double objPhi,
38  const double objZ,
39  const L1TrackCollection& tracks) const {
40  double ptSum = 0.;
41  int nrTrks = 0;
42 
43  const TrkCuts& cuts = trkCuts_[etaBinNr(objEta)];
44 
45  for (const auto& trk : tracks) {
46  const float trkPt = trk.momentum().perp();
47  if (passTrkSel(trk, trkPt, cuts, objEta, objPhi, objZ)) {
48  ptSum += trkPt;
49  nrTrks++;
50  }
51  }
52  return {nrTrks, ptSum};
53 }
54 
56  minPt = para.getParameter<double>("minPt");
57  auto sq = [](double val) { return val * val; };
58  minDR2 = sq(para.getParameter<double>("minDR"));
59  maxDR2 = sq(para.getParameter<double>("maxDR"));
60  minDEta = para.getParameter<double>("minDEta");
61  maxDZ = para.getParameter<double>("maxDZ");
62 }
63 
66  desc.add<double>("minPt", 2.0);
67  desc.add<double>("maxDR", 0.3);
68  desc.add<double>("minDR", 0.01);
69  desc.add<double>("minDEta", 0.003);
70  desc.add<double>("maxDZ", 0.7);
71  return desc;
72 }
73 
74 //as we have verfied that trkCuts_ size is etaBoundaries_ size +1
75 //then this is always a valid binnr for trkCuts_
76 size_t EgammaL1TkIsolation::etaBinNr(double eta) const {
77  if (useAbsEta_) {
78  eta = std::abs(eta);
79  }
80  auto res = std::upper_bound(etaBoundaries_.begin(), etaBoundaries_.end(), eta);
81  size_t binNr = std::distance(etaBoundaries_.begin(), res);
82  return binNr;
83 }
84 
86  const double trkPt,
87  const TrkCuts& cuts,
88  const double objEta,
89  const double objPhi,
90  const double objZ) {
91  if (trkPt > cuts.minPt && std::abs(objZ - trk.z0()) < cuts.maxDZ) {
92  const float trkEta = trk.eta();
93  const float dEta = trkEta - objEta;
94  const float dR2 = reco::deltaR2(objEta, objPhi, trkEta, trk.phi());
95  return dR2 >= cuts.minDR2 && dR2 <= cuts.maxDR2 && std::abs(dEta) >= cuts.minDEta;
96  }
97 
98  return false;
99 }
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
electrons_cff.bool
bool
Definition: electrons_cff.py:372
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
EgammaL1TkIsolation::TrkCuts::TrkCuts
TrkCuts(const edm::ParameterSet &para)
Definition: EgammaL1TkIsolation.cc:55
EgammaL1TkIsolation::passTrkSel
static bool passTrkSel(const L1Track &trk, const double trkPt, const TrkCuts &cuts, const double objEta, const double objPhi, const double objZ)
Definition: EgammaL1TkIsolation.cc:85
CalibrationSummaryClient_cfi.params
params
Definition: CalibrationSummaryClient_cfi.py:14
EgammaL1TkIsolation::EgammaL1TkIsolation
EgammaL1TkIsolation(const edm::ParameterSet &para)
Definition: EgammaL1TkIsolation.cc:7
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
HLT_2018_cff.distance
distance
Definition: HLT_2018_cff.py:6417
EgammaL1TkIsolation::TrkCuts::maxDR2
float maxDR2
Definition: EgammaL1TkIsolation.h:41
HLT_2018_cff.dEta
dEta
Definition: HLT_2018_cff.py:12289
EgammaL1TkIsolation::etaBinNr
size_t etaBinNr(double eta) const
Definition: EgammaL1TkIsolation.cc:76
deltaR.h
EgammaL1TkIsolation::trkCuts_
std::vector< TrkCuts > trkCuts_
Definition: EgammaL1TkIsolation.h:58
Track.h
reco::TrackBase::vz
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:632
cuda_std::upper_bound
__host__ constexpr __device__ RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
Definition: cudastdAlgorithm.h:45
PVValHelper::eta
Definition: PVValidationHelpers.h:69
EgammaL1TkIsolation::useAbsEta_
bool useAbsEta_
Definition: EgammaL1TkIsolation.h:56
reco::TrackBase::phi
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:620
edm::ParameterSet
Definition: ParameterSet.h:36
edm::ParameterSetDescription::addVPSet
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
Definition: ParameterSetDescription.h:149
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
reco::TrackBase
Definition: TrackBase.h:62
res
Definition: Electron.h:6
EgammaL1TkIsolation::TrkCuts::minDEta
float minDEta
Definition: EgammaL1TkIsolation.h:42
L1Track
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
heppy_batch.val
val
Definition: heppy_batch.py:351
EgammaL1TkIsolation::TrkCuts::minPt
float minPt
Definition: EgammaL1TkIsolation.h:39
std
Definition: JetResolutionObject.h:76
EgammaL1TkIsolation::TrkCuts::makePSetDescription
static edm::ParameterSetDescription makePSetDescription()
Definition: EgammaL1TkIsolation.cc:64
Exception
Definition: hltDiff.cc:246
L1TMuonDQMOffline_cfi.cuts
cuts
Definition: L1TMuonDQMOffline_cfi.py:41
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
EgammaL1TkIsolation::TrkCuts
Definition: EgammaL1TkIsolation.h:38
EgammaL1TkIsolation::TrkCuts::maxDZ
float maxDZ
Definition: EgammaL1TkIsolation.h:43
EgammaL1TkIsolation::TrkCuts::minDR2
float minDR2
Definition: EgammaL1TkIsolation.h:40
EgammaL1TkIsolation::fillPSetDescription
static void fillPSetDescription(edm::ParameterSetDescription &desc)
Definition: EgammaL1TkIsolation.cc:26
EgammaL1TkIsolation.h
L1TrackCollection
std::vector< L1Track > L1TrackCollection
Definition: L1Track.h:9
EgammaL1TkIsolation::calIsol
std::pair< int, double > calIsol(const reco::TrackBase &trk, const L1TrackCollection &l1Tks) const
Definition: EgammaL1TkIsolation.cc:32
EgammaL1TkIsolation::etaBoundaries_
std::vector< double > etaBoundaries_
Definition: EgammaL1TkIsolation.h:57