1 #include <pybind11/pybind11.h>
2 #include <pybind11/stl.h>
3 #include <pybind11/numpy.h>
7 namespace py = pybind11;
17 PYBIND11_OVERRIDE_PURE(
26 PYBIND11_OVERRIDE_PURE(
36 PYBIND11_OVERRIDE_PURE(
46 PYBIND11_OVERRIDE_PURE_NAME(
57 PYBIND11_OVERRIDE_PURE_NAME(
60 "get_sample_likelihood",
68 PYBIND11_OVERRIDE_PURE_NAME(
71 "clean_memory_before_fit",
78 PYBIND11_OVERRIDE_PURE(
87 std::string
GetKinVarName(
const int iSample,
const int Dimension)
const override {
88 PYBIND11_OVERRIDE_PURE(
99 PYBIND11_OVERRIDE_PURE(
109 PYBIND11_OVERRIDE_PURE(
118 PYBIND11_OVERRIDE_PURE(
127 PYBIND11_OVERRIDE_PURE(
136 PYBIND11_OVERRIDE_PURE_NAME(
146 const std::string& ProjectionVar_Str,
147 int kModeToFill = -1,
148 int kChannelToFill = -1,
150 TAxis* Axis =
nullptr)
override {
151 PYBIND11_OVERRIDE_PURE(
165 const std::string& ProjectionVar_StrX,
166 const std::string& ProjectionVar_StrY,
167 int kModeToFill = -1,
168 int kChannelToFill = -1,
170 TAxis* AxisX =
nullptr,
171 TAxis* AxisY =
nullptr)
override {
172 PYBIND11_OVERRIDE_PURE(
188 const std::string &ProjectionVar,
189 const std::vector<KinematicCut> &EventSelectionVec = {},
191 TAxis *Axis =
nullptr,
192 const std::vector<KinematicCut> &SubEventSelectionVec = {})
override {
193 PYBIND11_OVERRIDE_PURE(
207 const std::string& ProjectionVarX,
208 const std::string& ProjectionVarY,
209 const std::vector<KinematicCut>& EventSelectionVec = {},
211 TAxis* AxisX =
nullptr,
212 TAxis* AxisY =
nullptr,
213 const std::vector<KinematicCut>& SubEventSelectionVec = {})
override {
214 PYBIND11_OVERRIDE_PURE(
229 int GetNDim(
const int Sample)
const override {
230 PYBIND11_OVERRIDE_PURE(
239 const int iChannel)
const override {
240 PYBIND11_OVERRIDE_PURE(
259 PYBIND11_OVERRIDE_PURE_NAME(
262 "add_additional_weight_pointers",
270 PYBIND11_OVERRIDE_PURE(
279 PYBIND11_OVERRIDE_PURE_NAME(
290 PYBIND11_OVERRIDE_PURE_NAME(
301 PYBIND11_OVERRIDE_PURE_NAME(
304 "setup_experiment_MC",
311 PYBIND11_OVERRIDE_PURE_NAME(
320 PYBIND11_OVERRIDE_PURE_NAME(
323 "get_kinematic_by_name",
325 py::arg(
"variable_name")
330 PYBIND11_OVERRIDE_PURE_NAME(
333 "get_kinematic_name",
335 py::arg(
"variable_id")
340 PYBIND11_OVERRIDE_PURE_NAME(
343 "get_event_kinematic_value",
351 PYBIND11_OVERRIDE_PURE_NAME(
354 "get_event_kinematic_value",
362 PYBIND11_OVERRIDE_PURE_NAME(
365 "get_event_kinematic_value_reference",
372 PYBIND11_OVERRIDE_PURE_NAME(
375 "get_event_kinematic_value_reference",
383 PYBIND11_OVERRIDE_PURE_NAME(
386 "register_functional_parameters",
393 auto m_samples = m.def_submodule(
"samples");
395 "This is a Python binding of MaCh3s C++ based samples library.";
398 py::enum_<TestStatistic>(m_samples,
"TestStatistic")
412 "reweight the MC events in this sample. You will need to override this."
418 "Get the sample likelihood at the current point in your model space. You will need to override this."
424 "Set the test statistic that should be used when calculating likelihoods. \n\
425 :param test_stat: The new test statistic to use",
432 "Get the LLH for a bin by comparing the data and MC. The result depends on having previously set the test statistic using :py:meth:`pyMaCh3.samples.SampleHandlerBase.set_test_stat` \n\
433 :param data: The data content of the bin. \n\
434 :param mc: The mc content of the bin \n\
435 :param w2: The Sum(w_{i}^2) (sum of weights squared) in the bin, which is sigma^2_{MC stats}",
444 py::init<std::string, ParameterHandlerGeneric*>(),
445 "This should never be called directly as SampleHandlerFD is an abstract base class. \n\
446 However when creating a derived class, in the __init__() method, you should call the parent constructor i.e. this one by doing:: \n\
448 \tsuper(<your derived SampleHandler class>, self).__init__(*args) \n\
450 py::arg(
"mc_version"),
@ kNTestStatistics
Number of test statistics.
@ kPearson
Standard Pearson likelihood .
@ kBarlowBeeston
Barlow-Beeston () following Conway approximation ()
@ kDembinskiAbdelmotteleb
Based on .
@ kPoisson
Standard Poisson likelihood .
EW: As SampleHandlerBase is an abstract base class we have to do some gymnastics to get it to get it ...
TH1 * GetMCHist(const int Sample) override
Get MC histogram.
std::string GetName() const override
TH1 * Get1DVarHist(const int iSample, const std::string &ProjectionVar, const std::vector< KinematicCut > &EventSelectionVec={}, int WeightStyle=0, TAxis *Axis=nullptr, const std::vector< KinematicCut > &SubEventSelectionVec={}) override
void CleanMemoryBeforeFit() override
Allow to clean not used memory before fit starts.
double GetLikelihood() const override
double GetSampleLikelihood(const int iSample) const override
std::string GetKinVarName(const int iSample, const int Dimension) const override
Return Kinematic Variable name for specified sample and dimension for example "Reconstructed_Neutrino...
int GetNDim(const int Sample) const override
DB Function to differentiate 1D or 2D binning.
std::vector< double > ReturnKinematicParameterBinning(const int Sample, const std::string &KinematicParameter) const override
Return the binning used to draw a kinematic parameter.
int GetNOscChannels(const int iSample) const override
TH1 * GetW2Hist(const int Sample) override
Get W2 histogram.
std::string GetSampleTitle(const int iSample) const override
std::string GetFlavourName(const int iSample, const int iChannel) const override
TH1 * GetDataHist(const int Sample) override
Get Data histogram.
TH2 * Get2DVarHist(const int iSample, const std::string &ProjectionVarX, const std::string &ProjectionVarY, const std::vector< KinematicCut > &EventSelectionVec={}, int WeightStyle=0, TAxis *AxisX=nullptr, TAxis *AxisY=nullptr, const std::vector< KinematicCut > &SubEventSelectionVec={}) override
void PrintRates(const bool DataOnly=false) override
Helper function to print rates for the samples with LLH.
TH1 * Get1DVarHistByModeAndChannel(const int iSample, const std::string &ProjectionVar_Str, int kModeToFill=-1, int kChannelToFill=-1, int WeightStyle=0, TAxis *Axis=nullptr) override
TH2 * Get2DVarHistByModeAndChannel(const int iSample, const std::string &ProjectionVar_StrX, const std::string &ProjectionVar_StrY, int kModeToFill=-1, int kChannelToFill=-1, int WeightStyle=0, TAxis *AxisX=nullptr, TAxis *AxisY=nullptr) override
As SampleHandlerFD is an abstract base class we have to do some gymnastics to get it to get it into p...
void SetupSplines() override
initialise your splineXX object and then use InitialiseSplineObject to conviently setup everything up
const double * GetPointerToKinematicParameter(std::string, int) override
double ReturnKinematicParameter(int, int) override
int SetupExperimentMC() override
Experiment specific setup, returns the number of events which were loaded.
void CleanMemoryBeforeFit() override
Allow to clean not used memory before fit starts.
void Init() override
Initialise any variables that your experiment specific SampleHandler needs.
int ReturnKinematicParameterFromString(std::string)
void SetupFDMC() override
Function which translates experiment struct into core struct.
double ReturnKinematicParameter(std::string, int) override
Return the value of an associated kinematic parameter for an event.
void RegisterFunctionalParameters() override
HH - a experiment-specific function where the maps to actual functions are set up.
const double * GetPointerToKinematicParameter(double, int) override
std::string ReturnStringFromKinematicParameter(int)
void AddAdditionalWeightPointers() override
DB Function to determine which weights apply to which types of samples.
Class responsible for handling implementation of samples used in analysis, reweighting and returning ...
void SetTestStatistic(TestStatistic testStat)
Set the test statistic to be used when calculating the binned likelihoods.
virtual void Reweight()=0
double GetTestStatLLH(const double data, const double mc, const double w2) const
Calculate test statistic for a single bin. Calculation depends on setting of fTestStatistic....
SampleHandlerBase()
The main constructor.
virtual double GetLikelihood() const =0
Class responsible for handling implementation of samples used in analysis, reweighting and returning ...
SampleHandlerFD(std::string ConfigFileName, ParameterHandlerGeneric *xsec_cov, const std::shared_ptr< OscillationHandler > &OscillatorObj_=nullptr)
Constructor.
void initSamples(py::module &m)