28 const std::shared_ptr<OscillationHandler>& OscillatorObj_ =
nullptr);
34 std::string
GetName()
const override;
40 std::string
GetKinVarName(
const int iSample,
const int Dimension)
const override;
47 void PrintIntegral(
const int iSample,
const TString& OutputName=
"/dev/null",
const int WeightStyle=0,
const TString& OutputCSVName=
"/dev/null");
54 void AddData(
const int Sample, TH1* Data);
55 void AddData(
const int Sample,
const std::vector<double>& Data_Array);
59 void PrintRates(
const bool DataOnly =
false)
override;
75 TH1*
GetMCHist(
const int Sample)
override;
76 TH1*
GetMCHist(
const std::string& Sample);
79 TH1*
GetW2Hist(
const int Sample)
override;
80 TH1*
GetW2Hist(
const std::string& Sample);
95 std::string
GetFlavourName(
const int iSample,
const int iChannel)
const override {
100 return SampleDetails[iSample].OscChannels[iChannel].flavourName;
105 const std::vector<KinematicCut>& ExtraCuts);
106 TH1 *
Get1DVarHist(
const int iSample,
const std::string &ProjectionVar,
107 const std::vector<KinematicCut> &EventSelectionVec = {},
int WeightStyle = 0,
108 TAxis *Axis =
nullptr,
const std::vector<KinematicCut> &SubEventSelectionVec = {})
override;
109 TH2*
Get2DVarHist(
const int iSample,
const std::string& ProjectionVarX,
const std::string& ProjectionVarY,
110 const std::vector< KinematicCut >& EventSelectionVec = {},
111 int WeightStyle = 0, TAxis* AxisX =
nullptr, TAxis* AxisY =
nullptr,
112 const std::vector< KinematicCut >& SubEventSelectionVec = {})
override;
113 std::vector<KinematicCut>
BuildModeChannelSelection(
const int iSample,
const int kModeToFill,
const int kChannelToFill)
const;
115 void Fill1DSubEventHist(
const int iSample, TH1D* _h1DVar,
const std::string& ProjectionVar,
116 const std::vector< KinematicCut >& SubEventSelectionVec = {},
118 void Fill2DSubEventHist(
const int iSample, TH2D* _h2DVar,
const std::string& ProjectionVarX,
const std::string& ProjectionVarY,
119 const std::vector< KinematicCut >& SubEventSelectionVec = {},
int WeightStyle = 0);
122 int kModeToFill = -1,
int kChannelToFill = -1,
int WeightStyle = 0, TAxis* Axis =
nullptr)
override;
124 const std::string& ProjectionVar_StrY,
int kModeToFill = -1,
125 int kChannelToFill = -1,
int WeightStyle = 0,
126 TAxis* AxisX =
nullptr, TAxis* AxisY =
nullptr)
override;
136 int Selection1,
int Selection2 = -1,
137 int WeightStyle = 0, TAxis* Axis =
nullptr);
139 const std::string& KinematicProjectionY,
140 int Selection1,
int Selection2=-1,
int WeightStyle=0,
141 TAxis* XAxis =
nullptr, TAxis* YAxis =
nullptr);
143 int Selection1,
int Selection2 = -1,
int WeightStyle = 0, TAxis* Axis =
nullptr);
174 std::vector<double>
GetArrayForSample(
const int Sample,
const double* array)
const;
248 bool IsSubEventSelected(
const std::vector<KinematicCut> &SubEventCuts,
const int iEvent,
unsigned const int iSubEvent,
size_t nsubevents);
274 void CalcNormsBins(std::vector<NormParameter>& norm_parameters, std::vector< std::vector< int > >& norms_bins);
275 template <
typename ParT>
bool PassesSelection(
const ParT& Par, std::size_t iEvent);
291 virtual std::vector<double>
ReturnKinematicVector(std::string KinematicParameter,
int iEvent) {
return {}; (void)KinematicParameter; (void)iEvent;};
292 virtual std::vector<double>
ReturnKinematicVector(
int KinematicVariable,
int iEvent) {
return {}; (void)KinematicVariable; (void)iEvent;};
311 void FillHist(
const int Sample, TH1* Hist,
double* Array);
#define _noexcept_
KS: noexcept can help with performance but is terrible for debugging, this is meant to help easy way ...
#define _MaCh3_Safe_Include_Start_
KS: Avoiding warning checking for headers.
#define _MaCh3_Safe_Include_End_
KS: Restore warning checking after including external headers.
#define _restrict_
KS: Using restrict limits the effects of pointer aliasing, aiding optimizations. While reading I foun...
std::function< void(const double *, std::size_t)> FuncParFuncType
HH - a shorthand type for funcpar functions.
NuPDG
Enum to track the incoming neutrino species.
KS: Class handling binning for multiple samples.
Custom exception class used throughout MaCh3.
Class responsible for handling of systematic error parameters with different types defined in the con...
Class responsible for handling implementation of samples used in analysis, reweighting and returning ...
Class responsible for handling implementation of samples used in analysis, reweighting and returning ...
std::vector< FunctionalParameter > funcParsVec
HH - a vector that stores all the FuncPars struct.
std::vector< std::vector< KinematicCut > > Selection
a way to store selection cuts which you may push back in the get1DVar functions most of the time this...
virtual void Init()=0
Initialise any variables that your experiment specific SampleHandler needs.
std::vector< double > GetArrayForSample(const int Sample, const double *array) const
Return a sub-array for a given sample.
std::string ReturnStringFromKinematicVector(const int KinematicVariable) const
std::vector< SampleInfo > SampleDetails
Stores info about currently initialised sample.
std::unique_ptr< SplineBase > SplineHandler
Contains all your splines (binned or unbinned) and handles the setup and the returning of weights fro...
std::vector< FunctionalShifter > funcParsMap
HH - a map that relates the funcpar enum to pointer of FuncPars struct HH - Changed to a vector of po...
virtual void CalcWeightFunc(int iEvent)
Calculate weights for function parameters.
std::vector< double > GetMCArray(const int Sample) const
Return array storing MC entries for every bin.
virtual void SetupSplines()=0
initialise your splineXX object and then use InitialiseSplineObject to conviently setup everything up
ParameterHandlerGeneric * ParHandler
ETA - All experiments will need an xsec, det and osc cov.
void SetSplinePointers()
Set pointers for each event to appropriate weights, for unbinned based on event number while for binn...
bool FirstTimeW2
KS:Super hacky to update W2 or not.
std::unique_ptr< BinningHandler > Binning
KS: This stores binning information, in future could be come vector to store binning for every used s...
std::unordered_map< std::string, NuPDG > FileToInitPDGMap
double GetLikelihood() const override
DB Multi-threaded GetLikelihood.
std::vector< double > GetDataArray(const int Sample) const
Return array storing data entries for every bin.
NuPDG GetInitPDGFromFileName(const std::string &FileName) const
Retrieve the initial neutrino PDG code associated with a given input file name.
void InitialiseSplineObject()
double * SampleHandlerFD_data
DB Array to be filled in AddData.
std::vector< double > ReturnKinematicParameterBinning(const int Sample, const std::string &KinematicParameter) const override
Return the binning used to draw a kinematic parameter.
virtual int SetupExperimentMC()=0
Experiment specific setup, returns the number of events which were loaded.
const std::unordered_map< int, std::string > * ReversedKinematicVectors
void CalcNormsBins(std::vector< NormParameter > &norm_parameters, std::vector< std::vector< int > > &norms_bins)
Check whether a normalisation systematic affects an event or not.
TH2 * GetModeHist2D(const int iSample, int s, int m, int style=0)
const BinningHandler * GetBinningHandler() const
Get pointer to binning handler.
virtual void ResetShifts(const int iEvent)
HH - reset the shifted values to the original values.
std::string ReturnStringFromKinematicParameter(const int KinematicVariable) const
ETA function to generically convert a kinematic type from xsec cov to a string.
void FindNominalBinAndEdges()
std::vector< std::vector< FunctionalShifter * > > funcParsGrid
HH - a grid of vectors of enums for each sample and event.
std::unique_ptr< Manager > SampleManager
The manager object used to read the sample yaml file.
std::vector< TH2 * > ReturnHistsBySelection2D(const int iSample, const std::string &KinematicProjectionX, const std::string &KinematicProjectionY, int Selection1, int Selection2=-1, int WeightStyle=0, TAxis *XAxis=nullptr, TAxis *YAxis=nullptr)
std::unordered_map< std::string, NuPDG > FileToFinalPDGMap
std::vector< double > GetDataArray() const
Return array storing data entries for every bin.
std::unordered_map< int, FuncParFuncType > funcParsFuncMap
HH - a map that relates the funcpar enum to pointer of the actual function.
const double * GetPointerToOscChannel(const int iEvent) const
Get pointer to oscillation channel associated with given event. Osc channel is const.
std::vector< double > GetW2Array(const int Sample) const
Return array storing W2 entries for single sample.
const std::unordered_map< std::string, int > * KinematicVectors
void FillHist(const int Sample, TH1 *Hist, double *Array)
Fill a histogram with the event-level information used in the fit.
void LoadSingleSample(const int iSample, const YAML::Node &Settings)
void SetupNormParameters()
Setup the norm parameters by assigning each event with bin.
std::string GetName() const override
void SetupKinematicMap()
Ensure Kinematic Map is setup and make sure it is initialised correctly.
virtual const double * GetPointerToKinematicParameter(double KinematicVariable, int iEvent)=0
void PrintIntegral(const int iSample, const TString &OutputName="/dev/null", const int WeightStyle=0, const TString &OutputCSVName="/dev/null")
M3::float_t GetEventWeight(const int iEntry)
virtual void PrepFunctionalParameters()
Update the functional parameter values to the latest proposed values. Needs to be called before every...
std::string GetYBinVarName(const int Sample) const
SampleHandlerFD(std::string ConfigFileName, ParameterHandlerGeneric *xsec_cov, const std::shared_ptr< OscillationHandler > &OscillatorObj_=nullptr)
Constructor.
void Initialise()
Function which does a lot of the lifting regarding the workflow in creating different MC objects.
std::vector< double > GetMCArray() const
Return array storing MC entries for every bin.
int GetNDim(const int Sample) const override
DB Function to differentiate 1D or 2D binning.
std::vector< std::vector< KinematicCut > > ApplyTemporarySelection(const int iSample, const std::vector< KinematicCut > &ExtraCuts)
Temporarily extend Selection for a given sample with additional cuts. Returns the original Selection ...
void AddData(const int Sample, TH1 *Data)
virtual ~SampleHandlerFD()
destructor
std::string GetKinVarName(const int iSample, const int Dimension) const override
Return Kinematic Variable name for specified sample and dimension for example "Reconstructed_Neutrino...
std::string GetFlavourName(const int iSample, const int iChannel) const override
double * SampleHandlerFD_array
DB Array to be filled after reweighting.
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
std::vector< std::string > funcParsNamesVec
HH - a vector of string names for each functional parameter.
virtual const double * GetPointerToKinematicParameter(std::string KinematicParamter, int iEvent)=0
TLegend * ReturnStackHistLegend()
std::vector< KinematicCut > BuildModeChannelSelection(const int iSample, const int kModeToFill, const int kChannelToFill) const
virtual void SetupFDMC()=0
Function which translates experiment struct into core struct.
std::vector< double > GetW2Array() const
Return array storing W2 entries for every bin.
void SaveAdditionalInfo(TDirectory *Dir) override
Store additional info in a chan.
void Fill2DSubEventHist(const int iSample, TH2D *_h2DVar, const std::string &ProjectionVarX, const std::string &ProjectionVarY, const std::vector< KinematicCut > &SubEventSelectionVec={}, int WeightStyle=0)
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 PrintRates(const bool DataOnly=false) override
Helper function to print rates for the samples with LLH.
TH1 * GetW2Hist(const int Sample) override
Get W2 histogram.
std::string SampleHandlerName
A unique ID for each sample based on which we can define what systematic should be applied.
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
std::string GetXBinVarName(const int Sample) const
const M3::float_t * GetNuOscillatorPointers(const int iEvent) const
std::vector< TH1 * > ReturnHistsBySelection1D(const int iSample, const std::string &KinematicProjection, int Selection1, int Selection2=-1, int WeightStyle=0, TAxis *Axis=nullptr)
void InitialiseNuOscillatorObjects()
including Dan's magic NuOscillator
M3::float_t CalcWeightTotal(const EventInfo *_restrict_ MCEvent) const
Calculate the total weight weight for a given event.
void RegisterIndividualFunctionalParameter(const std::string &fpName, int fpEnum, FuncParFuncType fpFunc)
HH - a helper function for RegisterFunctionalParameter.
std::vector< std::vector< KinematicCut > > StoredSelection
What gets pulled from config options, these are constant after loading in this is of length 3: 0th in...
void SetBinning()
set the binning for 2D sample used for the likelihood calculation
bool UpdateW2
KS:Super hacky to update W2 or not.
std::shared_ptr< OscillationHandler > Oscillator
Contains oscillator handling calculating oscillation probabilities.
double GetSampleLikelihood(const int isample) const override
Get likelihood for single sample.
int GetNOscChannels(const int iSample) const override
bool IsSubEventSelected(const std::vector< KinematicCut > &SubEventCuts, const int iEvent, unsigned const int iSubEvent, size_t nsubevents)
JM Function which determines if a subevent is selected.
const std::unordered_map< std::string, int > * KinematicParameters
Mapping between string and kinematic enum.
void Fill1DSubEventHist(const int iSample, TH1D *_h1DVar, const std::string &ProjectionVar, const std::vector< KinematicCut > &SubEventSelectionVec={}, int WeightStyle=0)
virtual void RegisterFunctionalParameters()=0
HH - a experiment-specific function where the maps to actual functions are set up.
bool PassesSelection(const ParT &Par, std::size_t iEvent)
NuPDG GetFinalPDGFromFileName(const std::string &FileName) const
Retrieve the final neutrino PDG code associated with a given input file name.
void ResetHistograms()
Helper function to reset histograms.
TH1 * GetDataHist(const int Sample) override
Get Data histogram.
TH1 * GetModeHist1D(const int iSample, int s, int m, int style=0)
virtual double ReturnKinematicParameter(std::string KinematicParamter, int iEvent)=0
Return the value of an associated kinematic parameter for an event.
bool IsSubEventVarString(const std::string &VarStr)
JM Check if a kinematic parameter string corresponds to a subevent-level variable.
std::unordered_map< std::string, double > _modeNomWeightMap
const std::unordered_map< int, std::string > * ReversedKinematicParameters
Mapping between kinematic enum and string.
int ReturnKinematicVectorFromString(const std::string &KinematicStr) const
int GetSampleIndex(const std::string &SampleTitle) const
Get index of sample based on name.
virtual void ApplyShifts(const int iEvent)
ETA - generic function applying shifts.
std::string GetSampleTitle(const int Sample) const override
virtual double ReturnKinematicParameter(int KinematicVariable, int iEvent)=0
int ReturnKinematicParameterFromString(const std::string &KinematicStr) const
ETA function to generically convert a string from xsec cov to a kinematic type.
std::vector< EventInfo > MCSamples
Stores information about every MC event.
void SetupNuOscillatorPointers()
virtual std::vector< double > ReturnKinematicVector(int KinematicVariable, int iEvent)
THStack * ReturnStackedHistBySelection1D(const int iSample, const std::string &KinematicProjection, int Selection1, int Selection2=-1, int WeightStyle=0, TAxis *Axis=nullptr)
virtual std::vector< double > ReturnKinematicVector(std::string KinematicParameter, int iEvent)
void SetupReweightArrays()
Initialise data, MC and W2 histograms.
virtual void SetupFunctionalParameters()
ETA - a function to setup and pass values to functional parameters where you need to pass a value to ...
void FillArray()
DB Nice new multi-threaded function which calculates the event weights and fills the relevant bins of...
TH1 * GetMCHist(const int Sample) override
Get MC histogram.
double * SampleHandlerFD_array_w2
KS Array used for MC stat.
TLegend * THStackLeg
DB Miscellaneous Variables.
bool IsEventSelected(const int iSample, const int iEvent) _noexcept_
DB Function which determines if an event is selected, where Selection double looks like {{ND280Kinema...
std::unordered_map< std::string, int > funcParsNamesMap
HH - a map that relates the name of the functional parameter to funcpar enum.
TH1 * Get1DVarHistByModeAndChannel(const int iSample, const std::string &ProjectionVar_Str, int kModeToFill=-1, int kChannelToFill=-1, int WeightStyle=0, TAxis *Axis=nullptr) override
virtual void AddAdditionalWeightPointers()=0
DB Function to determine which weights apply to which types of samples.
Stores info about each MC event used during reweighting routine.