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
1 change: 1 addition & 0 deletions CIValidations/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ foreach(app
LLHValidation
PredictiveValidations
BinningValidations
MultiCanonicalValidations
)

add_executable(${app} ${app}.cpp)
Expand Down
3 changes: 3 additions & 0 deletions CIValidations/MaCh3CLI
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,9 @@ run_multicanoical_validations() {
# Basic MCMC processor test
${MaCh3_ROOT}/bin/ProcessMCMC ${MaCh3Tutorial_ROOT}/bin/TutorialDiagConfig.yaml ${MaCh3Tutorial_ROOT}/umbrella/umbrellafile0.root NoUmbrellaWeight ${MaCh3Tutorial_ROOT}/umbrella_output.root UmbrellaWeight

# Ensuring weights from solver are the same
${MaCh3Tutorial_ROOT}/CIValidations/MultiCanonicalValidations

# Testing of ReweightMCMC
${MaCh3_ROOT}/bin/ReweightMCMC ${MaCh3Tutorial_ROOT}/TutorialConfigs/ReweightingConfigs/PDG_2023_1D.yaml ${MaCh3Tutorial_ROOT}/umbrella_output.root
${MaCh3_ROOT}/bin/ProcessMCMC ${MaCh3Tutorial_ROOT}/bin/TutorialDiagConfig.yaml umbrella_output_reweighted_PDG_2023_1D.root
Expand Down
54 changes: 54 additions & 0 deletions CIValidations/MultiCanonicalValidations.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
// MaCh3 spline includes
#include "Utils/SplineMonoUtils.h"
#include "Utils/Comparison.h"

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

if (argc != 1) {
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
std::ofstream outFile("NewUmbrellaOut.txt");

TFile *Output = TFile::Open("umbrella_output.root", "READ");
if (!Output || Output->IsZombie()) {
MACH3LOG_CRITICAL("Couldn't find umbrella file, please run via CIValidations/MaCh3CLI --MultiCanonicalValidations");
throw MaCh3Exception(__FILE__ , __LINE__ );
}
TTree *Tree = Output->Get<TTree>("posteriors");

int window_id = M3::_BAD_INT_;
double umbrella_weight = M3::_BAD_DOUBLE_;
Tree->SetBranchStatus("*", false);
Tree->SetBranchStatus("umbrella_weight", true);
Tree->SetBranchAddress("umbrella_weight", &umbrella_weight);
Tree->SetBranchStatus("window_id", true);
Tree->SetBranchAddress("window_id", &window_id);

for (Long64_t iEvent = 0; iEvent < Tree->GetEntries(); iEvent += 10) {
Tree->GetEntry(iEvent);
outFile << "Event: " << iEvent << " umbrella_weight " << umbrella_weight << " window_id " << window_id << std::endl;
}

outFile.close();
bool TheSame = CompareTwoFiles(TutorialPath + "/CIValidations/TestOutputs/UmbrellaOut.txt", "NewUmbrellaOut.txt");

if(!TheSame) {
MACH3LOG_CRITICAL("Different weights mate");
throw MaCh3Exception(__FILE__ , __LINE__ );
} else {
MACH3LOG_INFO("Everything is correct");
}

return 0;
}
5 changes: 3 additions & 2 deletions CIValidations/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
* Checking if we can reproduce step proposal (fixed Random Number)
* Checking if tune correctly set values
* Checking if modifying YAML file with tune or correlation matrix works
* Checking special proposal (circular prior and flipping)

## FitterValidations
* Running MCMC, MinuitFit, PSO
Expand Down Expand Up @@ -49,8 +50,8 @@
## BinningValidations
* Checks if event migration works as intended

### TODO
* add test with different interpolations
## MultiCanonicalValidations
* Check if weights produced from multicnaoncial fit and later solver are not changing

## SamplePDFValidations
* Dump and compare event weights
Expand Down
Loading