From 6ef5ec3caf75e7c6e79100a843b776ba28e24ba7 Mon Sep 17 00:00:00 2001 From: Menai Lamers James Date: Wed, 9 Sep 2026 10:05:56 -0400 Subject: [PATCH 1/2] Add get step scale executable --- Tutorial/CMakeLists.txt | 1 + Tutorial/GetStepScaleLLHScanTutorial.cpp | 41 ++++++++++++++++++++++++ TutorialConfigs/FitterConfig.yaml | 2 ++ 3 files changed, 44 insertions(+) create mode 100755 Tutorial/GetStepScaleLLHScanTutorial.cpp diff --git a/Tutorial/CMakeLists.txt b/Tutorial/CMakeLists.txt index db92bbd9..92b82042 100755 --- a/Tutorial/CMakeLists.txt +++ b/Tutorial/CMakeLists.txt @@ -2,6 +2,7 @@ add_custom_target(TutorialApps) foreach(app LLHScanTutorial + GetStepScaleLLHScanTutorial PredictiveTutorial SigmaVarTutorial KinemDistributionTutorial diff --git a/Tutorial/GetStepScaleLLHScanTutorial.cpp b/Tutorial/GetStepScaleLLHScanTutorial.cpp new file mode 100755 index 00000000..accda97c --- /dev/null +++ b/Tutorial/GetStepScaleLLHScanTutorial.cpp @@ -0,0 +1,41 @@ +// MaCh3 spline includes +#include "Algorithms/MaCh3Factory.h" +#include "SamplesTutorial/SampleHandlerTutorial.h" + +int main(int argc, char *argv[]){ + + std::string filename = ""; + // Initialise manger responsible for config handling + std::unique_ptr FitManager; + if (argc == 2) + FitManager = MaCh3ManagerFactory(argc, argv); + else + FitManager = MaCh3ManagerFactory(argc - 1, argv); + + if (argc > 2) + filename = argv[2]; + + std::string OutputName = "LLH_" + FitManager->raw()["General"]["OutputFile"].as(); + + FitManager->OverrideSettings("General", "OutputFile", OutputName); + // Initialise covariance class reasonable for Systematics + auto xsec = MaCh3CovarianceFactory(FitManager.get(), "Xsec"); + + // Initialise samplePDF + auto SampleConfig = Get>(FitManager->raw()["General"]["TutorialSamples"], __FILE__ , __LINE__); + auto mySamples = MaCh3SampleHandlerFactory(SampleConfig, xsec.get()); + + // Create MCMC Class + std::unique_ptr MaCh3Fitter = MaCh3FitterFactory(FitManager.get()); + // Add covariance to MCM + MaCh3Fitter->AddSystObj(xsec.get()); + for (size_t i = 0; i < SampleConfig.size(); ++i) { + MaCh3Fitter->AddSampleHandler(mySamples[i]); + } + // Run Step Scale Tuning from LLH scan + MaCh3Fitter->GetStepScaleBasedOnLLHScan(filename); + for (size_t i = 0; i < SampleConfig.size(); ++i) { + delete mySamples[i]; + } + return 0; +} diff --git a/TutorialConfigs/FitterConfig.yaml b/TutorialConfigs/FitterConfig.yaml index 32f0341a..942e60c1 100755 --- a/TutorialConfigs/FitterConfig.yaml +++ b/TutorialConfigs/FitterConfig.yaml @@ -127,6 +127,8 @@ LLHScan: ScanRanges: delta_cp: [-3.14,3.14] sin2th_23: [0.35,0.65] + LLHType: "Total_LLH" + StepScaleParameters: [] SigmaVar: # Values of sigma you want to perform, it must contain 0! From 59814de2d8a47fc14258df81344c6237cd4c194d Mon Sep 17 00:00:00 2001 From: Menai Lamers James Date: Wed, 9 Sep 2026 10:51:38 -0400 Subject: [PATCH 2/2] Update readme with instructions for using getstepscale --- README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/README.md b/README.md index 7d812a4e..caec4023 100644 --- a/README.md +++ b/README.md @@ -766,6 +766,15 @@ It is possible to compare several LLH scan files simply by adding more files as ./bin/PlotLLH LLH_Test.root LLH_Test_2.root ``` +An estimate of the optimal step scale for each parameter can be made using the LLH scan. If many parameters step scale need to be updated, this is a good initial step. + +To return an updated covariance matrix with the new step scales, you can run as: +```bash +./bin/GetStepScaleLLHScanTutorial TutorialConfigs/FitterConfig.yaml +``` +Optionally if you have an existing file with the LLH scans, you can avoid re-running this step by including the file as an additional argument. + + ### Sigma Variations Sigma Variations are conceptually similar to the LLH scan, where we vary individual parameters and reweight the MC correspondingly, however here instead of looking at how the LLH changes, the focus is actually on how the sample spectra themselves respond to the parameter movements.