Skip to content

Commit

Permalink
removing setosccov and passing via the constructor,there are checks o…
Browse files Browse the repository at this point in the history
…n whether osccov is null or not so you know if you want to do osc weights or not
  • Loading branch information
EdAtkin committed Nov 18, 2024
1 parent ddd79cb commit 8611ffb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 22 deletions.
28 changes: 19 additions & 9 deletions samplePDF/samplePDFFDBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
#include "samplePDF/Structs.h"

#include<algorithm>
#include <memory>

samplePDFFDBase::samplePDFFDBase(std::string ConfigFileName, covarianceXsec* xsec_cov) : samplePDFBase()
samplePDFFDBase::samplePDFFDBase(std::string ConfigFileName, covarianceXsec* xsec_cov, covarianceOsc* osc_cov) : samplePDFBase()
{
MACH3LOG_INFO("-------------------------------------------------------------------");
MACH3LOG_INFO("Creating SamplePDFFDBase object");
Expand All @@ -17,11 +18,16 @@ samplePDFFDBase::samplePDFFDBase(std::string ConfigFileName, covarianceXsec* xse
throw MaCh3Exception(__FILE__, __LINE__);
}
XsecCov = xsec_cov;

if(!osc_cov){
MACH3LOG_WARN("You have pass a nullptr to a covarianceOsc, this means I will not calculate oscillation weights");
}
OscCov = osc_cov;

samplePDFFD_array = nullptr;
samplePDFFD_data = nullptr;

SampleManager = new manager(ConfigFileName.c_str());
SampleManager = std::unique_ptr<manager>(new manager(ConfigFileName.c_str()));
}

samplePDFFDBase::~samplePDFFDBase()
Expand Down Expand Up @@ -355,13 +361,17 @@ void samplePDFFDBase::reweight() // Reweight function - Depending on Osc Calcula
//KS: Reset the histograms before reweight
ResetHistograms();

std::vector<_float_> OscVec(OscCov->GetNumParams());
for (int iPar=0;iPar<OscCov->GetNumParams();iPar++) {
OscVec[iPar] = OscCov->getParProp(iPar);
}

for (int iSample=0;iSample<(int)MCSamples.size();iSample++) {
NuOscProbCalcers[iSample]->CalculateProbabilities(OscVec);
//You only need to do these things if OscCov has been initialised
//if not then you're not considering oscillations
if (OscCov) {
std::vector<_float_> OscVec(OscCov->GetNumParams());
for (int iPar=0;iPar<OscCov->GetNumParams();iPar++) {
OscVec[iPar] = OscCov->getParProp(iPar);
}

for (int iSample=0;iSample<(int)MCSamples.size();iSample++) {
NuOscProbCalcers[iSample]->CalculateProbabilities(OscVec);
}
}

fillArray();
Expand Down
16 changes: 3 additions & 13 deletions samplePDF/samplePDFFDBase.h
Original file line number Diff line number Diff line change
@@ -1,12 +1,5 @@
#pragma once

//C++ includes
#include <list>

//ROOT includes
#include "THStack.h"
#include "TLegend.h"

//MaCh3 includes
#include "OscProbCalcer/OscProbCalcerBase.h"
#include "Oscillator/OscillatorBase.h"
Expand All @@ -26,11 +19,11 @@ class samplePDFFDBase : public samplePDFBase
//######################################### Functions #########################################

samplePDFFDBase(){};
samplePDFFDBase(std::string mc_version, covarianceXsec* xsec_cov);
samplePDFFDBase(std::string mc_version, covarianceXsec* xsec_cov, covarianceOsc* osc_cov = nullptr);
virtual ~samplePDFFDBase();

int GetNDim(){return nDimensions;} //DB Function to differentiate 1D or 2D binning
std::string GetName(){return samplename;}
std::string GetName() {return samplename;}

//===============================================================================
// DB Reweighting and Likelihood functions
Expand All @@ -48,9 +41,6 @@ class samplePDFFDBase : public samplePDFBase
void reweight();
double GetEventWeight(int iSample, int iEntry);

/// @brief setup the Oscillation covariance object to get values to calculate probailities from
void SetOscCov(covarianceOsc* osc_cov){OscCov = osc_cov;};

/// @brief including Dan's magic NuOscillator
void SetupNuOscillator();

Expand Down Expand Up @@ -238,7 +228,7 @@ class samplePDFFDBase : public samplePDFBase
std::vector< std::vector<double> > Selection;
//===========================================================================

manager* SampleManager;
std::unique_ptr<manager> SampleManager;
void InitialiseSingleFDMCObject(int iSample, int nEvents);
void InitialiseSplineObject();

Expand Down

0 comments on commit 8611ffb

Please sign in to comment.