Back to home page

EIC code displayed by LXR

 
 

    


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

0001 // @(#)root/roostats:$Id$
0002 // Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
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_FeldmanCousins
0012 #define ROOSTATS_FeldmanCousins
0013 
0014 
0015 #include "Rtypes.h"
0016 
0017 #include "RooStats/IntervalCalculator.h"
0018 
0019 #include "RooStats/ToyMCSampler.h"
0020 #include "RooStats/ConfidenceBelt.h"
0021 #include "RooStats/PointSetInterval.h"
0022 
0023 #include "RooAbsData.h"
0024 #include "RooAbsPdf.h"
0025 #include "RooArgSet.h"
0026 
0027 class RooAbsData;
0028 
0029 namespace RooStats {
0030 
0031    class ConfInterval;
0032 
0033    class FeldmanCousins : public IntervalCalculator {
0034 
0035    public:
0036 
0037      /// Common constructor
0038      FeldmanCousins(RooAbsData& data, ModelConfig& model);
0039 
0040      ~FeldmanCousins() override;
0041 
0042       /// Main interface to get a ConfInterval (will be a PointSetInterval)
0043       PointSetInterval* GetInterval() const override;
0044 
0045       /// Get the size of the test (eg. rate of Type I error)
0046       double Size() const override {return fSize;}
0047       /// Get the Confidence level for the test
0048       double ConfidenceLevel()  const override {return 1.-fSize;}
0049       /// Set the DataSet
0050       void SetData(RooAbsData& /*data*/) override {
0051          std::cout << "DEPRECATED, set data in constructor" << std::endl;
0052       }
0053 
0054       /// User-defined set of points to test
0055       void SetParameterPointsToTest(RooAbsData& pointsToTest) {
0056          fPointsToTest = &pointsToTest;
0057       }
0058 
0059       /// User-defined set of points to test
0060       void SetPOIPointsToTest(RooAbsData& poiToTest) {
0061          fPOIToTest = &poiToTest;
0062       }
0063 
0064       /// set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
0065       void SetTestSize(double size) override {fSize = size;}
0066       /// set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
0067       void SetConfidenceLevel(double cl) override {fSize = 1.-cl;}
0068 
0069       void SetModel(const ModelConfig &) override;
0070 
0071       RooAbsData* GetPointsToScan() {
0072    if(!fPointsToTest) CreateParameterPoints();
0073    return fPointsToTest;
0074       }
0075 
0076       /// Get the confidence belt. This requires that CreateConfBelt() has been set.
0077       ConfidenceBelt* GetConfidenceBelt() {return fConfBelt;}
0078 
0079       void UseAdaptiveSampling(bool flag=true){fAdaptiveSampling=flag;}
0080 
0081       void AdditionalNToysFactor(double fact){fAdditionalNToysFactor = fact;}
0082 
0083       void SetNBins(Int_t bins) {fNbins = bins;}
0084 
0085       void FluctuateNumDataEntries(bool flag=true){fFluctuateData = flag;}
0086 
0087       void SaveBeltToFile(bool flag=true){
0088    fSaveBeltToFile = flag;
0089    if(flag) fCreateBelt = true;
0090       }
0091       void CreateConfBelt(bool flag=true){fCreateBelt = flag;}
0092 
0093       /// Returns instance of TestStatSampler. Use to change properties of
0094       /// TestStatSampler, e.g. GetTestStatSampler.SetTestSize(double size);
0095       TestStatSampler* GetTestStatSampler() const;
0096 
0097 
0098    private:
0099 
0100       /// initializes fPointsToTest data member (mutable)
0101       void CreateParameterPoints() const;
0102 
0103       /// initializes fTestStatSampler data member (mutable)
0104       void CreateTestStatSampler() const;
0105 
0106       double fSize;     ///< size of the test (eg. specified rate of Type I error)
0107       ModelConfig &fModel;
0108       RooAbsData & fData; ///< data set
0109 
0110       mutable ToyMCSampler* fTestStatSampler; ///< the test statistic sampler
0111       mutable RooAbsData* fPointsToTest;      ///< points to perform the construction
0112       mutable RooAbsData* fPOIToTest;         ///< value of POI points to perform the construction
0113       mutable ConfidenceBelt* fConfBelt;
0114       bool fAdaptiveSampling;               ///< controls use of adaptive sampling algorithm
0115       double fAdditionalNToysFactor;        ///< give user ability to ask for more toys
0116       Int_t fNbins;                           ///< number of samples per variable
0117       bool fFluctuateData;                  ///< tell ToyMCSampler to fluctuate number of entries in dataset
0118       bool fDoProfileConstruction;          ///< instead of full construction over nuisance parameters, do profile
0119       bool fSaveBeltToFile;                 ///< controls use if ConfidenceBelt should be saved to a TFile
0120       bool fCreateBelt;                     ///< controls use if ConfidenceBelt should be saved to a TFile
0121 
0122    protected:
0123       ClassDefOverride(FeldmanCousins,0)   // Interface for tools setting limits (producing confidence intervals)
0124    };
0125 }
0126 
0127 
0128 #endif