File indexing completed on 2025-12-16 10:29:44
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011 #ifndef ROOSTATS_FrequentistCalculator
0012 #define ROOSTATS_FrequentistCalculator
0013
0014
0015 #include "RooStats/HypoTestCalculatorGeneric.h"
0016
0017 #include "RooStats/ToyMCSampler.h"
0018
0019 #include "RooStats/DetailedOutputAggregator.h"
0020
0021 #include "RooFitResult.h"
0022
0023 namespace RooStats {
0024
0025 class FrequentistCalculator : public HypoTestCalculatorGeneric {
0026
0027 public:
0028 FrequentistCalculator(
0029 const RooAbsData &data,
0030 const ModelConfig &altModel,
0031 const ModelConfig &nullModel,
0032 TestStatSampler* sampler=nullptr
0033 ) :
0034 HypoTestCalculatorGeneric(data, altModel, nullModel, sampler),
0035 fNToysNull(-1),
0036 fNToysAlt(-1),
0037 fNToysNullTail(0),
0038 fNToysAltTail(0),
0039 fFitInfo(nullptr),
0040 fStoreFitInfo(false)
0041 {
0042 }
0043
0044 ~FrequentistCalculator() override {
0045 if( fConditionalMLEsNull ) delete fConditionalMLEsNull;
0046 if( fConditionalMLEsAlt ) delete fConditionalMLEsAlt;
0047 if( fFitInfo ) delete fFitInfo;
0048 }
0049
0050
0051
0052 void SetToys(int toysNull, int toysAlt) { fNToysNull = toysNull; fNToysAlt = toysAlt; }
0053
0054
0055 void SetNToysInTails(int toysNull, int toysAlt) { fNToysNullTail = toysNull; fNToysAltTail = toysAlt; }
0056
0057
0058
0059 void SetConditionalMLEsNull( const RooArgSet* c ) {
0060 if( fConditionalMLEsNull ) delete fConditionalMLEsNull;
0061
0062 if( c ) fConditionalMLEsNull = (const RooArgSet*)c->snapshot();
0063 else fConditionalMLEsNull = nullptr;
0064 }
0065
0066
0067
0068 void SetConditionalMLEsAlt( const RooArgSet* c ) {
0069 if( fConditionalMLEsAlt ) delete fConditionalMLEsAlt;
0070
0071 if( c ) fConditionalMLEsAlt = (const RooArgSet*)c->snapshot();
0072 else fConditionalMLEsAlt = nullptr;
0073 }
0074
0075 void StoreFitInfo(bool val = true) {
0076 fStoreFitInfo = val;
0077 }
0078
0079 const RooArgSet* GetFitInfo() const override {
0080 return fFitInfo;
0081 }
0082
0083 protected:
0084
0085 int PreNullHook(RooArgSet *parameterPoint, double obsTestStat) const override;
0086
0087
0088 int PreAltHook(RooArgSet *parameterPoint, double obsTestStat) const override;
0089
0090 void PreHook() const override;
0091 void PostHook() const override;
0092
0093 protected:
0094
0095 const RooArgSet* fConditionalMLEsNull = nullptr;
0096 const RooArgSet* fConditionalMLEsAlt = nullptr;
0097
0098
0099 int fNToysNull;
0100 int fNToysAlt;
0101
0102
0103 int fNToysNullTail;
0104 int fNToysAltTail;
0105
0106 private:
0107 mutable RooArgSet* fFitInfo;
0108 bool fStoreFitInfo;
0109
0110 protected:
0111 ClassDefOverride(FrequentistCalculator,0)
0112 };
0113 }
0114
0115 #endif