8samplePDFFDBase*
GetMaCh3DuneInstance(std::string SampleType, std::string SampleConfig, covarianceXsec* &xsec, covarianceOsc* &osc) {
10 samplePDFFDBase *FDSample;
11 if (SampleType ==
"BeamFD") {
13 }
else if (SampleType ==
"BeamND") {
17 }
else if (SampleType ==
"Atm") {
20 MACH3LOG_ERROR(
"Invalid SampleType: {} defined in {}", SampleType, SampleConfig);
21 throw MaCh3Exception(__FILE__, __LINE__);
27void MakeMaCh3DuneInstance(manager *FitManager, std::vector<samplePDFFDBase*> &DUNEPdfs, covarianceXsec *&xsec, covarianceOsc *&osc){
30 if (FitManager ==
nullptr) {
31 MACH3LOG_ERROR(
"Didn't find a good config in input configuration");
32 throw MaCh3Exception(__FILE__, __LINE__);
36 if(!FitManager->raw()[
"General"][
"DUNESamples"]){
37 MACH3LOG_ERROR(
"You didn't specify any DUNESample configs to create samples from. Please add General:DUNESamples to your config");
38 throw MaCh3Exception(__FILE__, __LINE__);
42 std::vector<std::string> xsecCovMatrixFile;
43 if (CheckNodeExists(FitManager->raw(),
"General",
"Systematics",
"XsecCovFile") ){
44 xsecCovMatrixFile = FitManager->raw()[
"General"][
"Systematics"][
"XsecCovFile"].as<std::vector<std::string>>();
46 MACH3LOG_ERROR(
"Require General:Systematics:XsecCovFile node in {}, please add this to the file!", FitManager->GetFileName());
47 throw MaCh3Exception(__FILE__, __LINE__);
52 xsec =
new covarianceXsec(xsecCovMatrixFile,
"xsec_cov");
55 MACH3LOG_INFO(
"covariance Xsec has already been created so I am not re-initialising the object");
60 std::vector<double> XsecParVals = xsec->getNominalArray();
62 xsec->setParameters(XsecParVals);
63 xsec->setStepScale(FitManager->raw()[
"General"][
"Systematics"][
"XsecStepScale"].as<
double>());
65 MACH3LOG_INFO(
"cov xsec setup");
66 MACH3LOG_INFO(
"------------------------------");
68 std::vector<std::string> OscMatrixFile = FitManager->raw()[
"General"][
"Systematics"][
"OscCovFile"].as<std::vector<std::string>>();
69 std::string OscMatrixName = FitManager->raw()[
"General"][
"Systematics"][
"OscCovName"].as<std::string>();
70 std::vector<double> oscpars = FitManager->raw()[
"General"][
"OscillationParameters"].as<std::vector<double>>();
72 std::string OscPars =
"";
74 for (
unsigned int i=0;i<oscpars.size();i++) {
75 OscPars+=std::to_string(oscpars[i]);
78 MACH3LOG_INFO(
"Oscillation Parameters being used: {} ", OscPars);
80 osc =
new covarianceOsc(OscMatrixFile,OscMatrixName.c_str());
81 osc->setName(
"osc_cov");
83 std::vector<std::string> OscFixParams = GetFromManager<std::vector<std::string>>(FitManager->raw()[
"General"][
"Systematics"][
"OscFix"], {
""});
85 if (OscFixParams.size() == 1 && OscFixParams.at(0) ==
"All") {
86 for (
int j = 0; j < osc->getNpars(); j++) {
87 osc->toggleFixParameter(j);
90 for (
unsigned int j = 0; j < OscFixParams.size(); j++) {
91 osc->toggleFixParameter(OscFixParams.at(j));
95 MACH3LOG_INFO(
"Osc cov setup");
96 MACH3LOG_INFO(
"------------------------------");
100 std::vector<std::string> XsecFixParams = GetFromManager<std::vector<std::string>>(FitManager->raw()[
"General"][
"Systematics"][
"XsecFix"], {
""});
103 if (XsecFixParams.size() == 1 && XsecFixParams.at(0) ==
"All") {
104 for (
int j = 0; j < xsec->getNpars(); j++) {
105 xsec->toggleFixParameter(j);
108 for (
unsigned int j = 0; j < XsecFixParams.size(); j++) {
109 xsec->toggleFixParameter(XsecFixParams.at(j));
112 MACH3LOG_INFO(
"xsec parameters loop done");
116 xsec->setParameters();
117 osc->setParameters(oscpars);
121 MACH3LOG_INFO(
"-------------------------------------------------------------------");
122 MACH3LOG_INFO(
"Loading DUNE samples..");
123 std::vector<std::string> DUNESampleConfigs = FitManager->raw()[
"General"][
"DUNESamples"].as<std::vector<std::string>>();
125 for(
unsigned int Sample_i = 0 ; Sample_i < DUNESampleConfigs.size() ; Sample_i++){
127 manager* tempSampleManager =
new manager(DUNESampleConfigs[Sample_i].c_str());
128 std::string SampleType = tempSampleManager->raw()[
"SampleType"].as<std::string>();
133#if DEBUG_DUNE_WEIGHTS==1
134 DUNEPdfs.back()->setWeightSwitchOffVector(FitManager->getWeightSwitchOffVector());
135 DUNEPdfs.back()->setXsecWeightSwitchOffVector(FitManager->getXsecWeightSwitchOffVector());