-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
36 changed files
with
113,706 additions
and
112,215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
foreach(TEST | ||
MaCh3Benchmark | ||
) | ||
|
||
add_executable(${TEST} ${TEST}.cpp) | ||
target_link_libraries(${TEST} PRIVATE Catch2::Catch2WithMain MaCh3::All MaCh3Tutorial::samplePDFTutorial) | ||
catch_discover_tests(${TEST}) | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
// MaCh3 spline includes | ||
#include "mcmc/MaCh3Factory.h" | ||
#include "samplePDF/samplePDFTutorial.h" | ||
|
||
#include "catch2/catch_test_macros.hpp" | ||
#include "catch2/benchmark/catch_benchmark.hpp" | ||
|
||
TEST_CASE("Benchmark MaCh3") { | ||
// Initialise manger responsible for config handling | ||
auto FitManager = std::make_unique<manager>("Inputs/FitterConfig.yaml"); | ||
|
||
// Initialise covariance class reasonable for Systematics | ||
covarianceXsec* xsec = MaCh3CovarianceFactory(FitManager.get(), "Xsec"); | ||
covarianceOsc* osc = MaCh3CovarianceFactory<covarianceOsc>(FitManager.get(), "Osc"); | ||
|
||
// Initialise samplePDF | ||
auto SampleConfig = FitManager->raw()["General"]["TutorialSamples"].as<std::vector<std::string>>(); | ||
auto mySamples = MaCh3SamplePDFFactory<samplePDFTutorial>(SampleConfig, xsec, osc); | ||
|
||
// Create MCMC Class | ||
std::unique_ptr<FitterBase> MaCh3Fitter = MaCh3FitterFactory(FitManager.get()); | ||
// Add covariance to MCM | ||
MaCh3Fitter->addSystObj(xsec); | ||
MaCh3Fitter->addSystObj(osc); | ||
for (size_t i = 0; i < SampleConfig.size(); ++i) { | ||
MaCh3Fitter->addSamplePDF(mySamples[i]); | ||
} | ||
// Benchmark | ||
BENCHMARK("MaCh3Fitter::DragRace") { | ||
MaCh3Fitter->DragRace(1); | ||
}; | ||
|
||
delete xsec; | ||
delete osc; | ||
for (size_t i = 0; i < SampleConfig.size(); ++i) { | ||
delete mySamples[i]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
#include "TRandom3.h" | ||
#include "TSpline.h" | ||
#include "TFile.h" | ||
#include "TGraph.h" | ||
#include "TString.h" | ||
#include "TH3F.h" | ||
|
||
#include <iostream> | ||
#include <algorithm> | ||
|
||
void CreateBinnedSplineFile(){ | ||
|
||
int nTrueEnergyBins = 5; | ||
int nXBins = 10; | ||
//To make splines in Etrue, x and y change this to be a larger number | ||
int nYBins = 1; | ||
double TrueEnergyBins[] = {0., 1.0, 2.0, 3.0, 4.0, 5.0}; | ||
double XBins[] = {0., 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0}; | ||
double YBins[] = {0.,10.0}; | ||
|
||
//Let's try out 5 systematics | ||
//This gives us a total of 5*10*10*5 = 2500 splines | ||
std::vector<int> SystematicKnots = {5, 7, 7, 2, 3};//, 7, 2, 7, 7, 7}; | ||
std::vector<std::vector<std::string>> SystematicModeNames = {{"ccqe"}, {"cc1pipm"}, {"2p2h"}, {"other"}, {"ccqe"}}; | ||
//Values to centre the gaussian response on | ||
std::vector<double> SystematicMeanResponse = {1.0, 2.0, 1.0, 1.5, 1.0}; | ||
std::vector<int> SystematicNominalKnot = {3, 4, 4, 1, 2}; | ||
std::vector<std::string> SystematicNames = {"mysyst1", "mysyst2", "mysyst3","mysyst4","mysyst5"}; | ||
|
||
if(SystematicKnots.size() != SystematicNames.size() && SystematicNames.size() != SystematicNominalKnot.size() && SystematicKnots.size() != SystematicMeanResponse.size()) { | ||
std::cerr << "Systematic vectors are not of equal length this might cause problems, please fix!" << std::endl; | ||
throw; | ||
} | ||
|
||
TRandom3 Random = TRandom3(0); | ||
|
||
auto OutputFile = std::unique_ptr<TFile>(TFile::Open("BinnedSplinesTutorialInputs.root", "RECREATE")); | ||
|
||
//Firstly let's write the dev.tmp.0.0 file which sets the binning | ||
TH3F* BinningHist = new TH3F("dev_tmp.0.0", "dev_tmp.0.0", nTrueEnergyBins, TrueEnergyBins, nXBins, XBins, nYBins, YBins); | ||
|
||
for(auto iSyst = 0 ; iSyst < SystematicNames.size() ; ++iSyst){ | ||
for(auto SystematicModeName : SystematicModeNames[iSyst]){ | ||
for(auto SystematicKnotNumber : SystematicKnots) { | ||
for(auto TrueEnergyBin_i = 0 ; TrueEnergyBin_i < nTrueEnergyBins ; ++TrueEnergyBin_i){ | ||
for(auto XBin_i = 0 ; XBin_i < nXBins ; ++XBin_i){ | ||
for(auto YBin_i = 0 ; YBin_i < nYBins ; ++YBin_i){ | ||
double knot_w = 1; | ||
TGraph *graph = new TGraph(SystematicKnotNumber); | ||
|
||
for(auto iKnot = 0 ; iKnot < SystematicKnotNumber ; ++iKnot) { | ||
//Check on if you are the nominal knot | ||
if(iKnot != SystematicNominalKnot[iSyst]) { | ||
//Do a random throw from a gaussian | ||
knot_w = Random.Gaus(SystematicMeanResponse[iSyst], 1.0); | ||
knot_w = std::max(0., knot_w); | ||
// std::cout << "Knot_w is " << knot_w << std::endl; | ||
//point number, x-val, y-val | ||
} | ||
graph->SetPoint(iKnot, iKnot, knot_w); | ||
} | ||
TSpline3 *Spline = new TSpline3(Form("dev.%s.%s.sp.%i.%i.%i", SystematicNames[iSyst].c_str(), SystematicModeName.c_str(), TrueEnergyBin_i, XBin_i, YBin_i),graph); | ||
Spline->SetName(Form("dev.%s.%s.sp.%i.%i.%i", SystematicNames[iSyst].c_str(), SystematicModeName.c_str(), TrueEnergyBin_i, XBin_i, YBin_i)); | ||
//This makes things slow but removes many backup-cycles being saved to the file | ||
Spline->Write(Spline->GetName(), TDirectoryFile::kOverwrite); | ||
delete graph; | ||
delete Spline; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
OutputFile->Write(); | ||
OutputFile->Close(); | ||
|
||
return; | ||
} |
Oops, something went wrong.