MaCh3  2.2.3
Reference Guide
SampleHandlerBase.h
Go to the documentation of this file.
1 #pragma once
2 
3 //C++ includes
4 #include <assert.h>
5 
6 //MaCh3 includes
9 #include "Manager/Manager.h"
10 #include "Manager/MaCh3Modes.h"
11 
13 //ROOT includes
14 #include "TTree.h"
15 #include "TH1D.h"
16 #include "TH2D.h"
17 #include "TMath.h"
18 #include "TFile.h"
19 #include "TROOT.h"
20 #include "TRandom3.h"
21 #include "TString.h"
23 
26 {
27  public:
31  virtual ~SampleHandlerBase();
32 
35 
38 
40  virtual inline M3::int_t GetNsamples(){ return nSamples; };
42  virtual inline std::string GetTitle()const {return "SampleHandler";};
44  virtual std::string GetSampleName(int Sample) const = 0;
46  virtual inline double GetSampleLikelihood(const int isample){(void) isample; return GetLikelihood();};
48  virtual void CleanMemoryBeforeFit() = 0;
50  virtual void SaveAdditionalInfo(TDirectory* Dir) {(void) Dir;};
53  MaCh3Modes* GetMaCh3Modes() const { return Modes.get(); }
54 
55  virtual void Reweight()=0;
57  virtual double GetLikelihood() = 0;
58 
60  unsigned int GetNEvents() const {return nEvents;}
62  virtual int GetNOscChannels(){ return 1; }
63 
64  // WARNING KS: Needed for sigma var
65  virtual void SetupBinning(const M3::int_t Selection, std::vector<double> &BinningX, std::vector<double> &BinningY){
66  (void) Selection; (void) BinningX; (void) BinningY; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented");}
67  virtual TH1* GetData(const int Selection) { (void) Selection; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented"); }
68  virtual TH2Poly* GetW2(const int Selection){ (void) Selection; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented");}
69  virtual TH1* GetPDF(const int Selection){ (void) Selection; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented");}
70  virtual inline TH1* GetPDFMode(const int Selection, const int Mode) {
71  (void) Selection; (void) Mode; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented"); }
72  virtual inline std::string GetKinVarLabel(const int sample, const int Dimension) {
73  (void) sample; (void) Dimension; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented"); };
74 
75 
80  double GetPoissonLLH(const double data, const double mc) const;
81 
167  double GetTestStatLLH(const double data, const double mc, const double w2) const;
168 
172  inline void SetTestStatistic(TestStatistic testStat){ fTestStatistic = testStat; }
173 
174 protected:
176  void QuietPlease();
178  void NowTalk();
179 
181  template <typename T>
182  bool MatchCondition(const std::vector<T>& allowedValues, const T& value) {
183  if (allowedValues.empty()) {
184  return true; // Apply to all if no specific values are specified
185  }
186  return std::find(allowedValues.begin(), allowedValues.end(), value) != allowedValues.end();
187  }
188 
191 
193  std::streambuf *buf;
195  std::streambuf *errbuf;
196 
199 
201  unsigned int nEvents;
202 
204  std::unique_ptr<MaCh3Modes> Modes;
205 };
#define _MaCh3_Safe_Include_Start_
KS: Avoiding warning checking for headers.
Definition: Core.h:109
#define _MaCh3_Safe_Include_End_
KS: Restore warning checking after including external headers.
Definition: Core.h:120
TestStatistic
Make an enum of the test statistic that we're using.
Custom exception class for MaCh3 errors.
KS: Class describing MaCh3 modes used in the analysis, it is being initialised from config.
Definition: MaCh3Modes.h:41
Class responsible for handling implementation of samples used in analysis, reweighting and returning ...
virtual ~SampleHandlerBase()
destructor
virtual void SetupBinning(const M3::int_t Selection, std::vector< double > &BinningX, std::vector< double > &BinningY)
virtual TH1 * GetPDFMode(const int Selection, const int Mode)
void NowTalk()
CW: Redirect std::cout to silence some experiment specific libraries.
std::unique_ptr< MaCh3Modes > Modes
Holds information about used Generator and MaCh3 modes.
virtual void Reweight()=0
virtual TH2Poly * GetW2(const int Selection)
std::streambuf * buf
Keep the cout buffer.
SampleHandlerBase()
The main constructor.
std::streambuf * errbuf
Keep the cerr buffer.
TestStatistic fTestStatistic
Test statistic tells what kind of likelihood sample is using.
virtual std::string GetKinVarLabel(const int sample, const int Dimension)
virtual TH1 * GetData(const int Selection)
M3::int_t nSamples
Contains how many samples we've got.
unsigned int nEvents
Number of MC events are there.
virtual void CleanMemoryBeforeFit()=0
Allow to clean not used memory before fit starts.
virtual void SaveAdditionalInfo(TDirectory *Dir)
Store additional info in a chan.
bool MatchCondition(const std::vector< T > &allowedValues, const T &value)
check if event is affected by following conditions, for example pdg, or modes etc
void QuietPlease()
CW: Redirect std::cout to silence some experiment specific libraries.
virtual TH1 * GetPDF(const int Selection)
virtual std::string GetSampleName(int Sample) const =0
void SetTestStatistic(TestStatistic testStat)
Set the test statistic to be used when calculating the binned likelihoods.
virtual double GetSampleLikelihood(const int isample)
MaCh3Modes * GetMaCh3Modes() const
Return pointer to MaCh3 modes.
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....
virtual double GetLikelihood()=0
unsigned int GetNEvents() const
virtual std::string GetTitle() const
virtual M3::int_t GetNsamples()
double GetPoissonLLH(const double data, const double mc) const
Calculate test statistic for a single bin using Poisson.
virtual int GetNOscChannels()
int int_t
Definition: Core.h:31