Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:22:29

0001 #include "L1Trigger/L1CaloTrigger/interface/ParametricCalibration.h"
0002 
0003 namespace l1tp2 {
0004   ParametricCalibration::ParametricCalibration(const edm::ParameterSet& cpset) {
0005     std::vector<double> etaBins = cpset.getParameter<std::vector<double>>("etaBins");
0006     std::vector<double> ptBins = cpset.getParameter<std::vector<double>>("ptBins");
0007     std::vector<double> scale = cpset.getParameter<std::vector<double>>("scale");
0008     etas.insert(etas.end(), etaBins.begin(), etaBins.end());
0009     pts.insert(pts.end(), ptBins.begin(), ptBins.end());
0010     scales.insert(scales.end(), scale.begin(), scale.end());
0011 
0012     if (pts.size() * etas.size() != scales.size())
0013       throw cms::Exception("Configuration",
0014                            "Bad number of calibration scales, pts.size() * etas.size() != scales.size()");
0015   }
0016 
0017   // ------------ method fills 'descriptions' with the allowed parameters for the module  ------------
0018   void ParametricCalibration::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
0019     edm::ParameterSetDescription desc;
0020     desc.setComment("");
0021     desc.addUntracked<std::vector<double>>("etaBins", std::vector<double>{});
0022     desc.addUntracked<std::vector<double>>("ptBins", std::vector<double>{});
0023     desc.addUntracked<std::vector<double>>("scale", std::vector<double>{});
0024     descriptions.add("createIdealTkAlRecords", desc);
0025   }
0026 
0027   float ParametricCalibration::operator()(const float pt, const float abseta) const {
0028     int ptBin = -1;
0029     for (unsigned int i = 0, n = pts.size(); i < n; ++i) {
0030       if (pt < pts[i]) {
0031         ptBin = i;
0032         break;
0033       }
0034     }
0035     int etaBin = -1;
0036     for (unsigned int i = 0, n = etas.size(); i < n; ++i) {
0037       if (abseta < etas[i]) {
0038         etaBin = i;
0039         break;
0040       }
0041     }
0042 
0043     if (ptBin == -1 || etaBin == -1)
0044       return 1;
0045     else
0046       return scales[ptBin * etas.size() + etaBin];
0047   }
0048 
0049 };  // namespace l1tp2