/usr/include/root/RooStats/HypoTestInverter.h is in libroot-roofit-dev 5.34.19+dfsg-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 | // @(#)root/roostats:$Id$
// Author: Kyle Cranmer, Lorenzo Moneta, Gregory Schott, Wouter Verkerke
/*************************************************************************
* Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOSTATS_HypoTestInverter
#define ROOSTATS_HypoTestInverter
#ifndef ROOSTATS_IntervalCalculator
#include "RooStats/IntervalCalculator.h"
#endif
#ifndef ROOSTATS_HypoTestInverterResult
#include "RooStats/HypoTestInverterResult.h"
#endif
class RooRealVar;
class TGraphErrors;
#include <memory>
namespace RooStats {
//class HypoTestCalculator;
class HybridCalculator;
class FrequentistCalculator;
class AsymptoticCalculator;
class HypoTestCalculatorGeneric;
class TestStatistic;
class HypoTestInverter : public IntervalCalculator {
public:
enum ECalculatorType { kUndefined = 0, kHybrid = 1, kFrequentist = 2, kAsymptotic = 3};
// default constructor (used only for I/O)
HypoTestInverter();
// constructor from generic hypotest calculator
HypoTestInverter( HypoTestCalculatorGeneric & hc,
RooRealVar* scannedVariable =0,
double size = 0.05) ;
// constructor from hybrid calculator
HypoTestInverter( HybridCalculator & hc,
RooRealVar* scannedVariable = 0,
double size = 0.05) ;
// constructor from frequentist calculator
HypoTestInverter( FrequentistCalculator & hc,
RooRealVar* scannedVariable,
double size = 0.05) ;
// constructor from asymptotic calculator
HypoTestInverter( AsymptoticCalculator & hc,
RooRealVar* scannedVariable,
double size = 0.05) ;
// constructor from two ModelConfigs (first sb (the null model) then b (the alt model)
HypoTestInverter( RooAbsData& data, ModelConfig &sb, ModelConfig &b,
RooRealVar * scannedVariable = 0, ECalculatorType type = kFrequentist,
double size = 0.05) ;
virtual HypoTestInverterResult* GetInterval() const;
void Clear();
// set for a fixed scan in nbins
void SetFixedScan(int nBins, double xMin = 1, double xMax = -1, bool scanLog = false ) {
fNBins = nBins;
fXmin = xMin; fXmax = xMax;
fScanLog = scanLog;
}
// set auto scan (default)
void SetAutoScan() { SetFixedScan(0); }
bool RunFixedScan( int nBins, double xMin, double xMax, bool scanLog = false ) const;
bool RunOnePoint( double thisX, bool adaptive = false, double clTarget = -1 ) const;
//bool RunAutoScan( double xMin, double xMax, double target, double epsilon=0.005, unsigned int numAlgorithm=0 );
bool RunLimit(double &limit, double &limitErr, double absTol = 0, double relTol = 0, const double *hint=0) const;
void UseCLs( bool on = true) { fUseCLs = on; if (fResults) fResults->UseCLs(on); }
virtual void SetData(RooAbsData &);
virtual void SetModel(const ModelConfig &) { } // not needed
// set the size of the test (rate of Type I error) ( Eg. 0.05 for a 95% Confidence Interval)
virtual void SetTestSize(Double_t size) {fSize = size; if (fResults) fResults->SetTestSize(size); }
// set the confidence level for the interval (eg. 0.95 for a 95% Confidence Interval)
virtual void SetConfidenceLevel(Double_t cl) {fSize = 1.-cl; if (fResults) fResults->SetConfidenceLevel(cl); }
// Get the size of the test (eg. rate of Type I error)
virtual Double_t Size() const {return fSize;}
// Get the Confidence level for the test
virtual Double_t ConfidenceLevel() const {return 1.-fSize;}
// destructor
virtual ~HypoTestInverter() ;
// retrieved a reference to the internally used HypoTestCalculator
// it might be invalid when the class is deleted
HypoTestCalculatorGeneric * GetHypoTestCalculator() const { return fCalculator0; }
// get the upper/lower limit distribution
SamplingDistribution * GetLowerLimitDistribution(bool rebuild=false, int nToys = 100);
SamplingDistribution * GetUpperLimitDistribution(bool rebuild=false, int nToys = 100);
// function to rebuild the distributions
SamplingDistribution * RebuildDistributions(bool isUpper=true, int nToys = 100,
TList * clsDist = 0, TList *clsbDist= 0, TList * clbDist = 0, const char * outputfile = "HypoTestInverterRebuiltDist.root");
// get the test statistic
TestStatistic * GetTestStatistic() const;
// set the test statistic
bool SetTestStatistic(TestStatistic& stat);
// set verbose level (0,1,2)
void SetVerbose(int level=1) { fVerbose = level; }
// set maximum number of toys
void SetMaximumToys(int ntoys) { fMaxToys = ntoys;}
// set numerical error in test statistic evaluation (default is zero)
void SetNumErr(double err) { fNumErr = err; }
// set flag to close proof for every new run
static void SetCloseProof(Bool_t flag);
protected:
// copy c-tor
HypoTestInverter(const HypoTestInverter & rhs);
// assignment
HypoTestInverter & operator=(const HypoTestInverter & rhs);
void CreateResults() const;
// run the hybrid at a single point
HypoTestResult * Eval( HypoTestCalculatorGeneric &hc, bool adaptive , double clsTarget) const;
// helper functions
static RooRealVar * GetVariableToScan(const HypoTestCalculatorGeneric &hc);
static void CheckInputModels(const HypoTestCalculatorGeneric &hc, const RooRealVar & scanVar);
private:
static unsigned int fgNToys;
static double fgCLAccuracy;
static double fgAbsAccuracy;
static double fgRelAccuracy;
static bool fgCloseProof;
static std::string fgAlgo;
// graph, used to compute the limit, not just for plotting!
mutable std::auto_ptr<TGraphErrors> fLimitPlot; //! plot of limits
// performance counter: remember how many toys have been thrown
mutable int fTotalToysRun;
int fMaxToys; // maximum number of toys to run
HypoTestCalculatorGeneric* fCalculator0; // pointer to the calculator passed in the constructor
std::auto_ptr<HypoTestCalculatorGeneric> fHC;
RooRealVar* fScannedVariable; // pointer to the constrained variable
mutable HypoTestInverterResult* fResults; // pointer to the result
bool fUseCLs;
bool fScanLog;
double fSize;
int fVerbose;
ECalculatorType fCalcType;
int fNBins;
double fXmin;
double fXmax;
double fNumErr;
protected:
ClassDef(HypoTestInverter,3) // HypoTestInverter class
};
}
#endif
|