CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
fPoly.cc
Go to the documentation of this file.
3 #include <algorithm>
4 #include <map>
5 namespace lumi{
6  class fPoly:public NormFunctor{
7  public:
8  fPoly(){}
9  ~fPoly(){}
10  void initialize(const std::map< std::string , float >& coeffmap,
11  const std::map< unsigned int, float >& afterglowmap);
12  virtual float getCorrection(float luminonorm,float intglumi,unsigned int nBXs)const override;
13  };
14 }//ns lumi
15 
16 void
17 lumi::fPoly::initialize(const std::map< std::string , float >& coeffmap,
18  const std::map< unsigned int, float >& afterglowmap){
19  m_coeffmap=coeffmap;
20  m_afterglowmap=afterglowmap;
21 }
22 float
23 lumi::fPoly::getCorrection(float luminonorm,float intglumi,unsigned int nBXs)const{
24  float result=1.0;
25  float avglumi=0.;
26  float c1=0.;
27  std::map< std::string , float >::const_iterator coeffIt=m_coeffmap.find("C1");
28  if(coeffIt!=m_coeffmap.end()){
29  c1=coeffIt->second;
30  }
31  if(c1!=0. && nBXs>0){
32  avglumi=c1*luminonorm/nBXs;
33  }
34  float Afterglow=1.0;
35  if(m_afterglowmap.size()!=0){
36  std::map< unsigned int, float >::const_iterator afterglowit=--m_afterglowmap.end();
37  if(nBXs>=afterglowit->first){
38  Afterglow=afterglowit->second;
39  }else{
40  afterglowit=m_afterglowmap.upper_bound(nBXs);
41  --afterglowit;
42  Afterglow=afterglowit->second;
43  }
44  }
45  float driftterm=1.0;
46  coeffIt=m_coeffmap.find("DRIFT");
47  if(coeffIt!=m_coeffmap.end()){
48  driftterm=1.0+coeffIt->second*intglumi;
49  }
50  float a0=1.0;
51  coeffIt=m_coeffmap.find("A0");
52  if(coeffIt!=m_coeffmap.end()){
53  a0=coeffIt->second;
54  }
55  float a1=0.;
56  coeffIt=m_coeffmap.find("A1");
57  if(coeffIt!=m_coeffmap.end()){
58  a1=coeffIt->second;
59  }
60  float a2=0.;
61  coeffIt=m_coeffmap.find("A2");
62  if(coeffIt!=m_coeffmap.end()){
63  a2=coeffIt->second;
64  }
65  result=a0*Afterglow/(1.+a1*avglumi+a2*avglumi*avglumi)*driftterm;
66  return result;
67 }
70 
tuple lumi
Definition: fjr2json.py:35
std::map< unsigned int, float > m_afterglowmap
Definition: NormFunctor.h:15
fPoly()
Definition: fPoly.cc:8
tuple result
Definition: query.py:137
float intglumi
Definition: normFunctors.py:63
~fPoly()
Definition: fPoly.cc:9
std::map< std::string, float > m_coeffmap
Definition: NormFunctor.h:14
void initialize(const std::map< std::string, float > &coeffmap, const std::map< unsigned int, float > &afterglowmap)
Definition: fPoly.cc:17
#define DEFINE_EDM_PLUGIN(factory, type, name)
float luminonorm
Definition: normFunctors.py:62
virtual float getCorrection(float luminonorm, float intglumi, unsigned int nBXs) const override
Definition: fPoly.cc:23