MaCh3  2.8.0
Reference Guide
DiagMCMCModule.cpp
Go to the documentation of this file.
8 #include "Manager/Manager.h"
10 
11 namespace M3{
12 
14 
16  m_parser = std::make_unique<MaCh3ArgumentParser>("diag", "1.0", argparse::default_arguments::help);
17  m_parser->add_description("Tool for MCMC diagnostic like autocorrelations.");
18  m_parser->add_argument("mcmc-output")
19  .help("MCMC chain root file.")
20  .metavar("MCMC_CHAIN")
21  .required();
22  m_parser->add_argument("config")
23  .help("Config file.")
24  .metavar("CONFIG")
25  .required();
26  return m_parser.get();
27  }
28 
29 
35  MACH3LOG_INFO("Producing single fit output");
36  std::string inputFile = m_parser->get<std::string>("mcmc-output");
37  std::string config = m_parser->get<std::string>("config");
38 
39  MACH3LOG_INFO("File for study: {}", inputFile);
40 
41  YAML::Node Settings = M3OpenConfig(config);
42 
43  // Make the processor
44  auto Processor = std::make_unique<MCMCProcessor>(inputFile);
45  Processor->SetOutputSuffix("_MCMC_Diag");
46  //KS:Turn off plotting detector and some other setting
47  Processor->SetExcludedTypes(GetFromManager<std::vector<std::string>>(Settings["DiagMCMC"]["ExcludedTypes"], {}, __FILE__, __LINE__));
48  Processor->SetExcludedNames(GetFromManager<std::vector<std::string>>(Settings["DiagMCMC"]["ExcludedNames"], {}, __FILE__, __LINE__));
49  Processor->SetExcludedGroups(GetFromManager<std::vector<std::string>>(Settings["DiagMCMC"]["ExcludedGroups"], {}, __FILE__, __LINE__));
50  Processor->SetPlotRelativeToPrior(GetFromManager<bool>(Settings["DiagMCMC"]["PlotRelativeToPrior"], false, __FILE__, __LINE__));
51  //KS: Use 20 batches for batched means
52  Processor->SetnBatches(GetFromManager<int>(Settings["DiagMCMC"]["nBatches"], 20, __FILE__, __LINE__));
53  Processor->SetnLags(GetFromManager<int>(Settings["DiagMCMC"]["nLags"], 25000, __FILE__, __LINE__));
54  Processor->SetPrintToPDF(GetFromManager<bool>(Settings["PrintToPDF"], true, __FILE__, __LINE__));
55  Processor->Initialise();
56  if(Settings["MaxEntries"]) {
57  Processor->SetEntries(Get<int>(Settings["MaxEntries"], __FILE__, __LINE__));
58  }
59  //KS: finally call main method
60  Processor->DiagMCMC();
61 
62  return 0;
63  }
64 }
Module for MCMC diagnostic analysis.
#define MACH3LOG_INFO
Definition: MaCh3Logger.h:35
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition: MaCh3Logger.h:60
Type GetFromManager(const YAML::Node &node, const Type defval, const std::string &File, const int Line)
Get content of config file if node is not found take default value specified.
Definition: YamlHelper.h:328
#define M3OpenConfig(filename)
Macro to simplify calling LoadYaml with file and line info.
Definition: YamlHelper.h:589
MaCh3ArgumentParser * get_parser() override
Get the argument parser for this module.
virtual ~DiagMCMCModule()
Destructor.
int Run() override
Execute the MCMC diagnostics.
Extended ArgumentParser with MaCh3-specific functionality.
Definition: m3argparse.hpp:17
std::unique_ptr< MaCh3ArgumentParser > m_parser
Argument parser for this plugin.
Definition: plugin.hpp:44
Main namespace for MaCh3 software.