Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:26:35

0001 #include "FWCore/ServiceRegistry/interface/Service.h"
0002 #include "RecoLuminosity/LumiProducer/interface/NormFunctor.h"
0003 #include <algorithm>
0004 #include <map>
0005 namespace lumi {
0006   class fPoly : public NormFunctor {
0007   public:
0008     fPoly() {}
0009     ~fPoly() override {}
0010     void initialize(const std::map<std::string, float>& coeffmap, const std::map<unsigned int, float>& afterglowmap);
0011     float getCorrection(float luminonorm, float intglumi, unsigned int nBXs) const override;
0012   };
0013 }  // namespace lumi
0014 
0015 void lumi::fPoly::initialize(const std::map<std::string, float>& coeffmap,
0016                              const std::map<unsigned int, float>& afterglowmap) {
0017   m_coeffmap = coeffmap;
0018   m_afterglowmap = afterglowmap;
0019 }
0020 float lumi::fPoly::getCorrection(float luminonorm, float intglumi, unsigned int nBXs) const {
0021   float result = 1.0;
0022   float avglumi = 0.;
0023   float c1 = 0.;
0024   std::map<std::string, float>::const_iterator coeffIt = m_coeffmap.find("C1");
0025   if (coeffIt != m_coeffmap.end()) {
0026     c1 = coeffIt->second;
0027   }
0028   if (c1 != 0. && nBXs > 0) {
0029     avglumi = c1 * luminonorm / nBXs;
0030   }
0031   float Afterglow = 1.0;
0032   if (!m_afterglowmap.empty()) {
0033     std::map<unsigned int, float>::const_iterator afterglowit = m_afterglowmap.lower_bound(nBXs + 1);
0034     if (afterglowit != m_afterglowmap.begin()) {
0035       Afterglow = (--afterglowit)->second;
0036     }
0037   }
0038   float driftterm = 1.0;
0039   coeffIt = m_coeffmap.find("DRIFT");
0040   if (coeffIt != m_coeffmap.end()) {
0041     driftterm = 1.0 + coeffIt->second * intglumi;
0042   }
0043   float a0 = 1.0;
0044   coeffIt = m_coeffmap.find("A0");
0045   if (coeffIt != m_coeffmap.end()) {
0046     a0 = coeffIt->second;
0047   }
0048   float a1 = 0.;
0049   coeffIt = m_coeffmap.find("A1");
0050   if (coeffIt != m_coeffmap.end()) {
0051     a1 = coeffIt->second;
0052   }
0053   float a2 = 0.;
0054   coeffIt = m_coeffmap.find("A2");
0055   if (coeffIt != m_coeffmap.end()) {
0056     a2 = coeffIt->second;
0057   }
0058   result = a0 * Afterglow / (1. + a1 * avglumi + a2 * avglumi * avglumi) * driftterm;
0059   return result;
0060 }
0061 #include "RecoLuminosity/LumiProducer/interface/NormFunctorPluginFactory.h"
0062 DEFINE_EDM_PLUGIN(lumi::NormFunctorPluginFactory, lumi::fPoly, "fPoly");