CMS 3D CMS Logo

ParametricCalibration.cc
Go to the documentation of this file.
2 
3 namespace l1tp2 {
5  std::vector<double> etaBins = cpset.getParameter<std::vector<double>>("etaBins");
6  std::vector<double> ptBins = cpset.getParameter<std::vector<double>>("ptBins");
7  std::vector<double> scale = cpset.getParameter<std::vector<double>>("scale");
8  etas.insert(etas.end(), etaBins.begin(), etaBins.end());
9  pts.insert(pts.end(), ptBins.begin(), ptBins.end());
10  scales.insert(scales.end(), scale.begin(), scale.end());
11 
12  if (pts.size() * etas.size() != scales.size())
13  throw cms::Exception("Configuration",
14  "Bad number of calibration scales, pts.size() * etas.size() != scales.size()");
15  }
16 
17  // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
20  desc.setComment("");
21  desc.addUntracked<std::vector<double>>("etaBins", std::vector<double>{});
22  desc.addUntracked<std::vector<double>>("ptBins", std::vector<double>{});
23  desc.addUntracked<std::vector<double>>("scale", std::vector<double>{});
24  descriptions.add("createIdealTkAlRecords", desc);
25  }
26 
27  float ParametricCalibration::operator()(const float pt, const float abseta) const {
28  int ptBin = -1;
29  for (unsigned int i = 0, n = pts.size(); i < n; ++i) {
30  if (pt < pts[i]) {
31  ptBin = i;
32  break;
33  }
34  }
35  int etaBin = -1;
36  for (unsigned int i = 0, n = etas.size(); i < n; ++i) {
37  if (abseta < etas[i]) {
38  etaBin = i;
39  break;
40  }
41  }
42 
43  if (ptBin == -1 || etaBin == -1)
44  return 1;
45  else
46  return scales[ptBin * etas.size() + etaBin];
47  }
48 
49 }; // namespace l1tp2
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
float operator()(const float pt, const float abseta) const
void add(std::string const &label, ParameterSetDescription const &psetDescription)
int etaBin(const l1t::HGCalMulticluster *cl)