fast pQCD calculations for hadron-induced processes
fastNLOCoeffAddBase.h
1 #ifndef __fastNLOCoeffAddBase__
2 #define __fastNLOCoeffAddBase__
3 
4 
5 #include "fastNLOCoeffBase.h"
6 #include "fastNLOConstants.h"
7 
8 namespace fastNLO {
9  struct WgtStat {
10  double WgtNevt = 0;
11  int NumTable = 1;
12  unsigned long long WgtNumEv = 0;
13  double WgtSumW2 = 0;
14  double SigSumW2 = 0;
15  double SigSum = 0;
16  fastNLO::v2d WgtObsSumW2;
17  fastNLO::v2d SigObsSumW2;
18  fastNLO::v2d SigObsSum;
19  std::vector < std::vector < unsigned long long > > WgtObsNumEv;
20 
21  void Erase() {
22  WgtNevt=0;
23  NumTable=1;
24  WgtNumEv=0;
25  WgtSumW2=0;
26  SigSumW2=0;
27  SigSum=0;
28  for ( auto& i : WgtObsSumW2 ) for ( auto& j : i ) j=0;
29  for ( auto& i : SigObsSumW2 ) for ( auto& j : i ) j=0;
30  for ( auto& i : SigObsSum ) for ( auto& j : i ) j=0;
31  for ( auto& i : WgtObsNumEv ) for ( auto& j : i ) j=0;
32  };
33 
34  void Add(const WgtStat& other ) {
35  this->WgtNevt += other.WgtNevt;
36  this->NumTable += other.NumTable;
37  this->WgtNumEv += other.WgtNumEv;
38  this->WgtSumW2 += other.WgtSumW2;
39  this->SigSumW2 += other.SigSumW2;
40  this->SigSum += other.SigSum;
41  if ( this->WgtObsNumEv.size() != other.WgtObsNumEv.size() ) exit(8);
42  for ( unsigned int i = 0 ; i<WgtObsNumEv.size() ; i++ ) {
43  if ( this->WgtObsNumEv[i].size() != other.WgtObsNumEv[i].size() ) exit(8);
44  for ( unsigned int j = 0 ; j<WgtObsNumEv[i].size() ; j++ ) {
45  this->WgtObsSumW2[i][j] += other.WgtObsSumW2[i][j];
46  this->SigObsSumW2[i][j] += other.SigObsSumW2[i][j];
47  this->SigObsSum[i][j] += other.SigObsSum[i][j];
48  this->WgtObsNumEv[i][j] += other.WgtObsNumEv[i][j];
49  }
50  }
51  };
52  WgtStat& operator+=(const WgtStat& other) { this->Add(other); return *this;}
53 
54  };
55 }
56 
58 
59  friend class fastNLOTable;
60  friend class fastNLOCreate;
61 
62 public:
63  fastNLOCoeffAddBase() = delete;
64  fastNLOCoeffAddBase(int NObsBin);
65  explicit fastNLOCoeffAddBase(const fastNLOCoeffBase& base);
66  virtual ~fastNLOCoeffAddBase() {}
67  virtual fastNLOCoeffAddBase* Clone() const;
68  static bool CheckCoeffConstants(const fastNLOCoeffBase* c, bool quiet = false);
69  void Read(std::istream& table);
70  virtual void Write(std::ostream& table, int ITabVersionWrite);
71  virtual void Add(const fastNLOCoeffAddBase& other, fastNLO::EMerge moption=fastNLO::kMerge);
72  virtual void Print(int iprint) const;
73 
74  // Manipulate coefficient bins
75  virtual void Clear();
76  virtual void NormalizeCoefficients(double wgt=1);
77  virtual void NormalizeCoefficients(const std::vector<std::vector<double> >& wgtProcBin) {};
78  virtual void MultiplyCoefficientsByConstant(double fact) {};
79  virtual void MultiplyBin(unsigned int iObsIdx, double fact) {};
80  virtual void MultiplyBinProc(unsigned int iObsIdx, unsigned int iProc, double fact) {};
81  virtual void EraseBin(unsigned int iObsIdx);
82  virtual void CatBin(const fastNLOCoeffAddBase& other, unsigned int iObsIdx);
83 
84  int GetIRef() const {return IRef;}
85  void SetIRef(int iref=1) {IRef=iref;}
86  double GetNevt() const { return Nevt; }
87  double GetNevt(int NObsBin, int NSubproc) const {
88  //return fWgt.WgtObsSumW2[NSubproc][NObsBin];
89  if (Nevt > 0) return Nevt;
90  else {std::cout<<"Todo. Preparation for v2.3."<< std::endl; return Nevt;}
91  }
92  void SetNevt(double nevt) { Nevt = nevt;}
93  int GetNxmax(int Obsbin) const ;
94  int GetXIndex(int Obsbin,int x1bin,int x2bin =0) const ;
95  int GetNSubproc() const { return NSubproc;}
96  int GetIScaleDep() const { return IScaleDep;}
97  int GetNPDF() const {return NPDFPDG.size();}
98  int GetPDFPDG(int iPDF) const {return NPDFPDG[iPDF];}
99  int GetNPDFDim() const {return NPDFDim;}
100  int GetIPDFdef1() const { return IPDFdef1; }
101  int GetIPDFdef2() const { return IPDFdef2; }
102  int GetIPDFdef3() const { return IPDFdef3; }
103  int GetNpow() const {return Npow;}
104  int GetNScales() const {return NScales;}
105  int GetNScaleDim() const {return NScaleDim;}
106  //std::vector<std::string > GetScaleDescript(int iScale=0) const { return ScaleDescript[iScale]; };
107  std::string GetScaleDescription(int iScale=0) const { return ScaleDescript[0][iScale]; }; // getter for scale description of scale iScale
108  std::vector<std::vector<std::string > > GetScaleDescr() const { return ScaleDescript; }
109  int GetNxtot1(int iBin) const { return XNode1[iBin].size(); }
110  int GetNxtot2(int iBin) const { return XNode2.size() > 0 ? XNode2[iBin].size() : -1; }
111 
112  double GetXNode1(int iObsBin, int iNode) const { return XNode1[iObsBin][iNode]; }
113  double GetXNode2(int iObsBin, int iNode) const { return XNode2[iObsBin][iNode]; }
114  double GetX1(int iObsBin, int iXnode) const;
115  double GetX2(int iObsBin, int iXnode) const;
116 
117  std::vector < double > GetXNodes1(int iObsBin) const { return XNode1[iObsBin]; }
118  std::vector < double > GetXNodes2(int iObsBin) const { return XNode2[iObsBin]; }
119 
120  bool IsReference() const {return IRef>0;};
121  bool IsCompatible(const fastNLOCoeffAddBase& other) const;
122  bool IsCatenable(const fastNLOCoeffAddBase& other) const;
123 
124  const std::vector<std::vector<std::pair<int,int> > >& GetPDFCoeff() const { return fPDFCoeff;}
125 
126  const fastNLO::WgtStat& GetWgtStat() const { return fWgt;}
127  fastNLO::WgtStat& AccessWgtStat() { return fWgt;}
128  double GetMergeWeight(fastNLO::EMerge moption, int proc, int bin) const ;
129 
130 protected:
131  void ReadCoeffAddBase(std::istream& table);
132  int GetScaledimfromvar(int scalevar) const;
133 
134  int IRef = 0;
135  int IScaleDep = 0;
136  double Nevt = 0;
137  int Npow = 0;
138  std::vector < int > NPDFPDG;
139  int NPDFDim = 0;
140  std::vector < int > NFFPDG;
141  int NFFDim = 0;
142  int NSubproc = 0;
143  int IPDFdef1 = 0;
144  int IPDFdef2 = 0;
145  int IPDFdef3 = 0;
146  std::vector<std::vector<std::pair<int,int> > > fPDFCoeff;
147  // Missing: linear PDF combinations for IPDFdef1=0
148  std::vector < double > Hxlim1;
149  fastNLO::v2d XNode1;
150  std::vector < double > Hxlim2;
151  fastNLO::v2d XNode2;
152  std::vector < int > Nztot;
153  std::vector < double > Hzlim;
154  fastNLO::v2d ZNode;
155  int NScales = 0;
156  int NScaleDim = 0;
157  std::vector < int > Iscale; // not used
158  std::vector < std::vector < std::string > > ScaleDescript;
159 
161  // double fWgtNevt = 0; //!< 'number of events', i.e. normalisation as suggested by generator (identical to previously use 'Nevt')
162  // unsigned long long fWgtNumEv = 0; //!< number of entries
163  // double fWgtSumW2 = 0; //!< Sum of all weight**2
164  // double fSigSumW2 = 0; //!< Sum of all sigma**2 (i.e. (wgt*alpha*pdf)**2 )
165  // double fSigSum = 0; //!< Sum of all sigma (i.e. (wgt*alpha*pdf)**2 )
166  // fastNLO::v2d fWgtObsSumW2; //!< sumw2[proc][obs]
167  // fastNLO::v2d fSigObsSumW2; //!< sumw2[proc][obs]
168  // fastNLO::v2d fSigObsSum; //!< sum[proc][obs]
169  // std::vector < std::vector < unsigned long long > > fWgtObsNumEv; //!< Nentries[proc][obs]
170 
171 
172 };
173 
174 #endif
void NormalizeCoefficients(double wgt=1)
Set number of events to wgt and adjust coefficients accordingly.
Definition: fastNLOCreate.cc:2720
double SigSum
Sum of all sigma (i.e. (wgt*alpha*pdf)**2 )
Definition: fastNLOCoeffAddBase.h:15
virtual void MultiplyBinProc(unsigned int iObsIdx, unsigned int iProc, double fact)
Multiply coefficients of one observable bin a factor.
Definition: fastNLOCoeffAddBase.h:80
void MultiplyCoefficientsByConstant(double c)
Multiply all coefficients with a constant factor c.
Definition: fastNLOCreate.cc:2837
fastNLO::WgtStat & AccessWgtStat()
Get weight and event counts.
Definition: fastNLOCoeffAddBase.h:127
void Clear()
Print all steering values obtained from steering files (of all fastNLOCreate instances);.
Definition: fastNLOCreate.h:111
fastNLO::WgtStat fWgt
event and weight counts
Definition: fastNLOCoeffAddBase.h:160
fastNLO::v2d WgtObsSumW2
sumw2[proc][obs]
Definition: fastNLOCoeffAddBase.h:16
std::vector< double > GetXNodes1(int iObsBin) const
return x value of pdf1 for x-node 1
Definition: fastNLOCoeffAddBase.h:117
int GetNxmax(const std::vector< double > *xGrid1, const std::vector< double > *xGrid2)
get maximum x-index
Definition: fastNLOCreate.cc:2676
Definition: fastNLOCoeffBase.h:15
const fastNLO::WgtStat & GetWgtStat() const
Get weight and event counts.
Definition: fastNLOCoeffAddBase.h:126
Definition: fastNLOCreate.h:22
fastNLO::v2d SigObsSum
sum[proc][obs]
Definition: fastNLOCoeffAddBase.h:18
fastNLO::v2d SigObsSumW2
sumw2[proc][obs]
Definition: fastNLOCoeffAddBase.h:17
void SetNevt(double nevt)
Set number of events.
Definition: fastNLOCoeffAddBase.h:92
Definition: fastNLOCoeffAddBase.h:8
double WgtNevt
&#39;number of events&#39;, i.e. normalisation as suggested by generator (identical to previously use &#39;Nevt&#39;)...
Definition: fastNLOCoeffAddBase.h:10
int NumTable
Number of tables merged into this table.
Definition: fastNLOCoeffAddBase.h:11
std::vector< std::vector< unsigned long long > > WgtObsNumEv
Nentries[proc][obs].
Definition: fastNLOCoeffAddBase.h:19
double WgtSumW2
Sum of all weight**2.
Definition: fastNLOCoeffAddBase.h:13
unsigned long long WgtNumEv
number of entries
Definition: fastNLOCoeffAddBase.h:12
Definition: fastNLOCoeffAddBase.h:57
Definition: fastNLOTable.h:20
virtual void MultiplyBin(unsigned int iObsIdx, double fact)
Multiply all coefficients of all bins by a constant factor.
Definition: fastNLOCoeffAddBase.h:79
double SigSumW2
Sum of all sigma**2 (i.e. (wgt*alpha*pdf)**2 )
Definition: fastNLOCoeffAddBase.h:14
Definition: fastNLOCoeffAddBase.h:9
int GetXIndex(const int &Obsbin, const int &x1bin, const int &x2bin) const
get x-index in case of two hadrons.
Definition: fastNLOCreate.cc:2655
std::vector< double > Hxlim1
fPDFCoeff[iSubProc][iPartonPair][pair]
Definition: fastNLOCoeffAddBase.h:148