diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc index 57f3e334061a454e5e2857122c665d5555b7c681..f6680dc2055658b4d57f6374a6e24974f180f8b0 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddBase.cc @@ -479,38 +479,14 @@ bool fastNLOCoeffAddBase::IsCompatible(const fastNLOCoeffAddBase& other) const { //return false; warn["IsCompatible"]<<"Continuing! (experimental: This is needed for kAttach, but may causes bugs otherwise. Please report!)"<<endl; } - // check x-nodes briefly - if ( fNObsBins != other.GetNObsBin() ){ - warn["IsCompatible"]<<"Different number of bins detected."<<endl; + // check x-nodes + if (!fastNLOTools::SameTails(GetAllXNodes1(), other.GetAllXNodes1())) { + warn["IsCompatible"] << "XNodes1 not compatible, set verbosity to debug for more information." << endl; return false; } - - // check x-nodes briefly - for ( int i = 0 ; i< fNObsBins ;i++ ){ - int thisNxtot = GetNxtot1(i); - int otherNxtot = other.GetNxtot1(i); - int thisOffset; - int otherOffset; - int minNxtot; - if (thisNxtot > otherNxtot) { - thisOffset = thisNxtot - otherNxtot; - otherOffset = 0; - minNxtot = otherNxtot; - } else { - thisOffset = 0; - otherOffset = otherNxtot - thisNxtot; - minNxtot = thisNxtot; - } - fastNLO::v1d otherXNodes = other.GetXNodes1(i); - - for (int j = 0; j < minNxtot; j++) { - if (XNode1[i][j + thisOffset] != otherXNodes[j + otherOffset]) { - warn["IsCompatible"] << "Different values for ObsBin=" << i << " and XNode=" << j - << " detected:" << GetXNode1(i, j + thisOffset) << " <-> " - << other.GetXNode1(i, j + otherOffset) << endl; - return false; - } - } + if (!fastNLOTools::SameTails(GetAllXNodes2(), other.GetAllXNodes2())) { + warn["IsCompatible"] << "XNodes2 not compatible, set verbosity to debug for more information." << endl; + return false; } // succesful! return true; diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFix.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFix.cc index 934c6513e131030854cc2c685850cc84c32ffb1e..964a6a0a8e54e3cf5371d23cc67f7d5a7f9591c7 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFix.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOCoeffAddFix.cc @@ -348,9 +348,18 @@ bool fastNLOCoeffAddFix::IsCatenable(const fastNLOCoeffAddFix& other) const { bool fastNLOCoeffAddFix::IsEquivalent(const fastNLOCoeffBase& other, double rtol) const { const fastNLOCoeffAddFix* op = dynamic_cast<const fastNLOCoeffAddFix*>(&other); if (op == nullptr) { + debug["IsEquivalent"] << "other is not of type fastNLOCoeffAddFix." << endl; return false; } + if (!fastNLOTools::SameTails(GetAllXNodes1(), op->GetAllXNodes1(), rtol)) { + debug["IsEquivalent"] << "XNode1 not equivalent, see above." << endl; + return false; + } + if (!fastNLOTools::SameTails(GetAllXNodes2(), op->GetAllXNodes2(), rtol)) { + debug["IsEquivalent"] << "XNode2 not equivalent, see above." << endl; + return false; + } fastNLO::v5d ost5 = op->SigmaTilde; if (SigmaTilde.size() != ost5.size()) { return false; @@ -367,17 +376,6 @@ bool fastNLOCoeffAddFix::IsEquivalent(const fastNLOCoeffBase& other, double rtol tOffsetXN1 = 0; oOffsetXN1 = onb1 - tnb1; } - for (int xNode = 0; xNode < std::min(tnb1, onb1); xNode++) { - double txn1 = GetXNode1(obsBin, xNode + tOffsetXN1); - double oxn1 = op->GetXNode1(obsBin, xNode + oOffsetXN1); - double rdiff = std::abs((txn1 - oxn1) / txn1); - if (rdiff > rtol) { - debug["IsEquivalent"] << "XNode1 rdiff too high: obsBin=" << obsBin << " xNode=" << xNode << - " txn1=" << txn1 << " oxn1=" << oxn1 << " rdiff=" << rdiff << endl; - return false; - } - } - fastNLO::v4d tst4 = SigmaTilde[obsBin]; fastNLO::v4d ost4 = ost5[obsBin]; diff --git a/v2.5/toolkit/fastnlotoolkit/fastNLOTools.cc b/v2.5/toolkit/fastnlotoolkit/fastNLOTools.cc index ec1df25f17fdbb90a338d8306784b7f3155b7786..f9c551c23b28f361c6a59bb835ec7caf4cf33b7a 100644 --- a/v2.5/toolkit/fastnlotoolkit/fastNLOTools.cc +++ b/v2.5/toolkit/fastnlotoolkit/fastNLOTools.cc @@ -532,4 +532,43 @@ namespace fastNLOTools { } } + //______________________________________________________________________________ + std::pair<fastNLO::v1d, fastNLO::v1d> GetTails(fastNLO::v1d& vector1, fastNLO::v1d& vector2) { + if (vector1.size() > vector2.size()) { + return std::make_pair(fastNLO::v1d(vector1.begin() + (vector1.size() - vector2.size()), vector1.end()), vector2); + } else if (vector1.size() < vector2.size()) { + return std::make_pair(vector1, fastNLO::v1d(vector2.begin() + (vector2.size() - vector1.size()), vector2.end())); + } else { + return std::make_pair(vector1, vector2); + } + } + + //______________________________________________________________________________ + bool SameTails(fastNLO::v1d vector1, fastNLO::v1d vector2, double rtol) { + std::tie(vector1, vector2) = GetTails(vector1, vector2); + for (unsigned int i = 0; i < vector1.size(); i++) { + if (abs(vector1[i] - vector2[i]) > abs(rtol * vector1[i])) { + debug["SameTails"] << "1D vector index is " << i << ". val1=" << vector1[i] + << " val2=" << vector2[i] << " rdiff=" + << abs((vector1[i]-vector2[i])/vector1[i]) << " rtol=" << rtol << endl; + return false; + } + } + return true; + } + + //______________________________________________________________________________ + bool SameTails(fastNLO::v2d vector1, fastNLO::v2d vector2, double rtol) { + if (vector1.size() != vector2.size()) { + debug["SameTails"] << "2D vectors have different sizes." << endl; + return false; + } + for (unsigned int i = 0; i < vector1.size(); i++) { + if (!SameTails(vector1[i], vector2[i], rtol)) { + debug["SameTails"] << "2D vector index is " << i << endl; + return false; + } + } + return true; + } } // end namespace fastNLO diff --git a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddBase.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddBase.h index 63543b94630ec045e8901462f217bbdabbce02c0..2746cd464aa8cf1d9e05b45540ad41a7f5c51d25 100644 --- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddBase.h +++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOCoeffAddBase.h @@ -158,6 +158,9 @@ public: std::vector < double > GetXNodes1(int iObsBin) const { return XNode1[iObsBin]; } std::vector < double > GetXNodes2(int iObsBin) const { return XNode2[iObsBin]; } + fastNLO::v2d GetAllXNodes1() const { return XNode1; } + fastNLO::v2d GetAllXNodes2() const { 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/fastNLOTools.h b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOTools.h index d5c625f25d772d3f3ff3043a899f72e8799fa0ff..4d9abac8b04a11b489d6e98dd506ee89302ff7cf 100644 --- a/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOTools.h +++ b/v2.5/toolkit/fastnlotoolkit/include/fastnlotk/fastNLOTools.h @@ -90,6 +90,10 @@ namespace fastNLOTools { //! Function prototype for string to enum conversion of central scale choice fastNLO::EScaleFunctionalForm GetScaleEnum(const std::string); + 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); + };