MaCh3  2.6.1
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 
22  py::class_<M3::Plotting::PlottingManager>(m_plotting, "PlottingManager")
23  .def(
24  py::init<const std::string &>(),
25  "construct a PlottingManager using the specified config file",
26  py::arg("config_file_name")
27  )
28 
29  .def(
30  py::init(),
31  "default constructor, will initialise the PlottingManager with the default plotting config"
32  )
33 
34  .def(
35  "initialise",
37  "initalise this PlottingManager"
38  )
39 
40  .def(
41  "usage",
43  "Print a usage message for the current executable"
44  )
45 
46  .def(
47  "parse_inputs",
49  "Parse command line variables",
50  py::arg("arguments")
51  )
52 
53  .def(
54  "set_exec",
56  "Set the name of the current executable, which will be used when getting executable specific options from the plotting config file",
57  py::arg("exec_name")
58  )
59 
60  .def(
61  "get_file_name",
63  "Get the path to a particular file",
64  py::arg("input_file_id")
65  )
66 
67  .def(
68  "get_file_label",
70  "Get the specified label of a particular input file",
71  py::arg("input_file_id")
72  )
73 
74  .def(
75  "get_draw_options",
77  "Get any additional root drawing options specified by the user"
78  )
79 
80  .def(
81  "get_output_name",
82  py::overload_cast<const std::string &>(&M3::Plotting::PlottingManager::getOutputName),
83  "Get the output name specified by the user, can specify an additional *suffix* to append to the file name but before the file extension",
84  py::arg("suffix") = ""
85  )
86 
87  .def(
88  "get_file_names",
90  "Get the list of all file names"
91  )
92 
93  .def(
94  "get_file_labels",
96  "Get the list of all file labels"
97  )
98 
99  .def(
100  "get_n_files",
102  "Get the number of specified files"
103  )
104 
105  .def(
106  "get_split_by_sample",
108  "Get whether or not the user has set the 'split by sample' (-s) option"
109  )
110 
111  .def(
112  "get_plot_ratios",
114  "Get whether or not the user specified the 'plot ratios' (-r) option"
115  )
116 
117  .def(
118  "get_draw_grid",
120  "Get wheter or not the user has specified the 'draw grid' (-g) option"
121  )
122 
123  .def(
124  "style",
125  &M3::Plotting::PlottingManager::style, py::return_value_policy::reference,
126  "Get the StyleManager associated with this PlottingManager"
127  )
128 
129  .def(
130  "input",
131  &M3::Plotting::PlottingManager::input, py::return_value_policy::reference,
132  "Get the InputManager associated with this PlottingManager"
133  )
134 
135  // 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 :/
136  // I think one solution would be to extend the PlottingManager class inside of python (add a pyPlottingManager (or something like that) that derives
137  // 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
138  ;
139 
140  py::class_<M3::Plotting::InputManager>(m_plotting, "InputManager")
141  .def(
142  "print",
144  "Print a summary of everything this manager knows"
145  )
146 
147  .def(
148  "get_llh_scan",
150  "Get the LLH scan for a particular parameter from a particular file",
151  py::arg("input_file_id"),
152  py::arg("param_name"),
153  py::arg("LLH_type") = "total"
154  )
155 
156  .def(
157  "get_llh_scan_by_sample",
159  "Get the LLH scan for a particular parameter from a particular file for a particular sample",
160  py::arg("input_file_id"),
161  py::arg("param"),
162  py::arg("sample")
163  )
164 
165  .def(
166  "get_enabled_llh",
168  "Get whether a particular file has LLH scans for a particular parameter",
169  py::arg("input_file_id"),
170  py::arg("param"),
171  py::arg("LLH_type") = "total"
172  )
173 
174  .def(
175  "get_enabled_llh_by_sample",
177  "Get whether a particular file has LLH scans for a particular parameter for a particular sample",
178  py::arg("input_file_id"),
179  py::arg("param"),
180  py::arg("sample")
181  )
182 
183  .def(
184  "get_post_fit_error",
186  "Get the post fit error for a parameter from a particular file",
187  py::arg("input_file_id"),
188  py::arg("param"),
189  py::arg("error_type") = ""
190  )
191 
192  .def(
193  "get_post_fit_value",
195  "Get the post fit value for a parameter from a particular file",
196  py::arg("input_file_id"),
197  py::arg("param"),
198  py::arg("error_type") = ""
199  )
200 
201  .def(
202  "get_known_parameters",
204  "Get all the parameters that this manager knows about. Useful for iterating over"
205  )
206 
207  .def(
208  "get_known_samples",
210  "Get all the samples that this manager knows about. Useful for iterating over"
211  )
212 
213  .def(
214  "get_tagged_parameters",
216  "Get all the parameters whose tags match some specified list",
217  py::arg("tags"),
218  py::arg("check_type") = "all"
219  )
220 
221  .def(
222  "get_tagged_samples",
224  "Get all the samples whose tags match some specified list",
225  py::arg("tags"),
226  py::arg("check_type") = "all"
227  )
228 
229  .def(
230  "get_n_input_files",
232  "Get the number of input files registered with this manager"
233  )
234 
235  .def(
236  "get_known_llh_parameters",
238  "Get all the parameters that a file has LLH scans for",
239  py::arg("file_id")
240  )
241 
242  .def(
243  "get_known_llh_samples",
245  "Get all the samples that a file has individual LLH scans for",
246  py::arg("file_id")
247  )
248 
249  .def(
250  "get_known_post_fit_parameters",
252  "Get all the parameters that a file has post fit values and errors for",
253  py::arg("file_id")
254  )
255 
256  .def(
257  "get_known_MCMC_parameters",
259  "Get all the parameters that a file has MCMC chain entries for",
260  py::arg("file_id")
261  )
262 
263  .def(
264  "get_known_1d_posterior_parameters",
266  "Get all the parameters that a file has processed 1d posteriors for",
267  py::arg("file_id")
268  )
269 
270  .def(
271  "get_MCMC_entry",
273  "Load up a particular step in the MCMC chain for a particular input file",
274  py::arg("file_id"),
275  py::arg("step")
276  )
277 
278  .def(
279  "get_MCMC_value",
281  "Get the value of a particular parameter for the current entry (set by set_MCMC_entry) in the chain for a particular file",
282  py::arg("file_id"),
283  py::arg("param")
284  )
285 
286  .def(
287  "get_n_MCMC_entries",
289  "Get the number of entries in the MCMC chain in a particular file"
290  )
291 
292  .def(
293  "get_1d_posterior",
295  "Get the 1d posterior for a particular parameter from a particular file",
296  py::arg("file_id"),
297  py::arg("param")
298  )
299  ;
300 
301  py::class_<M3::Plotting::StyleManager>(m_plotting, "StyleManager")
302  .def(
303  "prettify_parameter_name",
305  "Convert internally used parameter name to a nice pretty name that can be used in plots",
306  py::arg("param")
307  )
308 
309  .def(
310  "prettify_sample_name",
312  "Convert internally used sample name to a nice pretty name that can be used in plots",
313  py::arg("sample")
314  )
315  ;
316 }
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