Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
AsymptoticCalculator.h
Go to the documentation of this file.
1// @(#)root/roostats:$Id$
2// Author: Sven Kreiss, Kyle Cranmer Nov 2010
3/*************************************************************************
4 * Copyright (C) 1995-2008, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef ROOSTATS_AsymptoticCalculator
12#define ROOSTATS_AsymptoticCalculator
13
15#include "RooArgSet.h"
16#include "Rtypes.h"
17
18#include <memory>
19
20class RooArgList;
21class RooCategory;
22class RooFitResult;
23class RooRealVar;
24class RooPoisson;
25class RooProdPdf;
26
27
28namespace RooStats {
29
31
32 public:
34 RooAbsData &data, // need to pass non-const since RooAbsPdf::fitTo takes a non-const data set
35 const ModelConfig &altModel,
37 bool nominalAsimov = false
38 );
39
40 /// initialize the calculator by performing a global fit and make the Asimov data set
41 bool Initialize() const;
42
43 /// re-implement HypoTest computation using the asymptotic
44 HypoTestResult *GetHypoTest() const override;
45
46 /// Make Asimov data.
47 static RooAbsData * MakeAsimovData( RooAbsData & data, const ModelConfig & model, const RooArgSet & poiValues, RooArgSet & globObs, const RooArgSet * genPoiValues = nullptr);
48
49
50 /// Make a nominal Asimov data set from a model.
52
53
54
55 static RooAbsData * GenerateAsimovData(const RooAbsPdf & pdf, const RooArgSet & observables );
56
57 /// function given the null and the alt p value - return the expected one given the N - sigma value
58 static double GetExpectedPValues(double pnull, double palt, double nsigma, bool usecls, bool oneSided = true );
59
60 /// set test statistic for one sided (upper limits)
61 void SetOneSided(bool on) { fOneSided = on; }
62
63 /// set the test statistics for two sided (in case of upper limits
64 /// for discovery does not make really sense)
65 void SetTwoSided() { fOneSided = false; fOneSidedDiscovery = false;}
66
67 /// set the test statistics for one-sided discovery
69
70 /// use the signed (uncapped) profile likelihood test statistic.
71 /// When using a one-sided test statistic, the value is not set to zero when the best fit value of the
72 /// POI is beyond the tested value, but the sign of the test statistic is flipped instead
73 /// (see also ProfileLikelihoodTestStat::SetSigned).
74 /// It has no effect for the two-sided test statistics.
75 void SetSigned(bool on = true) { fSigned = on; }
76
77 /// re-implementation of setters since they are needed to re-initialize the calculator
90
91
92 bool IsTwoSided() const { return (!fOneSided && !fOneSidedDiscovery); }
93 bool IsOneSidedDiscovery() const { return fOneSidedDiscovery; }
94
95
96 /// set using of qtilde, by default is controlled if RoORealVar is limited or not
97 void SetQTilde(bool on) { fUseQTilde = on; }
98
99 /// return snapshot of the best fit parameter
100 const RooArgSet & GetBestFitPoi() const { return fBestFitPoi; }
101 /// return best fit parameter (firs of poi)
102 const RooRealVar * GetMuHat() const { return dynamic_cast<RooRealVar*>(fBestFitPoi.first()); }
103 /// return best fit value for all parameters
104 const RooArgSet & GetBestFitParams() const { return fBestFitPoi; }
105
106 /// Result of the unconditional fit to the observed data, performed by
107 /// Initialize() (updated if GetHypoTest() finds a better minimum).
108 /// Returns nullptr if the fit was skipped or has not been run yet.
109 /// The calculator keeps ownership of the returned object.
111 /// Result of the conditional fit to the observed data with the POI fixed
112 /// to the tested value, from the last call to GetHypoTest().
113 /// Returns nullptr if the fit was skipped or has not been run yet.
114 /// The calculator keeps ownership of the returned object.
115 const RooFitResult *GetFitResultCondObs() const { return fFitResultCondObs.get(); }
116 /// Result of the fit to the Asimov data set with the POI fixed to the
117 /// value of the alternate-model snapshot, performed by Initialize(). Since
118 /// the Asimov data set is generated at that POI value, this corresponds to
119 /// the unconditional minimum (updated if GetHypoTest() finds a better
120 /// minimum). Returns nullptr if the fit was skipped or has not been run
121 /// yet. The calculator keeps ownership of the returned object.
123 /// Result of the conditional fit to the Asimov data set with the POI
124 /// fixed to the tested value, from the last call to GetHypoTest().
125 /// Returns nullptr if the fit was skipped or has not been run yet.
126 /// The calculator keeps ownership of the returned object.
128
129 static void SetPrintLevel(int level);
130
131 private:
132 bool fOneSided; ///< for one sided PL test statistic (upper limits)
133 mutable bool fOneSidedDiscovery; ///< for one sided PL test statistic (for discovery)
134 bool fSigned = false; ///< use signed (uncapped) PL test statistic
135 bool fNominalAsimov; ///< make Asimov at nominal parameter values
136 mutable bool fIsInitialized; ///<! flag to check if calculator is initialized
137 mutable int fUseQTilde; ///< flag to indicate if using qtilde or not (-1 (default based on RooRealVar)), 0 false, 1 (true)
138 mutable double fNLLObs;
139 mutable double fNLLAsimov;
140
141 mutable RooAbsData * fAsimovData; ///< asimov data set
142 mutable RooArgSet fAsimovGlobObs; ///< snapshot of Asimov global observables
143 mutable RooArgSet fBestFitPoi; ///< snapshot of best fitted POI values
144 mutable RooArgSet fBestFitParams; ///< snapshot of all best fitted Parameter values
145
146 mutable std::unique_ptr<RooFitResult> fFitResultUncondObs; ///<! result of unconditional fit to observed data
147 mutable std::unique_ptr<RooFitResult> fFitResultCondObs; ///<! result of conditional fit to observed data
148 mutable std::unique_ptr<RooFitResult> fFitResultUncondAsimov; ///<! result of fit to Asimov data at the alt POI
149 mutable std::unique_ptr<RooFitResult> fFitResultCondAsimov; ///<! result of conditional fit to Asimov data
150
152 };
153}
154
155#endif
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void data
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void on
RooAbsArg * first() const
Abstract base class for binned and unbinned datasets.
Definition RooAbsData.h:56
Abstract interface for all probability density functions.
Definition RooAbsPdf.h:32
RooArgList is a container object that can hold multiple RooAbsArg objects.
Definition RooArgList.h:22
RooArgSet is a container object that can hold multiple RooAbsArg objects.
Definition RooArgSet.h:24
Object to represent discrete states.
Definition RooCategory.h:28
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
Poisson pdf.
Definition RooPoisson.h:18
Efficient implementation of a product of PDFs of the form.
Definition RooProdPdf.h:35
Variable that can be changed from the outside.
Definition RooRealVar.h:37
Hypothesis Test Calculator based on the asymptotic formulae for the profile likelihood ratio.
std::unique_ptr< RooFitResult > fFitResultCondObs
! result of conditional fit to observed data
std::unique_ptr< RooFitResult > fFitResultUncondAsimov
! result of fit to Asimov data at the alt POI
const RooFitResult * GetFitResultCondAsimov() const
Result of the conditional fit to the Asimov data set with the POI fixed to the tested value,...
const RooRealVar * GetMuHat() const
return best fit parameter (firs of poi)
static double GetExpectedPValues(double pnull, double palt, double nsigma, bool usecls, bool oneSided=true)
function given the null and the alt p value - return the expected one given the N - sigma value
void SetAlternateModel(const ModelConfig &altModel) override
Set the model for the alternate hypothesis.
std::unique_ptr< RooFitResult > fFitResultCondAsimov
! result of conditional fit to Asimov data
void SetOneSidedDiscovery(bool on)
set the test statistics for one-sided discovery
void SetData(RooAbsData &data) override
Set the DataSet.
static void SetPrintLevel(int level)
set print level (static function)
const RooFitResult * GetFitResultUncondAsimov() const
Result of the fit to the Asimov data set with the POI fixed to the value of the alternate-model snaps...
RooArgSet fAsimovGlobObs
snapshot of Asimov global observables
static RooAbsData * GenerateAsimovData(const RooAbsPdf &pdf, const RooArgSet &observables)
generate the asimov data for the observables (not the global ones) need to deal with the case of a si...
int fUseQTilde
flag to indicate if using qtilde or not (-1 (default based on RooRealVar)), 0 false,...
bool fIsInitialized
! flag to check if calculator is initialized
const RooFitResult * GetFitResultCondObs() const
Result of the conditional fit to the observed data with the POI fixed to the tested value,...
const RooArgSet & GetBestFitParams() const
return best fit value for all parameters
HypoTestResult * GetHypoTest() const override
re-implement HypoTest computation using the asymptotic
bool fOneSided
for one sided PL test statistic (upper limits)
RooArgSet fBestFitParams
snapshot of all best fitted Parameter values
AsymptoticCalculator(RooAbsData &data, const ModelConfig &altModel, const ModelConfig &nullModel, bool nominalAsimov=false)
constructor for asymptotic calculator from Data set and ModelConfig
std::unique_ptr< RooFitResult > fFitResultUncondObs
! result of unconditional fit to observed data
void SetTwoSided()
set the test statistics for two sided (in case of upper limits for discovery does not make really sen...
bool fSigned
use signed (uncapped) PL test statistic
bool fOneSidedDiscovery
for one sided PL test statistic (for discovery)
RooAbsData * fAsimovData
asimov data set
RooArgSet fBestFitPoi
snapshot of best fitted POI values
void SetQTilde(bool on)
set using of qtilde, by default is controlled if RoORealVar is limited or not
void SetSigned(bool on=true)
use the signed (uncapped) profile likelihood test statistic.
static RooAbsData * MakeAsimovData(RooAbsData &data, const ModelConfig &model, const RooArgSet &poiValues, RooArgSet &globObs, const RooArgSet *genPoiValues=nullptr)
Make Asimov data.
const RooArgSet & GetBestFitPoi() const
return snapshot of the best fit parameter
void SetNullModel(const ModelConfig &nullModel) override
re-implementation of setters since they are needed to re-initialize the calculator
bool fNominalAsimov
make Asimov at nominal parameter values
const RooFitResult * GetFitResultUncondObs() const
Result of the unconditional fit to the observed data, performed by Initialize() (updated if GetHypoTe...
void SetOneSided(bool on)
set test statistic for one sided (upper limits)
bool Initialize() const
initialize the calculator by performing a global fit and make the Asimov data set
Common base class for the Hypothesis Test Calculators.
void SetNullModel(const ModelConfig &nullModel) override
set the model for the null hypothesis (only B)
void SetData(RooAbsData &data) override
Set the DataSet.
void SetAlternateModel(const ModelConfig &altModel) override
Set the model for the alternate hypothesis (S+B)
HypoTestResult is a base class for results from hypothesis tests.
< A class that holds configuration information for a model using a workspace as a store
Definition ModelConfig.h:34
Namespace for the RooStats classes.
Definition CodegenImpl.h:67