From 0b00ae576631c7000f14d94db8de45b4cd8aab60 Mon Sep 17 00:00:00 2001 From: James Moore Date: Tue, 10 Oct 2023 16:40:00 +0100 Subject: [PATCH] Closure tests now work with fixed observables --- libnnpdf/src/NNPDF/dataset.h | 4 +++- libnnpdf/src/dataset.cc | 8 +++++--- libnnpdf/src/experiments.cc | 12 +++++++++++- validphys2/src/validphys/core.py | 2 +- 4 files changed, 20 insertions(+), 6 deletions(-) diff --git a/libnnpdf/src/NNPDF/dataset.h b/libnnpdf/src/NNPDF/dataset.h index 6f425e653..a5e31a417 100644 --- a/libnnpdf/src/NNPDF/dataset.h +++ b/libnnpdf/src/NNPDF/dataset.h @@ -38,6 +38,7 @@ namespace NNPDF mutable matrix fSqrtCov; //!< The Cholesky decomposition of the covariance matrix bool UseFixedPredictions; //!< Flag to indicate using fixed predictions from simu_factor file + int SpecialTheoryID; //!< The special hacky theory ID // private methods for constructor void GenCovMat() const; //!< Generate covariance matrix @@ -47,7 +48,7 @@ namespace NNPDF DataSet(); //!< Disable default constructor public: - DataSet(CommonData const&, FKSet const&, double weight=1., bool use_fixed_predictions=false); //!< Constructor + DataSet(CommonData const&, FKSet const&, double weight=1., bool use_fixed_predictions=false, int special_theory_id=0); //!< Constructor DataSet(const DataSet&, std::vector const&); //!< Masked Copy constructor DataSet(const DataSet&) = default; //!< Masked Copy constructor virtual ~DataSet(); //!< The destructor. @@ -61,6 +62,7 @@ namespace NNPDF // ************************ Data Get Methods ****************************** bool GetUseFixedPredictions() const {return UseFixedPredictions; } //!< Getter for UseFixedPredictions + int GetSpecialTheoryID() const {return SpecialTheoryID; } //!< The special hacky theory ID double const& GetT0Pred(int i) const { return fT0Pred[i];} //!< Return t0 prediction double GetWeight() const {return fWeight;} diff --git a/libnnpdf/src/dataset.cc b/libnnpdf/src/dataset.cc index 6cc2bab00..c043898f3 100644 --- a/libnnpdf/src/dataset.cc +++ b/libnnpdf/src/dataset.cc @@ -35,13 +35,14 @@ using namespace NNPDF; * \param weight the factor by which the importance of the dataset in the fit chiĀ² * is increased. */ -DataSet::DataSet(CommonData const& data, FKSet const& set, double weight, bool use_fixed_predictions): +DataSet::DataSet(CommonData const& data, FKSet const& set, double weight, bool use_fixed_predictions, int special_theory_id): CommonData(data), FKSet(set), fIsArtificial(false), fIsT0(false), fWeight(weight), - UseFixedPredictions(use_fixed_predictions) + UseFixedPredictions(use_fixed_predictions), + SpecialTheoryID(special_theory_id) { fT0Pred.reserve(fNData); @@ -56,7 +57,8 @@ DataSet::DataSet(const DataSet& set, std::vector const& mask): fIsArtificial(set.fIsArtificial), fIsT0(set.fIsT0), fWeight(set.fWeight), - UseFixedPredictions(set.UseFixedPredictions) + UseFixedPredictions(set.UseFixedPredictions), + SpecialTheoryID(set.SpecialTheoryID) { fT0Pred.reserve(fNData); diff --git a/libnnpdf/src/experiments.cc b/libnnpdf/src/experiments.cc index b9d0ceb78..05fa61c55 100644 --- a/libnnpdf/src/experiments.cc +++ b/libnnpdf/src/experiments.cc @@ -15,6 +15,7 @@ #include #include #include +#include "yaml-cpp/yaml.h" #include "NNPDF/experiments.h" #include "NNPDF/chisquared.h" @@ -24,6 +25,7 @@ #include "NNPDF/utils.h" #include "NNPDF/randomgenerator.h" #include "NNPDF/exceptions.h" +#include "NNPDF/pathlib.h" using namespace std; namespace NNPDF{ @@ -406,7 +408,15 @@ void Experiment::MakeClosure(const vector& predictions, bool cons { newdata[i] = theory.GetObsCV(i); // This is our opportunity to CONTAMINATE things, and sort out the fixed observables - cout << set.GetUseFixedPredictions() << endl; + if (set.GetUseFixedPredictions()) + { + string fixed_prediction_path = get_data_path() + "theory_" + std::to_string(set.GetSpecialTheoryID()) + "/simu_factors/SIMU_" + set.GetSetName() + ".yaml"; + cout << fixed_prediction_path << endl; + YAML::Node read_file = YAML::LoadFile(fixed_prediction_path); + + std::vector fixed_predictions = read_file["SM_fixed"].as>(); + newdata[i] = fixed_predictions[i]; + } } set.UpdateData(newdata.data()); // MakeClosure treated as shifts rather than normalisations diff --git a/validphys2/src/validphys/core.py b/validphys2/src/validphys/core.py index 6ce0a774b..3d21905b4 100644 --- a/validphys2/src/validphys/core.py +++ b/validphys2/src/validphys/core.py @@ -503,7 +503,7 @@ def load(self): fkset = FKSet(FKSet.parseOperator(self.op), fktables) - data = DataSet(cd, fkset, self.weight, self.use_fixed_predictions) + data = DataSet(cd, fkset, self.weight, self.use_fixed_predictions, int(self.thspec.id)) if self.cuts is not None: #ugly need to convert from numpy.int64 to int, so we can pass