MaCh3  2.6.1
Reference Guide
DiagMCMCModule.cpp
Go to the documentation of this file.
8 #include "Manager/Manager.h"
10 
11 
12 namespace M3{
13 
15 
17  m_parser = std::make_unique<MaCh3ArgumentParser>("diag", "1.0", argparse::default_arguments::help);
18  m_parser->add_description("Tool for MCMC diagnostic like autocorrelations.");
19  m_parser->add_argument("mcmc-output")
20  .help("MCMC chain root file.")
21  .metavar("MCMC_CHAIN")
22  .required();
23  m_parser->add_argument("config")
24  .help("Config file.")
25  .metavar("CONFIG")
26  .required();
27  return m_parser.get();
28  }
29 
30 
36  MACH3LOG_INFO("Producing single fit output");
37  std::string inputFile = m_parser->get<std::string>("mcmc-output");
38  std::string config = m_parser->get<std::string>("config");
39 
40  MACH3LOG_INFO("File for study: {}", inputFile);
41 
42  YAML::Node Settings = M3OpenConfig(config);
43 
44  // Make the processor
45  auto Processor = std::make_unique<MCMCProcessor>(inputFile);
46  Processor->SetOutputSuffix("_MCMC_Diag");
47  //KS:Turn off plotting detector and some other setting
48  Processor->SetExcludedTypes(GetFromManager<std::vector<std::string>>(Settings["DiagMCMC"]["ExcludedTypes"], {}, __FILE__, __LINE__));
49  Processor->SetExcludedNames(GetFromManager<std::vector<std::string>>(Settings["DiagMCMC"]["ExcludedNames"], {}, __FILE__, __LINE__));
50  Processor->SetExcludedGroups(GetFromManager<std::vector<std::string>>(Settings["DiagMCMC"]["ExcludedGroups"], {}, __FILE__, __LINE__));
51  Processor->SetPlotRelativeToPrior(GetFromManager<bool>(Settings["DiagMCMC"]["PlotRelativeToPrior"], false, __FILE__, __LINE__));
52  //KS: Use 20 batches for batched means
53  Processor->SetnBatches(GetFromManager<int>(Settings["DiagMCMC"]["nBatches"], 20, __FILE__, __LINE__));
54  Processor->SetnLags(GetFromManager<int>(Settings["DiagMCMC"]["nLags"], 25000, __FILE__, __LINE__));
55  Processor->SetPrintToPDF(GetFromManager<bool>(Settings["PrintToPDF"], true, __FILE__, __LINE__));
56  Processor->Initialise();
57  if(Settings["MaxEntries"]) {
58  Processor->SetEntries(Get<int>(Settings["MaxEntries"], __FILE__, __LINE__));
59  }
60  //KS: finally call main method
61  Processor->DiagMCMC();
62 
63  return 0;
64  }
65 }
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:329
#define M3OpenConfig(filename)
Macro to simplify calling LoadYaml with file and line info.
Definition: YamlHelper.h:590
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.