fast pQCD calculations for hadron-induced processes
fastNLOReader.h
1 #ifndef __fastNLOReader__
2 #define __fastNLOReader__
3 
4 #include "fastNLOTable.h"
5 #include "fastNLOPDFLinearCombinations.h"
6 
7 // ---- Getters for results---- //
8 struct XsUncertainty {
10  // keep definition of this class outside of fastNLOReader, beacause of python wrapper
11  std::vector < double > xs;
12  std::vector < double > dxsl;
13  std::vector < double > dxsu;
14 };
15 
16 
23 
24 public:
25  typedef double(*mu_func)(double,double);
26 
27  fastNLOReader(std::string filename);
30  virtual ~fastNLOReader();
31  void SetFilename(std::string filename) ;
32  void InitScalevariation();
33  void SetUnits(fastNLO::EUnits Unit);
35  bool SetContributionON(fastNLO::ESMCalculation eCalc , unsigned int Id , bool SetOn = true);
37  bool ActivateContribution(fastNLO::ESMCalculation eCalc , fastNLO::ESMOrder eOrd , bool SetOn = true);
39  int ContrId(const fastNLO::ESMCalculation eCalc, const fastNLO::ESMOrder eOrder) const;
41  void SetCoefficientUsageDefault();
43  inline bool GetIsFlexibleScaleTable(fastNLOCoeffAddBase* ctest=NULL) const {
44  if ( ctest ) return ctest->GetNScaleDep() >= 3;
45  else if ( B_LO() ) return B_LO()->GetIsFlexibleScale();
46  else if ( B_NLO() ) return B_NLO()->GetIsFlexibleScale();
47  else if ( B_NNLO() ) return B_NNLO()->GetIsFlexibleScale();
48  else return false;
49  }
50 
51  // ---- setters for scales of MuVar tables ---- //
52  void SetMuRFunctionalForm(fastNLO::EScaleFunctionalForm func);
53  void SetMuFFunctionalForm(fastNLO::EScaleFunctionalForm func);
54  void SetFunctionalForm(fastNLO::EScaleFunctionalForm func , fastNLO::EMuX kMuX);
55  bool SetScaleFactorsMuRMuF(double xmur, double xmuf);
56  void SetExternalFuncForMuR(mu_func);
57  void SetExternalFuncForMuF(mu_func);
58  void SetExternalConstantForMuR(double MuR);
59  void SetExternalConstantForMuF(double MuF);
60 
61  void UseHoppetScaleVariations(bool);
62 
63  // ---- Pdf interface ---- //
64  void FillPDFCache(double chksum=0., bool lForce=false);
65  virtual std::vector<double> GetXFX(double x, double muf) const = 0;
66 
67  // virtual functions for the user interface
68  virtual bool InitPDF() = 0;
69  virtual double EvolveAlphas(double Q) const = 0;
70 
71  // ---- alphas cache ---- //
72  void FillAlphasCache(bool lForce=false);
73 
74  // --- cache ---- //
75  void ResetCache() { fPDFCached=0; fAlphasCached=0;}
76 
77  // ---- Do the cross section calculation ---- //
78  void CalcCrossSection();
79  double RescaleCrossSectionUnits(double binsize, int xunits); // Rescale according to kAbsoluteUnits and Ipublunits settings
80 
81  std::vector < double > GetCrossSection();
82  std::vector < double > GetCrossSection(bool lNorm);
83  std::vector < double > GetNormCrossSection();
84  std::vector < std::map< double, double > > GetCrossSection_vs_x1();
85  std::vector < std::map< double, double > > GetCrossSection_vs_x2();
86 
87  std::vector < double > GetReferenceCrossSection();
88  std::vector < double > GetKFactors();
89  std::vector < double > GetQScales();
90  std::vector < std::vector < double > > GetCrossSection2Dim();
91 
92 
94  XsUncertainty GetScaleUncertainty( const fastNLO::EScaleUncertaintyStyle eScaleUnc );
95  XsUncertainty GetScaleUncertainty( const fastNLO::EScaleUncertaintyStyle eScaleUnc, bool lNorm );
97  std::vector< std::vector<double> > GetScaleUncertaintyVec( const fastNLO::EScaleUncertaintyStyle eScaleUnc );
98 
99  // ---- Getters for fastNLOReader member variables ---- //
100  fastNLO::EScaleFunctionalForm GetMuRFunctionalForm() const { return fMuRFunc; };
101  fastNLO::EScaleFunctionalForm GetMuFFunctionalForm() const { return fMuFFunc; };
102  fastNLO::EUnits GetUnits() const { return fUnits; };
103  mu_func GetExternalFuncForMuR() { return Fct_MuR; };
104  mu_func GetExternalFuncForMuF() { return Fct_MuF; };
105  double fConst_MuR;
106  double fConst_MuF;
107 
108  double GetScaleFactorMuR() const { return fScaleFacMuR; };
109  double GetScaleFactorMuF() const { return fScaleFacMuF; };
110  int GetScaleVariation() const { return fScalevar; };
111  std::string GetScaleDescription(const fastNLO::ESMOrder eOrder, int iScale=0) const;
112  double GetNevt(const fastNLO::ESMOrder eOrder) const;
113 
114  int GetNScaleVariations() const;
115  std::vector < double > GetScaleFactors() const;
116 
117  // ---- Print outs ---- //
119  void Print(int iprint) const;
120  void PrintContributionSummary(int iprint) const;
121  void PrintCrossSections() const;
122  void PrintCrossSectionsWithReference();
123 
124  // DEPRECATED
125  void PrintTableInfo(const int iprint = 0) const; // DEPRECATED, use PrintContributionSummary instead
126  void PrintFastNLOTableConstants(const int iprint = 2) const; // DEPRECATED, use Print instead
127  void PrintCrossSectionsData() const;
128  void PrintCrossSectionsDefault(std::vector<double> kthc = std::vector<double>()) const;
129  void RunFastNLODemo();
130 
131  // ---- Test virtual functions for reasonable values. ---- //
132  bool TestXFX();
133  bool TestAlphas();
134 
135 
136 protected:
137  fastNLOReader();
138  void OrderCoefficients() ;
139  //void ReadTable();
140  void StripWhitespace(std::string* s);
141 
142  void PrintScaleSettings(fastNLO::EMuX kMuX=fastNLO::kMuR);
143  void FillBlockBPDFLCsDISv20(fastNLOCoeffAddFix* B);
144  void FillBlockBPDFLCsDISv21(fastNLOCoeffAddFlex* B, fastNLOCoeffAddFlex* B0=NULL);
145  void FillBlockBPDFLCsHHCv20(fastNLOCoeffAddFix* B);
146  void FillBlockBPDFLCsHHCv21(fastNLOCoeffAddFlex* B);
147  void CalcAposterioriScaleVariationMuR();
148  void CalcAposterioriScaleVariationMuF();
149  void FillAlphasCacheInBlockBv20(fastNLOCoeffAddFix* B);
150  void FillAlphasCacheInBlockBv21(fastNLOCoeffAddFlex* B);
151  double CalcAlphas(double Q);
152  double CalcReferenceAlphas();
153  double CalcNewPDFChecksum();
154  double CalcChecksum(double mu);
155  bool PrepareCache();
156 
157  void CalcReferenceCrossSection();
158 
159  double CalcMu(fastNLO::EMuX kMuX, double scale1 , double scale2 , double scalefactor);
160  double FuncMixedOver1(double scale1 , double scale2) ;
161  double FuncMixedOver2(double scale1 , double scale2) ;
162  double FuncMixedOver4(double scale1 , double scale2) ;
163  double FuncMixed2s2Ov2(double scale1 , double scale2) ;
164  double FuncMixed2s2Ov4(double scale1 , double scale2) ;
165  double FuncPow4Sum(double scale1 , double scale2) ;
166  double FuncWgtAvg(double scale1 , double scale2) ;
167  double FuncLinearMean(double scale1 , double scale2) ;
168  double FuncLinearSum(double scale1 , double scale2) ;
169  double FuncMax(double scale1 , double scale2) ;
170  double FuncMin(double scale1 , double scale2) ;
171  double FuncProd(double scale1 , double scale2) ;
172  double FuncExpProd2(double scale1 , double scale2) ;
173 
174  void CalcCrossSectionv20(fastNLOCoeffAddFix* B);
175  void CalcCrossSectionv21(fastNLOCoeffAddFlex* B);
176 
177  fastNLOCoeffAddBase* B_LO() const {
178  //if ( BBlocksSMCalc[fastNLO::kFixedOrder][fastNLO::kLeading] !=0 )
179  return (fastNLOCoeffAddBase*) BBlocksSMCalc[fastNLO::kFixedOrder][fastNLO::kLeading];
180  // else if ( B_NLO()!= NULL ) return B_NLO();
181  // else if ( B_NNLO()!= NULL ) return B_NNLO();
182  };
183  fastNLOCoeffAddBase* B_NLO() const {
184  return (fastNLOCoeffAddBase*) BBlocksSMCalc[fastNLO::kFixedOrder][fastNLO::kNextToLeading];
185  };
186  fastNLOCoeffAddBase* B_NNLO() const {
187  return (fastNLOCoeffAddBase*) BBlocksSMCalc[fastNLO::kFixedOrder][fastNLO::kNextToNextToLeading];
188  };
189  fastNLOCoeffBase* B_ThC(int n=0) {
190  if (BBlocksSMCalc[fastNLO::kThresholdCorrection].empty()) return NULL;
191  else return BBlocksSMCalc[fastNLO::kThresholdCorrection][n];
192  };
193  fastNLOCoeffAddBase* B_Any() const {
194  if (B_LO() != NULL ) return B_LO();
195  else if ( B_NLO()!= NULL ) return B_NLO();
196  else if ( B_NNLO()!= NULL ) return B_NNLO();
197  // else if ( B_ThC(0)!= NULL ) return B_ThC(0);
198  // else if ( B_ThC(1)!= NULL ) return B_ThC(1);
199  else {
200  std::cerr<<"Error. Cannot get any additive contribution, but requested."<<std::endl;
201  exit(3);
202  return NULL;
203  }
204  };
205 
206  // ---- setters for scale variation in v2.0 tables ---- //
207  bool SetScaleVariation(int scalevar);
208 
209  // ---- human readable strings ---- //
210  //static const std::string fContrName[20];
211  //static const std::string fOrdName[4][4];
212  //static const std::string fNSDep[6];
213 
214 
215 protected:
216  std::string ffilename;
217  int fScalevar;
218  double fScaleFacMuR;
219  double fScaleFacMuF;
220  fastNLO::EScaleFunctionalForm fMuRFunc;
221  fastNLO::EScaleFunctionalForm fMuFFunc;
222  fastNLO::EUnits fUnits;
223  bool fPDFSuccess;
224  double fPDFCached;
225  double fAlphasCached;
226  mu_func Fct_MuR;
227  mu_func Fct_MuF;
228  std::vector < std::vector < bool > > bUseSMCalc;
229 
230  bool fUseHoppet;
231 
232  // ---- pointers to coefftables in fCoeff ---- //
233  // std::vector< std::vector < fastNLOCoeffAddBase* > > fCoAdd;
234  // std::vector< std::vector < fastNLOCoeffMult* > > fCoMult;
235  std::vector < std::vector < fastNLOCoeffBase* > > BBlocksSMCalc;
236 
237  // ---- Cross sections ---- //
238  std::vector < double > XSection_LO;
239  std::vector < double > XSection;
240  std::vector < double > kFactor;
241  std::vector < double > QScale_LO;
242  std::vector < double > QScale;
243  std::vector < std::map< double, double > > fXSection_vsX1;
244  std::vector < std::map< double, double > > fXSection_vsX2;
245 
246  // ---- reference tables ---- //
247  std::vector < double > XSectionRef;
248  std::vector < double > XSectionRefMixed;
249  std::vector < double > XSectionRef_s1;
250  std::vector < double > XSectionRef_s2;
251 
252 };
253 #endif
Definition: fastNLOPDFLinearCombinations.h:8
std::vector< std::map< double, double > > fXSection_vsX2
Cross section vs. x ( XSection_vsX1[bin][<x,xs>] )
Definition: fastNLOReader.h:244
std::vector< std::vector< fastNLOCoeffBase *> > BBlocksSMCalc
BlockB&#39;s for SM corrections.
Definition: fastNLOReader.h:235
double fConst_MuF
Constant value for the factorization scale. Used only for flexible-scale tables and if requested...
Definition: fastNLOReader.h:106
Definition: fastNLOCoeffBase.h:15
std::vector< double > xs
Struct for returning vectors with cross section and relative uncertainty.
Definition: fastNLOReader.h:11
mu_func Fct_MuF
Function, if you define your functional form for your scale external.
Definition: fastNLOReader.h:227
Definition: fastNLOReader.h:17
double fConst_MuR
Constant value for the renormalization scale. Used only for flexible-scale tables and if requested...
Definition: fastNLOReader.h:104
Definition: fastNLOReader.h:8
bool GetIsFlexibleScaleTable(fastNLOCoeffAddBase *ctest=NULL) const
Get, if this table is a &#39;flexible-scale&#39; table or not.
Definition: fastNLOReader.h:43
Definition: fastNLOCoeffAddFlex.h:8
Definition: fastNLOCoeffAddBase.h:57
mu_func Fct_MuR
Function, if you define your functional form for your scale external.
Definition: fastNLOReader.h:226
std::vector< std::vector< bool > > bUseSMCalc
switch calculations ON/OFF
Definition: fastNLOReader.h:228
Definition: fastNLOCoeffAddFix.h:8
Definition: fastNLOTable.h:20