Logo ROOT   6.16/01
Reference Guide
List of all members | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Static Protected Member Functions | Private Attributes | Static Private Attributes | List of all members
RooStats::HypoTestInverter Class Reference

HypoTestInverter class for performing an hypothesis test inversion by scanning the hypothesis test results of an HypoTestCalculator for various values of the parameter of interest.

By looking at the confidence level curve of the result an upper limit, where it intersects the desired confidence level, can be derived. The class implements the RooStats::IntervalCalculator interface and returns an RooStats::HypoTestInverterResult class. The result is a SimpleInterval, which via the method UpperLimit returns to the user the upper limit value.

The HypoTestInverter implements various option for performing the scan. HypoTestInverter::RunFixedScan will scan using a fixed grid the parameter of interest. HypoTestInverter::RunAutoScan will perform an automatic scan to find optimally the curve and it will stop until the desired precision is obtained. The confidence level value at a given point can be done via HypoTestInverter::RunOnePoint. The class can scan the CLs+b values or alternatively CLs (if the method HypoTestInverter::UseCLs has been called).

Contributions to this class have been written by Giovanni Petrucciani and Annapaola Decosa

Definition at line 36 of file HypoTestInverter.h.

Public Types

enum  ECalculatorType { kUndefined = 0 , kHybrid = 1 , kFrequentist = 2 , kAsymptotic = 3 }
 

Public Member Functions

 HypoTestInverter ()
 default constructor (doesn't do anything) More...
 
 HypoTestInverter (AsymptoticCalculator &hc, RooRealVar *scannedVariable, double size=0.05)
 Constructor from a reference to a AsymptoticCalculator The calculator must be created before by using the S+B model for the null and the B model for the alt If no variable to scan are given they are assumed to be the first variable from the parameter of interests of the null model. More...
 
 HypoTestInverter (FrequentistCalculator &hc, RooRealVar *scannedVariable, double size=0.05)
 Constructor from a reference to a FrequentistCalculator The calculator must be created before by using the S+B model for the null and the B model for the alt If no variable to scan are given they are assumed to be the first variable from the parameter of interests of the null model. More...
 
 HypoTestInverter (HybridCalculator &hc, RooRealVar *scannedVariable=0, double size=0.05)
 Constructor from a reference to a HybridCalculator The calculator must be created before by using the S+B model for the null and the B model for the alt If no variable to scan are given they are assumed to be the first variable from the parameter of interests of the null model. More...
 
 HypoTestInverter (HypoTestCalculatorGeneric &hc, RooRealVar *scannedVariable=0, double size=0.05)
 Constructor from a HypoTestCalculatorGeneric The HypoTest calculator must be a FrequentistCalculator or HybridCalculator type Other type of calculators are not supported. More...
 
 HypoTestInverter (RooAbsData &data, ModelConfig &sb, ModelConfig &b, RooRealVar *scannedVariable=0, ECalculatorType type=kFrequentist, double size=0.05)
 Constructor from a model for B model and a model for S+B. More...
 
virtual ~HypoTestInverter ()
 destructor (delete the HypoTestInverterResult) More...
 
void Clear ()
 delete contained result and graph More...
 
virtual Double_t ConfidenceLevel () const
 Get the Confidence level for the test. More...
 
HypoTestCalculatorGenericGetHypoTestCalculator () const
 
virtual HypoTestInverterResultGetInterval () const
 Run a fixed scan or the automatic scan depending on the configuration Return if needed a copy of the result object which will be managed by the user. More...
 
SamplingDistributionGetLowerLimitDistribution (bool rebuild=false, int nToys=100)
 get the distribution of lower limit if rebuild = false (default) it will re-use the results of the scan done for obtained the observed limit and no extra toys will be generated if rebuild a new set of B toys will be done and the procedure will be repeated for each toy More...
 
TestStatisticGetTestStatistic () const
 return the test statistic which is or will be used by the class More...
 
SamplingDistributionGetUpperLimitDistribution (bool rebuild=false, int nToys=100)
 get the distribution of lower limit if rebuild = false (default) it will re-use the results of the scan done for obtained the observed limit and no extra toys will be generated if rebuild a new set of B toys will be done and the procedure will be repeated for each toy The nuisance parameter value used for rebuild is the current one in the model so it is user responsibility to set to the desired value (nomi More...
 
SamplingDistributionRebuildDistributions (bool isUpper=true, int nToys=100, TList *clsDist=0, TList *clsbDist=0, TList *clbDist=0, const char *outputfile="HypoTestInverterRebuiltDist.root")
 rebuild the sampling distributions by generating some toys and find for each of them a new upper limit Return the upper limit distribution and optionally also the pValue distributions for Cls, Clsb and Clbxs as a TList for each scanned point The method uses the present parameter value. More...
 
bool RunFixedScan (int nBins, double xMin, double xMax, bool scanLog=false) const
 Run a Fixed scan in npoints between min and max. More...
 
bool RunLimit (double &limit, double &limitErr, double absTol=0, double relTol=0, const double *hint=0) const
 run an automatic scan until the desired accuracy is reached Start by default from the full interval (min,max) of the POI and then via bisection find the line crossing the target line Optionally an hint can be provided and the scan will be done closer to that value If by bisection the desired accuracy will not be reached a fit to the points is performed More...
 
bool RunOnePoint (double thisX, bool adaptive=false, double clTarget=-1) const
 run only one point at the given POI value More...
 
void SetAutoScan ()
 
virtual void SetConfidenceLevel (Double_t cl)
 set the confidence level for the interval (e.g. 0.95 for a 95% Confidence Interval) More...
 
virtual void SetData (RooAbsData &)
 Set the DataSet ( add to the the workspace if not already there ?) More...
 
void SetFixedScan (int nBins, double xMin=1, double xMax=-1, bool scanLog=false)
 
void SetMaximumToys (int ntoys)
 
virtual void SetModel (const ModelConfig &)
 Set the Model. More...
 
void SetNumErr (double err)
 
virtual void SetTestSize (Double_t size)
 set the size of the test (rate of Type I error) ( e.g. 0.05 for a 95% Confidence Interval) More...
 
bool SetTestStatistic (TestStatistic &stat)
 set the test statistic to use More...
 
void SetVerbose (int level=1)
 
virtual Double_t Size () const
 Get the size of the test (eg. rate of Type I error) More...
 
void UseCLs (bool on=true)
 
- Public Member Functions inherited from RooStats::IntervalCalculator
virtual ~IntervalCalculator ()
 
virtual Double_t ConfidenceLevel () const =0
 Get the Confidence level for the test. More...
 
virtual ConfIntervalGetInterval () const =0
 Main interface to get a ConfInterval, pure virtual. More...
 
virtual void SetConfidenceLevel (Double_t cl)=0
 set the confidence level for the interval (e.g. 0.95 for a 95% Confidence Interval) More...
 
virtual void SetData (RooAbsData &)=0
 Set the DataSet ( add to the the workspace if not already there ?) More...
 
virtual void SetModel (const ModelConfig &)=0
 Set the Model. More...
 
virtual void SetTestSize (Double_t size)=0
 set the size of the test (rate of Type I error) ( e.g. 0.05 for a 95% Confidence Interval) More...
 
virtual Double_t Size () const =0
 Get the size of the test (eg. rate of Type I error) More...
 

Static Public Member Functions

static void SetCloseProof (Bool_t flag)
 set flag to close proof for every new run More...
 

Protected Member Functions

 HypoTestInverter (const HypoTestInverter &rhs)
 copy-constructor NOTE: this class does not copy the contained result and the HypoTestCalculator, but only the pointers It requires the original HTI to be alive More...
 
void CreateResults () const
 create a new HypoTestInverterResult to hold all computed results More...
 
HypoTestResultEval (HypoTestCalculatorGeneric &hc, bool adaptive, double clsTarget) const
 Run the Hypothesis test at a previous configured point (internal function called by RunOnePoint) More...
 
HypoTestInverteroperator= (const HypoTestInverter &rhs)
 assignment operator NOTE: this class does not copy the contained result and the HypoTestCalculator, but only the pointers It requires the original HTI to be alive More...
 

Static Protected Member Functions

static void CheckInputModels (const HypoTestCalculatorGeneric &hc, const RooRealVar &scanVar)
 check the model given the given hypotestcalculator More...
 
static RooRealVarGetVariableToScan (const HypoTestCalculatorGeneric &hc)
 get the variable to scan try first with null model if not go to alternate model More...
 

Private Attributes

ECalculatorType fCalcType
 
HypoTestCalculatorGenericfCalculator0
 
std::unique_ptr< HypoTestCalculatorGenericfHC
 
std::unique_ptr< TGraphErrorsfLimitPlot
 
int fMaxToys
 
int fNBins
 
double fNumErr
 
HypoTestInverterResultfResults
 
bool fScanLog
 
RooRealVarfScannedVariable
 pointer to the generic hypotest calculator used More...
 
double fSize
 
int fTotalToysRun
 plot of limits More...
 
bool fUseCLs
 
int fVerbose
 
double fXmax
 
double fXmin
 

Static Private Attributes

static double fgAbsAccuracy = 0.05
 
static std::string fgAlgo = "logSecant"
 
static double fgCLAccuracy = 0.005
 
static bool fgCloseProof = false
 
static unsigned int fgNToys = 500
 
static double fgRelAccuracy = 0.05
 

#include <RooStats/HypoTestInverter.h>

Inheritance diagram for RooStats::HypoTestInverter:
[legend]

Member Enumeration Documentation

◆ ECalculatorType

Enumerator
kUndefined 
kHybrid 
kFrequentist 
kAsymptotic 

Definition at line 40 of file HypoTestInverter.h.

Constructor & Destructor Documentation

◆ HypoTestInverter() [1/7]

HypoTestInverter::HypoTestInverter ( )

default constructor (doesn't do anything)

Definition at line 166 of file HypoTestInverter.cxx.

◆ HypoTestInverter() [2/7]

HypoTestInverter::HypoTestInverter ( HypoTestCalculatorGeneric hc,
RooRealVar scannedVariable = 0,
double  size = 0.05 
)

Constructor from a HypoTestCalculatorGeneric The HypoTest calculator must be a FrequentistCalculator or HybridCalculator type Other type of calculators are not supported.

The calculator must be created before by using the S+B model for the null and the B model for the alt If no variable to scan are given they are assumed to be the first variable from the parameter of interests of the null model

Definition at line 191 of file HypoTestInverter.cxx.

◆ HypoTestInverter() [3/7]

HypoTestInverter::HypoTestInverter ( HybridCalculator hc,
RooRealVar scannedVariable = 0,
double  size = 0.05 
)

Constructor from a reference to a HybridCalculator The calculator must be created before by using the S+B model for the null and the B model for the alt If no variable to scan are given they are assumed to be the first variable from the parameter of interests of the null model.

Definition at line 244 of file HypoTestInverter.cxx.

◆ HypoTestInverter() [4/7]

HypoTestInverter::HypoTestInverter ( FrequentistCalculator hc,
RooRealVar scannedVariable,
double  size = 0.05 
)

Constructor from a reference to a FrequentistCalculator The calculator must be created before by using the S+B model for the null and the B model for the alt If no variable to scan are given they are assumed to be the first variable from the parameter of interests of the null model.

Definition at line 277 of file HypoTestInverter.cxx.

◆ HypoTestInverter() [5/7]

HypoTestInverter::HypoTestInverter ( AsymptoticCalculator hc,
RooRealVar scannedVariable,
double  size = 0.05 
)

Constructor from a reference to a AsymptoticCalculator The calculator must be created before by using the S+B model for the null and the B model for the alt If no variable to scan are given they are assumed to be the first variable from the parameter of interests of the null model.

Definition at line 309 of file HypoTestInverter.cxx.

◆ HypoTestInverter() [6/7]

HypoTestInverter::HypoTestInverter ( RooAbsData data,
ModelConfig sbModel,
ModelConfig bModel,
RooRealVar scannedVariable = 0,
ECalculatorType  type = kFrequentist,
double  size = 0.05 
)

Constructor from a model for B model and a model for S+B.

An HypoTestCalculator (Hybrid of Frequentis) will be created using the S+B model as the null and the B model as the alternate If no variable to scan are given they are assumed to be the first variable from the parameter of interests of the null model

Definition at line 342 of file HypoTestInverter.cxx.

◆ ~HypoTestInverter()

HypoTestInverter::~HypoTestInverter ( )
virtual

destructor (delete the HypoTestInverterResult)

Definition at line 415 of file HypoTestInverter.cxx.

◆ HypoTestInverter() [7/7]

HypoTestInverter::HypoTestInverter ( const HypoTestInverter rhs)
protected

copy-constructor NOTE: this class does not copy the contained result and the HypoTestCalculator, but only the pointers It requires the original HTI to be alive

Definition at line 378 of file HypoTestInverter.cxx.

Member Function Documentation

◆ CheckInputModels()

void HypoTestInverter::CheckInputModels ( const HypoTestCalculatorGeneric hc,
const RooRealVar scanVar 
)
staticprotected

check the model given the given hypotestcalculator

Definition at line 126 of file HypoTestInverter.cxx.

◆ Clear()

void HypoTestInverter::Clear ( )

delete contained result and graph

Definition at line 448 of file HypoTestInverter.cxx.

◆ ConfidenceLevel()

virtual Double_t RooStats::HypoTestInverter::ConfidenceLevel ( ) const
inlinevirtual

Get the Confidence level for the test.

Implements RooStats::IntervalCalculator.

Definition at line 108 of file HypoTestInverter.h.

◆ CreateResults()

void HypoTestInverter::CreateResults ( ) const
protected

create a new HypoTestInverterResult to hold all computed results

Definition at line 457 of file HypoTestInverter.cxx.

◆ Eval()

HypoTestResult * HypoTestInverter::Eval ( HypoTestCalculatorGeneric hc,
bool  adaptive,
double  clsTarget 
) const
protected

Run the Hypothesis test at a previous configured point (internal function called by RunOnePoint)

Definition at line 520 of file HypoTestInverter.cxx.

◆ GetHypoTestCalculator()

HypoTestCalculatorGeneric * RooStats::HypoTestInverter::GetHypoTestCalculator ( ) const
inline

Definition at line 115 of file HypoTestInverter.h.

◆ GetInterval()

HypoTestInverterResult * HypoTestInverter::GetInterval ( ) const
virtual

Run a fixed scan or the automatic scan depending on the configuration Return if needed a copy of the result object which will be managed by the user.

Implements RooStats::IntervalCalculator.

Definition at line 489 of file HypoTestInverter.cxx.

◆ GetLowerLimitDistribution()

SamplingDistribution * HypoTestInverter::GetLowerLimitDistribution ( bool  rebuild = false,
int  nToys = 100 
)

get the distribution of lower limit if rebuild = false (default) it will re-use the results of the scan done for obtained the observed limit and no extra toys will be generated if rebuild a new set of B toys will be done and the procedure will be repeated for each toy

Definition at line 1026 of file HypoTestInverter.cxx.

◆ GetTestStatistic()

TestStatistic * HypoTestInverter::GetTestStatistic ( void  ) const

return the test statistic which is or will be used by the class

Definition at line 424 of file HypoTestInverter.cxx.

◆ GetUpperLimitDistribution()

SamplingDistribution * HypoTestInverter::GetUpperLimitDistribution ( bool  rebuild = false,
int  nToys = 100 
)

get the distribution of lower limit if rebuild = false (default) it will re-use the results of the scan done for obtained the observed limit and no extra toys will be generated if rebuild a new set of B toys will be done and the procedure will be repeated for each toy The nuisance parameter value used for rebuild is the current one in the model so it is user responsibility to set to the desired value (nomi

Definition at line 1053 of file HypoTestInverter.cxx.

◆ GetVariableToScan()

RooRealVar * HypoTestInverter::GetVariableToScan ( const HypoTestCalculatorGeneric hc)
staticprotected

get the variable to scan try first with null model if not go to alternate model

Definition at line 105 of file HypoTestInverter.cxx.

◆ operator=()

HypoTestInverter & HypoTestInverter::operator= ( const HypoTestInverter rhs)
protected

assignment operator NOTE: this class does not copy the contained result and the HypoTestCalculator, but only the pointers It requires the original HTI to be alive

Definition at line 393 of file HypoTestInverter.cxx.

◆ RebuildDistributions()

SamplingDistribution * HypoTestInverter::RebuildDistributions ( bool  isUpper = true,
int  nToys = 100,
TList clsDist = 0,
TList clsbDist = 0,
TList clbDist = 0,
const char *  outputfile = "HypoTestInverterRebuiltDist.root" 
)

rebuild the sampling distributions by generating some toys and find for each of them a new upper limit Return the upper limit distribution and optionally also the pValue distributions for Cls, Clsb and Clbxs as a TList for each scanned point The method uses the present parameter value.

It is user responsibility to give the current parameters to rebuild the distributions It returns a upper or lower limit distribution depending on the isUpper flag, however it computes also the lower limit distribution and it is saved in the output file as an histogram

Definition at line 1085 of file HypoTestInverter.cxx.

◆ RunFixedScan()

bool HypoTestInverter::RunFixedScan ( int  nBins,
double  xMin,
double  xMax,
bool  scanLog = false 
) const

Run a Fixed scan in npoints between min and max.

Definition at line 603 of file HypoTestInverter.cxx.

◆ RunLimit()

bool HypoTestInverter::RunLimit ( double &  limit,
double &  limitErr,
double  absTol = 0,
double  relTol = 0,
const double *  hint = 0 
) const

run an automatic scan until the desired accuracy is reached Start by default from the full interval (min,max) of the POI and then via bisection find the line crossing the target line Optionally an hint can be provided and the scan will be done closer to that value If by bisection the desired accuracy will not be reached a fit to the points is performed

Definition at line 760 of file HypoTestInverter.cxx.

◆ RunOnePoint()

bool HypoTestInverter::RunOnePoint ( double  thisX,
bool  adaptive = false,
double  clTarget = -1 
) const

run only one point at the given POI value

Definition at line 665 of file HypoTestInverter.cxx.

◆ SetAutoScan()

void RooStats::HypoTestInverter::SetAutoScan ( )
inline

Definition at line 85 of file HypoTestInverter.h.

◆ SetCloseProof()

void HypoTestInverter::SetCloseProof ( Bool_t  flag)
static

set flag to close proof for every new run

Definition at line 97 of file HypoTestInverter.cxx.

◆ SetConfidenceLevel()

virtual void RooStats::HypoTestInverter::SetConfidenceLevel ( Double_t  cl)
inlinevirtual

set the confidence level for the interval (e.g. 0.95 for a 95% Confidence Interval)

Implements RooStats::IntervalCalculator.

Definition at line 104 of file HypoTestInverter.h.

◆ SetData()

void HypoTestInverter::SetData ( RooAbsData )
virtual

Set the DataSet ( add to the the workspace if not already there ?)

Implements RooStats::IntervalCalculator.

Definition at line 1072 of file HypoTestInverter.cxx.

◆ SetFixedScan()

void RooStats::HypoTestInverter::SetFixedScan ( int  nBins,
double  xMin = 1,
double  xMax = -1,
bool  scanLog = false 
)
inline

Definition at line 78 of file HypoTestInverter.h.

◆ SetMaximumToys()

void RooStats::HypoTestInverter::SetMaximumToys ( int  ntoys)
inline

Definition at line 135 of file HypoTestInverter.h.

◆ SetModel()

virtual void RooStats::HypoTestInverter::SetModel ( const ModelConfig )
inlinevirtual

Set the Model.

Implements RooStats::IntervalCalculator.

Definition at line 99 of file HypoTestInverter.h.

◆ SetNumErr()

void RooStats::HypoTestInverter::SetNumErr ( double  err)
inline

Definition at line 138 of file HypoTestInverter.h.

◆ SetTestSize()

virtual void RooStats::HypoTestInverter::SetTestSize ( Double_t  size)
inlinevirtual

set the size of the test (rate of Type I error) ( e.g. 0.05 for a 95% Confidence Interval)

Implements RooStats::IntervalCalculator.

Definition at line 102 of file HypoTestInverter.h.

◆ SetTestStatistic()

bool HypoTestInverter::SetTestStatistic ( TestStatistic stat)

set the test statistic to use

Definition at line 436 of file HypoTestInverter.cxx.

◆ SetVerbose()

void RooStats::HypoTestInverter::SetVerbose ( int  level = 1)
inline

Definition at line 132 of file HypoTestInverter.h.

◆ Size()

virtual Double_t RooStats::HypoTestInverter::Size ( ) const
inlinevirtual

Get the size of the test (eg. rate of Type I error)

Implements RooStats::IntervalCalculator.

Definition at line 106 of file HypoTestInverter.h.

◆ UseCLs()

void RooStats::HypoTestInverter::UseCLs ( bool  on = true)
inline

Definition at line 95 of file HypoTestInverter.h.

Member Data Documentation

◆ fCalcType

ECalculatorType RooStats::HypoTestInverter::fCalcType
private

Definition at line 188 of file HypoTestInverter.h.

◆ fCalculator0

HypoTestCalculatorGeneric* RooStats::HypoTestInverter::fCalculator0
private

Definition at line 179 of file HypoTestInverter.h.

◆ fgAbsAccuracy

double HypoTestInverter::fgAbsAccuracy = 0.05
staticprivate

Definition at line 166 of file HypoTestInverter.h.

◆ fgAlgo

std::string HypoTestInverter::fgAlgo = "logSecant"
staticprivate

Definition at line 169 of file HypoTestInverter.h.

◆ fgCLAccuracy

double HypoTestInverter::fgCLAccuracy = 0.005
staticprivate

Definition at line 165 of file HypoTestInverter.h.

◆ fgCloseProof

bool HypoTestInverter::fgCloseProof = false
staticprivate

Definition at line 168 of file HypoTestInverter.h.

◆ fgNToys

unsigned int HypoTestInverter::fgNToys = 500
staticprivate

Definition at line 164 of file HypoTestInverter.h.

◆ fgRelAccuracy

double HypoTestInverter::fgRelAccuracy = 0.05
staticprivate

Definition at line 167 of file HypoTestInverter.h.

◆ fHC

std::unique_ptr<HypoTestCalculatorGeneric> RooStats::HypoTestInverter::fHC
private

Definition at line 180 of file HypoTestInverter.h.

◆ fLimitPlot

std::unique_ptr<TGraphErrors> RooStats::HypoTestInverter::fLimitPlot
mutableprivate

Definition at line 172 of file HypoTestInverter.h.

◆ fMaxToys

int RooStats::HypoTestInverter::fMaxToys
private

Definition at line 177 of file HypoTestInverter.h.

◆ fNBins

int RooStats::HypoTestInverter::fNBins
private

Definition at line 189 of file HypoTestInverter.h.

◆ fNumErr

double RooStats::HypoTestInverter::fNumErr
private

Definition at line 192 of file HypoTestInverter.h.

◆ fResults

HypoTestInverterResult* RooStats::HypoTestInverter::fResults
mutableprivate

Definition at line 182 of file HypoTestInverter.h.

◆ fScanLog

bool RooStats::HypoTestInverter::fScanLog
private

Definition at line 185 of file HypoTestInverter.h.

◆ fScannedVariable

RooRealVar* RooStats::HypoTestInverter::fScannedVariable
private

pointer to the generic hypotest calculator used

Definition at line 181 of file HypoTestInverter.h.

◆ fSize

double RooStats::HypoTestInverter::fSize
private

Definition at line 186 of file HypoTestInverter.h.

◆ fTotalToysRun

int RooStats::HypoTestInverter::fTotalToysRun
mutableprivate

plot of limits

Definition at line 176 of file HypoTestInverter.h.

◆ fUseCLs

bool RooStats::HypoTestInverter::fUseCLs
private

Definition at line 184 of file HypoTestInverter.h.

◆ fVerbose

int RooStats::HypoTestInverter::fVerbose
private

Definition at line 187 of file HypoTestInverter.h.

◆ fXmax

double RooStats::HypoTestInverter::fXmax
private

Definition at line 191 of file HypoTestInverter.h.

◆ fXmin

double RooStats::HypoTestInverter::fXmin
private

Definition at line 190 of file HypoTestInverter.h.

Libraries for RooStats::HypoTestInverter:
[legend]

The documentation for this class was generated from the following files: