diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOCreate.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOCreate.cc index 8f61330e1beb05cda2a40890f577c0e6d23ee8bb..b3ebce13f5497aa3f1979f0ece68a07c89303dc4 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOCreate.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOCreate.cc @@ -2904,7 +2904,7 @@ void fastNLOCreate::FillContribution(int scalevar, const double wgtfac) { // --- sanity if (p<0 || p > c->GetNSubproc()) { - logger.error["FillContribution"]<<"Unknown process Id p = "<<p<<endl; + logger.error[__func__]<<"Unknown process Id p = "<<p<<endl; exit(1); } @@ -2934,7 +2934,7 @@ void fastNLOCreate::FillContribution(int scalevar, const double wgtfac) { //logger.debug["FillContributionFlexHHC"]<<endl; if ( wgtfac != 1.0 ) { - logger.error["FillContributionFlexHHC"]<<"Additional weight factor wgtfac = " << wgtfac << "not yet implemented for flex-scale tables, aborted!"<<endl; + logger.error[__func__]<<"Additional weight factor wgtfac = " << wgtfac << "not yet implemented for flex-scale tables, aborted!"<<endl; exit(1); } @@ -4627,10 +4627,10 @@ void fastNLOCreate::InitInterpolationKernels() { delete kernmin; } else if(fScenConsts.X_NNodeCounting == "NodeDensity") { logger.debug["InitInterpolationKernels"]<<"Setting x nodes as a density: "<<fScenConsts.X_NNodeCounting<<endl; - fKernX1[i] = MakeInterpolationKernels(fScenConsts.X_Kernel,nxtot,fScenConsts.X_DistanceMeasure); // use 1 as upper x-value + fKernX1[i] = MakeInterpolationKernels(fScenConsts.X_Kernel, nxtot, fScenConsts.X_DistanceMeasure, false); // use 1 as upper x-value fKernX1[i]->MakeGrids(4,fReduceXmin); if (npdf == 2) { - fKernX2[i] = MakeInterpolationKernels(fScenConsts.X_Kernel,nxtot,fScenConsts.X_DistanceMeasure); // use 1 as upper x-value + fKernX2[i] = MakeInterpolationKernels(fScenConsts.X_Kernel,nxtot,fScenConsts.X_DistanceMeasure, false); // use 1 as upper x-value fKernX2[i]->MakeGrids(4,fReduceXmin); } } else { @@ -4658,7 +4658,7 @@ void fastNLOCreate::InitInterpolationKernels() { fScenConsts.Mu1_DistanceMeasure); fKernMu1[i]->MakeGrids(nqtot1); } else if (fScenConsts.Mu1_NNodeCounting == "NodeDensity") { - fKernMu1[i] = MakeInterpolationKernels(fScenConsts.Mu1_Kernel, nqtot1, fScenConsts.Mu1_DistanceMeasure); + fKernMu1[i] = MakeInterpolationKernels(fScenConsts.Mu1_Kernel, nqtot1, fScenConsts.Mu1_DistanceMeasure, true); fKernMu1[i]->MakeGrids(4); } else if (fScenConsts.Mu1_NNodeCounting != "NodesPerDim1" && fScenConsts.Mu1_NNodeCounting != "NodesPerDim2" && @@ -4681,7 +4681,7 @@ void fastNLOCreate::InitInterpolationKernels() { fScenConsts.Mu2_DistanceMeasure); fKernMu2[i]->MakeGrids(nqtot2); } else if (fScenConsts.Mu2_NNodeCounting == "NodeDensity") { - fKernMu2[i] = MakeInterpolationKernels(fScenConsts.Mu2_Kernel, nqtot2, fScenConsts.Mu2_DistanceMeasure); + fKernMu2[i] = MakeInterpolationKernels(fScenConsts.Mu2_Kernel, nqtot2, fScenConsts.Mu2_DistanceMeasure, false); fKernMu2[i]->MakeGrids(4); } else if (fScenConsts.Mu2_NNodeCounting != "NodesPerDim1" && fScenConsts.Mu2_NNodeCounting != "NodesPerDim2" && @@ -4703,7 +4703,7 @@ void fastNLOCreate::InitInterpolationKernels() { } } else if (fScenConsts.Mu1_NNodeCounting == "NodeDensity") { for (unsigned int k = 0 ; k<fScaleFac.size() ; k++) { - fKernMuS[i][k] = MakeInterpolationKernels(fScenConsts.Mu1_Kernel, nqtot1, fScenConsts.Mu1_DistanceMeasure); + fKernMuS[i][k] = MakeInterpolationKernels(fScenConsts.Mu1_Kernel, nqtot1, fScenConsts.Mu1_DistanceMeasure, true); fKernMuS[i][k]->MakeGrids(4); } } else if (fScenConsts.Mu1_NNodeCounting != "NodesPerDim1" && @@ -4759,18 +4759,18 @@ fastNLOInterpolBase* fastNLOCreate::MakeInterpolationKernels(string KernelName, // ___________________________________________________________________________________________________ -fastNLOInterpolBase* fastNLOCreate::MakeInterpolationKernels(string KernelName, double density, const std::string& distancemeasure) { +fastNLOInterpolBase* fastNLOCreate::MakeInterpolationKernels(string KernelName, double density, const std::string& distancemeasure, bool extendHigh) { //! This function identifies the string-identifier //! and creates the corresponding fastNLO Interpolation kernel fastNLOGrid::GridType type = fastNLOInterpolBase::TranslateGridType(distancemeasure); if (KernelName == "CatmullRom" || KernelName == "Catmull") - return new fastNLOInterpolCatmullRom(density,type); + return new fastNLOInterpolCatmullRom(density, type, extendHigh); else if (KernelName == "Lagrange") - return new fastNLOInterpolLagrange(density,type); + return new fastNLOInterpolLagrange(density, type, extendHigh); else if (KernelName == "Linear") - return new fastNLOInterpolLinear(density,type); + return new fastNLOInterpolLinear(density, type, extendHigh); else if (KernelName == "OneNode") { logger.error["MakeInterpolationKernels"]<<"Cannot create a OneNode kernel with a density. Exiting."<<endl; exit(1); diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolBase.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolBase.cc index afaf4460f9d49575583b72ce1d46f3a95c4f96af..e87fd048c989efa5c6efb9820acb6be5a1670d14 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolBase.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolBase.cc @@ -4,6 +4,7 @@ #include <cfloat> #include <cmath> #include <cstdlib> +#include <cassert> #include <fstream> #include <iostream> #include <vector> @@ -24,7 +25,7 @@ fastNLOInterpolBase::fastNLOInterpolBase(double min, double max, fastNLOGrid::Gr //______________________________________________________________________________ -fastNLOInterpolBase::fastNLOInterpolBase(double density, fastNLOGrid::GridType type, int nMinNodes) : +fastNLOInterpolBase::fastNLOInterpolBase(double density, fastNLOGrid::GridType type, int nMinNodes, bool extendHigh) : PrimalScream("fastNLOInterpol"),fNMinNodes(nMinNodes) { debug["fastNLOInterpolBase"]<<"New fastNLOInterpolBase instance (density contructor)."<<endl; fLastGridPointWasRemoved=false; @@ -32,6 +33,7 @@ fastNLOInterpolBase::fastNLOInterpolBase(double density, fastNLOGrid::GridType t debug["fastNLOInterpolBase"]<<"nMinNodes = "<<nMinNodes<<endl; fdm = type; fExtendLow = true; + fExtendHigh = extendHigh; fvalmax = 1.0; double valMinH = -(nMinNodes - 1) / density; @@ -170,8 +172,6 @@ void fastNLOInterpolBase::MakeGrids(int nNodes, double ReduceXmin){ int fastNLOInterpolBase::FindLargestPossibleNode(double x, bool canExtend = false){ // --- find x position in range: 0 <= node1 < nnode1-1 - int node1 = fgrid.size()-2; // --- initialize with largest possible value - if ( fLastGridPointWasRemoved ) node1=fgrid.size()-1; if (canExtend && fExtendLow) { bool gridExtended = false; while ( x < fgrid[1] ) { @@ -200,15 +200,58 @@ int fastNLOInterpolBase::FindLargestPossibleNode(double x, bool canExtend = fals fgrid.insert(fgrid.begin(), Function_4thrtlog10_inv(newxH)); break; default: - error["MakeGridFromHGrid"]<<"Unknown grid type."<<endl; + error[__func__]<<"Unknown grid type."<<endl; } - debug["FindLargestPossibleNode"]<<"Value is smaller than smallest node. Extending grid. x="<<x<<endl; + debug[__func__]<<"Value is smaller than smallest node. Extending grid. x="<<x<<endl; gridExtended = true; } if (gridExtended) { return 1; } } + + if (canExtend && fExtendHigh) { + assert(!fLastGridPointWasRemoved); + bool gridExtended = false; + while ( x > fgrid[fgrid.size() - 2] ) { + double newxH = fHgrid[fHgrid.size() - 1] + (fHgrid[fHgrid.size() - 1] - fHgrid[fHgrid.size() - 2]); + fHgrid.push_back(newxH); + switch (fdm) { + case fastNLOGrid::kLinear: + fgrid.push_back(newxH); + break; + case fastNLOGrid::kLogLog025: + fgrid.push_back(Function_loglog025_inv(newxH)); + break; + case fastNLOGrid::kLog10: + fgrid.push_back(Function_log10_inv(newxH)); + break; + case fastNLOGrid::kSqrtLog10: + fgrid.push_back(Function_sqrtlog10_inv(newxH)); + break; + case fastNLOGrid::kLogLog: + fgrid.push_back(Function_loglog_inv(newxH)); + break; + case fastNLOGrid::k3rdrtLog10: + fgrid.push_back(Function_3rdrtlog10_inv(newxH)); + break; + case fastNLOGrid::k4thrtLog10: + fgrid.push_back(Function_4thrtlog10_inv(newxH)); + break; + default: + error[__func__]<<"Unknown grid type."<<endl; + } + debug[__func__]<<"Value is larger than largest node. Extending grid. x="<<x<<endl; + gridExtended = true; + } + if (gridExtended) { + return fgrid.size() - 3; + } + } + + int node1 = fgrid.size()-2; // --- initialize with largest possible value + if ( fLastGridPointWasRemoved ) node1=fgrid.size()-1; + if ( x==fgrid[0] ) { return 0; } else if ( x < fgrid[0] ) { @@ -414,7 +457,7 @@ bool fastNLOInterpolBase::CheckX(double& x) { fLastVal[1] = x; // use this to monitor whenever there was an incident x = fgrid[0]; } - else if ( x > fgrid.back() ) { + else if ( x > fgrid.back() && !fExtendHigh ) { if ( fLastGridPointWasRemoved ) { if ( x > fvalmax ) { if ( x!=fLastVal[2] && x/fgrid.back()-1. > 1.e-6) diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolCatmullRom.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolCatmullRom.cc index c31c4481131f72d302615683e847dd021281ac91..c852dc5601ef77f45174d45a0c82a37aa8af2196 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolCatmullRom.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolCatmullRom.cc @@ -20,7 +20,9 @@ fastNLOInterpolCatmullRom::fastNLOInterpolCatmullRom(double min, double max, fas //______________________________________________________________________________ -fastNLOInterpolCatmullRom::fastNLOInterpolCatmullRom(double density, fastNLOGrid::GridType type) : fastNLOInterpolBase(density,type,4) { +fastNLOInterpolCatmullRom::fastNLOInterpolCatmullRom(double density, fastNLOGrid::GridType type, bool extendHigh) : + fastNLOInterpolBase(density, type, 4, extendHigh) { + debug["fastNLOInterpolLagrange"]<<"New fastNLOInterpolCatmullRom instance."<<endl; } diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLagrange.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLagrange.cc index 5458be9bbab3ce55463fa947746dfc292f6baff5..148d8ba0a499f2d58fd72a63a65e577091675777 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLagrange.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLagrange.cc @@ -18,7 +18,9 @@ fastNLOInterpolLagrange::fastNLOInterpolLagrange(double min, double max, fastNLO //______________________________________________________________________________ -fastNLOInterpolLagrange::fastNLOInterpolLagrange(double density, fastNLOGrid::GridType type) : fastNLOInterpolBase(density,type,4) { +fastNLOInterpolLagrange::fastNLOInterpolLagrange(double density, fastNLOGrid::GridType type, bool extendHigh) : + fastNLOInterpolBase(density, type, 4, extendHigh) { + debug["fastNLOInterpolLagrange"]<<"New fastNLOInterpolLagrange instance."<<endl; } diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLinear.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLinear.cc index 2872ff6bcc88de3bc5544e4d6d2405c305e507f8..c5d7e097956e5d61c9528ca2546c671cd1110053 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLinear.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLinear.cc @@ -18,7 +18,9 @@ fastNLOInterpolLinear::fastNLOInterpolLinear(double min, double max, fastNLOGrid //______________________________________________________________________________ -fastNLOInterpolLinear::fastNLOInterpolLinear(double density, fastNLOGrid::GridType type) : fastNLOInterpolBase(density,type,4) { +fastNLOInterpolLinear::fastNLOInterpolLinear(double density, fastNLOGrid::GridType type, bool extendHigh) + : fastNLOInterpolBase(density, type, 4, extendHigh) { + debug["fastNLOInterpolLagrange"]<<"New fastNLOInterpolLinear instance."<<endl; } diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCreate.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCreate.h index af9b7b86243256744591ec9ab07cce0a1e38d221..fbeb7ec70112710421fa9d0b39accaa981d04f1c 100644 --- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCreate.h +++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCreate.h @@ -198,7 +198,7 @@ protected: void InitCoeffTable(); void InitInterpolationKernels(); fastNLOInterpolBase* MakeInterpolationKernels(std::string KernelName, double xdn, double xup, const std::string& distancemeasure); - fastNLOInterpolBase* MakeInterpolationKernels(std::string KernelName, double density, const std::string& distancemeasure); + fastNLOInterpolBase* MakeInterpolationKernels(std::string KernelName, double density, const std::string& distancemeasure, bool extendHigh); void InitGrids(); void GetWarmupValues(); bool CheckWarmupConsistency(); //!< Check consistency of warmup bin-grid and variables with steering values. diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolBase.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolBase.h index 9a7169e3fdd63f0a74919c112ccdc690b808b3fe..cbe69c5d7aa4d42f7d7259a3c44fb79af3bada95 100644 --- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolBase.h +++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolBase.h @@ -29,7 +29,7 @@ class fastNLOInterpolBase : public PrimalScream { public: fastNLOInterpolBase(double min, double max, fastNLOGrid::GridType type, int nMinNodes); - fastNLOInterpolBase(double density, fastNLOGrid::GridType type, int nMinNodes); + fastNLOInterpolBase(double density, fastNLOGrid::GridType type, int nMinNodes, bool extendHigh); virtual ~fastNLOInterpolBase(void); const std::vector<std::pair<int,double> >& GetNodeValues(double val); @@ -109,6 +109,7 @@ protected: std::vector<double> fHgrid; int fnmod ; // variable for final nodes. Has to be filled by inherited algorithm bool fExtendLow = false; + bool fExtendHigh = false; }; diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolCatmullRom.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolCatmullRom.h index 0df406e253195691adadda613e7c3514f2157b1a..cbd3dfa675d6ae3d95099a0933a1025174c99b93 100644 --- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolCatmullRom.h +++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolCatmullRom.h @@ -16,7 +16,7 @@ class fastNLOInterpolCatmullRom : public fastNLOInterpolBase { public: fastNLOInterpolCatmullRom(double min, double max, fastNLOGrid::GridType type); - fastNLOInterpolCatmullRom(double density, fastNLOGrid::GridType type); + fastNLOInterpolCatmullRom(double density, fastNLOGrid::GridType type, bool extendHigh); ~fastNLOInterpolCatmullRom(void); // vector<pair<int,double> > CalcNodeValues(double val); diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolLagrange.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolLagrange.h index deff97057022efa674cc199ec1a303378eea34e9..60cdda107f748d905653f945512de8efcfc16d99 100644 --- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolLagrange.h +++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolLagrange.h @@ -23,7 +23,7 @@ class fastNLOInterpolLagrange : public fastNLOInterpolBase { public: fastNLOInterpolLagrange(double min, double max, fastNLOGrid::GridType type); - fastNLOInterpolLagrange(double density, fastNLOGrid::GridType type); + fastNLOInterpolLagrange(double density, fastNLOGrid::GridType type, bool extendHigh); ~fastNLOInterpolLagrange(void); // vector<pair<int,double> > CalcNodeValues(double val); diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolLinear.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolLinear.h index ceb174b1385fd30be25daf0fec5b4980a6d313e8..70fa1a0a4d8b6fe978af9b857761779b4705a8a8 100644 --- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolLinear.h +++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOInterpolLinear.h @@ -22,7 +22,7 @@ class fastNLOInterpolLinear : public fastNLOInterpolBase { public: fastNLOInterpolLinear(double min, double max, fastNLOGrid::GridType type); - fastNLOInterpolLinear(double density, fastNLOGrid::GridType type); + fastNLOInterpolLinear(double density, fastNLOGrid::GridType type, bool extendHigh); ~fastNLOInterpolLinear(void); // vector<pair<int,double> > CalcNodeValues(double val);