diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc index 3d236b21cd104822bd92b3ebcf5dd9072fc7acf3..1bca96f556c5c113305317fa62a3ba2ed918381c 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc @@ -378,12 +378,12 @@ void fastNLOCoeffAddBase::Add(const fastNLOCoeffAddBase& other, fastNLO::EMerge } for (int i = 0; i < fNObsBins; i++) { - fastNLO::v1d thisXNodes1i = GetXNodes1(i); - fastNLO::v1d otherXNodes1i = other.GetXNodes1(i); - for (int j = otherXNodes1i.size() - thisXNodes1i.size(); j > 0; j--) { - thisXNodes1i.insert(thisXNodes1i.begin(), otherXNodes1i[j - 1]); + fastNLOTools::ExtendHead(XNode1[i], other.XNode1[i]); + } + if (NPDFDim > 1) { + for (int i = 0; i < fNObsBins; i++) { + fastNLOTools::ExtendHead(XNode2[i], other.XNode2[i]); } - XNode1[i] = thisXNodes1i; } if ( moption==fastNLO::kAttach ) { diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFix.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFix.cc index 7347157e0ca3ea40f6b187c6945df315750a1ac1..93a67f9213a3d28b2f73c6a46d314e8bd2db4014 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFix.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFix.cc @@ -197,19 +197,30 @@ void fastNLOCoeffAddFix::Add(const fastNLOCoeffAddBase& other, fastNLO::EMerge m const fastNLOCoeffAddFix& othfix = (const fastNLOCoeffAddFix&)other; if ( moption==fastNLO::kMerge ) { fastNLO::v5d otherSigmaTilde = othfix.SigmaTilde; - for( int i=0 ; i<fNObsBins ; i++ ){ - for( int k=0 ; k<GetTotalScalevars() ; k++ ){ - for( int l=0 ; l<GetTotalScalenodes() ; l++ ){ - fastNLO::v2d thisX = SigmaTilde[i][k][l]; - fastNLO::v2d otherX = otherSigmaTilde[i][k][l]; - while (thisX.size() < otherX.size()) { - thisX.insert(thisX.begin(), fastNLO::v1d(GetNSubproc())); + for(int obsBin=0 ; obsBin<fNObsBins ; obsBin++){ + for(int scalevar=0 ; scalevar<GetTotalScalevars() ; scalevar++){ + for(int scalenode=0 ; scalenode<GetTotalScalenodes() ; scalenode++){ + fastNLO::v2d& thisX = SigmaTilde[obsBin][scalevar][scalenode]; + fastNLO::v2d& otherX = otherSigmaTilde[obsBin][scalevar][scalenode]; + int thisNxtot1 = GetNxtot1(obsBin); + int thisNxtot2 = GetNxtot2(obsBin); + int otherNxtot1 = othfix.GetNxtot1(obsBin); + int otherNxtot2 = othfix.GetNxtot2(obsBin); + if (thisNxtot1 < otherNxtot1) { + fastNLOTools::ExtendSigmaTildeX(thisX, thisNxtot1, otherNxtot1, + thisNxtot2, thisNxtot2, NPDFDim, fastNLO::v1d(NSubproc)); + } else if (thisNxtot1 > otherNxtot1) { + fastNLOTools::ExtendSigmaTildeX(otherX, otherNxtot1, thisNxtot1, + otherNxtot2, otherNxtot2, NPDFDim, fastNLO::v1d(NSubproc)); } - while (otherX.size() < thisX.size()) { - otherX.insert(otherX.begin(), fastNLO::v1d(GetNSubproc())); + int maxNxtot1 = max(thisNxtot1, otherNxtot1); + if (thisNxtot2 < otherNxtot2) { + fastNLOTools::ExtendSigmaTildeX(thisX, maxNxtot1, maxNxtot1, + thisNxtot2, otherNxtot2, NPDFDim, fastNLO::v1d(NSubproc)); + } else if (thisNxtot2 > otherNxtot2) { + fastNLOTools::ExtendSigmaTildeX(otherX, maxNxtot1, maxNxtot1, + otherNxtot2, thisNxtot2, NPDFDim, fastNLO::v1d(NSubproc)); } - SigmaTilde[i][k][l] = thisX; - otherSigmaTilde[i][k][l] = otherX; } } } diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFlex.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFlex.cc index 0f24af1c451884bc611155648596e7a375a8b876..54d248f0bb1a5d8661d3315b23270f5483224524 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFlex.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFlex.cc @@ -219,13 +219,13 @@ void fastNLOCoeffAddFlex::Add(const fastNLOCoeffAddBase& other, fastNLO::EMerge } const fastNLOCoeffAddFlex& othflex = (const fastNLOCoeffAddFlex&) other; if ( moption==fastNLO::kMerge ) { - fastNLOTools::AddVectors( SigmaTildeMuIndep , othflex.SigmaTildeMuIndep ); + ExtendAndAddSigmaTilde(othflex, SigmaTildeMuIndep, othflex.SigmaTildeMuIndep); if ( NScaleDep==3 || NScaleDep>=5 ) { - fastNLOTools::AddVectors( SigmaTildeMuFDep , othflex.SigmaTildeMuFDep ); - fastNLOTools::AddVectors( SigmaTildeMuRDep , othflex.SigmaTildeMuRDep ); + ExtendAndAddSigmaTilde(othflex, SigmaTildeMuFDep, othflex.SigmaTildeMuFDep); + ExtendAndAddSigmaTilde(othflex, SigmaTildeMuRDep, othflex.SigmaTildeMuRDep); if (( NScaleDep>=6 || !SigmaTildeMuRRDep.empty()) // both tables contain log^2 contributions (default case) && (othflex.NScaleDep>=6 || !othflex.SigmaTildeMuRRDep.empty()) ) { - fastNLOTools::AddVectors( SigmaTildeMuRRDep , othflex.SigmaTildeMuRRDep ); + ExtendAndAddSigmaTilde(othflex, SigmaTildeMuRRDep, othflex.SigmaTildeMuRRDep); } else if ( NScaleDep==6 && othflex.NScaleDep==5 ) { // this tables contains log^2 contributions, but the other does not // nothing todo. @@ -235,8 +235,8 @@ void fastNLOCoeffAddFlex::Add(const fastNLOCoeffAddBase& other, fastNLO::EMerge NScaleDep = 6; } if ( NScaleDep>=7 || !SigmaTildeMuFFDep.empty()) { - fastNLOTools::AddVectors( SigmaTildeMuFFDep , othflex.SigmaTildeMuFFDep ); - fastNLOTools::AddVectors( SigmaTildeMuRFDep , othflex.SigmaTildeMuRFDep ); + ExtendAndAddSigmaTilde(othflex, SigmaTildeMuFFDep, othflex.SigmaTildeMuFFDep); + ExtendAndAddSigmaTilde(othflex, SigmaTildeMuRFDep, othflex.SigmaTildeMuRFDep); } } fastNLOTools::AddVectors( SigmaRefMixed , othflex.SigmaRefMixed ); @@ -354,6 +354,38 @@ void fastNLOCoeffAddFlex::Add(const fastNLOCoeffAddBase& other, fastNLO::EMerge } +//________________________________________________________________________________________________________________ // +void fastNLOCoeffAddFlex::ExtendAndAddSigmaTilde( + const fastNLOCoeffAddFlex& othflex, fastNLO::v5d& ThisSigmaTilde, fastNLO::v5d OtherSigmaTilde) { + for(int obsBin=0 ; obsBin<fNObsBins ; obsBin++){ + fastNLO::v3d insertValue = fastNLO::v3d( + GetNScaleNode1(obsBin), fastNLO::v2d(GetNScaleNode2(obsBin), fastNLO::v1d(GetNSubproc()))); + fastNLO::v4d& thisX = ThisSigmaTilde[obsBin]; + fastNLO::v4d& otherX = OtherSigmaTilde[obsBin]; + int thisNxtot1 = GetNxtot1(obsBin); + int thisNxtot2 = GetNxtot2(obsBin); + int otherNxtot1 = othflex.GetNxtot1(obsBin); + int otherNxtot2 = othflex.GetNxtot2(obsBin); + if (thisNxtot1 < otherNxtot1) { + fastNLOTools::ExtendSigmaTildeX(thisX, thisNxtot1, otherNxtot1, + thisNxtot2, thisNxtot2, NPDFDim, insertValue); + } else if (thisNxtot1 > otherNxtot1) { + fastNLOTools::ExtendSigmaTildeX(otherX, otherNxtot1, thisNxtot1, + otherNxtot2, otherNxtot2, NPDFDim, insertValue); + } + int maxNxtot1 = max(thisNxtot1, otherNxtot1); + if (thisNxtot2 < otherNxtot2) { + fastNLOTools::ExtendSigmaTildeX(thisX, maxNxtot1, maxNxtot1, + thisNxtot2, otherNxtot2, NPDFDim, insertValue); + } else if (thisNxtot2 > otherNxtot2) { + fastNLOTools::ExtendSigmaTildeX(otherX, maxNxtot1, maxNxtot1, + otherNxtot2, thisNxtot2, NPDFDim, insertValue); + } + } + fastNLOTools::AddVectors(ThisSigmaTilde, OtherSigmaTilde); +} + + //________________________________________________________________________________________________________________ // void fastNLOCoeffAddFlex::Clear() { //! Set all elements of sigma tilde to zero diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOTools.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOTools.cc index ac382d06c839dd6c02ebdd63aee69ab93f9d5121..287717f8a25b3e10a9e07ef8d7bd51bf459ddbd8 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOTools.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOTools.cc @@ -573,7 +573,7 @@ namespace fastNLOTools { } //______________________________________________________________________________ - bool ExtendHead(fastNLO::v1d& vector1, fastNLO::v1d& vector2) { + bool ExtendHead(fastNLO::v1d& vector1, const fastNLO::v1d& vector2) { if (vector1.size() < vector2.size()) { vector1.insert(vector1.begin(), vector2.begin(), vector2.begin() + (vector2.size() - vector1.size())); return true; diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddFlex.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddFlex.h index 2c463ef48a686d47a7ca9ea43cb6d6a0134730e2..4544b963c1a6af08ec9482ea9463274a89103d14 100644 --- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddFlex.h +++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddFlex.h @@ -58,6 +58,7 @@ public: protected: void ReadCoeffAddFlex(std::istream& table, int ITabVersionRead); + void ExtendAndAddSigmaTilde(const fastNLOCoeffAddFlex& othflex, fastNLO::v5d& ThisSigmaTilde, fastNLO::v5d OtherSigmaTilde); int fILOord; // obtained from Scenario int fSTildeDISFormat = 1; // format of sigma-tilde coefficients (0: log(mu2/q2), 1: log(mu2)) diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOTools.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOTools.h index 434ace17d77446d6ddfc972e34d9196702fb0002..caa8341ac15aced0fba212579b71d36e4a5ed443 100644 --- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOTools.h +++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOTools.h @@ -93,7 +93,7 @@ namespace fastNLOTools { std::pair<fastNLO::v1d, fastNLO::v1d> GetTails(fastNLO::v1d& vector1, fastNLO::v1d& vector2); bool SameTails(fastNLO::v1d vector1, fastNLO::v1d vector2, double rtol=0.0); bool SameTails(fastNLO::v2d vector1, fastNLO::v2d vector2, double rtol=0.0); - bool ExtendHead(fastNLO::v1d& vector1, fastNLO::v1d& vector2); + bool ExtendHead(fastNLO::v1d& vector1, const fastNLO::v1d& vector2); template <typename T> void ExtendSigmaTildeX( std::vector<T>& SigmaTildeX, unsigned int OldDimSize1, unsigned int NewDimSize1, unsigned int OldDimSize2, unsigned int NewDimSize2, int NPDFDim, T InsertValue);