Go to the documentation of this file.00001 #include "FWCore/ServiceRegistry/interface/Service.h"
00002 #include "RecoLuminosity/LumiProducer/interface/NormFunctor.h"
00003 #include <algorithm>
00004 #include <map>
00005 namespace lumi{
00006 class fPoly:public NormFunctor{
00007 public:
00008 fPoly(){}
00009 ~fPoly(){}
00010 void initialize(const std::map< std::string , float >& coeffmap,
00011 const std::map< unsigned int, float >& afterglowmap);
00012 virtual float getCorrection(float luminonorm,float intglumi,unsigned int nBXs)const;
00013 };
00014 }
00015
00016 void
00017 lumi::fPoly::initialize(const std::map< std::string , float >& coeffmap,
00018 const std::map< unsigned int, float >& afterglowmap){
00019 m_coeffmap=coeffmap;
00020 m_afterglowmap=afterglowmap;
00021 }
00022 float
00023 lumi::fPoly::getCorrection(float luminonorm,float intglumi,unsigned int nBXs)const{
00024 float result=1.0;
00025 float avglumi=0.;
00026 float c1=0.;
00027 std::map< std::string , float >::const_iterator coeffIt=m_coeffmap.find("C1");
00028 if(coeffIt!=m_coeffmap.end()){
00029 c1=coeffIt->second;
00030 }
00031 if(c1!=0. && nBXs>0){
00032 avglumi=c1*luminonorm/nBXs;
00033 }
00034 float Afterglow=1.0;
00035 if(m_afterglowmap.size()!=0){
00036 std::map< unsigned int, float >::const_iterator afterglowit=--m_afterglowmap.end();
00037 if(nBXs>=afterglowit->first){
00038 Afterglow=afterglowit->second;
00039 }else{
00040 afterglowit=m_afterglowmap.upper_bound(nBXs);
00041 --afterglowit;
00042 Afterglow=afterglowit->second;
00043 }
00044 }
00045 float driftterm=1.0;
00046 coeffIt=m_coeffmap.find("DRIFT");
00047 if(coeffIt!=m_coeffmap.end()){
00048 driftterm=1.0+coeffIt->second*intglumi;
00049 }
00050 float a0=1.0;
00051 coeffIt=m_coeffmap.find("A0");
00052 if(coeffIt!=m_coeffmap.end()){
00053 a0=coeffIt->second;
00054 }
00055 float a1=0.;
00056 coeffIt=m_coeffmap.find("A1");
00057 if(coeffIt!=m_coeffmap.end()){
00058 a1=coeffIt->second;
00059 }
00060 float a2=0.;
00061 coeffIt=m_coeffmap.find("A2");
00062 if(coeffIt!=m_coeffmap.end()){
00063 a2=coeffIt->second;
00064 }
00065 result=a0*Afterglow/(1.+a1*avglumi+a2*avglumi*avglumi)*driftterm;
00066 return result;
00067 }
00068 #include "RecoLuminosity/LumiProducer/interface/NormFunctorPluginFactory.h"
00069 DEFINE_EDM_PLUGIN(lumi::NormFunctorPluginFactory,lumi::fPoly,"fPoly");
00070