File indexing completed on 2025-10-31 09:15:44
0001 
0002 
0003 
0004 
0005 
0006 
0007 
0008 
0009 
0010 
0011 #ifndef ROOSTATS_DebuggingSampler
0012 #define ROOSTATS_DebuggingSampler
0013 
0014 
0015 
0016 
0017 
0018 
0019 
0020 
0021 
0022 
0023 #include "Rtypes.h"
0024 
0025 #include <vector>
0026 
0027 #include "RooStats/TestStatSampler.h"
0028 #include "RooStats/SamplingDistribution.h"
0029 
0030 #include "RooRealVar.h"
0031 #include "TRandom.h"
0032 
0033 namespace RooStats {
0034 
0035  class DebuggingSampler: public TestStatSampler {
0036 
0037    public:
0038      DebuggingSampler() :
0039        fTestStatistic{new RooRealVar("UniformTestStatistic","UniformTestStatistic",0,0,1)},
0040        fRand{new TRandom()}
0041      {}
0042      ~DebuggingSampler() override {
0043        delete fRand;
0044        delete fTestStatistic;
0045      }
0046 
0047      
0048      SamplingDistribution* GetSamplingDistribution(RooArgSet& paramsOfInterest) override  {
0049        (void)paramsOfInterest; 
0050        
0051        std::vector<double> testStatVec;
0052        testStatVec.reserve(1000);
0053 for(Int_t i=0; i<1000; ++i){
0054     testStatVec.push_back( fRand->Uniform() );
0055        }
0056        return new SamplingDistribution("UniformSamplingDist", "for debugging", testStatVec );
0057      }
0058 
0059      
0060      double EvaluateTestStatistic(RooAbsData& , RooArgSet& ) override  {
0061        
0062        
0063        return fRand->Uniform();
0064      }
0065 
0066       
0067       TestStatistic* GetTestStatistic()  const override {
0068          std::cout << "GetTestStatistic() IS NOT IMPLEMENTED FOR THIS SAMPLER. Returning nullptr." << std::endl;
0069          return nullptr; 
0070       }
0071 
0072       
0073       double ConfidenceLevel()  const override {return 1.-fSize;}
0074 
0075       
0076       void Initialize(RooAbsArg& , RooArgSet& , RooArgSet&  ) override {
0077       }
0078 
0079       
0080       void SetPdf(RooAbsPdf&) override {}
0081 
0082       
0083       virtual void SetParameters(RooArgSet&) {}
0084       
0085       void SetNuisanceParameters(const RooArgSet&) override {}
0086       
0087       void SetParametersForTestStat(const RooArgSet& ) override {}
0088       
0089       void SetGlobalObservables(const RooArgSet& ) override {}
0090 
0091 
0092       
0093       void SetTestSize(double size) override {fSize = size;}
0094       
0095       void SetConfidenceLevel(double cl) override {fSize = 1.-cl;}
0096 
0097       
0098       void SetTestStatistic(TestStatistic* ) override {
0099          std::cout << "SetTestStatistic(...) IS NOT IMPLEMENTED FOR THIS SAMPLER" << std::endl;
0100       }
0101 
0102    private:
0103       double fSize;
0104       RooRealVar* fTestStatistic;
0105       TRandom* fRand;
0106 
0107    protected:
0108       ClassDefOverride(DebuggingSampler,1)   
0109    };
0110 }
0111 
0112 
0113 #endif