MaCh3 2.2.1
Reference Guide
Loading...
Searching...
No Matches
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 GetNMCSamples() { return nSamples; }
64 virtual int GetNOscChannels(){ return 1; }
65
66 // WARNING KS: Needed for sigma var
67 virtual void SetupBinning(const M3::int_t Selection, std::vector<double> &BinningX, std::vector<double> &BinningY){
68 (void) Selection; (void) BinningX; (void) BinningY; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented");}
69 virtual TH1* GetData(const int Selection) { (void) Selection; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented"); }
70 virtual TH2Poly* GetW2(const int Selection){ (void) Selection; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented");}
71 virtual TH1* GetPDF(const int Selection){ (void) Selection; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented");}
72 virtual inline TH1* GetPDFMode(const int Selection, const int Mode) {
73 (void) Selection; (void) Mode; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented"); }
74 virtual inline std::string GetKinVarLabel(const int sample, const int Dimension) {
75 (void) sample; (void) Dimension; throw MaCh3Exception(__FILE__ , __LINE__ , "Not implemented"); };
76
81 double GetTestStatLLH(double data, double mc) const;
95 double GetTestStatLLH(const double data, const double mc, const double w2) const;
99 inline void SetTestStatistic(TestStatistic testStat){ fTestStatistic = testStat; }
100
101protected:
103 void QuietPlease();
105 void NowTalk();
106
108 template <typename T>
109 bool MatchCondition(const std::vector<T>& allowedValues, const T& value) {
110 if (allowedValues.empty()) {
111 return true; // Apply to all if no specific values are specified
112 }
113 return std::find(allowedValues.begin(), allowedValues.end(), value) != allowedValues.end();
114 }
115
118
120 std::streambuf *buf;
122 std::streambuf *errbuf;
123
126
128 unsigned int nEvents;
129
131 std::unique_ptr<MaCh3Modes> Modes;
132};
#define _MaCh3_Safe_Include_Start_
KS: Avoiding warning checking for headers.
Definition: Core.h:106
#define _MaCh3_Safe_Include_End_
KS: Restore warning checking after including external headers.
Definition: Core.h:117
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)
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 TH1 * GetPDFMode(const int Selection, const int Mode)
std::streambuf * buf
Keep the cout buffer.
virtual TH1 * GetPDF(const int Selection)
SampleHandlerBase()
The main constructor.
std::streambuf * errbuf
Keep the cerr buffer.
virtual TH2Poly * GetW2(const int Selection)
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 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)
virtual int GetNMCSamples()
virtual double GetLikelihood()=0
unsigned int GetNEvents() const
virtual std::string GetTitle() const
MaCh3Modes * GetMaCh3Modes() const
Return pointer to MaCh3 modes.
double GetTestStatLLH(double data, double mc) const
Calculate test statistic for a single bin using Poisson.
virtual M3::int_t GetNsamples()
virtual int GetNOscChannels()
int int_t
Definition: Core.h:29