Skip to content

Commit

Permalink
Closure tests now work with fixed observables
Browse files Browse the repository at this point in the history
  • Loading branch information
James Moore committed Oct 10, 2023
1 parent 807fa25 commit 0b00ae5
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
4 changes: 3 additions & 1 deletion libnnpdf/src/NNPDF/dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ namespace NNPDF
mutable matrix<double> 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
Expand All @@ -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<int> const&); //!< Masked Copy constructor
DataSet(const DataSet&) = default; //!< Masked Copy constructor
virtual ~DataSet(); //!< The destructor.
Expand All @@ -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;}
Expand Down
8 changes: 5 additions & 3 deletions libnnpdf/src/dataset.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand All @@ -56,7 +57,8 @@ DataSet::DataSet(const DataSet& set, std::vector<int> const& mask):
fIsArtificial(set.fIsArtificial),
fIsT0(set.fIsT0),
fWeight(set.fWeight),
UseFixedPredictions(set.UseFixedPredictions)
UseFixedPredictions(set.UseFixedPredictions),
SpecialTheoryID(set.SpecialTheoryID)
{
fT0Pred.reserve(fNData);

Expand Down
12 changes: 11 additions & 1 deletion libnnpdf/src/experiments.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
#include <iomanip>
#include <cmath>
#include <numeric>
#include "yaml-cpp/yaml.h"

#include "NNPDF/experiments.h"
#include "NNPDF/chisquared.h"
Expand All @@ -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{
Expand Down Expand Up @@ -406,7 +408,15 @@ void Experiment::MakeClosure(const vector<ThPredictions>& 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<float> fixed_predictions = read_file["SM_fixed"].as<std::vector<float>>();
newdata[i] = fixed_predictions[i];
}
}

set.UpdateData(newdata.data()); // MakeClosure treated as shifts rather than normalisations
Expand Down
2 changes: 1 addition & 1 deletion validphys2/src/validphys/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 0b00ae5

Please sign in to comment.