diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOCreate.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOCreate.cc index 5423714ab6e816924a7b492cc04006480efff24e..5c4dd2bb8839ea6b7b024c7f17086f7e6af44837 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOCreate.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOCreate.cc @@ -2451,11 +2451,13 @@ void fastNLOCreate::FillAllSubprocesses(const vector<vector<fnloEvent> >& events fStats._nEvPS++; fastNLOCoeffAddFix* c = (fastNLOCoeffAddFix*)GetTheCoeffTable(); + int NSubProc = c->GetNSubproc(); // do interpolation double xmin = GetTheCoeffTable()->GetNPDFDim() == 1 ? std::min(fEvent._x1,fEvent._x2) : fEvent._x1; double xmax = GetTheCoeffTable()->GetNPDFDim() == 1 ? std::max(fEvent._x1,fEvent._x2) : fEvent._x2; vector<pair<int,double> > nxlo = fKernX1[ObsBin]->GetNodeValues(xmin); vector<pair<int,double> > nxup = fKernX2[ObsBin]->GetNodeValues(xmax); + unsigned int maxNumNodes = c->GetNxmax(ObsBin); if (fApplyPDFReweight) { fKernX1[ObsBin]->CheckX(xmin); @@ -2471,6 +2473,10 @@ void fastNLOCreate::FillAllSubprocesses(const vector<vector<fnloEvent> >& events const vector<pair<int,double> >& nmu = fKernMuS[ObsBin][is]->GetNodeValues(mu); for (unsigned int m1 = 0 ; m1<nmu.size() ; m1++) { fastNLO::v2d& stm1 = st[is][nmu[m1].first]; + while(stm1.size() <= maxNumNodes) { + logger.debug["FillAllSubProcesses"] << "SigmaTilde ObsBin=" << ObsBin << " extended!" << endl; + stm1.insert(stm1.begin(), fastNLO::v1d(NSubProc)); + } for (unsigned int p = 0 ; p<events[is].size() ; p++) { double wgt = wgtfac * events[is][p]._w * nmu[m1].second / BinSize[ObsBin]; // ....................................................................................... @@ -4487,10 +4493,18 @@ void fastNLOCreate::InitInterpolationKernels() { fKernX2[i]->MakeGrids(nxbin); // fReduceXmin accounted for above } 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,wrmX[i],1,fScenConsts.X_DistanceMeasure); // use 1 as upper x-value + fKernX1[i]->MakeGrids(nxtot,fReduceXmin); + if (npdf == 2) { + fKernX2[i] = MakeInterpolationKernels(fScenConsts.X_Kernel,wrmX[i],1,fScenConsts.X_DistanceMeasure); + fKernX2[i]->MakeGrids(nxtot,fReduceXmin); + } } else { // error logger.error["InitInterpolationKernels"]<<"Cannot understand node counting: "<<fScenConsts.X_NNodeCounting<<"."<<endl; - logger.error["InitInterpolationKernels"]<<"Supported options are: 'NodesPerMagnitude', 'NodesPerBin' and 'NodesMax'."<<endl; + logger.error["InitInterpolationKernels"]<<"Supported options are: 'NodesPerMagnitude', 'NodesPerBin', 'NodesMax' and 'NodeDensity'."<<endl; } // Remove last node at x = 1; is multiplied by PDFs equalling zero anyway. diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolBase.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolBase.cc index 1420164da094e6a81d41eba160dd0ae44d60c347..3accba008881c44c89ac0749ab65eee8cc386f12 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolBase.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolBase.cc @@ -132,11 +132,20 @@ int fastNLOInterpolBase::FindLargestPossibleNode(double x){ // --- 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 ( x < fgrid[0] ) { - warn["FindLargestPossibleNode"]<<"Value is smaller than smallest node. Using first node. This may bias the result! x="<<x<<endl; + bool gridExtended = false; + while ( x < fgrid[0] ) { + double low = Function_sqrtlog10(fgrid[0]); + double high = Function_sqrtlog10(fgrid[1]); + double new_x = Function_sqrtlog10_inv(low - (high - low)); + fgrid.insert(fgrid.begin(), new_x); + info["FindLargestPossibleNode"]<<"Value is smaller than smallest node. Extending grid. x="<<x<<endl; + //warn["FindLargestPossibleNode"]<<"Value is smaller than smallest node. Using first node. This may bias the result! x="<<x<<endl; + gridExtended = true; + } + if (gridExtended) { return 0; } - else if ( x==fgrid[0] ) { + if ( x==fgrid[0] ) { return 0; } if ( x > fgrid.back() ) { @@ -332,7 +341,7 @@ bool fastNLOInterpolBase::CheckX(double& x) { return true; } //printf("x=%e, %e; fgrid=%e, %e; ratio: %e\n",x,x-1.,fgrid[0],fgrid[0]-1,x/fgrid[0]-1); - if ( x < fgrid[0] ) { + if ( x < fgrid[0] && false) { if ( x!=fLastVal[1] && fgrid[0]/x-1>1.e-6) warn["CheckX"]<<"Value "<<x<<" is smaller than smallest node (min="<<fgrid[0]<<"). Using this first node."<<endl; fLastVal[1] = x; // use this to monitor whenever there was an incident diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLagrange.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLagrange.cc index e568192d4bdb4f9f39476a84ad88a765f1c151b4..92d0753ba5e98619c69a5c97fbe6e94d3956f443 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLagrange.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOInterpolLagrange.cc @@ -33,6 +33,8 @@ void fastNLOInterpolLagrange::CalcNodeValues(vector<pair<int,double> >& nodes, d static const unsigned int nS = 4; // number of nodes that receive contributions from this interpolation + int nnode = FindLargestPossibleNode(x); + // --- relative distance delta - in function fdm H(x) // deltascale (Interpol(.,.,.delta,.): relative distance of value to node 'nnode' double delta = GetDelta(x); @@ -41,7 +43,6 @@ void fastNLOInterpolLagrange::CalcNodeValues(vector<pair<int,double> >& nodes, d // --- get scale interpolation kernel and updated scalenode position: 1 <= nmu < ntot-2 int nmod = 0; // --- variable for final node - int nnode = FindLargestPossibleNode(x); int nmax = fgrid.size()-2; if (fLastGridPointWasRemoved) nmax=fgrid.size()-1;