Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
154 commits
Select commit Hold shift + click to select a range
f13fa22
Fixed NHits calculation
May 1, 2025
80d953e
Merge branch 'jmartin/feature/NDGAr' into jmartin/feature/NDGAr_new_m…
May 6, 2025
7e83a33
Further fixed nhits calculation
May 6, 2025
2c1cb4f
Bug fix
May 6, 2025
186399e
Updated config
May 6, 2025
05c594a
Fixed bugs and finished alternative momres calculation
May 8, 2025
79522b8
Merge branch 'jmartin/feature/NDGAr' into jmartin/feature/NDGAr_new_m…
May 8, 2025
49d845f
Cleaned up isparticleaccepted in samplepdfbeamndgar
May 19, 2025
7fae1b3
All changes needed to get atmospheric code to work with Core::EventSt…
dbarrow257 May 21, 2025
7aa5760
Cleaned up isparticleaccepted and multiple bug fixes
Jude412 May 28, 2025
dd322c8
Fixed MACH3LOG printing enum error
Jude412 May 28, 2025
0a281ba
Merge branch 'develop' into jmartin/feature/NDGAr
Jude412 Jun 3, 2025
108c1f3
Merge remote-tracking branch 'origin/develop' into jmartin/feature/NDGAr
Jude412 Jun 3, 2025
6fc8fa6
Merged old and new StructsDUNE.h
Jude412 Jun 3, 2025
7e86844
Delete old StructsDUNE.h
Jude412 Jun 3, 2025
7473e10
Fixed badly-behaved merge
Jude412 Jun 3, 2025
dd7e33d
PreMerge with develop
dbarrow257 Jun 23, 2025
4743e1c
Merge with develop
dbarrow257 Jun 23, 2025
2372f07
Now compile against bleeding-edge core develop
dbarrow257 Jun 23, 2025
fc92c3a
Get Fit.cpp working, add catch for NAN recoCZ in atmospherics
dbarrow257 Jun 23, 2025
81ecf0c
All apps now compile
dbarrow257 Jun 23, 2025
67234f7
Fix EventRate OscChan breakdown
dbarrow257 Jun 24, 2025
60068e7
Include using poly densities
dbarrow257 Jun 24, 2025
466e50b
Testing MCMC speed
dbarrow257 Jun 24, 2025
0eb723a
Use Core::v2.2.0 instead of develop
dbarrow257 Jun 27, 2025
09eb017
Replaced nans with bad doubles
Jude412 Jul 3, 2025
17ebca3
Starting to investigate secondaries
Jude412 Jul 7, 2025
bb333ef
Include Secondaries
Jude412 Jul 18, 2025
5c4bf46
Neaten
Jude412 Jul 18, 2025
e0a3f5b
Adjust containment definition
Jude412 Aug 1, 2025
8eb755b
Use constant density by default. Changes to config to use ProcessMCMC…
dbarrow257 Aug 11, 2025
c8e5b17
Check secondaries for curvature resolution
Jude412 Aug 14, 2025
fb0a2d9
Minor change
Jude412 Aug 14, 2025
6802a92
Should work for beam FD now.
hank-hua Aug 26, 2025
2ed0aa0
Clean Up
Jude412 Sep 17, 2025
bd9e99a
Merge branch 'jmartin/feature/EDepContainment' into jmartin/feature/N…
Jude412 Sep 17, 2025
cfdd05c
Ammended to read in fastgarsim files
Jude412 Sep 23, 2025
4216319
Should work for ND now, though not very efficient.
hank-hua Sep 24, 2025
72477d3
Merge branch 'develop' into hhua/feature/core_v2_2_0
hank-hua Sep 24, 2025
ffb16e0
Bump to 2.2.2.
hank-hua Sep 25, 2025
afb8aca
Fixed stuff
Jude412 Sep 29, 2025
3b51d7b
Trying to find true geometry...
Jude412 Sep 30, 2025
2da98d1
Trimmed off unused reco-related code, no longer read splines/caf (jus…
Jude412 Oct 8, 2025
a3c57a5
Merged hanks 2.2 branch and fixed merge conflicts
Jude412 Oct 8, 2025
d3b608b
Got v2.2.2 running but still bugged
Jude412 Oct 10, 2025
2c79b6d
Resize particle-parameter vectors to n_prim not n_particles
Jude412 Oct 13, 2025
774410e
Clear branch vectors before GetEntry()
Jude412 Oct 14, 2025
201911b
Added new script for testing an acceptance metric
Jude412 Oct 15, 2025
eadd2d4
Changed std::vector<bool>s to std::vector<int>s, made downsampling co…
Jude412 Oct 15, 2025
1967837
Merge remote-tracking branch 'origin/jmartin/feature/NDGAr' into jmar…
Jude412 Oct 15, 2025
32d2382
Cleaned up configs and scripts
Jude412 Oct 16, 2025
86d102a
More cleanup
Jude412 Oct 16, 2025
32b787b
Added missing atm file
Jude412 Oct 17, 2025
bd72bc7
Cleaned up structs
Jude412 Oct 17, 2025
f5f3268
Merge pull request #89 from DUNE/jmartin/feature/NDGAr
hank-hua Oct 20, 2025
e70c3f9
Make linter happy.
hank-hua Oct 20, 2025
58f1301
Added binned nuosc config files.
hank-hua Oct 20, 2025
09e70bf
Formatted EventRates_Beam_NDGAr.yaml to make linter happy.
hank-hua Oct 20, 2025
6e824b5
Use pdg info from CAFs instead.
hank-hua Oct 20, 2025
17e189e
Linter.
hank-hua Oct 20, 2025
9cb2657
Fixing CI.
hank-hua Oct 20, 2025
d429d51
Fixed merge problems
Jude412 Oct 22, 2025
632ca37
Fixed clangd warnings
Jude412 Oct 22, 2025
778a041
Fixed clangd warnings
Jude412 Oct 22, 2025
e6d1ac5
Cleaned repo
Jude412 Oct 22, 2025
527fc1b
Updated config
Jude412 Oct 22, 2025
421a183
Reformatted yamls and added to plotting script
Jude412 Oct 23, 2025
1f743f2
Added det syst file.
hank-hua Oct 27, 2025
7f776af
Fix link_files.sh.
hank-hua Oct 31, 2025
63fa7ba
Added kinematic parameters (epi0, leptracklength)
Jude412 Nov 3, 2025
c8c0014
Breaking up dunemc_base struct by sample.
hank-hua Nov 3, 2025
8f0cbab
Merged hhua/feature/core_v2_2_0
Jude412 Nov 3, 2025
fe6813e
Merge pull request #91 from DUNE/jmartin/feature/NDGAr
hank-hua Nov 3, 2025
ba4b212
Addressing Dan's comments.
hank-hua Nov 4, 2025
f7032fe
vscode formatted the ndgar yaml to make linter happy.
hank-hua Nov 4, 2025
8a18a50
Added option to use shared nuosc for beam FD samples.
hank-hua Nov 11, 2025
c66a79e
Bump to v2.2.3 and renamed mcmc->MR2T2 following core changes.
hank-hua Nov 11, 2025
e75776d
Moved to using manager and fitter factories in core v2.2.3.
hank-hua Nov 11, 2025
932d35c
Linter.
hank-hua Nov 11, 2025
ec06009
New plots in eventrates config
Jude412 Nov 13, 2025
598e979
Split CI files by oscillation channels so we don't read the same file…
hank-hua Nov 13, 2025
26b88ab
Merge branch 'develop' into hhua/feature/core_v2_2_0
dbarrow257 Nov 18, 2025
d4d3606
Merge pull request #86 from DUNE/hhua/feature/core_v2_2_0
dbarrow257 Nov 18, 2025
1815a6e
Made containment definition configurable
Jude412 Nov 19, 2025
56782aa
Merge remote-tracking branch 'origin/develop' into jmartin/feature/NDGAr
Jude412 Nov 19, 2025
566235c
Removed NDGAr-related ifdefs
Jude412 Nov 20, 2025
ec4f3b4
Fixed linter
Jude412 Nov 20, 2025
5d0c7a4
Finish fixing linter (hopefully)
Jude412 Nov 20, 2025
b4be2fd
Removed some trailing spaces
Jude412 Nov 20, 2025
1c180cd
Merge pull request #93 from DUNE/jmartin/feature/NDGAr
dbarrow257 Dec 5, 2025
867ceb9
FD works now.
hank-hua Jan 2, 2026
65d54ae
Updated configs and core version.
hank-hua Jan 2, 2026
731cae9
Steal file changes from jmartin/feaure/NDGAr
Jude412 Jan 12, 2026
0b5e3c5
Adjusted configs
Jude412 Jan 12, 2026
7d26947
Merged jmartin/feature/NDGAr
Jude412 Jan 13, 2026
ed2d1ba
Renaming of particle->prim to distinguish from plots of secondaries, …
Jude412 Mar 9, 2026
abbef50
ND event rates seem to work.
hank-hua Mar 11, 2026
1563298
Update atmospherics to work with core::v2.3.2
dbarrow257 Mar 19, 2026
a20e113
Better optimised read-in to avoid double loop
dbarrow257 Mar 20, 2026
a662680
Changes needed to compile and run against Core::v2.4.2 - event rates …
dbarrow257 Mar 23, 2026
5b69d52
First implementation of new containment definitions
Jude412 Mar 24, 2026
5bc128a
Merge remote-tracking branch 'origin/jmartin/feature/NDGAr_fastgarsim…
Jude412 Mar 24, 2026
a6e95e0
Updated NDGAr side for 2.4.2 compatability
Jude412 Mar 24, 2026
d14e34d
Fixed pot weighting and added NEUT MaCh3Modes
Jude412 Mar 25, 2026
13d840b
Removed stray debugging message
Jude412 Mar 25, 2026
f6a7ec0
Minor PR adjustments
Jude412 Mar 25, 2026
8711129
Merge pull request #99 from DUNE/jmartin/feature/CoreV2.4.2_NDGAr
dbarrow257 Mar 25, 2026
4b003d0
Remove cmake hack
KSkwarczynski Mar 26, 2026
269297f
Add missing file
dbarrow257 Apr 10, 2026
a82f0bb
update MaCh3 DUNE to compile against v2.5.X
Apr 14, 2026
4867992
fix typo in readme input path
Apr 15, 2026
3e4c5d3
tweak to mtuple file paths, SubSample->OscChannel
Apr 15, 2026
bcadfa6
Fix over-zealous virtual public removal
Apr 15, 2026
0fd438d
Fix up factory
Apr 15, 2026
192e492
Update apps to use single covariance structure, make xsec consistentl…
Apr 15, 2026
f4f1324
Add extra * to make sure FD samples are still picked up
Apr 15, 2026
c095a61
More config tweaks,
Apr 15, 2026
cda5b70
Fix infinite loop, remove unecessary methods, correct overloads
Apr 15, 2026
a6f5789
Let apps not use osc options
Apr 16, 2026
eda9c1d
Fix sample naming in configs
Apr 16, 2026
60cad3f
Fix struct typing, allowing Target to be double (for compatibility re…
Apr 16, 2026
7597b33
Update sigma variation
Apr 16, 2026
6f556ee
Correctly have target as kinematic property
Apr 16, 2026
905b518
Revert sigma var changes
Apr 16, 2026
dbee750
Fix NDGar struct to have target
Apr 17, 2026
1f9adfe
ND LLH now matches v2.0.0.
hank-hua Apr 20, 2026
873188f
Merge pull request #102 from DUNE/hhua/feature/core2.4.2
dbarrow257 Apr 23, 2026
27325aa
Merge pull request #100 from KSkwarczynski/patch-3
dbarrow257 Apr 23, 2026
cedc550
Bump production height averaging to be true by default
dbarrow257 Apr 23, 2026
115cdcb
No need for the specific Atmos cmake flag anymore
dbarrow257 Apr 23, 2026
ac6b0d7
Merge
Apr 23, 2026
1eae667
Complete merge
Apr 24, 2026
afd45ab
Update ND sample handler for 2.5.0
Apr 24, 2026
eada561
Config fixes
Apr 27, 2026
d9dfda3
Add comments, add helper factory method for making instance
Apr 27, 2026
3c1bb26
Update apps to use helper method
Apr 27, 2026
b9e1f9e
Remove accidentally added app
Apr 27, 2026
179f396
Remove accidental python finding from CMakeLists
Apr 27, 2026
5e65541
Clean up sigma variation
Apr 27, 2026
9a23d14
Remove (void*)beamNDCov as it's not needed
Apr 27, 2026
16d30a1
Consistently make things BeamFD
Apr 27, 2026
aa469e2
Ensure ND_*->BeamND* to be clearly consistent with FD Beam configs
Apr 27, 2026
a4e44d5
Restore original oscillator behaviour to FD samples
Apr 27, 2026
d861aea
More sample name fixes
Apr 27, 2026
6d0376a
Merge pull request #101 from DUNE/hwallace/feature/CoreV2.5.X
Charlotte-Knight Apr 27, 2026
cc8f527
fix yaml linting
Charlotte-Knight Apr 27, 2026
60c3ccb
Fix Eventrates CI
Charlotte-Knight Apr 27, 2026
bb6e6d2
Fix EventRates CI round 2
Charlotte-Knight Apr 27, 2026
e0017fd
Merge branch 'develop' into dbarrow257/feature/CoreV2.4.2
Charlotte-Knight Apr 27, 2026
4367ed5
Add Beam EventRates output for later cross checking
Charlotte-Knight Apr 28, 2026
0868e92
Merge branch 'dbarrow257/feature/CoreV2.4.2' of github.com:DUNE/MaCh3…
Charlotte-Knight Apr 28, 2026
24257fd
Event Rates log for Atmospherics
Apr 29, 2026
c3483f7
Merge pull request #103 from DUNE/dbarrow257/feature/CoreV2.4.2
Charlotte-Knight Apr 29, 2026
0ba0bfa
patch: update MaCh3DUNE version to 1.2.0 in CMakeLists.txt (#104)
Charlotte-Knight Apr 29, 2026
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
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ jupyter_env
Doc
Inputs/Atmospherics/CAFs
nohup.out
output*.txt
*.txt
*.log
.cache/
118 changes: 60 additions & 58 deletions Apps/EventRates.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,62 +14,60 @@

#include "Samples/MaCh3DUNEFactory.h"
#include "Samples/StructsDUNE.h"
#include "Fitters/MaCh3Factory.h"

void Write1DHistogramsToFile(std::string OutFileName, std::vector<TH1*> Histograms) {
void Write1DHistogramsToFile(std::string OutFileName, std::vector<std::unique_ptr<TH1>>& Histograms) {
auto OutputFile = std::unique_ptr<TFile>(TFile::Open(OutFileName.c_str(), "RECREATE"));
OutputFile->cd();
for(auto Hist : Histograms){
for(auto& Hist : Histograms){
Hist->Write();
}
OutputFile->Close();
}

void Write1DHistogramsToPdf(std::string OutFileName, std::vector<TH1*> Histograms) {
void Write1DHistogramsToPdf(std::string OutFileName, std::vector<std::unique_ptr<TH1>>& Histograms) {
//Remove root from end of file
OutFileName.erase(OutFileName.find('.'));
OutFileName+=".pdf";

auto c1 = std::unique_ptr<TCanvas>(new TCanvas("c1", "c1", 800, 600));
c1->cd();
c1->Print(std::string(OutFileName+"[").c_str());
for(auto Hist : Histograms){
for(auto& Hist : Histograms){
Hist->Draw("HIST");
c1->Print(OutFileName.c_str());
}
c1->Print(std::string(OutFileName+"]").c_str());
}

int main(int argc, char * argv[]) {
MaCh3Utils::MaCh3Usage(argc, argv);
auto fitMan = std::unique_ptr<manager>(new manager(argv[1]));
M3::Utils::MaCh3Usage(argc, argv);
auto FitManager = MaCh3ManagerFactory(argc, argv);

//###############################################################################################################################
//Create SampleHandlerFD objects

ParameterHandlerGeneric* xsec = nullptr;
ParameterHandlerOsc* osc = nullptr;

std::vector<SampleHandlerFD*> DUNEPdfs;
MakeMaCh3DuneInstance(fitMan.get(), DUNEPdfs, xsec, osc);
//Create SampleHandlerBase objects
auto [param_handler, samples] = MaCh3DuneFactory(FitManager);

//###############################################################################################################################
//Perform reweight and print total integral

std::vector<TH1*> DUNEHists;
for(auto Sample : DUNEPdfs){
Sample->Reweight();
if (Sample->GetNDim() == 1)
DUNEHists.push_back(Sample->Get1DHist());
else if (Sample->GetNDim() == 2)
DUNEHists.push_back(Sample->Get2DHist());

std::string EventRateString = fmt::format("{:.2f}", Sample->Get1DHist()->Integral());
MACH3LOG_INFO("Event rate for {} : {:<5}", Sample->GetTitle(), EventRateString);
std::vector<std::unique_ptr<TH1>> DUNEHists;
for(auto& handler : samples){
if (!handler){
MACH3LOG_ERROR("Sample not set up correctly");
throw MaCh3Exception(__FILE__, __LINE__);
}
handler->Reweight();
for (int iSample=0; iSample<handler->GetNSamples(); iSample++) {
DUNEHists.push_back(M3::Clone(handler->GetMCHist(iSample)));

Sample->PrintIntegral();
std::string EventRateString = fmt::format("{:.2f}", handler->GetMCHist(iSample)->Integral());
MACH3LOG_INFO("Event rate for {} : {:<5}", handler->GetSampleTitle(iSample), EventRateString);
handler->PrintIntegral(iSample);
}
}

std::string OutFileName = GetFromManager<std::string>(fitMan->raw()["General"]["OutputFile"], "EventRatesOutput.root");
std::string OutFileName = GetFromManager<std::string>(FitManager->raw()["General"]["OutputFile"], "EventRatesOutput.root");
Write1DHistogramsToFile(OutFileName, DUNEHists);
Write1DHistogramsToPdf(OutFileName, DUNEHists);

Expand All @@ -80,24 +78,26 @@ int main(int argc, char * argv[]) {
MACH3LOG_INFO("========================================================================");
MACH3LOG_INFO("Oscillation Mode Breakdown:");

for(auto Sample : DUNEPdfs) {
MACH3LOG_INFO("======================");
int nOscChannels = Sample->GetNMCSamples();
for (int iOscChan=0;iOscChan<nOscChannels;iOscChan++) {
std::vector< KinematicCut > SelectionVec;

KinematicCut SelecChannel;
SelecChannel.ParamToCutOnIt = Sample->ReturnKinematicParameterFromString("OscillationChannel");
SelecChannel.LowerBound = iOscChan;
SelecChannel.UpperBound = iOscChan+1;
SelectionVec.push_back(SelecChannel);

TH1* Hist = Sample->Get1DVarHist(Sample->GetXBinVarName(),SelectionVec);
MACH3LOG_INFO("{:<20} : {:<20} : {:<20.2f}",Sample->GetTitle(),Sample->GetFlavourName(iOscChan),Hist->Integral());
for(auto handler : samples) {
for (int iSample = 0; iSample < handler->GetNSamples(); iSample++) {
MACH3LOG_INFO("======================");
int nOscChannels = handler->GetNOscChannels(iSample);
for (int iOscChan=0;iOscChan<nOscChannels;iOscChan++) {
std::vector< KinematicCut > SelectionVec;

KinematicCut SelecChannel;
SelecChannel.ParamToCutOnIt = handler->ReturnKinematicParameterFromString("OscillationChannel");
SelecChannel.LowerBound = iOscChan;
SelecChannel.UpperBound = iOscChan+1;
SelectionVec.push_back(SelecChannel);

auto Hist = handler->Get1DVarHist(iSample, handler->GetKinVarName(iSample, 0),SelectionVec);
MACH3LOG_INFO("{:<20} : {:<20} : {:<20.2f}",handler->GetSampleTitle(iSample),handler->GetFlavourName(iSample, iOscChan),Hist->Integral());
}

auto Hist = handler->Get1DVarHist(iSample, handler->GetKinVarName(iSample, 0));
MACH3LOG_INFO("{:<20} : {:<20.2f}",handler->GetSampleTitle(iSample),Hist->Integral());
}

TH1* Hist = Sample->Get1DVarHist(Sample->GetXBinVarName());
MACH3LOG_INFO("{:<20} : {:<20.2f}",Sample->GetTitle(),Hist->Integral());
}

//###############################################################################################################################
Expand All @@ -107,26 +107,28 @@ int main(int argc, char * argv[]) {
MACH3LOG_INFO("========================================================================");
MACH3LOG_INFO("Interaction Mode Breakdown:");

for(auto Sample : DUNEPdfs) {
MACH3LOG_INFO("======================");
for(auto handler : samples) {
for (int iSample = 0; iSample < handler->GetNSamples(); iSample++) {
MACH3LOG_INFO("======================");

MaCh3Modes* Modes = Sample->GetMaCh3Modes();
int nModeChannels = Modes->GetNModes();
for (int iModeChan=0;iModeChan<nModeChannels;iModeChan++) {
std::vector< KinematicCut > SelectionVec;
MaCh3Modes* Modes = handler->GetMaCh3Modes();
int nModeChannels = Modes->GetNModes();
for (int iModeChan=0;iModeChan<nModeChannels;iModeChan++) {
std::vector< KinematicCut > SelectionVec;

KinematicCut SelecChannel;
SelecChannel.ParamToCutOnIt = Sample->ReturnKinematicParameterFromString("Mode");
SelecChannel.LowerBound = iModeChan;
SelecChannel.UpperBound = iModeChan+1;
SelectionVec.push_back(SelecChannel);
KinematicCut SelecChannel;
SelecChannel.ParamToCutOnIt = handler->ReturnKinematicParameterFromString("Mode");
SelecChannel.LowerBound = iModeChan;
SelecChannel.UpperBound = iModeChan+1;
SelectionVec.push_back(SelecChannel);

TH1* Hist = Sample->Get1DVarHist(Sample->GetXBinVarName(),SelectionVec);
MACH3LOG_INFO("{:<20} : {:<20} : {:<20.2f}",Sample->GetTitle(),Modes->GetMaCh3ModeName(iModeChan),Hist->Integral());
}
auto Hist = handler->Get1DVarHist(iSample, handler->GetKinVarName(iSample,0), SelectionVec);
MACH3LOG_INFO("{:<20} : {:<20} : {:<20.2f}",handler->GetSampleTitle(iSample),Modes->GetMaCh3ModeName(iModeChan),Hist->Integral());
}

TH1* Hist = Sample->Get1DVarHist(Sample->GetXBinVarName());
MACH3LOG_INFO("{:<20} : {:<20.2f}",Sample->GetTitle(),Hist->Integral());
auto Hist = handler->Get1DVarHist(iSample, handler->GetKinVarName(iSample,0));
MACH3LOG_INFO("{:<20} : {:<20.2f}",handler->GetSampleTitle(iSample),Hist->Integral());
}
}

//###############################################################################################################################
Expand Down
91 changes: 32 additions & 59 deletions Apps/Fit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,28 +12,17 @@
#include <TColor.h>
#include <TMath.h>

#include "Fitters//mcmc.h"
#include "Fitters/MaCh3Factory.h"
#include "Samples/MaCh3DUNEFactory.h"

int main(int argc, char * argv[]) {

// ----------------------- OPTIONS ---------------------------------------- //
if(argc == 1){
MACH3LOG_INFO("Usage: bin/jointFitDUNEBeam Configs/config.yaml");
return 1;
}

manager *FitManager = new manager(argv[1]);
auto FitManager = MaCh3ManagerFactory(argc, argv);
auto OutputFileName = FitManager->raw()["General"]["OutputFile"].as<std::string>();

ParameterHandlerGeneric* xsec = nullptr;
ParameterHandlerOsc* osc = nullptr;

//####################################################################################
//Create samplePDFSKBase Objs

std::vector<SampleHandlerFD*> DUNEPdfs;
MakeMaCh3DuneInstance(FitManager, DUNEPdfs, xsec, osc);
//Create sample handler + parameter_handler objects
auto [param_handler, samples] = MaCh3DuneFactory(FitManager);

//Some place to store the histograms
std::vector<TH1*> PredictionHistograms;
Expand All @@ -42,64 +31,48 @@ int main(int argc, char * argv[]) {
auto OutputFile = std::unique_ptr<TFile>(TFile::Open(OutputFileName.c_str(), "RECREATE"));
OutputFile->cd();

osc->SetParameters(FitManager->raw()["General"]["OscillationParameters"].as<std::vector<double>>());
for (unsigned sample_i = 0 ; sample_i < DUNEPdfs.size() ; ++sample_i) {

std::string name = DUNEPdfs[sample_i]->GetTitle();
sample_names.push_back(name);
TString NameTString = TString(name.c_str());
for (auto handler : samples) {
for (unsigned iSample = 0; iSample < handler->GetNSamples(); ++iSample) {

DUNEPdfs[sample_i] -> Reweight();
if (DUNEPdfs[sample_i]->GetNDim() == 1){
PredictionHistograms.push_back(static_cast<TH1*>(DUNEPdfs[sample_i] -> Get1DHist() -> Clone(NameTString+"_unosc")));
DUNEPdfs[sample_i]->AddData(static_cast<TH1D*>(PredictionHistograms[sample_i]));
}
std::string name = handler->GetSampleTitle(iSample);
sample_names.push_back(name);
TString NameTString = TString(name.c_str());

else if (DUNEPdfs[sample_i]->GetNDim() == 2){
PredictionHistograms.push_back(static_cast<TH1*>(DUNEPdfs[sample_i] -> Get2DHist() -> Clone(NameTString+"_unosc")));
DUNEPdfs[sample_i]->AddData(static_cast<TH2D*>(PredictionHistograms[sample_i]));
}
else {
MACH3LOG_ERROR("Unsupported number of dimensions > 2 - Quitting");
throw MaCh3Exception(__FILE__ , __LINE__ );
handler->Reweight();
PredictionHistograms.push_back(static_cast<TH1*>(handler->GetMCHist(iSample)->Clone(NameTString+"_DataHist")));

if (handler->GetNDim(iSample) == 1){
handler->AddData(iSample, static_cast<TH1D*>(PredictionHistograms.back()));
} else if (handler->GetNDim(iSample) == 2){
handler->AddData(iSample, static_cast<TH2D*>(PredictionHistograms.back()));
}

else {
MACH3LOG_ERROR("Unsupported number of dimensions > 2 - Quitting");
throw MaCh3Exception(__FILE__ , __LINE__ );
}

MACH3LOG_INFO("Integrals of nominal hists: ");
MACH3LOG_INFO("{} : {}",name.c_str(),PredictionHistograms.back()->Integral());
MACH3LOG_INFO("--------------");
}


}

//Now print out some event rates, we'll make a nice latex table at some point
for (unsigned iPDF = 0; iPDF < DUNEPdfs.size() ; ++iPDF) {
MACH3LOG_INFO("Integrals of nominal hists: ");
MACH3LOG_INFO("{} : {}",sample_names[iPDF].c_str(),PredictionHistograms[iPDF]->Integral());
MACH3LOG_INFO("--------------");
}

//###########################################################################################################
//MCMC

std::unique_ptr<mcmc> MaCh3Fitter = std::make_unique<mcmc>(FitManager);
auto MaCh3Fitter = MaCh3FitterFactory(FitManager.get());

bool StartFromPreviousChain = GetFromManager(FitManager->raw()["General"]["StartFromPos"], false);

//Start chain from random position unless continuing a chain
if(!StartFromPreviousChain){
if (!GetFromManager(FitManager->raw()["General"]["StatOnly"], false)) {
xsec->ThrowParameters();
param_handler->ThrowParameters();
}
osc->SetParameters();
osc->ThrowParameters();
}


//Add systematic objects
MaCh3Fitter->AddSystObj(osc);
if (GetFromManager(FitManager->raw()["General"]["StatOnly"], false)){
MACH3LOG_INFO("Running a stat-only fit so no systematics will be applied");
}
else {
MaCh3Fitter->AddSystObj(xsec);
}

MaCh3Fitter->AddSystObj(param_handler.get());

if (StartFromPreviousChain) {
std::string PreviousChainPath = FitManager->raw()["General"]["PosFileName"].as<std::string>();
Expand All @@ -108,7 +81,7 @@ int main(int argc, char * argv[]) {
}

//Add samples
for(auto Sample : DUNEPdfs){
for(auto Sample : samples){
MaCh3Fitter->AddSampleHandler(Sample);
}

Expand All @@ -117,8 +90,8 @@ int main(int argc, char * argv[]) {
MaCh3Fitter->RunMCMC();

//Writing the memory usage at the end to eventually spot some nasty leak
MACH3LOG_WARN("\033[0;31mCurrent Total RAM usage is {:.2f} GB\033[0m", MaCh3Utils::getValue("VmRSS") / 1048576.0);
MACH3LOG_WARN("\033[0;31mOut of Total available RAM {:.2f} GB\033[0m", MaCh3Utils::getValue("MemTotal") / 1048576.0);
MACH3LOG_WARN("\033[0;31mCurrent Total RAM usage is {:.2f} GB\033[0m", M3::Utils::getValue("VmRSS") / 1048576.0);
MACH3LOG_WARN("\033[0;31mOut of Total available RAM {:.2f} GB\033[0m", M3::Utils::getValue("MemTotal") / 1048576.0);

return 0;
}
Loading
Loading