Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:30:28

0001 #include "L1Trigger/Phase2L1ParticleFlow/interface/ParametricResolution.h"
0002 
0003 std::vector<float> l1tpf::ParametricResolution::getVFloat(const edm::ParameterSet &cpset, const std::string &name) {
0004   std::vector<double> vd = cpset.getParameter<std::vector<double>>(name);
0005   return std::vector<float>(vd.begin(), vd.end());
0006 }
0007 
0008 l1tpf::ParametricResolution::ParametricResolution(const edm::ParameterSet &cpset)
0009     : etas_(getVFloat(cpset, "etaBins")), offsets_(getVFloat(cpset, "offset")), scales_(getVFloat(cpset, "scale")) {
0010   if (cpset.existsAs<std::vector<double>>("ptMin")) {
0011     ptMins_ = getVFloat(cpset, "ptMin");
0012   } else {
0013     float ptMin = cpset.existsAs<double>("ptMin") ? cpset.getParameter<double>("ptMin") : 0;
0014     ptMins_ = std::vector<float>(etas_.size(), ptMin);
0015   }
0016   if (cpset.existsAs<std::vector<double>>("ptMax")) {
0017     ptMaxs_ = getVFloat(cpset, "ptMax");
0018   } else {
0019     ptMaxs_ = std::vector<float>(etas_.size(), 1e6);
0020   }
0021 
0022   std::string skind = cpset.getParameter<std::string>("kind");
0023   if (skind == "track")
0024     kind_ = Kind::Track;
0025   else if (skind == "calo")
0026     kind_ = Kind::Calo;
0027   else
0028     throw cms::Exception("Configuration", "Bad kind of resolution: " + skind);
0029 }
0030 
0031 float l1tpf::ParametricResolution::operator()(const float pt, const float abseta) const {
0032   for (unsigned int i = 0, n = etas_.size(); i < n; ++i) {
0033     if (pt > ptMaxs_[i])
0034       continue;
0035     if (abseta < etas_[i]) {
0036       switch (kind_) {
0037         case Kind::Track:
0038           return pt * std::min<float>(1.f, std::hypot(pt * scales_[i] * 0.001, offsets_[i]));
0039         case Kind::Calo:
0040           return std::min<float>(pt, pt * scales_[i] + offsets_[i]);
0041           if (pt < ptMins_[i])
0042             return pt * std::min<float>(1, scales_[i] + offsets_[i] / ptMins_[i]);
0043           return std::min<float>(pt, pt * scales_[i] + offsets_[i]);
0044       }
0045     }
0046   }
0047   return std::min<float>(pt, 0.3 * pt + 7);  // saturate to 100% at 10 GeV, and to 30% at high pt
0048 }