MaCh3  2.8.0
Reference Guide
SampleHandlerBase.h
Go to the documentation of this file.
1 #pragma once
2 
3 //MaCh3 includes
4 #include "Samples/SampleInfo.h"
5 #include "Samples/EventInfo.h"
6 
11 #include "Samples/BinningHandler.h"
13 
15 #include "THStack.h"
16 #include "TLegend.h"
18 
20  kModePlot = 0,
21  kOscChannelPlot = 1
22 };
23 
36 {
37  public:
38  //######################################### Functions #########################################
41  SampleHandlerBase(std::string ConfigFileName, ParameterHandlerGeneric* _ParHandler,
42  const std::shared_ptr<OscillationHandler>& OscillatorObj_ = nullptr);
44  virtual ~SampleHandlerBase();
45 
47  int GetNDim(const int Sample) const final { return SampleDetails[Sample].nDimensions; }
49  std::string GetName() const final;
51  std::string GetSampleTitle(const int iSample) const final {return SampleDetails[iSample].SampleTitle;}
54  std::string GetSampleName(const int iSample) const {return SampleDetails[iSample].SampleName;}
56  std::string GetKinVarName(const int iSample, const int Dimension) const final;
57 
60  void PrintIntegral(const int iSample, const TString& OutputName="/dev/null", const int WeightStyle=0, const TString& OutputCSVName="/dev/null");
62  double GetSampleIntegral(const int iSample, const std::vector<KinematicCut> &EventSelectionVec, int WeightStyle);
64  std::vector<double> ReturnSampleIntegralBySelection(const int iSample, const SamplePlotType Selection1,
65  const int Selection2, const int WeightStyle);
66 
70  void AddData(const int Sample, TH1* Data);
71 
75  void AddData(const int Sample, const std::vector<double>& Data_Array);
76 
78  void PrintRates(const bool DataOnly = false) final;
80  double GetLikelihood() const override;
82  double GetSampleLikelihood(const int iSample) const override;
83  //===============================================================================
84 
87  int GetSampleIndex(const std::string& SampleTitle) const;
88 
90  const TH1* GetDataHist(const int Sample) final;
93  const TH1* GetDataHist(const std::string& Sample);
94 
96  const TH1* GetMCHist(const int Sample) final;
99  const TH1* GetMCHist(const std::string& Sample);
100 
102  const TH1* GetW2Hist(const int Sample) final;
105  const TH1* GetW2Hist(const std::string& Sample);
107  void Reweight() override;
110  M3::float_t GetEventWeight(const int iEvent);
111 
113  int GetNOscChannels(const int iSample) const final {return static_cast<int>(SampleDetails[iSample].OscChannels.size());};
115  std::string GetFlavourName(const int iSample, const int iChannel) const final {
116  if (iChannel < 0 || iChannel > GetNOscChannels(iSample)) {
117  MACH3LOG_ERROR("Invalid Channel Requested: {}", iChannel);
118  throw MaCh3Exception(__FILE__ , __LINE__);
119  }
120  return SampleDetails[iSample].OscChannels[iChannel].flavourName;
121  }
123  std::unique_ptr<TH1> Get1DVarHist(const int iSample, const std::string &ProjectionVar,
124  const std::vector<KinematicCut> &EventSelectionVec = {}, int WeightStyle = 0,
125  const std::vector<KinematicCut> &SubEventSelectionVec = {}) final;
127  std::unique_ptr<TH2> Get2DVarHist(const int iSample, const std::string& ProjectionVarX, const std::string& ProjectionVarY,
128  const std::vector< KinematicCut >& EventSelectionVec = {},
129  int WeightStyle = 0, const std::vector< KinematicCut >& SubEventSelectionVec = {}) final;
132  std::vector<KinematicCut> BuildModeChannelSelection(const int iSample, const int kModeToFill, const int kChannelToFill) const;
134  void Fill1DSubEventHist(const int iSample, TH1D* _h1DVar, const std::string& ProjectionVar,
135  const std::vector< KinematicCut >& SubEventSelectionVec = {},
136  int WeightStyle=0);
138  void Fill2DSubEventHist(const int iSample, TH2* _h2DVar, const std::string& ProjectionVarX, const std::string& ProjectionVarY,
139  const std::vector< KinematicCut >& SubEventSelectionVec = {}, int WeightStyle = 0);
141  std::unique_ptr<TH1> Get1DVarHistByModeAndChannel(const int iSample, const std::string& ProjectionVar_Str,
142  const int kModeToFill = -1, const int kChannelToFill = -1,
143  const int WeightStyle = 0) final;
145  std::unique_ptr<TH2> Get2DVarHistByModeAndChannel(const int iSample, const std::string& ProjectionVar_StrX,
146  const std::string& ProjectionVar_StrY, const int kModeToFill = -1,
147  const int kChannelToFill = -1, const int WeightStyle = 0) final;
148 
152  int GetRangeForPlotType(const SamplePlotType TypeEnum, const int iSample) const;
153 
154  std::vector<std::unique_ptr<TH1>> ReturnHistsBySelection1D(const int iSample, const std::string& KinematicProjection,
155  const SamplePlotType Selection1, const int Selection2 = -1,
156  const int WeightStyle = 0);
157  std::vector<std::unique_ptr<TH2>> ReturnHistsBySelection2D(const int iSample, const std::string& KinematicProjectionX,
158  const std::string& KinematicProjectionY,
159  const SamplePlotType Selection1, const int Selection2 = -1,
160  const int WeightStyle=0);
161  std::unique_ptr<THStack> ReturnStackedHistBySelection1D(const int iSample, const std::string& KinematicProjection,
162  const SamplePlotType Selection1, const int Selection2 = -1, const int WeightStyle = 0);
164  const TLegend* ReturnStackHistLegend() const {return THStackLeg;}
165 
167  int ReturnKinematicParameterFromString(const std::string& KinematicStr) const;
169  std::string ReturnStringFromKinematicParameter(const int KinematicVariable) const;
170 
172  void SaveAdditionalInfo(TDirectory* Dir) final;
173 
175  int ReturnKinematicVectorFromString(const std::string& KinematicStr) const;
177  std::string ReturnStringFromKinematicVector(const int KinematicVariable) const;
179  bool IsSubEventVarString(const std::string& VarStr) const;
180 
182  unsigned int GetNEvents() const {return nEvents;}
183 
185  auto GetDataArray() const {
186  return SampleHandler_data;
187  }
189  auto GetMCArray() const {
190  return SampleHandler_array;
191  }
193  auto GetW2Array() const {
194  return SampleHandler_array_w2;
195  }
197  std::vector<double> GetArrayForSample(const int Sample, std::vector<double> const & array) const;
198 
201  std::vector<double> GetDataArray(const int Sample) const {
202  return GetArrayForSample(Sample, SampleHandler_data);
203  }
206  std::vector<double> GetMCArray(const int Sample) const {
207  return GetArrayForSample(Sample, SampleHandler_array);
208  }
211  std::vector<double> GetW2Array(const int Sample) const {
213  }
215  void CheckEmptyBins() const;
216 
217  protected:
222  const M3::float_t* GetNuOscillatorPointers(const int iEvent) const;
226  void ReadConfig();
228  void LoadSingleSample(const int iSample, const YAML::Node& Settings);
229 
231  virtual void AddAdditionalWeightPointers() = 0;
232 
234  void SetupKinematicMap();
235 
238  virtual void SetupSplines() = 0;
239 
240  //DB Require all objects to have a function which reads in the MC
242  virtual void Init() = 0;
243 
245  virtual int SetupExperimentMC() = 0;
246 
248  virtual void SetupMC() = 0;
250  virtual void InititialiseData() = 0;
251 
253  void Initialise();
254 
255  //===============================================================================
258  void SetSplinePointers();
261  std::vector< SplineIndex > GetSplineBins(int Event, BinnedSplineHandler* BinnedSpline, bool& ThrowCrititcal) const;
262 
264  void FindNominalBinAndEdges();
265 
267  void SetBinning();
268 
270  void SetupReweightArrays();
271  //===============================================================================
272 
273  // ----- start Functional Parameters -----
277  virtual void PrepFunctionalParameters(){};
278 
299  template <typename EventType, typename SFType>
301  std::vector<EventType> &ExptEvents,
302  std::vector<std::string> const &par_names,
303  SFType shift_func);
304 
307  template <typename EventType, typename SFType>
308  void RegisterIndividualFunctionalParameter(std::vector<EventType> &ExptEvents,
309  std::string const &par_name,
310  SFType shift_func);
313  virtual void ApplyShifts(const int iEvent);
315  virtual void ResetShifts([[maybe_unused]] const int iEvent) {};
320  virtual void FinaliseShifts([[maybe_unused]] const int iEvent) {};
321  // ----- end Functional Parameters -----
322 
324  bool IsEventSelected(const int iSample, const int iEvent) _noexcept_;
326  bool IsSubEventSelected(const std::vector<KinematicCut> &SubEventCuts, const int iEvent, unsigned const int iSubEvent, size_t nsubevents);
327 
330  void CalcNormsBins(std::vector<std::vector<NormParameter>>& norm_parameters, std::vector< std::vector< int > >& norms_bins);
331  template <typename ParT> bool PassesSelection(const ParT& Par, std::size_t iEvent);
334 
340  virtual void CalcWeightFunc([[maybe_unused]] const int iEvent) {return;};
341 
343  double ReturnKinematicParameter(const std::string& KinematicParameter, int iEvent) const {
344  return ReturnKinematicParameter(ReturnKinematicParameterFromString(KinematicParameter), iEvent);
345  }
347  virtual double ReturnKinematicParameter(const int KinematicVariable, const int iEvent) const = 0;
348 
349  // === JM declare the same functions for kinematic vectors ===
350  std::vector<double> ReturnKinematicVector(const std::string& KinematicParameter, const int iEvent) const {
351  return ReturnKinematicVector(ReturnKinematicVectorFromString(KinematicParameter), iEvent);
352  }
353  virtual std::vector<double> ReturnKinematicVector([[maybe_unused]] const int KinematicVariable,
354  [[maybe_unused]] const int iEvent) const {return {};};
355  // ===========================================================
356 
358  std::vector<double> ReturnKinematicParameterBinning(const int Sample, const std::string &KinematicParameter) const final;
359 
360  const double* GetPointerToKinematicParameter(const std::string& KinematicParameter, int iEvent) const {
361  return GetPointerToKinematicParameter(ReturnKinematicParameterFromString(KinematicParameter), iEvent);
362  }
363  virtual const double* GetPointerToKinematicParameter(const int KinematicVariable, const int iEvent) const = 0;
364 
366  const double* GetPointerToOscChannel(const int iEvent) const;
368  void SetupNormParameters();
370  void SetupOscParameters();
371  //===============================================================================
376  void FillHist(const int Sample, TH1* Hist, std::vector<double> &Array);
377 
380  void FillArray();
381 
385  void InitialiseSplineObject();
386 
388  std::unique_ptr<SplineBase> SplineHandler;
389 
391  std::shared_ptr<OscillationHandler> Oscillator;
392 
393  //===============================================================================
394  //DB Variables required for GetLikelihood
396  std::unique_ptr<BinningHandler> Binning;
398  std::vector<double> SampleHandler_array;
400  std::vector<double> SampleHandler_array_w2;
402  std::vector<double> SampleHandler_data;
403  //===============================================================================
404 
405  //===============================================================================
407  std::vector<EventInfo> MCEvents;
409  std::vector<SampleInfo> SampleDetails;
410  //===============================================================================
411 
412  //===============================================================================
413  //DB Covariance Objects
416 
417  //===============================================================================
419  std::string SampleHandlerName;
420 
421  //===========================================================================
425  std::vector< std::vector< KinematicCut > > StoredSelection;
428  std::vector< std::vector< KinematicCut > > Selection;
429  //===========================================================================
430 
432  const std::unordered_map<std::string, int>* KinematicParameters;
434  const std::unordered_map<int, std::string>* ReversedKinematicParameters;
435 
436  // === JM mapping between string and kinematic vector enum ===
437  const std::unordered_map<std::string, int>* KinematicVectors;
438  const std::unordered_map<int, std::string>* ReversedKinematicVectors;
439  // ===========================================================
440 
442  std::unique_ptr<Manager> SampleManager;
443 
444  std::unordered_map<std::string, double> _modeNomWeightMap;
445 
446  //===============================================================================
448  TLegend* THStackLeg = nullptr;
449 
453  bool UpdateW2;
454 
456  NuPDG GetInitPDGFromFileName(const std::string& FileName) const {return FileToInitPDGMap.at(FileName);}
458  NuPDG GetFinalPDGFromFileName(const std::string& FileName) const {return FileToFinalPDGMap.at(FileName);}
459 
460  private:
463  std::vector<std::vector<KinematicCut>> ApplyTemporarySelection(const int iSample,
464  const std::vector<KinematicCut>& ExtraCuts);
466  std::unordered_map<std::string, NuPDG> FileToInitPDGMap;
468  std::unordered_map<std::string, NuPDG> FileToFinalPDGMap;
469 
472 
474  unsigned int nEvents;
475 };
476 
477 //template implementation details live here
#define _noexcept_
KS: noexcept can help with performance but is terrible for debugging, this is meant to help easy way ...
Definition: Core.h:96
#define _MaCh3_Safe_Include_Start_
KS: Avoiding warning checking for headers.
Definition: Core.h:126
#define _MaCh3_Safe_Include_End_
#define _restrict_
KS: Using restrict limits the effects of pointer aliasing, aiding optimizations. While reading I foun...
Definition: Core.h:108
#define MACH3LOG_ERROR
Definition: MaCh3Logger.h:37
SamplePlotType
@ kOscChannelPlot
@ kModePlot
NuPDG
Enum to track the incoming neutrino species.
Definition: SampleStructs.h:95
Bin-by-bin class calculating response for spline parameters.
KS: Class handling binning for multiple samples.
Custom exception class used throughout MaCh3.
The manager class is responsible for managing configurations and settings.
Definition: Manager.h:17
Interface between NuOscillator and MaCh3, meant to compute oscillation weights for events/bin.
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 ...
M3::float_t GetEventWeight(const int iEvent)
Computes the total event weight for a given entry.
std::vector< double > ReturnKinematicVector(const std::string &KinematicParameter, const int iEvent) const
void InitialiseSplineObject()
Setup spline handler (both binned or unbinned)
virtual ~SampleHandlerBase()
destructor
std::string SampleHandlerName
Identifier of this Sample Handler, mostly used for fancy printing in FitterBase.
void RegisterIndividualFunctionalParameter(std::vector< EventType > &ExptEvents, std::string const &par_name, SFType shift_func)
LP - Registration template function for one-dimensional functional shifts.
const std::unordered_map< int, std::string > * ReversedKinematicParameters
Mapping between kinematic enum and string.
virtual const double * GetPointerToKinematicParameter(const int KinematicVariable, const int iEvent) const =0
std::shared_ptr< OscillationHandler > Oscillator
Contains oscillator handling calculating oscillation probabilities.
int GetNDim(const int Sample) const final
DB Get what dimensionality binning for given sample has.
std::vector< KinematicCut > BuildModeChannelSelection(const int iSample, const int kModeToFill, const int kChannelToFill) const
Construct vector of kinematic cuts that will be applied, on top of default cuts include stuff like cu...
void SetBinning()
set the binning for 2D sample used for the likelihood calculation
void PrintIntegral(const int iSample, const TString &OutputName="/dev/null", const int WeightStyle=0, const TString &OutputCSVName="/dev/null")
Computes and prints the integral breakdown of all modes and oscillation channels for a given sample.
void RegisterIndividualFunctionalParameter(std::vector< EventType > &ExptEvents, std::vector< std::string > const &par_names, SFType shift_func)
LP - Registration template function for multi-dimensional functional shifts.
std::unique_ptr< Manager > SampleManager
The manager object used to read the sample yaml file.
std::string GetKinVarName(const int iSample, const int Dimension) const final
Return Kinematic Variable name for specified sample and dimension for example "Reconstructed_Neutrino...
bool PassesSelection(const ParT &Par, std::size_t iEvent)
void ResetHistograms() _noexcept_
Helper function to reset histograms.
bool IsSubEventVarString(const std::string &VarStr) const
JM: Check if a kinematic parameter string corresponds to a subevent-level variable.
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) final
Build a 1D histogram for a given variable, optionally filtered by mode and channel.
void SetupNormParameters()
Setup the norm parameters by assigning each event with bin.
void ReadConfig()
Load information about sample handler and corresponding samples from config file.
const TH1 * GetW2Hist(const int Sample) final
Get W2 histogram.
void SetupKinematicMap()
Ensure Kinematic Map is setup and make sure it is initialised correctly.
NuPDG GetFinalPDGFromFileName(const std::string &FileName) const
Retrieve the final neutrino PDG code associated with a given input file name.
std::vector< std::vector< KinematicCut > > StoredSelection
DB Vectors to store which kinematic cuts we apply. Gets used in IsEventSelected Read in from sample y...
virtual void Init()=0
Initialise any variables that your experiment specific SampleHandler needs.
const TH1 * GetDataHist(const int Sample) final
Get Data histogram.
SampleHandlerBase(std::string ConfigFileName, ParameterHandlerGeneric *_ParHandler, const std::shared_ptr< OscillationHandler > &OscillatorObj_=nullptr)
Constructor.
std::string GetFlavourName(const int iSample, const int iChannel) const final
Get the flavour name for a given sample and oscillation channel.
std::unordered_map< std::string, NuPDG > FileToFinalPDGMap
Mapping from input file names to final neutrino PDG codes.
std::vector< double > ReturnKinematicParameterBinning(const int Sample, const std::string &KinematicParameter) const final
Return the binning used to draw a kinematic parameter.
void InitialiseNuOscillatorObjects()
including Dan's magic NuOscillator
const std::unordered_map< std::string, int > * KinematicParameters
Mapping between string and kinematic enum.
const TLegend * ReturnStackHistLegend() const
Return the legend used for stacked histograms with sample info.
std::unordered_map< std::string, double > _modeNomWeightMap
void CheckEmptyBins() const
Loop over bins and checks if there are any which have 0 entries.
std::string ReturnStringFromKinematicVector(const int KinematicVariable) const
JM: Convert a kinematic vector integer ID to its corresponding name as a string.
bool IsEventSelected(const int iSample, const int iEvent) _noexcept_
DB Function which determines if an event is selected based on KinematicCut.
void SaveAdditionalInfo(TDirectory *Dir) final
Store additional info in a chain.
std::vector< std::unique_ptr< TH2 > > ReturnHistsBySelection2D(const int iSample, const std::string &KinematicProjectionX, const std::string &KinematicProjectionY, const SamplePlotType Selection1, const int Selection2=-1, const int WeightStyle=0)
virtual void PrepFunctionalParameters()
Update the functional parameter values to the latest proposed values. Needs to be called before every...
std::unordered_map< std::string, NuPDG > FileToInitPDGMap
Mapping from input file names to initial neutrino PDG codes.
void SetSplinePointers()
Set pointers for each event to appropriate weights, for unbinned based on event number while for binn...
std::unique_ptr< BinningHandler > Binning
KS: This stores binning information, in future could be come vector to store binning for every used s...
ParameterHandlerGeneric * ParHandler
ETA - All experiments will need an xsec, det and osc cov.
NuPDG GetInitPDGFromFileName(const std::string &FileName) const
Retrieve the initial neutrino PDG code associated with a given input file name.
bool UpdateW2
KS:Super hacky to update W2 or not.
const std::unordered_map< int, std::string > * ReversedKinematicVectors
std::string GetSampleName(const int iSample) const
Sample name tag used only for getting relevant uncertainties.
void Fill1DSubEventHist(const int iSample, TH1D *_h1DVar, const std::string &ProjectionVar, const std::vector< KinematicCut > &SubEventSelectionVec={}, int WeightStyle=0)
Fill projection histogram by looping over all events, and skipping one which doesn't pass specified c...
virtual void SetupMC()=0
Function which translates experiment struct into core struct.
virtual void InititialiseData()=0
Function responsible for loading data from file or loading from file.
virtual void CalcWeightFunc([[maybe_unused]] const int iEvent)
Calculate weights for function parameters.
unsigned int GetNEvents() const
Return total number of events.
virtual void ApplyShifts(const int iEvent)
ETA - generic function applying shifts.
void Initialise()
Function which does a lot of the lifting regarding the workflow in creating different MC objects.
virtual void SetupSplines()=0
initialise your splineXX object and then use InitialiseSplineObject to conveniently setup everything ...
M3::detail::Functional functional
Helper object for storing/updating information related to functional shift parameters.
virtual void RegisterFunctionalParameters()
HH - a experiment-specific function where the maps to actual functions are set up.
double GetSampleLikelihood(const int iSample) const override
Get likelihood (-logL) for a single sample.
void SetupReweightArrays()
Initialise data, MC and W2 histograms.
virtual void AddAdditionalWeightPointers()=0
DB Function to determine which weights apply to which types of samples.
void Fill2DSubEventHist(const int iSample, TH2 *_h2DVar, const std::string &ProjectionVarX, const std::string &ProjectionVarY, const std::vector< KinematicCut > &SubEventSelectionVec={}, int WeightStyle=0)
Fill projection histogram by looping over all events, and skipping one which doesn't pass specified c...
void FillHist(const int Sample, TH1 *Hist, std::vector< double > &Array)
Fill a histogram with the event-level information used in the fit.
virtual int SetupExperimentMC()=0
Experiment specific setup, returns the number of events which were loaded.
void FindNominalBinAndEdges()
Functions which find the nominal bin and bin edges.
const M3::float_t * GetNuOscillatorPointers(const int iEvent) const
Get pointer to NuOscillator weight for a given event.
std::string GetName() const final
Get name for Sample Handler.
virtual void FinaliseShifts([[maybe_unused]] const int iEvent)
LP - Optionally calculate derived observables after all shifts have been applied.
std::vector< SplineIndex > GetSplineBins(int Event, BinnedSplineHandler *BinnedSpline, bool &ThrowCrititcal) const
Retrieve the spline bin indices associated with a given event.
virtual void ResetShifts([[maybe_unused]] const int iEvent)
HH - reset the shifted values to the original values.
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 ...
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
int GetSampleIndex(const std::string &SampleTitle) const
Get index of sample based on name.
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...
TLegend * THStackLeg
DB: Legend associated with stacked histograms produced by this class.
void AddData(const int Sample, TH1 *Data)
DB: Add data for a given sample from a ROOT histogram.
void SetupNuOscillatorPointers()
Initialise pointer to oscillation weight to NuOscillator object.
double ReturnKinematicParameter(const std::string &KinematicParameter, int iEvent) const
Return the value of an associated kinematic parameter for an event.
std::vector< double > GetDataArray(const int Sample) const
Return array storing data entries for every bin.
std::unique_ptr< THStack > ReturnStackedHistBySelection1D(const int iSample, const std::string &KinematicProjection, const SamplePlotType Selection1, const int Selection2=-1, const int WeightStyle=0)
double GetLikelihood() const override
Return likelihood (-LogL) for all samples.
unsigned int nEvents
Number of MC events are there.
std::vector< EventInfo > MCEvents
Stores information about every MC event.
M3::float_t CalcWeightTotal(const EventInfo *_restrict_ MCEvent) const _noexcept_
Calculate the total weight weight for a given event.
std::vector< double > GetMCArray(const int Sample) const
Return array storing MC entries for every bin.
auto GetDataArray() const
Return array storing data entries for every bin.
std::unique_ptr< SplineBase > SplineHandler
Contains all your splines (binned or unbinned) and handles the setup and the returning of weights fro...
std::vector< SampleInfo > SampleDetails
Stores info about currently initialised sample.
int GetNOscChannels(const int iSample) const final
Get number of oscillation channels for a single sample.
std::vector< std::unique_ptr< TH1 > > ReturnHistsBySelection1D(const int iSample, const std::string &KinematicProjection, const SamplePlotType Selection1, const int Selection2=-1, const int WeightStyle=0)
void CalcNormsBins(std::vector< std::vector< NormParameter >> &norm_parameters, std::vector< std::vector< int > > &norms_bins)
Check whether a normalisation systematic affects an event or not.
std::unique_ptr< TH2 > Get2DVarHist(const int iSample, const std::string &ProjectionVarX, const std::string &ProjectionVarY, const std::vector< KinematicCut > &EventSelectionVec={}, int WeightStyle=0, const std::vector< KinematicCut > &SubEventSelectionVec={}) final
Build a 2D projection of MC events into specified variables.
void LoadSingleSample(const int iSample, const YAML::Node &Settings)
Initialise single sample from config file.
std::vector< double > SampleHandler_data
DB Array to be filled in AddData.
std::vector< double > SampleHandler_array_w2
KS Array used for MC stat.
int GetRangeForPlotType(const SamplePlotType TypeEnum, const int iSample) const
KS: Return range for plot type, for example number of modes, osc channels etc.
void PrintRates(const bool DataOnly=false) final
Helper function to print rates for the samples with LLH.
void Reweight() override
main routine modifying MC prediction based on proposed parameter values
std::string ReturnStringFromKinematicParameter(const int KinematicVariable) const
ETA function to generically convert a kinematic type from param handler to a string.
double GetSampleIntegral(const int iSample, const std::vector< KinematicCut > &EventSelectionVec, int WeightStyle)
Print number of events for a given sample with specified cuts.
std::vector< double > ReturnSampleIntegralBySelection(const int iSample, const SamplePlotType Selection1, const int Selection2, const int WeightStyle)
Return sample integral after for given sample with specified restriction like only single mode.
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) final
Build a 2D histogram for given variables, optionally filtered by mode and channel.
std::unique_ptr< TH1 > Get1DVarHist(const int iSample, const std::string &ProjectionVar, const std::vector< KinematicCut > &EventSelectionVec={}, int WeightStyle=0, const std::vector< KinematicCut > &SubEventSelectionVec={}) final
Return 1D projection of MC into given 1D variable (doesn't have to be variable used in the fit)
void SetupOscParameters()
Setup the osc parameters.
int ReturnKinematicParameterFromString(const std::string &KinematicStr) const
ETA function to generically convert a string from param handler to a kinematic type.
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.
std::vector< double > GetArrayForSample(const int Sample, std::vector< double > const &array) const
Return a sub-array for a given sample.
const double * GetPointerToKinematicParameter(const std::string &KinematicParameter, int iEvent) const
std::vector< double > SampleHandler_array
DB Array to be filled after reweighting.
virtual std::vector< double > ReturnKinematicVector([[maybe_unused]] const int KinematicVariable, [[maybe_unused]] const int iEvent) const
int ReturnKinematicVectorFromString(const std::string &KinematicStr) const
JM: Convert a kinematic vector name to its corresponding integer ID.
auto GetMCArray() const
Return array storing MC entries for every bin.
const TH1 * GetMCHist(const int Sample) final
Get MC histogram.
virtual double ReturnKinematicParameter(const int KinematicVariable, const int iEvent) const =0
Return the value of an associated kinematic parameter for an event.
void FillArray()
Function which does the core reweighting. This assumes that oscillation weights have already been cal...
auto GetW2Array() const
Return array storing W2 entries for every bin.
std::string GetSampleTitle(const int iSample) const final
Get fancy title for specified samples.
bool FirstTimeW2
KS:Super hacky to update W2 or not.
Class responsible for handling implementation of samples used in analysis, reweighting and returning ...
Base class for calculating weight from spline.
Definition: SplineBase.h:30
Main namespace for MaCh3 software.
double float_t
Definition: Core.h:37
Stores info about each MC event used during reweighting routine.
Definition: EventInfo.h:13
KS: Small struct used for applying kinematic cuts.
Helper object for storing/updating information related to functional shift parameters.
KS: Store info about MC sample.
Definition: SampleInfo.h:40