MaCh3  2.5.0
Reference Guide
SampleHandlerBase.h
Go to the documentation of this file.
1 #pragma once
2 
3 //MaCh3 includes
10 
12 #include "THStack.h"
13 #include "TLegend.h"
15 
22 {
23  public:
24  //######################################### Functions #########################################
27  SampleHandlerBase(std::string ConfigFileName, ParameterHandlerGeneric* xsec_cov,
28  const std::shared_ptr<OscillationHandler>& OscillatorObj_ = nullptr);
30  virtual ~SampleHandlerBase();
31 
34  int GetNDim(const int Sample) const final { return SampleDetails[Sample].nDimensions; }
36  std::string GetName() const final;
38  std::string GetSampleTitle(const int Sample) const final {return SampleDetails[Sample].SampleTitle;}
39 
43  std::string GetKinVarName(const int iSample, const int Dimension) const final;
44 
46  void PrintIntegral(const int iSample, const TString& OutputName="/dev/null", const int WeightStyle=0, const TString& OutputCSVName="/dev/null");
47 
48  //===============================================================================
49  // DB Reweighting and Likelihood functions
50 
51  //ETA - abstract these to SampleHandlerBase
52  //DB Require these four functions to allow conversion from TH1(2)D to array for multi-threaded GetLikelihood
53  void AddData(const int Sample, TH1* Data);
54  void AddData(const int Sample, const std::vector<double>& Data_Array);
55 
58  void PrintRates(const bool DataOnly = false) final;
60  double GetLikelihood() const override;
62  double GetSampleLikelihood(const int isample) const override;
63  //===============================================================================
64 
67  int GetSampleIndex(const std::string& SampleTitle) const;
68 
70  const TH1* GetDataHist(const int Sample) final;
71  const TH1* GetDataHist(const std::string& Sample);
72 
74  const TH1* GetMCHist(const int Sample) final;
75  const TH1* GetMCHist(const std::string& Sample);
76 
78  const TH1* GetW2Hist(const int Sample) final;
79  const TH1* GetW2Hist(const std::string& Sample);
81  void Reweight() override;
83  M3::float_t GetEventWeight(const int iEntry);
84 
85  const M3::float_t* GetNuOscillatorPointers(const int iEvent) const;
86 
88  int GetNOscChannels(const int iSample) const final {return static_cast<int>(SampleDetails[iSample].OscChannels.size());};
89 
90  std::string GetFlavourName(const int iSample, const int iChannel) const final {
91  if (iChannel < 0 || iChannel > GetNOscChannels(iSample)) {
92  MACH3LOG_ERROR("Invalid Channel Requested: {}", iChannel);
93  throw MaCh3Exception(__FILE__ , __LINE__);
94  }
95  return SampleDetails[iSample].OscChannels[iChannel].flavourName;
96  }
97  std::unique_ptr<TH1> Get1DVarHist(const int iSample, const std::string &ProjectionVar,
98  const std::vector<KinematicCut> &EventSelectionVec = {}, int WeightStyle = 0,
99  const std::vector<KinematicCut> &SubEventSelectionVec = {}) final;
100  std::unique_ptr<TH2> Get2DVarHist(const int iSample, const std::string& ProjectionVarX, const std::string& ProjectionVarY,
101  const std::vector< KinematicCut >& EventSelectionVec = {},
102  int WeightStyle = 0, const std::vector< KinematicCut >& SubEventSelectionVec = {}) final;
103  std::vector<KinematicCut> BuildModeChannelSelection(const int iSample, const int kModeToFill, const int kChannelToFill) const;
104 
105  void Fill1DSubEventHist(const int iSample, TH1D* _h1DVar, const std::string& ProjectionVar,
106  const std::vector< KinematicCut >& SubEventSelectionVec = {},
107  int WeightStyle=0);
108  void Fill2DSubEventHist(const int iSample, TH2* _h2DVar, const std::string& ProjectionVarX, const std::string& ProjectionVarY,
109  const std::vector< KinematicCut >& SubEventSelectionVec = {}, int WeightStyle = 0);
110 
111  std::unique_ptr<TH1> Get1DVarHistByModeAndChannel(const int iSample, const std::string& ProjectionVar_Str,
112  const int kModeToFill = -1, const int kChannelToFill = -1,
113  const int WeightStyle = 0) final;
114  std::unique_ptr<TH2> Get2DVarHistByModeAndChannel(const int iSample, const std::string& ProjectionVar_StrX,
115  const std::string& ProjectionVar_StrY, const int kModeToFill = -1,
116  const int kChannelToFill = -1, const int WeightStyle = 0) final;
117 
118  std::unique_ptr<TH1> GetModeHist1D(const int iSample, int s, int m, int style = 0) {
119  return Get1DVarHistByModeAndChannel(iSample, GetKinVarName(iSample, 0), m, s, style);
120  }
121  std::unique_ptr<TH2> GetModeHist2D(const int iSample, int s, int m, int style = 0) {
122  return Get2DVarHistByModeAndChannel(iSample, GetKinVarName(iSample, 0), GetKinVarName(iSample, 1), m, s, style);
123  }
124 
125  std::vector<std::unique_ptr<TH1>> ReturnHistsBySelection1D(const int iSample, const std::string& KinematicProjection,
126  const int Selection1, const int Selection2 = -1,
127  const int WeightStyle = 0);
128  std::vector<std::unique_ptr<TH2>> ReturnHistsBySelection2D(const int iSample, const std::string& KinematicProjectionX,
129  const std::string& KinematicProjectionY,
130  const int Selection1, const int Selection2=-1,
131  const int WeightStyle=0);
132  std::unique_ptr<THStack> ReturnStackedHistBySelection1D(const int iSample, const std::string& KinematicProjection,
133  const int Selection1, const int Selection2 = -1, const int WeightStyle = 0);
135  const TLegend* ReturnStackHistLegend() const {return THStackLeg;}
136 
138  int ReturnKinematicParameterFromString(const std::string& KinematicStr) const;
140  std::string ReturnStringFromKinematicParameter(const int KinematicVariable) const;
141 
143  void SaveAdditionalInfo(TDirectory* Dir) final;
144 
146  int ReturnKinematicVectorFromString(const std::string& KinematicStr) const;
148  std::string ReturnStringFromKinematicVector(const int KinematicVariable) const;
150  bool IsSubEventVarString(const std::string& VarStr) const;
151 
153  auto GetDataArray() const {
154  return SampleHandler_data;
155  }
157  auto GetMCArray() const {
158  return SampleHandler_array;
159  }
161  auto GetW2Array() const {
162  return SampleHandler_array_w2;
163  }
165  std::vector<double> GetArrayForSample(const int Sample, std::vector<double> const & array) const;
166 
168  std::vector<double> GetDataArray(const int Sample) const {
169  return GetArrayForSample(Sample, SampleHandler_data);
170  }
172  std::vector<double> GetMCArray(const int Sample) const {
173  return GetArrayForSample(Sample, SampleHandler_array);
174  }
176  std::vector<double> GetW2Array(const int Sample) const {
178  }
179 
180  protected:
186  void ReadConfig();
188  void LoadSingleSample(const int iSample, const YAML::Node& Settings);
189 
191  virtual void AddAdditionalWeightPointers() = 0;
192 
194  void SetupKinematicMap();
195 
198  virtual void SetupSplines() = 0;
199 
200  //DB Require all objects to have a function which reads in the MC
202  virtual void Init() = 0;
203 
205  virtual int SetupExperimentMC() = 0;
206 
208  virtual void SetupMC() = 0;
210  virtual void InititialiseData() = 0;
211 
213  void Initialise();
214 
216  std::unique_ptr<SplineBase> SplineHandler;
217 
219  std::shared_ptr<OscillationHandler> Oscillator;
220  //===============================================================================
223  void SetSplinePointers();
226  std::vector< std::vector<int> > GetSplineBins(int Event, BinnedSplineHandler* BinnedSpline, bool& ThrowCrititcal) const;
227 
228  //Functions which find the nominal bin and bin edges
229  void FindNominalBinAndEdges();
230 
232  void SetBinning();
233 
235  void SetupReweightArrays();
236  //===============================================================================
237 
238  // ----- Functional Parameters -----
240  virtual void SetupFunctionalParameters();
242  void RegisterIndividualFunctionalParameter(const std::string& fpName, int fpEnum, FuncParFuncType fpFunc);
244  virtual void RegisterFunctionalParameters() = 0;
246  virtual void PrepFunctionalParameters(){};
248  virtual void ApplyShifts(const int iEvent);
249 
251  bool IsEventSelected(const int iSample, const int iEvent) _noexcept_;
253  bool IsSubEventSelected(const std::vector<KinematicCut> &SubEventCuts, const int iEvent, unsigned const int iSubEvent, size_t nsubevents);
255  virtual void ResetShifts(const int iEvent) {(void)iEvent;};
260  virtual void FinaliseShifts(const int iEvent) {(void)iEvent;};
262  std::vector<std::vector<FunctionalShifter*>> funcParsGrid;
267  std::vector<FunctionalShifter> funcParsMap;
268 
271 
273  std::vector<FunctionalParameter> funcParsVec;
276  std::unordered_map<std::string, int> funcParsNamesMap;
279  std::unordered_map<int, FuncParFuncType> funcParsFuncMap;
281  std::vector<std::string> funcParsNamesVec = {};
282 
284  void CalcNormsBins(std::vector<NormParameter>& norm_parameters, std::vector< std::vector< int > >& norms_bins);
285  template <typename ParT> bool PassesSelection(const ParT& Par, std::size_t iEvent);
288 
294  virtual void CalcWeightFunc(const int iEvent) {return; (void)iEvent;};
295 
297  double ReturnKinematicParameter(const std::string& KinematicParameter, int iEvent) const {
298  return ReturnKinematicParameter(ReturnKinematicParameterFromString(KinematicParameter), iEvent);
299  }
300  virtual double ReturnKinematicParameter(const int KinematicVariable, const int iEvent) const = 0;
301 
302  // === JM declare the same functions for kinematic vectors ===
303  std::vector<double> ReturnKinematicVector(const std::string& KinematicParameter, const int iEvent) const {
304  return ReturnKinematicVector(ReturnKinematicVectorFromString(KinematicParameter), iEvent);
305  }
306  virtual std::vector<double> ReturnKinematicVector(const int KinematicVariable, const int iEvent) const {
307  return {}; (void)KinematicVariable; (void)iEvent;};
308  // ===========================================================
309 
311  std::vector<double> ReturnKinematicParameterBinning(const int Sample, const std::string &KinematicParameter) const final;
312 
313  const double* GetPointerToKinematicParameter(const std::string& KinematicParameter, int iEvent) const {
314  return GetPointerToKinematicParameter(ReturnKinematicParameterFromString(KinematicParameter), iEvent);
315  }
316  virtual const double* GetPointerToKinematicParameter(const int KinematicVariable, const int iEvent) const = 0;
317 
319  const double* GetPointerToOscChannel(const int iEvent) const;
321  void SetupNormParameters();
323  void SetupOscParameters();
324  //===============================================================================
329  void FillHist(const int Sample, TH1* Hist, std::vector<double> &Array);
330 
332 #ifdef MULTITHREAD
335  void FillArray_MP();
336 #endif
339  void FillArray();
340 
342  void ResetHistograms();
343 
344  //===============================================================================
345  //DB Variables required for GetLikelihood
347  std::unique_ptr<BinningHandler> Binning;
349  std::vector<double> SampleHandler_array;
351  std::vector<double> SampleHandler_array_w2;
353  std::vector<double> SampleHandler_data;
354  //===============================================================================
355 
356  //===============================================================================
358  std::vector<EventInfo> MCEvents;
360  std::vector<SampleInfo> SampleDetails;
361  //===============================================================================
362 
363  //===============================================================================
364  //DB Covariance Objects
367 
368  //===============================================================================
370  std::string SampleHandlerName;
371 
372  //===========================================================================
373  //DB Vectors to store which kinematic cuts we apply
374  //like in XsecNorms but for events in sample. Read in from sample yaml file
375  //What gets used in IsEventSelected, which gets set equal to user input plus
376  //all the vectors in StoreSelection
377 
380  std::vector< std::vector< KinematicCut > > StoredSelection;
383  std::vector< std::vector< KinematicCut > > Selection;
384  //===========================================================================
385 
387  const std::unordered_map<std::string, int>* KinematicParameters;
389  const std::unordered_map<int, std::string>* ReversedKinematicParameters;
390 
391  // === JM mapping between string and kinematic vector enum ===
392  const std::unordered_map<std::string, int>* KinematicVectors;
393  const std::unordered_map<int, std::string>* ReversedKinematicVectors;
394  // ===========================================================
395 
397  std::unique_ptr<Manager> SampleManager;
398  void InitialiseSplineObject();
399 
400  std::unordered_map<std::string, double> _modeNomWeightMap;
401 
402  //===============================================================================
404  TLegend* THStackLeg = nullptr;
405  //===============================================================================
406 
410  bool UpdateW2;
411 
413  NuPDG GetInitPDGFromFileName(const std::string& FileName) const {return FileToInitPDGMap.at(FileName);}
415  NuPDG GetFinalPDGFromFileName(const std::string& FileName) const {return FileToFinalPDGMap.at(FileName);}
416 
417  private:
420  std::vector<std::vector<KinematicCut>> ApplyTemporarySelection(const int iSample,
421  const std::vector<KinematicCut>& ExtraCuts);
422 
423  std::unordered_map<std::string, NuPDG> FileToInitPDGMap;
424  std::unordered_map<std::string, NuPDG> FileToFinalPDGMap;
425 
426  enum FDPlotType {
428  kOscChannelPlot = 1
429  };
430 };
#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_
KS: Restore warning checking after including external headers.
Definition: Core.h:141
#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
std::function< void(const M3::float_t *, std::size_t)> FuncParFuncType
HH - a shorthand type for funcpar functions.
NuPDG
Enum to track the incoming neutrino species.
Definition: SampleStructs.h:94
Bin-by-bin class calculating response for spline parameters.
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 ...
std::vector< double > ReturnKinematicVector(const std::string &KinematicParameter, const int iEvent) const
virtual ~SampleHandlerBase()
destructor
std::string SampleHandlerName
A unique ID for each sample based on which we can define what systematic should be applied.
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
void SetBinning()
set the binning for 2D sample used for the likelihood calculation
std::unique_ptr< TH1 > GetModeHist1D(const int iSample, int s, int m, int style=0)
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.
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)
std::unordered_map< std::string, int > funcParsNamesMap
HH - a map that relates the name of the functional parameter to funcpar enum.
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
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.
virtual void FinaliseShifts(const int iEvent)
LP - Optionally calculate derived observables after all shifts have been applied.
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
What gets pulled from config options, these are constant after loading in this is of length 3: 0th in...
virtual void Init()=0
Initialise any variables that your experiment specific SampleHandler needs.
const TH1 * GetDataHist(const int Sample) final
Get Data histogram.
std::string GetFlavourName(const int iSample, const int iChannel) const final
std::unordered_map< std::string, NuPDG > FileToFinalPDGMap
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
virtual std::vector< double > ReturnKinematicVector(const int KinematicVariable, const int iEvent) const
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 FillArray_MP()
DB Nice new multi-threaded function which calculates the event weights and fills the relevant bins of...
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 chan.
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
std::vector< std::string > funcParsNamesVec
HH - a vector of string names for each functional parameter.
void SetSplinePointers()
Set pointers for each event to appropriate weights, for unbinned based on event number while for binn...
SampleHandlerBase(std::string ConfigFileName, ParameterHandlerGeneric *xsec_cov, const std::shared_ptr< OscillationHandler > &OscillatorObj_=nullptr)
Constructor.
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.
M3::float_t GetEventWeight(const int iEntry)
Computes the total event weight for a given entry.
bool UpdateW2
KS:Super hacky to update W2 or not.
const std::unordered_map< int, std::string > * ReversedKinematicVectors
std::vector< FunctionalShifter > funcParsMap
HH - a map that relates the funcpar enum to pointer of FuncPars struct HH - Changed to a vector of po...
void Fill1DSubEventHist(const int iSample, TH1D *_h1DVar, const std::string &ProjectionVar, const std::vector< KinematicCut > &SubEventSelectionVec={}, int WeightStyle=0)
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 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 conviently setup everything up
double GetSampleLikelihood(const int isample) const override
Get likelihood for single sample.
virtual void ResetShifts(const int iEvent)
HH - reset the shifted values to the original values.
std::vector< std::vector< FunctionalShifter * > > funcParsGrid
HH - a grid of vectors of enums for each sample and event.
void CalcNormsBins(std::vector< NormParameter > &norm_parameters, std::vector< std::vector< int > > &norms_bins)
Check whether a normalisation systematic affects an event or not.
void SetupReweightArrays()
Initialise data, MC and W2 histograms.
std::vector< std::unique_ptr< TH1 > > ReturnHistsBySelection1D(const int iSample, const std::string &KinematicProjection, const int Selection1, const int Selection2=-1, const int WeightStyle=0)
std::vector< std::unique_ptr< TH2 > > ReturnHistsBySelection2D(const int iSample, const std::string &KinematicProjectionX, const std::string &KinematicProjectionY, const int Selection1, const int Selection2=-1, const int WeightStyle=0)
void ResetHistograms()
Helper function to reset 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)
void FillHist(const int Sample, TH1 *Hist, std::vector< double > &Array)
Fill a histogram with the event-level information used in the fit.
std::unique_ptr< TH2 > GetModeHist2D(const int iSample, int s, int m, int style=0)
virtual int SetupExperimentMC()=0
Experiment specific setup, returns the number of events which were loaded.
const M3::float_t * GetNuOscillatorPointers(const int iEvent) const
virtual void SetupFunctionalParameters()
ETA - a function to setup and pass values to functional parameters where you need to pass a value to ...
std::string GetName() const final
Get name for Sample Handler.
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...
std::vector< std::vector< int > > GetSplineBins(int Event, BinnedSplineHandler *BinnedSpline, bool &ThrowCrititcal) const
Retrieve the spline bin indices associated with a given event.
TLegend * THStackLeg
DB Miscellaneous Variables.
void AddData(const int Sample, TH1 *Data)
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 int Selection1, const int Selection2=-1, const int WeightStyle=0)
std::unordered_map< int, FuncParFuncType > funcParsFuncMap
HH - a map that relates the funcpar enum to pointer of the actual function.
double GetLikelihood() const override
DB Multi-threaded GetLikelihood.
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::string GetSampleTitle(const int Sample) const final
Get fancy title for specified samples.
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
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.
virtual void RegisterFunctionalParameters()=0
HH - a experiment-specific function where the maps to actual functions are set up.
std::vector< double > SampleHandler_array_w2
KS Array used for MC stat.
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 xsec cov to a string.
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
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
void SetupOscParameters()
Setup the osc parameters.
int ReturnKinematicParameterFromString(const std::string &KinematicStr) const
ETA function to generically convert a string from xsec cov 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.
void RegisterIndividualFunctionalParameter(const std::string &fpName, int fpEnum, FuncParFuncType fpFunc)
HH - a helper function for RegisterFunctionalParameter.
virtual void CalcWeightFunc(const int iEvent)
Calculate weights for function parameters.
const double * GetPointerToKinematicParameter(const std::string &KinematicParameter, int iEvent) const
std::vector< double > SampleHandler_array
DB Array to be filled after reweighting.
int ReturnKinematicVectorFromString(const std::string &KinematicStr) const
JM: Convert a kinematic vector name to its corresponding integer ID.
std::vector< FunctionalParameter > funcParsVec
HH - a vector that stores all the FuncPars struct.
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
void FillArray()
Function which does the core reweighting, fills the SampleHandlerBase::SampleHandler_array vector wit...
auto GetW2Array() const
Return array storing W2 entries for every bin.
bool FirstTimeW2
KS:Super hacky to update W2 or not.
Class responsible for handling implementation of samples used in analysis, reweighting and returning ...
Main namespace for MaCh3 software.
double float_t
Definition: Core.h:37
Stores info about each MC event used during reweighting routine.