MaCh3  2.5.1
Reference Guide
Public Member Functions | List of all members
PySampleHandlerInterface Class Reference

EW: As SampleHandlerBase is an abstract base class we have to do some gymnastics to get it to get it into python. More...

#include <python/samples.h>

Inheritance diagram for PySampleHandlerInterface:
[legend]
Collaboration diagram for PySampleHandlerInterface:
[legend]

Public Member Functions

std::string GetName () const override
 Get name for Sample Handler. More...
 
std::string GetSampleTitle (const int iSample) const override
 Get fancy title for specified samples. More...
 
int GetNOscChannels (const int iSample) const override
 Get number of oscillation channels for a single sample. More...
 
void Reweight () override
 main routine modifying MC prediction based on proposed parameter values More...
 
double GetSampleLikelihood (const int iSample) const override
 Get likelihood (-logL) for a single sample. More...
 
void CleanMemoryBeforeFit () override
 Allow to clean not used memory before fit starts. More...
 
void PrintRates (const bool DataOnly=false) override
 Helper function to print rates for the samples with LLH. More...
 
std::string GetKinVarName (const int iSample, const int Dimension) const override
 Return Kinematic Variable name for specified sample and dimension for example "Reconstructed_Neutrino_Energy". More...
 
std::vector< double > ReturnKinematicParameterBinning (const int Sample, const std::string &KinematicParameter) const override
 Return the binning used to draw a kinematic parameter. More...
 
TH1 * GetDataHist (const int Sample) override
 Get Data histogram. More...
 
TH1 * GetMCHist (const int Sample) override
 Get MC histogram. More...
 
TH1 * GetW2Hist (const int Sample) override
 Get W2 histogram. More...
 
double GetLikelihood () const override
 Return likelihood (-logL) for all samples. More...
 
std::unique_ptr< TH1 > Get1DVarHistByModeAndChannel (const int iSample, const std::string &ProjectionVar_Str, const int kModeToFill=-1, const int kChannelToFill=-1, const int WeightStyle=0) override
 Build a 1D histogram for a given variable, optionally filtered by mode and channel. More...
 
std::unique_ptr< TH2 > Get2DVarHistByModeAndChannel (const int iSample, const std::string &ProjectionVar_StrX, const std::string &ProjectionVar_StrY, const int kModeToFill=-1, const int kChannelToFill=-1, const int WeightStyle=0) override
 Build a 2D histogram for given variables, optionally filtered by mode and channel. More...
 
std::unique_ptr< TH1 > Get1DVarHist (const int iSample, const std::string &ProjectionVar, const std::vector< KinematicCut > &EventSelectionVec={}, const int WeightStyle=0, const std::vector< KinematicCut > &SubEventSelectionVec={}) override
 Return 1D projection of MC into given 1D variable (doesn't have to be variable used in the fit) More...
 
std::unique_ptr< TH2 > Get2DVarHist (const int iSample, const std::string &ProjectionVarX, const std::string &ProjectionVarY, const std::vector< KinematicCut > &EventSelectionVec={}, const int WeightStyle=0, const std::vector< KinematicCut > &SubEventSelectionVec={}) override
 Build a 2D projection of MC events into specified variables. More...
 
int GetNDim (const int Sample) const override
 DB Get what dimensionality binning for given sample has. More...
 
std::string GetFlavourName (const int iSample, const int iChannel) const override
 Get the flavour name for a given sample and oscillation channel. More...
 
 SampleHandlerInterface ()
 The main constructor. More...
 
- Public Member Functions inherited from SampleHandlerInterface
 SampleHandlerInterface ()
 The main constructor. More...
 
virtual ~SampleHandlerInterface ()
 destructor More...
 
virtual M3::int_t GetNSamples ()
 returns total number of samples More...
 
virtual void SaveAdditionalInfo (TDirectory *Dir)
 Store additional info in a chain. More...
 
MaCh3ModesGetMaCh3Modes () const
 Return pointer to MaCh3 modes. More...
 
unsigned int GetNEvents () const
 Return total number of events. More...
 
double GetPoissonLLH (const double data, const double mc) const
 Calculate test statistic for a single bin using Poisson. More...
 
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. Data and mc -> 0 cut-offs are defined in M3::LOW_MC_BOUND. More...
 
void SetTestStatistic (TestStatistic testStat)
 Set the test statistic to be used when calculating the binned likelihoods. More...
 
TestStatistic GetTestStatistic () const
 Get the test statistic used when calculating the binned likelihoods. More...
 

Additional Inherited Members

- Protected Member Functions inherited from SampleHandlerInterface
void QuietPlease ()
 CW: Redirect std::cout to silence some experiment specific libraries. More...
 
void NowTalk ()
 CW: Redirect std::cout to silence some experiment specific libraries. More...
 
template<typename T >
bool MatchCondition (const std::vector< T > &allowedValues, const T &value)
 check if event is affected by following conditions, for example pdg, or modes etc More...
 
- Protected Attributes inherited from SampleHandlerInterface
TestStatistic fTestStatistic
 Test statistic tells what kind of likelihood sample is using. More...
 
std::streambuf * buf
 Keep the cout buffer. More...
 
std::streambuf * errbuf
 Keep the cerr buffer. More...
 
M3::int_t nSamples
 Contains how many samples we've got. More...
 
unsigned int nEvents
 Number of MC events are there. More...
 
std::unique_ptr< MaCh3ModesModes
 Holds information about used Generator and MaCh3 modes. More...
 

Detailed Description

EW: As SampleHandlerBase is an abstract base class we have to do some gymnastics to get it to get it into python.

Definition at line 20 of file samples.h.

Member Function Documentation

◆ CleanMemoryBeforeFit()

void PySampleHandlerInterface::CleanMemoryBeforeFit ( )
inlineoverridevirtual

Allow to clean not used memory before fit starts.

Implements SampleHandlerInterface.

Definition at line 77 of file samples.h.

77  {
78  PYBIND11_OVERRIDE_PURE_NAME(
79  void, /* Return type */
80  SampleHandlerInterface, /* Parent class */
81  "clean_memory_before_fit",
82  CleanMemoryBeforeFit /* Name of function in C++ (must match Python name) */
83  );
84  }
void CleanMemoryBeforeFit() override
Allow to clean not used memory before fit starts.
Definition: samples.h:77
Class responsible for handling implementation of samples used in analysis, reweighting and returning ...

◆ Get1DVarHist()

std::unique_ptr<TH1> PySampleHandlerInterface::Get1DVarHist ( const int  iSample,
const std::string &  ProjectionVar,
const std::vector< KinematicCut > &  EventSelectionVec = {},
const int  WeightStyle = 0,
const std::vector< KinematicCut > &  SubEventSelectionVec = {} 
)
inlineoverridevirtual

Return 1D projection of MC into given 1D variable (doesn't have to be variable used in the fit)

Parameters
iSampleIndex of the sample.
ProjectionVarname of variable
EventSelectionVecVector of additional cuts like cut on interaction mode
WeightStyleAlow to modify weight for example if equal to 1 all weights are set to 1
SubEventSelectionVecVector of additional cuts for sub event (particle, ring etc.)

Implements SampleHandlerInterface.

Definition at line 183 of file samples.h.

185  {},
186  const int WeightStyle = 0,
187  const std::vector<KinematicCut> &SubEventSelectionVec = {}) override {
188  (void) iSample;
189  (void) ProjectionVar;
190  (void) EventSelectionVec;
191  (void) WeightStyle;
192  (void) SubEventSelectionVec;
193  return nullptr;
194  }

◆ Get1DVarHistByModeAndChannel()

std::unique_ptr<TH1> PySampleHandlerInterface::Get1DVarHistByModeAndChannel ( const int  iSample,
const std::string &  ProjectionVar_Str,
const int  kModeToFill = -1,
const int  kChannelToFill = -1,
const int  WeightStyle = 0 
)
inlineoverridevirtual

Build a 1D histogram for a given variable, optionally filtered by mode and channel.

Parameters
iSampleIndex of the sample.
ProjectionVar_StrName of the variable to project onto.
kModeToFillInteraction mode to select (-1 means all modes).
kChannelToFillOscillation channel to select (-1 means all channels).
WeightStyleWeighting scheme (e.g. 0 = nominal weights, 1 = unit weights).

Implements SampleHandlerInterface.

Definition at line 155 of file samples.h.

159  {
160  (void) iSample;
161  (void) ProjectionVar_Str;
162  (void) kModeToFill;
163  (void) kChannelToFill;
164  (void) WeightStyle;
165  return nullptr;
166  }

◆ Get2DVarHist()

std::unique_ptr<TH2> PySampleHandlerInterface::Get2DVarHist ( const int  iSample,
const std::string &  ProjectionVarX,
const std::string &  ProjectionVarY,
const std::vector< KinematicCut > &  EventSelectionVec = {},
const int  WeightStyle = 0,
const std::vector< KinematicCut > &  SubEventSelectionVec = {} 
)
inlineoverridevirtual

Build a 2D projection of MC events into specified variables.

Parameters
iSampleIndex of the sample.
ProjectionVarXName of the variable for the X axis.
ProjectionVarYName of the variable for the Y axis.
EventSelectionVecVector of event-level selection cuts.
WeightStyleWeighting scheme (e.g. 0 = nominal weights, 1 = unit weights).
SubEventSelectionVecVector of sub-event selection cuts.

Implements SampleHandlerInterface.

Definition at line 196 of file samples.h.

199  {},
200  const int WeightStyle = 0,
201  const std::vector<KinematicCut>& SubEventSelectionVec = {}) override {
202  (void) iSample;
203  (void) ProjectionVarX;
204  (void) ProjectionVarY;
205  (void) EventSelectionVec;
206  (void) WeightStyle;
207  (void) SubEventSelectionVec;
208  return nullptr;
209  }

◆ Get2DVarHistByModeAndChannel()

std::unique_ptr<TH2> PySampleHandlerInterface::Get2DVarHistByModeAndChannel ( const int  iSample,
const std::string &  ProjectionVar_StrX,
const std::string &  ProjectionVar_StrY,
const int  kModeToFill = -1,
const int  kChannelToFill = -1,
const int  WeightStyle = 0 
)
inlineoverridevirtual

Build a 2D histogram for given variables, optionally filtered by mode and channel.

Parameters
iSampleIndex of the sample.
ProjectionVar_StrXName of the variable for the X axis.
ProjectionVar_StrYName of the variable for the Y axis.
kModeToFillInteraction mode to select (-1 means all modes).
kChannelToFillOscillation channel to select (-1 means all channels).
WeightStyleWeighting scheme (e.g. 0 = nominal weights, 1 = unit weights).

Implements SampleHandlerInterface.

Definition at line 168 of file samples.h.

173  {
174  (void) iSample;
175  (void) ProjectionVar_StrX;
176  (void) ProjectionVar_StrY;
177  (void) kModeToFill;
178  (void) kChannelToFill;
179  (void) WeightStyle;
180  return nullptr;
181  }

◆ GetDataHist()

TH1* PySampleHandlerInterface::GetDataHist ( const int  Sample)
inlineoverridevirtual

Get Data histogram.

Parameters
SampleSample enumerator

Implements SampleHandlerInterface.

Definition at line 118 of file samples.h.

118  {
119  PYBIND11_OVERRIDE_PURE(
120  TH1*, /* Return type */
121  SampleHandlerInterface, /* Parent class */
122  GetDataHist, /* Name of function in C++ (must match Python name) */
123  Sample /* Argument(s) */
124  );
125  }
TH1 * GetDataHist(const int Sample) override
Get Data histogram.
Definition: samples.h:118

◆ GetFlavourName()

std::string PySampleHandlerInterface::GetFlavourName ( const int  iSample,
const int  iChannel 
) const
inlineoverridevirtual

Get the flavour name for a given sample and oscillation channel.

Parameters
iSampleIndex of the sample.
iChannelIndex of the oscillation channel within the sample.

Implements SampleHandlerInterface.

Definition at line 220 of file samples.h.

221  {
222  PYBIND11_OVERRIDE_PURE(
223  std::string, /* Return type */
224  SampleHandlerInterface, /* Parent class */
225  GetFlavourName, /* Name of function in C++ */
226  iSample,
227  iChannel
228  );
229  }
std::string GetFlavourName(const int iSample, const int iChannel) const override
Get the flavour name for a given sample and oscillation channel.
Definition: samples.h:220

◆ GetKinVarName()

std::string PySampleHandlerInterface::GetKinVarName ( const int  iSample,
const int  Dimension 
) const
inlineoverridevirtual

Return Kinematic Variable name for specified sample and dimension for example "Reconstructed_Neutrino_Energy".

Parameters
iSampleSample index
DimensionDimension index

Implements SampleHandlerInterface.

Definition at line 97 of file samples.h.

97  {
98  PYBIND11_OVERRIDE_PURE(
99  std::string, /* Return type */
100  SampleHandlerInterface, /* Parent class */
101  GetKinVarName, /* Name of function in C++ (must match Python name) */
102  iSample, /* Argument(s) */
103  Dimension /* Argument(s) */
104  );
105  }
std::string GetKinVarName(const int iSample, const int Dimension) const override
Return Kinematic Variable name for specified sample and dimension for example "Reconstructed_Neutrino...
Definition: samples.h:97

◆ GetLikelihood()

double PySampleHandlerInterface::GetLikelihood ( ) const
inlineoverridevirtual

Return likelihood (-logL) for all samples.

Implements SampleHandlerInterface.

Definition at line 145 of file samples.h.

145  {
146  PYBIND11_OVERRIDE_PURE_NAME(
147  double, /* Return type */
148  SampleHandlerInterface, /* Parent class */
149  "get_likelihood", /* Python name*/
150  GetLikelihood /* Name of function in C++ (must match Python name) */
151  /* Argument(s) */
152  );
153  }
double GetLikelihood() const override
Return likelihood (-logL) for all samples.
Definition: samples.h:145

◆ GetMCHist()

TH1* PySampleHandlerInterface::GetMCHist ( const int  Sample)
inlineoverridevirtual

Get MC histogram.

Parameters
SampleSample enumerator

Implements SampleHandlerInterface.

Definition at line 127 of file samples.h.

127  {
128  PYBIND11_OVERRIDE_PURE(
129  TH1*, /* Return type */
130  SampleHandlerInterface, /* Parent class */
131  GetMCHist, /* Name of function in C++ (must match Python name) */
132  Sample /* Argument(s) */
133  );
134  }
TH1 * GetMCHist(const int Sample) override
Get MC histogram.
Definition: samples.h:127

◆ GetName()

std::string PySampleHandlerInterface::GetName ( ) const
inlineoverridevirtual

Get name for Sample Handler.

Implements SampleHandlerInterface.

Definition at line 26 of file samples.h.

26  {
27  PYBIND11_OVERRIDE_PURE(
28  std::string, /* Return type */
29  SampleHandlerInterface, /* Parent class */
30  GetName, /* Name of function in C++ (must match Python name) */
31  );
32  }
std::string GetName() const override
Get name for Sample Handler.
Definition: samples.h:26

◆ GetNDim()

int PySampleHandlerInterface::GetNDim ( const int  Sample) const
inlineoverridevirtual

DB Get what dimensionality binning for given sample has.

Parameters
SampleNumber of sample

Implements SampleHandlerInterface.

Definition at line 211 of file samples.h.

211  {
212  PYBIND11_OVERRIDE_PURE(
213  int, /* Return type */
214  SampleHandlerInterface, /* Parent class */
215  GetNDim, /* Name of function in C++ */
216  Sample
217  );
218  }
int GetNDim(const int Sample) const override
DB Get what dimensionality binning for given sample has.
Definition: samples.h:211

◆ GetNOscChannels()

int PySampleHandlerInterface::GetNOscChannels ( const int  iSample) const
inlineoverridevirtual

Get number of oscillation channels for a single sample.

Parameters
iSampleSample enumerator

Implements SampleHandlerInterface.

Definition at line 45 of file samples.h.

45  {
46  PYBIND11_OVERRIDE_PURE(
47  int, /* Return type */
48  SampleHandlerInterface, /* Parent class */
49  GetNOscChannels, /* Name of function in C++ (must match Python name) */
50  iSample /* Argument(s) */
51  );
52  }
int GetNOscChannels(const int iSample) const override
Get number of oscillation channels for a single sample.
Definition: samples.h:45

◆ GetSampleLikelihood()

double PySampleHandlerInterface::GetSampleLikelihood ( const int  iSample) const
inlineoverridevirtual

Get likelihood (-logL) for a single sample.

Parameters
iSampleSample enumerator

Implements SampleHandlerInterface.

Definition at line 66 of file samples.h.

66  {
67  PYBIND11_OVERRIDE_PURE_NAME(
68  double, /* Return type */
69  SampleHandlerInterface, /* Parent class */
70  "get_sample_likelihood",
71  GetSampleLikelihood, /* Name of function in C++ (must match Python name) */
72  iSample /* Argument(s) */
73  );
74  }
double GetSampleLikelihood(const int iSample) const override
Get likelihood (-logL) for a single sample.
Definition: samples.h:66

◆ GetSampleTitle()

std::string PySampleHandlerInterface::GetSampleTitle ( const int  iSample) const
inlineoverridevirtual

Get fancy title for specified samples.

Parameters
iSampleSample enumerator

Implements SampleHandlerInterface.

Definition at line 35 of file samples.h.

35  {
36  PYBIND11_OVERRIDE_PURE(
37  std::string, /* Return type */
38  SampleHandlerInterface, /* Parent class */
39  GetSampleTitle, /* Name of function in C++ (must match Python name) */
40  iSample /* Argument(s) */
41  );
42  }
std::string GetSampleTitle(const int iSample) const override
Get fancy title for specified samples.
Definition: samples.h:35

◆ GetW2Hist()

TH1* PySampleHandlerInterface::GetW2Hist ( const int  Sample)
inlineoverridevirtual

Get W2 histogram.

Parameters
SampleSample enumerator

Implements SampleHandlerInterface.

Definition at line 136 of file samples.h.

136  {
137  PYBIND11_OVERRIDE_PURE(
138  TH1*, /* Return type */
139  SampleHandlerInterface, /* Parent class */
140  GetW2Hist, /* Name of function in C++ (must match Python name) */
141  Sample /* Argument(s) */
142  );
143  }
TH1 * GetW2Hist(const int Sample) override
Get W2 histogram.
Definition: samples.h:136

◆ PrintRates()

void PySampleHandlerInterface::PrintRates ( const bool  DataOnly = false)
inlineoverridevirtual

Helper function to print rates for the samples with LLH.

Parameters
DataOnlywhether to print data only rates

Implements SampleHandlerInterface.

Definition at line 87 of file samples.h.

87  {
88  PYBIND11_OVERRIDE_PURE(
89  void, /* Return type */
90  SampleHandlerInterface, /* Parent class */
91  PrintRates, /* Name of function in C++ (must match Python name) */
92  DataOnly /* Argument(s) */
93  );
94  }
void PrintRates(const bool DataOnly=false) override
Helper function to print rates for the samples with LLH.
Definition: samples.h:87

◆ ReturnKinematicParameterBinning()

std::vector<double> PySampleHandlerInterface::ReturnKinematicParameterBinning ( const int  Sample,
const std::string &  KinematicParameter 
) const
inlineoverridevirtual

Return the binning used to draw a kinematic parameter.

Parameters
iSampleIndex of the sample.
KinematicParametername of variable

Implements SampleHandlerInterface.

Definition at line 108 of file samples.h.

108  {
109  PYBIND11_OVERRIDE_PURE(
110  std::vector<double>, /* Return type */
111  SampleHandlerInterface, /* Parent class */
112  GetKinVarName, /* Name of function in C++ (must match Python name) */
113  Sample, /* Argument(s) */
114  KinematicParameter /* Argument(s) */
115  );
116  }

◆ Reweight()

void PySampleHandlerInterface::Reweight ( )
inlineoverridevirtual

main routine modifying MC prediction based on proposed parameter values

Implements SampleHandlerInterface.

Definition at line 55 of file samples.h.

55  {
56  PYBIND11_OVERRIDE_PURE_NAME(
57  void, /* Return type */
58  SampleHandlerInterface, /* Parent class */
59  "reweight",
60  Reweight /* Name of function in C++ (must match Python name) */
61  );
62  }
void Reweight() override
main routine modifying MC prediction based on proposed parameter values
Definition: samples.h:55

◆ SampleHandlerInterface()

SampleHandlerInterface::SampleHandlerInterface

The main constructor.

Definition at line 38 of file SampleHandlerInterface.cpp.

4  {
5 // ***************************************************************************
6  nEvents = 0;
7  nSamples = 0;
8 }
M3::int_t nSamples
Contains how many samples we've got.
unsigned int nEvents
Number of MC events are there.

The documentation for this class was generated from the following file: