From 3a7b3c63d579d170d3f13a02f66eea65b6702e71 Mon Sep 17 00:00:00 2001
From: Klaus Rabbertz <klaus.rabbertz@cern.ch>
Date: Wed, 25 Sep 2024 15:46:38 +0200
Subject: [PATCH] Preps. for ref. values & for pineappl conversion

---
 .../fastnlotoolkit/fastNLOCoeffAddBase.cc     | 10 ++-
 .../fastnlotoolkit/fastNLOCoeffBase.cc        | 24 ++++--
 v2.5/toolkit/fastnlotoolkit/fastNLOReader.cc  | 78 +++++++++++++++++++
 .../include/fastnlotk/fastNLOCoeffAddBase.h   |  9 ++-
 .../include/fastnlotk/fastNLOCoeffAddFlex.h   |  6 +-
 .../include/fastnlotk/fastNLOCoeffBase.h      |  2 +-
 .../include/fastnlotk/fastNLOReader.h         | 27 ++++---
 7 files changed, 125 insertions(+), 31 deletions(-)

diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc
index 1bca96f5..9348d7bf 100644
--- a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc
+++ b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc
@@ -801,11 +801,12 @@ void fastNLOCoeffAddBase::EraseBin(unsigned int iObsIdx, int ITabVersionRead) {
       if ( NCoeffInfoBlocks > 0 ) {
          debug["EraseBin"]<<"Found " << NCoeffInfoBlocks << " InfoBlocks with bins to be erased, too." << endl;
          for ( int i=0; i < NCoeffInfoBlocks; i++ ) {
-            if ( ICoeffInfoBlockFlag1[i] == 0 && ICoeffInfoBlockFlag2[i] == 0 ) {
+            if ( (ICoeffInfoBlockFlag1[i] == 0 || ICoeffInfoBlockFlag1[i] == 1) &&
+                 (ICoeffInfoBlockFlag2[i] == 0 || ICoeffInfoBlockFlag2[i] == 1) ) { // All possibilities for now. Potential extra info in description.
                CoeffInfoBlockContent[i].erase(CoeffInfoBlockContent[i].begin()+iObsIdx);
                NCoeffInfoBlockCont[i] = NCoeffInfoBlockCont[i] - 1;
             } else {
-               error["EraseBin"]<<"Erase bin not yet implemented for InfoBlocks other than with flags 1,2 = 0, 0:" <<
+               error["EraseBin"]<<"Erase bin not yet implemented for InfoBlocks other than with flags 1,2 = [0,1],[0,1]:" <<
                   ICoeffInfoBlockFlag1[i] << ", " << ICoeffInfoBlockFlag2[i] << ", aborted!" << endl;
                exit(567);
             }
@@ -834,11 +835,12 @@ void fastNLOCoeffAddBase::CatBin(const fastNLOCoeffAddBase& other, unsigned int
       if ( NCoeffInfoBlocks > 0 ) {
          debug["CatBin"]<<"Found " << NCoeffInfoBlocks << " InfoBlocks with bins to be catenated, too." << endl;
          for ( int i=0; i < NCoeffInfoBlocks; i++ ) {
-            if ( ICoeffInfoBlockFlag1[i] == 0 && ICoeffInfoBlockFlag2[i] == 0 ) {
+            if ( (ICoeffInfoBlockFlag1[i] == 0 || ICoeffInfoBlockFlag1[i] == 1) &&
+                 (ICoeffInfoBlockFlag2[i] == 0 || ICoeffInfoBlockFlag2[i] == 1) ) { // All possibilities for now. Potential extra info in description.
                CoeffInfoBlockContent[i].push_back(other.CoeffInfoBlockContent[i][iObsIdx]);
                NCoeffInfoBlockCont[i] = NCoeffInfoBlockCont[i] + 1;
             } else {
-               error["CatBin"]<<"Catenate bins not yet implemented for InfoBlocks other than with flags 1,2 = 0, 0:" <<
+               error["CatBin"]<<"Catenate bins not yet implemented for InfoBlocks other than with flags 1,2 = [0,1],[0,1]:" <<
                   ICoeffInfoBlockFlag1[i] << ", " << ICoeffInfoBlockFlag2[i] << ", aborted!" << endl;
                exit(678);
             }
diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffBase.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffBase.cc
index ef2cca46..b9d3951b 100644
--- a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffBase.cc
+++ b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffBase.cc
@@ -150,8 +150,16 @@ bool fastNLOCoeffBase::IsCatenable(const fastNLOCoeffBase& other) const {
       return false;
    }
    if ( ! (fVersionRead < 25000) ) {
-      if ( (HasCoeffInfoBlock(0,0) && ! other.HasCoeffInfoBlock(0,0)) ||
-           (! HasCoeffInfoBlock(0,0) && other.HasCoeffInfoBlock(0,0)) ) {
+      if (
+          (HasCoeffInfoBlock(0,0) && ! other.HasCoeffInfoBlock(0,0)) ||
+          (! HasCoeffInfoBlock(0,0) && other.HasCoeffInfoBlock(0,0)) ||
+          (HasCoeffInfoBlock(0,1) && ! other.HasCoeffInfoBlock(0,1)) ||
+          (! HasCoeffInfoBlock(0,1) && other.HasCoeffInfoBlock(0,1)) ||
+          (HasCoeffInfoBlock(1,0) && ! other.HasCoeffInfoBlock(1,0)) ||
+          (! HasCoeffInfoBlock(1,0) && other.HasCoeffInfoBlock(1,0)) ||
+          (HasCoeffInfoBlock(1,1) && ! other.HasCoeffInfoBlock(1,1)) ||
+          (! HasCoeffInfoBlock(1,1) && other.HasCoeffInfoBlock(1,1))
+          ) {
          debug["IsCatenable"]<<"Missing InfoBlock in either of the two tables. Skipped."<<endl;
          return false;
       }
@@ -279,22 +287,22 @@ int fastNLOCoeffBase::GetCoeffInfoBlockIndex(int fICoeffInfoBlockFlag1, int fICo
 }
 
 void fastNLOCoeffBase::AddCoeffInfoBlock(int fICoeffInfoBlockFlag1, int fICoeffInfoBlockFlag2, std::vector<std::string> Description,
-                                         std::vector<double> Uncertainty) {
+                                         std::vector<double> Content) {
    info["AddCoeffInfoBlocks"]<<"Adding additional InfoBlock with flags "<<fICoeffInfoBlockFlag1<<" and "<<fICoeffInfoBlockFlag2<<" to table contribution."<<endl;
    NCoeffInfoBlocks += 1;
    ICoeffInfoBlockFlag1.push_back(fICoeffInfoBlockFlag1);
    ICoeffInfoBlockFlag2.push_back(fICoeffInfoBlockFlag2);
    NCoeffInfoBlockDescr.push_back(Description.size());
    CoeffInfoBlockDescript.push_back(Description);
-   NCoeffInfoBlockCont.push_back(Uncertainty.size());
-   CoeffInfoBlockContent.push_back(Uncertainty);
+   NCoeffInfoBlockCont.push_back(Content.size());
+   CoeffInfoBlockContent.push_back(Content);
 }
 
 void fastNLOCoeffBase::AddCoeffInfoBlock(int fICoeffInfoBlockFlag1, int fICoeffInfoBlockFlag2, std::vector<std::string> Description,
                                          std::string filename, unsigned int icola, unsigned int icolb) {
    info["AddCoeffInfoBlocks"]<<"Adding additional InfoBlock reading data from file "<<filename<<endl;
-   std::vector<double> Uncertainty = fastNLOTools::ReadUncertaintyFromFile(filename, icola, icolb);
-   AddCoeffInfoBlock(fICoeffInfoBlockFlag1, fICoeffInfoBlockFlag2, Description, Uncertainty);
+   std::vector<double> Content = fastNLOTools::ReadUncertaintyFromFile(filename, icola, icolb);
+   AddCoeffInfoBlock(fICoeffInfoBlockFlag1, fICoeffInfoBlockFlag2, Description, Content);
 }
 
 void fastNLOCoeffBase::ReadCoeffInfoBlocks(istream& table, int ITabVersionRead) {
@@ -307,7 +315,7 @@ void fastNLOCoeffBase::ReadCoeffInfoBlocks(istream& table, int ITabVersionRead)
          int iflag;
          table >> iflag;
          ICoeffInfoBlockFlag1.push_back(iflag);
-         if (ICoeffInfoBlockFlag1[i] == 0) {
+         if (ICoeffInfoBlockFlag1[i] == 0 || ICoeffInfoBlockFlag1[i] == 1) {
             debug["ReadCoeffInfoBlocks"]<<"Found info block of type ICoeffInfoBlockFlag1 = "<<ICoeffInfoBlockFlag1[i]<<endl;
          } else {
             error["ReadCoeffInfoBlocks"]<<"Found info block of unknown type ICoeffInfoBlockFlag1 = "<<ICoeffInfoBlockFlag1[i]<<endl;
diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOReader.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOReader.cc
index 30456581..7887ef6f 100644
--- a/v2.5/toolkit/fastnlotoolkit/fastNLOReader.cc
+++ b/v2.5/toolkit/fastnlotoolkit/fastNLOReader.cc
@@ -1173,6 +1173,7 @@ void fastNLOReader::CalcReferenceCrossSection() {
    //!  Initialize the internal arrays for the reference cross
    //!  sections with the information from the FastNLO file
    //!
+   logger.debug["CalcReferenceCrossSection"]<<"Starting CalcReferenceCrossSection ..."<<endl;
 
    XSectionRef.clear();
    XSectionRef.resize(NObsBin);
@@ -1243,6 +1244,83 @@ void fastNLOReader::CalcReferenceCrossSection() {
 }
 
 
+//______________________________________________________________________________
+void fastNLOReader::CalcRefCrossSection() {
+   //!
+   //!  Initialize the internal arrays for the reference cross
+   //!  sections from the InfoBlocks of the fastNLO file (v2.7 upwards)
+   //!
+   logger.debug["CalcRefCrossSection"]<<"Starting CalcRefCrossSection ..."<<endl;
+
+   XSectionRef.clear();
+   XSectionRef.resize(NObsBin);
+   XSectionRefMixed.clear();
+   XSectionRef_s1.clear();
+   XSectionRef_s2.clear();
+   XSectionRefMixed.resize(NObsBin);
+   XSectionRef_s1.resize(NObsBin);
+   XSectionRef_s2.resize(NObsBin);
+
+   if (!GetIsFlexibleScaleTable()) {
+      fastNLOCoeffAddBase* Coeff_LO_Ref = GetReferenceTable(kLeading);
+      fastNLOCoeffAddBase* Coeff_NLO_Ref = GetReferenceTable(kNextToLeading);
+      fastNLOCoeffAddBase* Coeff_NNLO_Ref = GetReferenceTable(kNextToNextToLeading);
+      if (Coeff_LO_Ref && Coeff_NLO_Ref && Coeff_NNLO_Ref)
+         logger.warn["CalcRefCrossSection"]<<"Found NNLO reference cross section. Returning reference of LO+NLO+NNLO.\n";
+      if (Coeff_LO_Ref && Coeff_NLO_Ref) {
+         for (unsigned int i=0; i<NObsBin; i++) {
+            for (int l=0; l<Coeff_LO_Ref->GetNSubproc(); l++) {
+               //TODO ask Klaus about this: if (!fSubprocActive[l]) continue;
+               fastNLOCoeffAddFix* c = (fastNLOCoeffAddFix*)Coeff_LO_Ref;
+               int xUnits = c->GetIXsectUnits();
+               double unit = RescaleCrossSectionUnits(BinSize[i], xUnits);
+               XSectionRef[i] +=  c->GetSigmaTilde(i,0,0,0,l) * unit / c->GetNevt(i,l) ; // no scalevariations in LO tables
+            }
+            for (int l=0; l<Coeff_NLO_Ref->GetNSubproc(); l++) {
+               //TODO ask Klaus about this: if (!fSubprocActive[l]) continue;
+               fastNLOCoeffAddFix* c = (fastNLOCoeffAddFix*)Coeff_NLO_Ref;
+               int xUnits = c->GetIXsectUnits();
+               double unit = RescaleCrossSectionUnits(BinSize[i], xUnits);
+               XSectionRef[i] +=  c->GetSigmaTilde(i,fScalevar,0,0,l) * unit / c->GetNevt(i,l);
+            }
+            if (Coeff_NNLO_Ref) {
+               for (int l=0; l<Coeff_NNLO_Ref->GetNSubproc(); l++) {
+                  //TODO ask Klaus about this: if (!fSubprocActive[l]) continue;
+                  fastNLOCoeffAddFix* c = (fastNLOCoeffAddFix*)Coeff_NNLO_Ref;
+                  int xUnits = c->GetIXsectUnits();
+                  double unit = RescaleCrossSectionUnits(BinSize[i], xUnits);
+                  XSectionRef[i] +=  c->GetSigmaTilde(i,fScalevar,0,0,l) * unit / c->GetNevt(i,l);
+               }
+            }
+         }
+      } else
+         logger.warn["CalcRefCrossSection"]<<"No reference cross sections for LO and NLO available.\n";
+   } else {
+      for (unsigned int i=0; i<NObsBin; i++) {
+         fastNLOCoeffAddFlex* cLO = (fastNLOCoeffAddFlex*)BBlocksSMCalc[kFixedOrder][kLeading];
+         int xUnits = cLO->GetIXsectUnits();
+         double unit = RescaleCrossSectionUnits(BinSize[i], xUnits);
+         for (int n=0; n<cLO->GetNSubproc(); n++) {
+            //TODO if (!fSubprocActive[n]) continue;
+            XSectionRefMixed[i]             += cLO->SigmaRefMixed[i][n] * unit / cLO->GetNevt(i,n);
+            XSectionRef_s1[i]               += cLO->SigmaRef_s1[i][n] * unit / cLO->GetNevt(i,n);
+            XSectionRef_s2[i]               += cLO->SigmaRef_s2[i][n] * unit / cLO->GetNevt(i,n);
+         }
+         fastNLOCoeffAddFlex* cNLO = (fastNLOCoeffAddFlex*)BBlocksSMCalc[kFixedOrder][kNextToLeading];
+         xUnits = cNLO->GetIXsectUnits();
+         unit = RescaleCrossSectionUnits(BinSize[i], xUnits);
+         for (int n=0; n<cNLO->GetNSubproc(); n++) {
+            //TODO if (!fSubprocActive[n]) continue;
+            XSectionRefMixed[i]             += cNLO->SigmaRefMixed[i][n] * unit / cNLO->GetNevt(i,n);
+            XSectionRef_s1[i]               += cNLO->SigmaRef_s1[i][n] * unit / cNLO->GetNevt(i,n);
+            XSectionRef_s2[i]               += cNLO->SigmaRef_s2[i][n] * unit / cNLO->GetNevt(i,n);
+         }
+         // todo: nnlo reference cross section
+      }
+   }
+}
+
+
 //______________________________________________________________________________
 bool fastNLOReader::PrepareCache() {
    // check pdf cache
diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddBase.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddBase.h
index 9023a408..d5cfc128 100644
--- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddBase.h
+++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddBase.h
@@ -148,7 +148,7 @@ public:
    int GetNScaleDim() const {return NScaleDim;}
    //std::vector<std::string > GetScaleDescript(int iScale=0) const { return ScaleDescript[iScale]; };
    std::string GetScaleDescription(int iScale=0) const { return ScaleDescript[0][iScale]; };         // getter for scale description of scale iScale
-   std::vector<std::vector<std::string > > GetScaleDescr() const { return ScaleDescript; }
+   const std::vector<std::vector<std::string > >& GetScaleDescr() const { return ScaleDescript; }
    int GetNxtot1(int iBin) const { return XNode1[iBin].size(); }
    int GetNxtot2(int iBin) const { return XNode2.size() > 0 ? XNode2[iBin].size() : -1; }
 
@@ -157,12 +157,13 @@ public:
    double GetX1(int iObsBin, int iXnode) const; //! return x value of pdf1 for x-node 1
    double GetX2(int iObsBin, int iXnode) const; //! return x value of pdf1 for x-node 1
 
-   std::vector < double > GetXNodes1(int iObsBin) const { return XNode1[iObsBin]; }
-   std::vector < double > GetXNodes2(int iObsBin) const { return XNode2[iObsBin]; }
+   const std::vector < double >& GetXNodes1(int iObsBin) const { return XNode1[iObsBin]; }
+   const std::vector < double >& GetXNodes2(int iObsBin) const { return XNode2[iObsBin]; }
 
    fastNLO::v2d GetAllXNodes1() const { return XNode1; }
    fastNLO::v2d GetAllXNodes2() const { return XNode2; }
-
+   fastNLO::v2d* AccessAllXNodes1() { return &XNode1; }
+   fastNLO::v2d* AccessAllXNodes2() { return &XNode2; }
    bool IsReference() const {return IRef>0;};
    bool IsCompatible(const fastNLOCoeffAddBase& other) const;
    bool IsCatenable(const fastNLOCoeffAddBase& other) const;
diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddFlex.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddFlex.h
index 84761a5f..80fd287c 100644
--- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddFlex.h
+++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddFlex.h
@@ -38,8 +38,10 @@ public:
    unsigned int GetNScaleNode2(int iObsBin) const { return ScaleNode2[iObsBin].size(); };
    double GetScaleNode1(int iObsBin, int iNode) const { return ScaleNode1[iObsBin][iNode]; };
    double GetScaleNode2(int iObsBin, int iNode) const { return ScaleNode2[iObsBin][iNode]; };
-   std::vector < double > GetScaleNodes1(int iObsBin) const { return ScaleNode1[iObsBin]; };
-   std::vector < double > GetScaleNodes2(int iObsBin) const { return ScaleNode2[iObsBin]; };
+   fastNLO::v2d* AccessScaleNode1() { return &XNode1; }
+   fastNLO::v2d* AccessScaleNode2() { return &XNode2; }
+   const std::vector < double >& GetScaleNodes1(int iObsBin) const { return ScaleNode1[iObsBin]; };
+   const std::vector < double >& GetScaleNodes2(int iObsBin) const { return ScaleNode2[iObsBin]; };
    bool IsCompatible(const fastNLOCoeffAddFlex& other) const;                   //!< check for compatibilty for adding/merging of two tables
    bool IsCatenable(const fastNLOCoeffAddFlex& other) const;        //!< Check for compatibility of two contributions for merging/adding
    std::vector<fastNLO::v5d*>  AccessSigmaTildes() {
diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffBase.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffBase.h
index 3df26914..162b8d52 100644
--- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffBase.h
+++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffBase.h
@@ -94,7 +94,7 @@ public:
    int GetNCoeffInfoBlocks() const {return NCoeffInfoBlocks;}
    // Provide uncertainty via input vector
    void AddCoeffInfoBlock(int ICoeffInfoBlockFlag1, int ICoeffInfoBlockFlag2, std::vector<std::string> Description,
-                          std::vector<double> uncertainty);
+                          std::vector<double> Content);
    // Provide uncertainty reading from filename
    void AddCoeffInfoBlock(int ICoeffInfoBlockFlag1, int ICoeffInfoBlockFlag2, std::vector<std::string> Description,
                           std::string filename, unsigned int icola = 0, unsigned int icolb = 0);
diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOReader.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOReader.h
index c491b5ce..1814ad13 100644
--- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOReader.h
+++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOReader.h
@@ -84,33 +84,38 @@ public:
    void ResetCache() { fPDFCached=0; fAlphasCached=0;}
 
    // ---- Do the cross section calculation ---- //
-   void CalcCrossSection();
-   double RescaleCrossSectionUnits(double binsize, int xunits);                         // Rescale according to kAbsoluteUnits and Ipublunits settings
+   void CalcCrossSection();                                      //!< Main method to calculate cross sections
+   void CalcReferenceCrossSection();                             //!< Old-style from grid like entries; is this working at all? Remove? TODO
+   void CalcRefCrossSection();                                   //!< New-style from InfoBlocks
+   std::vector < double > GetCrossSection(bool lNorm = false);   //!< Return vector with all cross section values, normalize on request
+   std::vector < double > GetReferenceCrossSection();            //!< Old-style from grid like entries; is this working at all? Remove? TODO
+   std::vector < double > GetRefCrossSection();                  //!< New-style from InfoBlocks
 
-   std::vector < double > GetCrossSection(bool lNorm = false);      //!< Return vector with all cross section values, normalize on request
-   std::vector < double > GetUncertainty(bool lNorm = false);       //!< Return vector with additional uncertainty of cross section values, normalise on request (NOT YET IMPLEMENTED)
    std::vector < double > GetNormCrossSection(bool lNormScale = false, double xmurd = 1.0, double xmufd = 1.0); //!< Return vector with all normalized cross section values
-   std::vector < std::map< double, double > > GetCrossSection_vs_x1(); //! Cross section vs. x1 ( XSection_vsX1[bin][<x,xs>] )
-   std::vector < std::map< double, double > > GetCrossSection_vs_x2(); //! Cross section vs. x2 ( XSection_vsX1[bin][<x,xs>] )
+   std::vector < std::map< double, double > > GetCrossSection_vs_x1();                                          //! Cross section vs. x1 ( XSection_vsX1[bin][<x,xs>] ) Working? TODO
+   std::vector < std::map< double, double > > GetCrossSection_vs_x2();                                          //! Cross section vs. x2 ( XSection_vsX1[bin][<x,xs>] ) Working? TODO
+   std::vector < std::vector < double > > GetCrossSection2Dim();                                                //! Needed? Working? TODO
 
-   std::vector < double > GetReferenceCrossSection();
-   std::vector < double > GetQScales();   //!< Order (power of alpha_s) rel. to LO: 0 --> LO, 1 --> NLO
-   std::vector < std::vector < double > > GetCrossSection2Dim();
+   std::vector < double > GetQScales();                         //!< Order (power of alpha_s) rel. to LO: 0 --> LO, 1 --> NLO
+   std::vector < double > GetUncertainty(bool lNorm = false);   //!< Return vector with statistical uncertainty of cross section values, normalise on request (NOT YET IMPLEMENTED) TODO
 
    //! Return struct with vectors (for C++) or vector of vectors (for Python) containing the cross section values and the selected uncertainty
    //! Enum of Uncertaintstyle decides on method to call, but does not work for Python extension --> switch back to use differently named UncertaintyVec methods
+   //! Scale uncertainty
    XsUncertainty GetXsUncertainty(const fastNLO::EScaleUncertaintyStyle eScaleUnc, bool lNorm = false, double sclfac = 1.);
    // std::vector< std::vector<double> > GetXsUncertaintyVec(const fastNLO::EScaleUncertaintyStyle eScaleUnc, bool lNorm = false, int iprint = 0, double sclfac = 1.);
    // void PrintXsUncertaintyVec(fastNLO::EScaleUncertaintyStyle, std::string UncName, bool lNorm = false, double sclfac =1.);
    std::vector< std::vector<double> > GetScaleUncertaintyVec(const fastNLO::EScaleUncertaintyStyle eScaleUnc, bool lNorm = false, int iprint = 0, double sclfac = 1.);
    void PrintScaleUncertaintyVec(fastNLO::EScaleUncertaintyStyle, std::string UncName, bool lNorm = false, double sclfac =1.);
-   //
+   //! Statistical uncertainty
    XsUncertainty GetXsUncertainty(const fastNLO::EStatUncertaintyStyle eStatUnc, bool lNorm = false);
    // std::vector< std::vector<double> > GetXsUncertaintyVec(const fastNLO::EStatUncertaintyStyle eStatUnc, bool lNorm = false, int iprint = 0);
    // void PrintXsUncertaintyVec(fastNLO::EStatUncertaintyStyle, std::string UncName, bool lNorm = false);
    std::vector< std::vector<double> > GetStatUncertaintyVec(const fastNLO::EStatUncertaintyStyle eStatUnc, bool lNorm = false, int iprint = 0);
    void PrintStatUncertaintyVec(fastNLO::EStatUncertaintyStyle, std::string UncName, bool lNorm = false);
 
+   double RescaleCrossSectionUnits(double binsize, int xunits);   // Rescale according to kAbsoluteUnits and Ipublunits settings
+
    // ---- Getters for fastNLOReader member variables ---- //
    fastNLO::EScaleFunctionalForm GetMuRFunctionalForm() const { return fMuRFunc; };
    fastNLO::EScaleFunctionalForm GetMuFFunctionalForm() const { return fMuFFunc; };
@@ -164,8 +169,6 @@ protected:
    double CalcChecksum(double mu);
    bool PrepareCache();
 
-   void CalcReferenceCrossSection();
-
    double CalcMu(fastNLO::EMuX kMuX, double scale1 , double scale2 , double scalefactor);
    double FuncMixedOver1(double scale1 , double scale2) ;
    double FuncMixedOver2(double scale1 , double scale2) ;
-- 
GitLab