CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 }
ParameterDescriptionBase * addVPSet(U const &iLabel, ParameterSetDescription const &validator, std::vector< ParameterSet > const &defaults)
std::vector< double > etaBoundaries_
__host__ __device__ constexpr RandomIt upper_bound(RandomIt first, RandomIt last, const T &value, Compare comp={})
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:649
auto const & tracks
cannot be loose
static bool passTrkSel(const L1Track &trk, const double trkPt, const TrkCuts &cuts, const double objEta, const double objPhi, const double objZ)
EgammaL1TkIsolation(const edm::ParameterSet &para)
TkSoA const *__restrict__ CAHitNtupletGeneratorKernelsGPU::QualityCuts cuts
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:652
TrkCuts(const edm::ParameterSet &para)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
ParameterDescriptionBase * add(U const &iLabel, T const &value)
static edm::ParameterSetDescription makePSetDescription()
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:661
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
size_t etaBinNr(double eta) const
std::vector< TrkCuts > trkCuts_
static void fillPSetDescription(edm::ParameterSetDescription &desc)
std::pair< int, double > calIsol(const reco::TrackBase &trk, const L1TrackCollection &l1Tks) const
std::vector< L1Track > L1TrackCollection
Definition: L1Track.h:9