MaCh3  2.8.0
Reference Guide
SmearModule.cpp
Go to the documentation of this file.
2 #include "Manager/Manager.h"
4 
8 
9 namespace M3{
10 SmearModule::~SmearModule() = default;
11 
13  m_parser = std::make_unique<MaCh3ArgumentParser>("smear", "1.0", argparse::default_arguments::help);
14  m_parser->add_description("Tool for smearing MCMC chains.");
15  m_parser->add_argument("mcmc-output")
16  .help("MCMC chain root file.")
17  .metavar("MCMC_CHAIN")
18  .required();
19  m_parser->add_argument("config")
20  .help("Config file.")
21  .metavar("CONFIG")
22  .required();
23  return m_parser.get();
24 }
25 
26 void SmearModule::SmearChain(const std::string& inputFile, const std::string& config){
27  MACH3LOG_INFO("File for study: {}", inputFile);
28 
29  YAML::Node Settings = M3OpenConfig(config);
30 
31  // Make the processor
32  auto Processor = std::make_unique<MCMCProcessor>(inputFile);
33  Processor->SetOutputSuffix("_Smear_MCMC");
34  Processor->Initialise();
35 
36  const auto& Smear = Settings["SmearChain"];
37 
38  std::vector<std::string> Names = Get<std::vector<std::string>>(Smear["Smear"][0], __FILE__, __LINE__);
39  std::vector<double> ErrorValue = Get<std::vector<double>>(Smear["Smear"][1], __FILE__, __LINE__);
40 
41  bool SaveUnsmearedBranch = GetFromManager<bool>(Smear["SaveUnsmearedBranch"], false, __FILE__ , __LINE__);
42  Processor->SmearChain(Names, ErrorValue, SaveUnsmearedBranch);
43 }
44 
47  MACH3LOG_INFO("Producing single fit output");
48  std::string filename = m_parser->get<std::string>("mcmc-output");
49  std::string config = m_parser->get<std::string>("config");
50  SmearChain(filename, config);
51 
52  return 0;
53 }
54 }
55 
56 
57 
58 
59 
60 
61 
62 
63 
64 
65 
66 
67 
68 
69 
70 
71 
72 
73 void SmearChain(const std::string& inputFile, const std::string& config)
74 {
75  MACH3LOG_INFO("File for study: {}", inputFile);
76 
77  YAML::Node Settings = M3OpenConfig(config);
78 
79  // Make the processor
80  auto Processor = std::make_unique<MCMCProcessor>(inputFile);
81  Processor->SetOutputSuffix("_Smear_MCMC");
82  Processor->Initialise();
83 
84  const auto& Smear = Settings["SmearChain"];
85 
86  std::vector<std::string> Names = Get<std::vector<std::string>>(Smear["Smear"][0], __FILE__, __LINE__);
87  std::vector<double> ErrorValue = Get<std::vector<double>>(Smear["Smear"][1], __FILE__, __LINE__);
88 
89  bool SaveUnsmearedBranch = GetFromManager<bool>(Smear["SaveUnsmearedBranch"], false, __FILE__ , __LINE__);
90  Processor->SmearChain(Names, ErrorValue, SaveUnsmearedBranch);
91 }
92 
93 int main(int argc, char *argv[]) {
95  if (argc != 3)
96  {
97  MACH3LOG_ERROR("How to use: {} MCMC_Output.root config", argv[0]);
98  throw MaCh3Exception(__FILE__ , __LINE__ );
99  }
100  MACH3LOG_INFO("Producing single fit output");
101  std::string filename = argv[1];
102  std::string config = argv[2];
103  SmearChain(filename, config);
104 
105  return 0;
106 }
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:37
#define MACH3LOG_INFO
Definition: MaCh3Logger.h:35
void SetMaCh3LoggerFormat()
Set messaging format of the logger.
Definition: MaCh3Logger.h:60
int main(int argc, char *argv[])
Definition: SmearModule.cpp:93
void SmearChain(const std::string &inputFile, const std::string &config)
Definition: SmearModule.cpp:73
Allows you to smear contour. For example after performing sets of study one finds out that used sets ...
#define M3OpenConfig(filename)
Macro to simplify calling LoadYaml with file and line info.
Definition: YamlHelper.h:589
Extended ArgumentParser with MaCh3-specific functionality.
Definition: m3argparse.hpp:17
std::unique_ptr< MaCh3ArgumentParser > m_parser
Argument parser for this plugin.
Definition: plugin.hpp:47
int Run() override
Execute the MCMC diagnostics.
Definition: SmearModule.cpp:45
virtual ~SmearModule()
Destructor.
MaCh3ArgumentParser * get_parser() override
Get the argument parser for this module.
Definition: SmearModule.cpp:12
void SmearChain(const std::string &inputFile, const std::string &config)
Definition: SmearModule.cpp:26
Custom exception class used throughout MaCh3.
Main namespace for MaCh3 software.