MaCh3  2.4.2
Reference Guide
Functions
plotting.cpp File Reference
#include <pybind11/pybind11.h>
#include <pybind11/stl.h>
#include <vector>
#include <string>
#include "Plotting/PlottingUtils/PlottingUtils.h"
#include "Plotting/PlottingUtils/PlottingManager.h"
#include "Plotting/PlottingUtils/StyleManager.h"
#include "Plotting/PlottingUtils/InputManager.h"
Include dependency graph for plotting.cpp:

Go to the source code of this file.

Functions

void initPlotting (py::module &m)
 

Function Documentation

◆ initPlotting()

void initPlotting ( py::module &  m)

Definition at line 15 of file plotting.cpp.

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