Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CIValidations/BinningValidations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -358,6 +358,11 @@ int main(int argc, char *argv[])
MACH3LOG_CRITICAL("You specified arguments, but none are needed. (Program name: {})", argv[0]);
throw MaCh3Exception(__FILE__ , __LINE__ );
}
if(!std::getenv("MaCh3Tutorial_ROOT")){
MACH3LOG_CRITICAL("${MaCh3Tutorial_ROOT} is not defined in the environment,"
" have you sourced setup.MaCh3Tutorial.sh? ");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
std::string TutorialPath = std::getenv("MaCh3Tutorial_ROOT");

// Open a file in write mode
Expand Down
5 changes: 5 additions & 0 deletions CIValidations/CovarianceValidations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ void ValidateCholeskyDecomposition(std::ostream& outFile) {
/// @brief This simply updates YAML file
void TuneValidations(std::ostream& outFile)
{
if(!std::getenv("MaCh3Tutorial_ROOT")){
MACH3LOG_CRITICAL("${MaCh3Tutorial_ROOT} is not defined in the environment,"
" have you sourced setup.MaCh3Tutorial.sh? ");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
std::string TutorialPath = std::getenv("MaCh3Tutorial_ROOT");
YAML::Node Node = M3OpenConfig(TutorialPath + "/TutorialConfigs/CovObjs/SystematicModel.yaml");
std::vector<double> TuneValues = {1.05, 0.90, 1.10, 1.05, 1.05, 1.05, 1.05, 1.05, 0., 10};
Expand Down
10 changes: 10 additions & 0 deletions CIValidations/FitterValidations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@

void FitVal(const std::string& Algo, bool MoreTests)
{
if(!std::getenv("MaCh3Tutorial_ROOT")){
MACH3LOG_CRITICAL("${MaCh3Tutorial_ROOT} is not defined in the environment,"
" have you sourced setup.MaCh3Tutorial.sh? ");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
std::string TutorialPath = std::getenv("MaCh3Tutorial_ROOT");
std::string ManagerInput = TutorialPath + "/TutorialConfigs/FitterConfig.yaml";
auto FitManager = std::make_unique<Manager>(ManagerInput);
Expand Down Expand Up @@ -71,6 +76,11 @@ void FitVal(const std::string& Algo, bool MoreTests)

void StartFromPosteriorTest(const std::string& PreviousName)
{
if(!std::getenv("MaCh3Tutorial_ROOT")){
MACH3LOG_CRITICAL("${MaCh3Tutorial_ROOT} is not defined in the environment,"
" have you sourced setup.MaCh3Tutorial.sh? ");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
std::string TutorialPath = std::getenv("MaCh3Tutorial_ROOT");
std::string ManagerInput = TutorialPath + "/TutorialConfigs/FitterConfig.yaml";
auto FitManager = std::make_unique<Manager>(ManagerInput);
Expand Down
5 changes: 5 additions & 0 deletions CIValidations/LLHValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ int main(int argc, char *argv[])
throw MaCh3Exception(__FILE__ , __LINE__ );
}
MACH3LOG_INFO("Testing LLH scan");
if(!std::getenv("MaCh3Tutorial_ROOT")){
MACH3LOG_CRITICAL("${MaCh3Tutorial_ROOT} is not defined in the environment,"
" have you sourced setup.MaCh3Tutorial.sh? ");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
std::string TutorialPath = std::getenv("MaCh3Tutorial_ROOT");

std::string command = TutorialPath + "/bin/LLHScanTutorial " +
Expand Down
5 changes: 5 additions & 0 deletions CIValidations/MaCh3ModeValidations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,11 @@ int main(int argc, char *argv[])
}
MACH3LOG_INFO("Testing MaCh3 Mode");

if(!std::getenv("MaCh3Tutorial_ROOT")){
MACH3LOG_CRITICAL("${MaCh3Tutorial_ROOT} is not defined in the environment,"
" have you sourced setup.MaCh3Tutorial.sh? ");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
std::string TutorialPath = std::getenv("MaCh3Tutorial_ROOT");
std::string ModeInput = TutorialPath + "/TutorialConfigs/MaCh3Modes.yaml";
auto Modes = std::make_unique<MaCh3Modes>(ModeInput);
Expand Down
10 changes: 10 additions & 0 deletions CIValidations/SamplePDFValidations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ _MaCh3_Safe_Include_End_ //}
void SharedNuOscTest(const std::string& config, ParameterHandlerGeneric* xsec) {
MACH3LOG_INFO("Utilising a shared NuOscillator object between all atmospheric samples");

if(!std::getenv("MaCh3Tutorial_ROOT")){
MACH3LOG_CRITICAL("${MaCh3Tutorial_ROOT} is not defined in the environment,"
" have you sourced setup.MaCh3Tutorial.sh? ");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
std::string OscillatorConfig = std::string(std::getenv("MaCh3Tutorial_ROOT")) + "/TutorialConfigs/NuOscillator/CUDAProb3.yaml";
auto OscParams = xsec->GetOscParsFromSampleName("Tutorial_ATM");
auto OscillatorObj = std::make_shared<OscillationHandler>(OscillatorConfig, true, OscParams, 6);
Expand All @@ -19,6 +24,11 @@ void SharedNuOscTest(const std::string& config, ParameterHandlerGeneric* xsec) {

void NoSplinesNoOscTest(const std::string& config){
MACH3LOG_INFO("Utilising a shared NuOscillator object between all atmospheric samples");
if(!std::getenv("MaCh3Tutorial_ROOT")){
MACH3LOG_CRITICAL("${MaCh3Tutorial_ROOT} is not defined in the environment,"
" have you sourced setup.MaCh3Tutorial.sh? ");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
std::string TutorialPath = std::getenv("MaCh3Tutorial_ROOT");
std::vector<std::string> ParameterMatrixFile = {TutorialPath + "/TutorialConfigs/CovObjs/PCATest.yaml"};
auto xsec = std::make_unique<ParameterHandlerGeneric>(ParameterMatrixFile, "xsec_cov");
Expand Down
5 changes: 5 additions & 0 deletions CIValidations/SigmaVarValidation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,11 @@ int main(int argc, char *argv[])
throw MaCh3Exception(__FILE__ , __LINE__ );
}
MACH3LOG_INFO("Testing Sigma Var");
if(!std::getenv("MaCh3Tutorial_ROOT")){
MACH3LOG_CRITICAL("${MaCh3Tutorial_ROOT} is not defined in the environment,"
" have you sourced setup.MaCh3Tutorial.sh? ");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
std::string TutorialPath = std::getenv("MaCh3Tutorial_ROOT");

std::string command = TutorialPath + "/bin/SigmaVarTutorial " +
Expand Down
5 changes: 5 additions & 0 deletions CIValidations/SplineValidations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,11 @@ int main(int argc, char *argv[])
MACH3LOG_CRITICAL("You specified arguments, but none are needed. (Program name: ", argv[0]);
throw MaCh3Exception(__FILE__ , __LINE__ );
}
if(!std::getenv("MaCh3Tutorial_ROOT")){
MACH3LOG_CRITICAL("${MaCh3Tutorial_ROOT} is not defined in the environment,"
" have you sourced setup.MaCh3Tutorial.sh? ");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
std::string TutorialPath = std::getenv("MaCh3Tutorial_ROOT");

// Open a file in write mode
Expand Down
5 changes: 5 additions & 0 deletions CIValidations/pValueValidations.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,11 @@ int main(int argc, char *argv[])
MACH3LOG_CRITICAL("You specified arguments, but none are needed. (Program name: {})", argv[0]);
throw MaCh3Exception(__FILE__ , __LINE__ );
}
if(!std::getenv("MaCh3Tutorial_ROOT")){
MACH3LOG_CRITICAL("${MaCh3Tutorial_ROOT} is not defined in the environment,"
" have you sourced setup.MaCh3Tutorial.sh? ");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
std::string TutorialPath = std::getenv("MaCh3Tutorial_ROOT");

std::vector<std::string> xsecCovMatrixFile = {TutorialPath + "/TutorialConfigs/CovObjs/SystematicModel.yaml",
Expand Down
62 changes: 23 additions & 39 deletions SamplesTutorial/SampleHandlerTutorial.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,48 +35,32 @@ void SampleHandlerTutorial::Init() {
MACH3LOG_INFO("-------------------------------------------------------------------");
}

void SampleHandlerTutorial::DebugShift(const M3::float_t* par, std::size_t iEvent) {
// HH: This is a debug function to shift the reco energy to 4 GeV if the reco energy is less than 2 GeV
if (TutorialSamples[iEvent].RecoEnu < 2.0 && *par != 0) {
TutorialSamples[iEvent].RecoEnu_shifted = 4;
void DebugShift(double const &pval, TutorialMCInfo &ev) {
if (ev.RecoEnu < 2.0 && pval != 0) {
ev.RecoEnu_shifted = 4;
}
}

void SampleHandlerTutorial::EResLep(const M3::float_t* par, std::size_t iEvent) {
// HH: Lepton energy resolution contribution to reco energy
TutorialSamples[iEvent].RecoEnu_shifted += (*par) * TutorialSamples[iEvent].ELep;
}

void SampleHandlerTutorial::EResTot(const M3::float_t* par, std::size_t iEvent) {
// HH: Total energy resolution contribution to reco energy
TutorialSamples[iEvent].RecoEnu_shifted += (*par) * TutorialSamples[iEvent].RecoEnu;
}
};

// example using a non-capturing lambda
void SampleHandlerTutorial::RegisterFunctionalParameters() {
MACH3LOG_INFO("Registering functional parameters");
// This function manually populates the map of functional parameters
// Maps the name of the functional parameter to the pointer of the function

// This is the part where we manually enter things
// A lambda function has to be used so we can refer to a non-static member function
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wunused-parameter"
RegisterIndividualFunctionalParameter("DebugNothing",
kDebugNothing,
[this](const M3::float_t* par, std::size_t iEvent) {});

RegisterIndividualFunctionalParameter("DebugShift",
kDebugShift,
[this](const M3::float_t* par, std::size_t iEvent) { this->DebugShift(par, iEvent); });

RegisterIndividualFunctionalParameter("EResLep",
kEResLep,
[this](const M3::float_t* par, std::size_t iEvent) { this->EResLep(par, iEvent); });

RegisterIndividualFunctionalParameter("EResTot",
kEResTot,
[this](const M3::float_t* par, std::size_t iEvent) { this->EResTot(par, iEvent); });
#pragma GCC diagnostic pop
RegisterIndividualFunctionalParameter(
TutorialSamples, "DebugNothing",
[](double const &pval, TutorialMCInfo &ev) {});

// example using a free function
RegisterIndividualFunctionalParameter(TutorialSamples, "DebugShift",
DebugShift);

RegisterIndividualFunctionalParameter(
TutorialSamples, "EResLep", [](double const &pval, TutorialMCInfo &ev) {
ev.RecoEnu_shifted += pval * ev.ELep;
});

RegisterIndividualFunctionalParameter(
TutorialSamples, "EResTot", [](double const &pval, TutorialMCInfo &ev) {
ev.RecoEnu_shifted += pval * ev.RecoEnu;
});
}

void SampleHandlerTutorial::ResetShifts(const int iEvent) {
Expand Down Expand Up @@ -325,7 +309,7 @@ double SampleHandlerTutorial::ReturnKinematicParameter(const int KinematicVariab
return *paramPointer;
}

// === JM Define ReturnKinematicVector functions ===
// === JM Define ReturnKinematicVector functions ===
std::vector<double> SampleHandlerTutorial::ReturnKinematicVector(const int KinematicVector, const int iEvent) const {
switch (KinematicVector) {
case kParticleEnergy:
Expand Down
10 changes: 3 additions & 7 deletions SamplesTutorial/SampleHandlerTutorial.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class SampleHandlerTutorial : public SampleHandlerBase
virtual ~SampleHandlerTutorial();

enum KinematicTypes {kTrueNeutrinoEnergy, kTrueQ2, kM3Mode, kTarget, kRecoNeutrinoEnergy, kOscChannel, kTargetNucleus};

// === JM enum for particle-level parameters ===
enum KinematicParticleVecs {kParticleEnergy, kParticlePDG, kParticleBeamAngle};
// =============================================
Expand All @@ -31,7 +31,7 @@ class SampleHandlerTutorial : public SampleHandlerBase
void CleanMemoryBeforeFit() final;

double ReturnKinematicParameter(const int KinematicVariable, const int iEvent) const final;

// === JM ReturnKinematicVector declarations for particle-level parameters ===
void FillParticles(int eventIndex, int nParticles, int PDGLep, double ELep, std::mt19937& gen);
std::vector<double> ReturnKinematicVector(const int KinematicVector, const int iEvent) const final;
Expand Down Expand Up @@ -64,7 +64,7 @@ class SampleHandlerTutorial : public SampleHandlerBase
{kRecoNeutrinoEnergy, "RecoNeutrinoEnergy"},
{kOscChannel, "OscillationChannel"},
};

// === JM maps for particle-level parameters ===
const std::unordered_map<std::string, int> KinematicVectorsTutorial = {
{"ParticleEnergy", kParticleEnergy},
Expand All @@ -86,9 +86,5 @@ class SampleHandlerTutorial : public SampleHandlerBase
enum FuncParEnum {kDebugNothing, kDebugShift, kEResLep, kEResTot};
void RegisterFunctionalParameters() final;
void ResetShifts(const int iEvent) final;

void DebugShift(const M3::float_t* par, std::size_t iEvent);
void EResLep(const M3::float_t* par, std::size_t iEvent);
void EResTot(const M3::float_t* par, std::size_t iEvent);
// =================================
};
Loading