MaCh3  2.8.0
Reference Guide
plotting.h
Go to the documentation of this file.
1 #pragma once
2 
5 
6 #include <pybind11/pybind11.h>
7 #include <pybind11/stl.h>
8 
9 #include <vector>
10 #include <string>
11 
16 
17 namespace py = pybind11;
18 
19 
20 void initPlottingModule(py::module &m_plotting){
21  py::class_<M3::Plotting::PlottingManager>(m_plotting, "PlottingManager")
22  .def(
23  py::init<const std::string &>(),
24  "construct a PlottingManager using the specified config file",
25  py::arg("config_file_name")
26  )
27 
28  .def(
29  py::init(),
30  "default constructor, will initialise the PlottingManager with the default plotting config"
31  )
32 
33  .def(
34  "initialise",
36  "initalise this PlottingManager"
37  )
38 
39  .def(
40  "usage",
42  "Print a usage message for the current executable"
43  )
44 
45  .def(
46  "parse_inputs",
48  "Parse command line variables",
49  py::arg("arguments")
50  )
51 
52  .def(
53  "set_exec",
55  "Set the name of the current executable, which will be used when getting executable specific options from the plotting config file",
56  py::arg("exec_name")
57  )
58 
59  .def(
60  "get_file_name",
62  "Get the path to a particular file",
63  py::arg("input_file_id")
64  )
65 
66  .def(
67  "get_file_label",
69  "Get the specified label of a particular input file",
70  py::arg("input_file_id")
71  )
72 
73  .def(
74  "get_draw_options",
76  "Get any additional root drawing options specified by the user"
77  )
78 
79  .def(
80  "get_output_name",
81  py::overload_cast<const std::string &>(&M3::Plotting::PlottingManager::getOutputName),
82  "Get the output name specified by the user, can specify an additional *suffix* to append to the file name but before the file extension",
83  py::arg("suffix") = ""
84  )
85 
86  .def(
87  "get_file_names",
89  "Get the list of all file names"
90  )
91 
92  .def(
93  "get_file_labels",
95  "Get the list of all file labels"
96  )
97 
98  .def(
99  "get_n_files",
101  "Get the number of specified files"
102  )
103 
104  .def(
105  "get_split_by_sample",
107  "Get whether or not the user has set the 'split by sample' (-s) option"
108  )
109 
110  .def(
111  "get_plot_ratios",
113  "Get whether or not the user specified the 'plot ratios' (-r) option"
114  )
115 
116  .def(
117  "get_draw_grid",
119  "Get wheter or not the user has specified the 'draw grid' (-g) option"
120  )
121 
122  .def(
123  "style",
124  &M3::Plotting::PlottingManager::style, py::return_value_policy::reference,
125  "Get the StyleManager associated with this PlottingManager"
126  )
127 
128  .def(
129  "input",
130  &M3::Plotting::PlottingManager::input, py::return_value_policy::reference,
131  "Get the InputManager associated with this PlottingManager"
132  )
133 
134  // EM: I can't figure out how to add the getOption methods as theres not really a way to deduce the return type from yaml so leaving them out for now :/
135  // I think one solution would be to extend the PlottingManager class inside of python (add a pyPlottingManager (or something like that) that derives
136  // from this one and add the functions to that) and then fold that python code into the module somehow. But that is currently beyond my pybinding abilities
137  ;
138 
139  py::class_<M3::Plotting::InputManager>(m_plotting, "InputManager")
140  .def(
141  "print",
143  "Print a summary of everything this manager knows"
144  )
145 
146  .def(
147  "get_llh_scan",
149  "Get the LLH scan for a particular parameter from a particular file",
150  py::arg("input_file_id"),
151  py::arg("param_name"),
152  py::arg("LLH_type") = "total"
153  )
154 
155  .def(
156  "get_llh_scan_by_sample",
158  "Get the LLH scan for a particular parameter from a particular file for a particular sample",
159  py::arg("input_file_id"),
160  py::arg("param"),
161  py::arg("sample")
162  )
163 
164  .def(
165  "get_enabled_llh",
167  "Get whether a particular file has LLH scans for a particular parameter",
168  py::arg("input_file_id"),
169  py::arg("param"),
170  py::arg("LLH_type") = "total"
171  )
172 
173  .def(
174  "get_enabled_llh_by_sample",
176  "Get whether a particular file has LLH scans for a particular parameter for a particular sample",
177  py::arg("input_file_id"),
178  py::arg("param"),
179  py::arg("sample")
180  )
181 
182  .def(
183  "get_post_fit_error",
185  "Get the post fit error for a parameter from a particular file",
186  py::arg("input_file_id"),
187  py::arg("param"),
188  py::arg("error_type") = ""
189  )
190 
191  .def(
192  "get_post_fit_value",
194  "Get the post fit value for a parameter from a particular file",
195  py::arg("input_file_id"),
196  py::arg("param"),
197  py::arg("error_type") = ""
198  )
199 
200  .def(
201  "get_known_parameters",
203  "Get all the parameters that this manager knows about. Useful for iterating over"
204  )
205 
206  .def(
207  "get_known_samples",
209  "Get all the samples that this manager knows about. Useful for iterating over"
210  )
211 
212  .def(
213  "get_tagged_parameters",
215  "Get all the parameters whose tags match some specified list",
216  py::arg("tags"),
217  py::arg("check_type") = "all"
218  )
219 
220  .def(
221  "get_tagged_samples",
223  "Get all the samples whose tags match some specified list",
224  py::arg("tags"),
225  py::arg("check_type") = "all"
226  )
227 
228  .def(
229  "get_n_input_files",
231  "Get the number of input files registered with this manager"
232  )
233 
234  .def(
235  "get_known_llh_parameters",
237  "Get all the parameters that a file has LLH scans for",
238  py::arg("file_id")
239  )
240 
241  .def(
242  "get_known_llh_samples",
244  "Get all the samples that a file has individual LLH scans for",
245  py::arg("file_id")
246  )
247 
248  .def(
249  "get_known_post_fit_parameters",
251  "Get all the parameters that a file has post fit values and errors for",
252  py::arg("file_id")
253  )
254 
255  .def(
256  "get_known_MCMC_parameters",
258  "Get all the parameters that a file has MCMC chain entries for",
259  py::arg("file_id")
260  )
261 
262  .def(
263  "get_known_1d_posterior_parameters",
265  "Get all the parameters that a file has processed 1d posteriors for",
266  py::arg("file_id")
267  )
268 
269  .def(
270  "get_MCMC_entry",
272  "Load up a particular step in the MCMC chain for a particular input file",
273  py::arg("file_id"),
274  py::arg("step")
275  )
276 
277  .def(
278  "get_MCMC_value",
280  "Get the value of a particular parameter for the current entry (set by set_MCMC_entry) in the chain for a particular file",
281  py::arg("file_id"),
282  py::arg("param")
283  )
284 
285  .def(
286  "get_n_MCMC_entries",
288  "Get the number of entries in the MCMC chain in a particular file"
289  )
290 
291  .def(
292  "get_1d_posterior",
294  "Get the 1d posterior for a particular parameter from a particular file",
295  py::arg("file_id"),
296  py::arg("param")
297  )
298  ;
299 
300  py::class_<M3::Plotting::StyleManager>(m_plotting, "StyleManager")
301  .def(
302  "prettify_parameter_name",
304  "Convert internally used parameter name to a nice pretty name that can be used in plots",
305  py::arg("param")
306  )
307 
308  .def(
309  "prettify_sample_name",
311  "Convert internally used sample name to a nice pretty name that can be used in plots",
312  py::arg("sample")
313  )
314  ;
315 }
void print(const std::string &printLevel="summary") const
Print out what this Inputmanager instance knows about.
const std::vector< std::string > & getKnownParameters() const
Definition: InputManager.h:475
const std::vector< std::string > & getKnownSamples() const
Definition: InputManager.h:476
std::vector< std::vector< double > > getLLHScan(const int fileNum, const std::string &paramName, const std::string &LLHType) const
Get the log likelihood scan data for a particular parameter from a particular input file.
Definition: InputManager.h:291
double getPostFitValue(const int fileNum, const std::string &paramName, std::string errorType="") const
Get the post fit value for a particular parameter from a particular input file.
void getMCMCentry(const int fileNum, const int entry) const
Get the MCMC chain entry in an InputFile.
Definition: InputManager.h:304
bool getEnabledLLHBySample(const int fileNum, const std::string &paramName, const std::string &sample) const
Get whether or not a particular parameter has an LLH scan in a particular input file for a particular...
Definition: InputManager.h:435
int getnMCMCentries(const int fileNum) const
Get the number of entries in the MCMC chain in a particular file.
Definition: InputManager.h:351
std::vector< std::vector< double > > get1dPosterior(const int fileNum, const std::string &paramName) const
Get the 1d posterior particular parameter from a particular input file.
Definition: InputManager.h:339
double getPostFitError(const int fileNum, const std::string &paramName, std::string errorType="") const
Get the post fit error for a particular parameter from a particular input file.
double getMCMCvalue(int fileNum, const std::string &paramName) const
Get the parameter value for the current step for a particular parameter from a particular input file.
Definition: InputManager.h:324
std::vector< std::vector< double > > getSampleSpecificLLHScan(const int fileNum, const std::string &paramName, const std::string &sample) const
Get the log likelihood scan for a particular parameter, for a specific sample, from a particular inpu...
Definition: InputManager.h:388
std::vector< std::string > getTaggedSamples(const std::vector< std::string > &tags, std::string checkType="all") const
Get all samples which have some set of tags.
Definition: InputManager.h:497
size_t getNInputFiles() const
Definition: InputManager.h:477
const std::vector< std::string > & getKnownLLHSamples(int fileId) const
Definition: InputManager.h:511
bool getEnabledLLH(const int fileNum, const std::string &paramName, const std::string &LLHType="total") const
Get whether or not a particular parameter has an LLH scan in a particular input file.
Definition: InputManager.h:424
const std::vector< std::string > & getKnownPostFitParameters(int fileId) const
Definition: InputManager.h:514
const std::vector< std::string > & getKnownMCMCParameters(int fileId) const
Definition: InputManager.h:517
const std::vector< std::string > & getKnown1dPosteriorParameters(int fileId) const
Definition: InputManager.h:520
const std::vector< std::string > & getKnownLLHParameters(int fileId) const
Definition: InputManager.h:508
std::vector< std::string > getTaggedParameters(const std::vector< std::string > &tags, std::string checkType="all") const
Get all parameters which have some set of tags.
Definition: InputManager.h:486
void setExec(const std::string &execName)
Internally set the name of the executable that manager is being used in.
void initialise()
initalise this PlottingManager.
const std::string getOutputName()
Get the straight up output file name with no bells or whistles, just the file extension.
const InputManager & input() const
Get the InputManager contained within this PlottingManager, for doing input related things.
const std::vector< std::string > getFileNames() const
const std::string getFileLabel(int i) const
const std::string getFileName(int i) const
const StyleManager & style() const
Get the StyleManager contained within this PlottingManager, for doing style related things.
const std::vector< std::string > getFileLabels() const
void usage() const
Print a usage message for the current executable.
void parseInputsVec(const std::vector< std::string > &argv)
Parse vector of command line arguments.
const std::string getDrawOptions() const
std::string prettifyParamName(const std::string &origName) const
Convert hideous and vulgar internal parameter name into a beautiful presentable name.
Definition: StyleManager.h:40
void initPlottingModule(py::module &m_plotting)
Definition: plotting.h:20