Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-12-16 10:29:45

0001 // @(#)root/roostats:$Id$
0002 // Author: Kyle Cranmer, Sven Kreiss   23/05/10
0003 /*************************************************************************
0004  * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers.               *
0005  * All rights reserved.                                                  *
0006  *                                                                       *
0007  * For the licensing terms see $ROOTSYS/LICENSE.                         *
0008  * For the list of contributors see $ROOTSYS/README/CREDITS.             *
0009  *************************************************************************/
0010 
0011 #ifndef ROOSTATS_HypoTestCalculatorGeneric
0012 #define ROOSTATS_HypoTestCalculatorGeneric
0013 
0014 
0015 #ifndef ROOT_Rtypes
0016 #include "Rtypes.h" // necessary for TNamed
0017 #endif
0018 
0019 #include "RooStats/HypoTestCalculator.h"
0020 
0021 #include "RooStats/ModelConfig.h"
0022 
0023 #include "RooStats/TestStatistic.h"
0024 
0025 #include "RooStats/TestStatSampler.h"
0026 
0027 #include "RooStats/SamplingDistribution.h"
0028 
0029 #include "RooStats/HypoTestResult.h"
0030 
0031 
0032 namespace RooStats {
0033 
0034    class HypoTestCalculatorGeneric : public HypoTestCalculator {
0035 
0036    public:
0037       HypoTestCalculatorGeneric(
0038                         const RooAbsData &data,
0039                         const ModelConfig &altModel,
0040                         const ModelConfig &nullModel,
0041                         TestStatSampler* sampler=nullptr
0042       );
0043 
0044 
0045       ~HypoTestCalculatorGeneric() override;
0046 
0047       /// inherited methods from HypoTestCalculator interface
0048       HypoTestResult* GetHypoTest() const override;
0049 
0050       /// set the model for the null hypothesis (only B)
0051       void SetNullModel(const ModelConfig &nullModel) override { fNullModel = &nullModel; }
0052       const RooAbsData * GetData(void) const { return fData; }
0053       const ModelConfig* GetNullModel(void) const { return fNullModel; }
0054       virtual const RooArgSet* GetFitInfo() const { return nullptr; }
0055       /// Set the model for the alternate hypothesis  (S+B)
0056       void SetAlternateModel(const ModelConfig &altModel) override { fAltModel = &altModel; }
0057       const ModelConfig* GetAlternateModel(void) const { return fAltModel; }
0058       /// Set the DataSet
0059       void SetData(RooAbsData &data) override { fData = &data; }
0060 
0061       /// Returns instance of TestStatSampler. Use to change properties of
0062       /// TestStatSampler, e.g. GetTestStatSampler.SetTestSize(double size);
0063       TestStatSampler* GetTestStatSampler(void) const { return fTestStatSampler; }
0064 
0065       /// Set this for re-using always the same toys for alternate hypothesis in
0066       /// case of calls at different null parameter points
0067       /// This is useful to get more stable bands when running the HypoTest inversion
0068       void UseSameAltToys();
0069 
0070 
0071    protected:
0072       // should return zero (to be used later for conditional flow)
0073       virtual int CheckHook(void) const { return 0; }
0074       virtual int PreNullHook(RooArgSet* /*parameterPoint*/, double /*obsTestStat*/) const { return 0; }
0075       virtual int PreAltHook(RooArgSet* /*parameterPoint*/, double /*obsTestStat*/) const { return 0; }
0076       virtual void PreHook() const { }
0077       virtual void PostHook() const { }
0078 
0079    protected:
0080       const ModelConfig *fAltModel;
0081       const ModelConfig *fNullModel;
0082       const RooAbsData *fData;
0083       TestStatSampler *fTestStatSampler;
0084       TestStatSampler *fDefaultSampler;
0085       TestStatistic *fDefaultTestStat;
0086 
0087       unsigned int fAltToysSeed;   // to have same toys for alternate
0088 
0089    private:
0090       void SetupSampler(const ModelConfig& model) const;
0091       void SetAdaptiveLimits(double obsTestStat, bool forNull) const;
0092       SamplingDistribution* GenerateSamplingDistribution(
0093          ModelConfig *thisModel,
0094          double obsTestStat,
0095          RooAbsPdf *impDens=nullptr,
0096          const RooArgSet *impSnapshot=nullptr
0097       ) const;
0098 
0099 
0100    protected:
0101    ClassDefOverride(HypoTestCalculatorGeneric,0)
0102 };
0103 }
0104 
0105 #endif