CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
ParametricResolution.cc
Go to the documentation of this file.
2 
3 std::vector<float> l1tpf::ParametricResolution::getVFloat(const edm::ParameterSet &cpset, const std::string &name) {
4  std::vector<double> vd = cpset.getParameter<std::vector<double>>(name);
5  return std::vector<float>(vd.begin(), vd.end());
6 }
7 
9  : etas_(getVFloat(cpset, "etaBins")), offsets_(getVFloat(cpset, "offset")), scales_(getVFloat(cpset, "scale")) {
10  if (cpset.existsAs<std::vector<double>>("ptMin")) {
11  ptMins_ = getVFloat(cpset, "ptMin");
12  } else {
13  float ptMin = cpset.existsAs<double>("ptMin") ? cpset.getParameter<double>("ptMin") : 0;
14  ptMins_ = std::vector<float>(etas_.size(), ptMin);
15  }
16  if (cpset.existsAs<std::vector<double>>("ptMax")) {
17  ptMaxs_ = getVFloat(cpset, "ptMax");
18  } else {
19  ptMaxs_ = std::vector<float>(etas_.size(), 1e6);
20  }
21 
22  std::string skind = cpset.getParameter<std::string>("kind");
23  if (skind == "track")
25  else if (skind == "calo")
26  kind_ = Kind::Calo;
27  else
28  throw cms::Exception("Configuration", "Bad kind of resolution: " + skind);
29 }
30 
31 float l1tpf::ParametricResolution::operator()(const float pt, const float abseta) const {
32  for (unsigned int i = 0, n = etas_.size(); i < n; ++i) {
33  if (pt > ptMaxs_[i])
34  continue;
35  if (abseta < etas_[i]) {
36  switch (kind_) {
37  case Kind::Track:
38  return pt * std::min<float>(1.f, std::hypot(pt * scales_[i] * 0.001, offsets_[i]));
39  case Kind::Calo:
40  return std::min<float>(pt, pt * scales_[i] + offsets_[i]);
41  if (pt < ptMins_[i])
42  return pt * std::min<float>(1, scales_[i] + offsets_[i] / ptMins_[i]);
43  return std::min<float>(pt, pt * scales_[i] + offsets_[i]);
44  }
45  }
46  }
47  return std::min<float>(pt, 0.3 * pt + 7); // saturate to 100% at 10 GeV, and to 30% at high pt
48 }
bool existsAs(std::string const &parameterName, bool trackiness=true) const
checks if a parameter exists as a given type
Definition: ParameterSet.h:171
constexpr float ptMin
std::vector< DeviationSensor2D * > vd
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
static std::vector< float > getVFloat(const edm::ParameterSet &cpset, const std::string &name)
float operator()(const float pt, const float abseta) const