Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 #include "RecoLuminosity/LumiProducer/interface/LumiCorrectionParam.h"
0002 #include "RecoLuminosity/LumiProducer/interface/NormFunctor.h"
0003 #include "RecoLuminosity/LumiProducer/interface/NormFunctorPluginFactory.h"
0004 #include <iomanip>
0005 #include <ostream>
0006 #include <memory>
0007 LumiCorrectionParam::LumiCorrectionParam()
0008     : m_lumitype(LumiCorrectionParam::HF),
0009       m_ncollidingbx(0),
0010       m_normtag(""),
0011       m_corrfunc(""),
0012       m_amodetag("PROTPHYS"),
0013       m_beamegev(0.),
0014       m_intglumi(0.) {}
0015 LumiCorrectionParam::LumiCorrectionParam(LumiCorrectionParam::LumiType lumitype)
0016     : m_lumitype(lumitype),
0017       m_ncollidingbx(0),
0018       m_normtag(""),
0019       m_corrfunc(""),
0020       m_amodetag("PROTPHYS"),
0021       m_beamegev(0.),
0022       m_intglumi(0.) {}
0023 
0024 float LumiCorrectionParam::getCorrection(float luminonorm) const {
0025   std::unique_ptr<lumi::NormFunctor> ptr(lumi::NormFunctorPluginFactory::get()->create(m_corrfunc));
0026   (*ptr).initialize(m_coeffmap, m_afterglows);
0027   float result = (*ptr).getCorrection(luminonorm, m_intglumi, m_ncollidingbx);
0028   return result;
0029 }
0030 unsigned int LumiCorrectionParam::ncollidingbunches() const { return m_ncollidingbx; }
0031 std::string LumiCorrectionParam::normtag() const { return m_normtag; }
0032 std::string LumiCorrectionParam::corrFunc() const { return m_corrfunc; }
0033 const std::map<std::string, float>& LumiCorrectionParam::nonlinearCoeff() const { return m_coeffmap; }
0034 const std::map<unsigned int, float>& LumiCorrectionParam::afterglows() const { return m_afterglows; }
0035 std::string LumiCorrectionParam::amodetag() const { return m_amodetag; }
0036 unsigned int LumiCorrectionParam::beamegev() const { return m_beamegev; }
0037 float LumiCorrectionParam::intglumi() const { return m_intglumi; }
0038 void LumiCorrectionParam::setNBX(unsigned int nbx) { m_ncollidingbx = nbx; }
0039 void LumiCorrectionParam::setNormtag(const std::string& normtag) { m_normtag = normtag; }
0040 void LumiCorrectionParam::setcorrFunc(const std::string& corrfunc) { m_corrfunc = corrfunc; }
0041 void LumiCorrectionParam::setnonlinearCoeff(std::map<std::string, float>& coeffmap) { m_coeffmap = coeffmap; }
0042 void LumiCorrectionParam::setafterglows(std::map<unsigned int, float>& afterglows) { m_afterglows = afterglows; }
0043 void LumiCorrectionParam::setdescription(const std::string& amodetag, unsigned int beamegev) {
0044   m_amodetag = amodetag;
0045   m_beamegev = beamegev;
0046 }
0047 void LumiCorrectionParam::setintglumi(float intglumi) { m_intglumi = intglumi; }
0048 
0049 std::ostream& operator<<(std::ostream& s, LumiCorrectionParam const& lumiparam) {
0050   s << "\n LumiCorrectionParam\n";
0051   s << "   normtag " << lumiparam.normtag() << "\n";
0052   s << "   corrfunc " << lumiparam.corrFunc() << "\n";
0053   s << "   ncollidingbx " << lumiparam.ncollidingbunches() << "\n";
0054   s << "   amodetag " << lumiparam.amodetag() << "\n";
0055   s << "   beamegev " << lumiparam.beamegev() << "\n";
0056   s << "   intglumi " << lumiparam.intglumi() << "\n";
0057   std::map<std::string, float>::const_iterator it;
0058   std::map<std::string, float>::const_iterator itBeg = lumiparam.nonlinearCoeff().begin();
0059   std::map<std::string, float>::const_iterator itEnd = lumiparam.nonlinearCoeff().end();
0060   for (it = itBeg; it != itEnd; ++it) {
0061     s << "   params " << it->first << " " << it->second << "\n";
0062   }
0063   std::map<unsigned int, float>::const_iterator ait;
0064   std::map<unsigned int, float>::const_iterator aitBeg = lumiparam.afterglows().begin();
0065   std::map<unsigned int, float>::const_iterator aitEnd = lumiparam.afterglows().end();
0066   for (ait = aitBeg; ait != aitEnd; ++ait) {
0067     s << "   afterglows " << ait->first << " " << ait->second << "\n";
0068   }
0069   return s;
0070 }