15#ifdef XROOFIT_USE_PRAGMA_ONCE
18#if !defined(XROOFIT_XROONLLVAR_H) || defined(XROOFIT_USE_PRAGMA_ONCE)
19#ifndef XROOFIT_USE_PRAGMA_ONCE
20#define XROOFIT_XROONLLVAR_H
52class HypoTestInverterResult;
64 double value()
const {
return std::pair<double, double>::first; }
65 double error()
const {
return std::pair<double, double>::second; }
72 xRooNLLVar(
const std::shared_ptr<RooAbsPdf> &pdf,
const std::shared_ptr<RooAbsData> &
data,
74 xRooNLLVar(
const std::shared_ptr<RooAbsPdf> &pdf,
75 const std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>> &
data,
88 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
90 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
91 generate(
bool expected =
false,
int seed = 0);
97 const std::shared_ptr<xRooNLLVar> &nll =
nullptr);
103 std::shared_ptr<xRooNLLVar>
nll()
const
111 ?
RooArgList(*std::unique_ptr<RooAbsCollection>(get()->floatParsFinal().selectByAttrib(
"poi",
true)))
117 xRooFitResult cfit(
const char *poiValues,
const char *alias =
nullptr);
121 double impact(
const char *poi,
const char *
np,
bool up =
true,
bool prefit =
false,
bool approx =
false);
122 double impact(
const char *
np,
bool up =
true,
bool prefit =
false,
bool approx =
false)
125 if (_poi.size() != 1)
126 throw std::runtime_error(
"xRooFitResult::impact: not one POI");
127 return impact(poi().contentsString().c_str(),
np, up, prefit, approx);
133 double conditionalError(
const char *poi,
const char *nps,
bool up =
true,
bool approx =
false);
138 RooArgList ranknp(
const char *poi,
bool up =
true,
bool prefit =
false,
139 double approxThreshold = std::numeric_limits<double>::infinity());
142 ranknp(
bool up =
true,
bool prefit =
false,
double approxThreshold = std::numeric_limits<double>::infinity())
145 if (_poi.size() != 1)
146 throw std::runtime_error(
"xRooFitResult::ranknp: not one POI");
147 return ranknp(poi().contentsString().c_str(), up, prefit, approxThreshold);
151 std::shared_ptr<xRooNLLVar>
fNll;
153 std::shared_ptr<std::map<std::string, xRooFitResult>>
fCfits;
156 xRooFitResult minimize(
const std::shared_ptr<ROOT::Fit::FitConfig> & =
nullptr);
158 void SetFitConfig(
const std::shared_ptr<ROOT::Fit::FitConfig> &in) { fFitConfig = in; }
159 std::shared_ptr<ROOT::Fit::FitConfig> fitConfig();
166 void Print(
Option_t *opt =
"")
const override;
173 std::pair<double, double> pll(
bool readOnly =
false);
174 std::pair<double, double> sigma_mu(
bool readOnly =
false);
175 std::shared_ptr<const RooFitResult> ufit(
bool readOnly =
false);
176 std::shared_ptr<const RooFitResult> cfit_null(
bool readOnly =
false);
177 std::shared_ptr<const RooFitResult> cfit_alt(
bool readOnly =
false);
178 std::shared_ptr<const RooFitResult> cfit_lbound(
bool readOnly =
false);
179 std::shared_ptr<const RooFitResult>
gfit() {
return fGenFit; }
181 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
fData;
182 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
data();
184 std::pair<double, double> getVal(
const char *
what);
187 std::pair<double, double> pNull_asymp(
double nSigma = std::numeric_limits<double>::quiet_NaN());
188 std::pair<double, double> pAlt_asymp(
double nSigma = std::numeric_limits<double>::quiet_NaN());
189 std::pair<double, double> pCLs_asymp(
double nSigma = std::numeric_limits<double>::quiet_NaN());
190 std::pair<double, double>
191 ts_asymp(
double nSigma = std::numeric_limits<double>::quiet_NaN());
193 std::pair<double, double> pNull_toys(
double nSigma = std::numeric_limits<double>::quiet_NaN());
194 std::pair<double, double> pAlt_toys(
double nSigma = std::numeric_limits<double>::quiet_NaN());
195 std::pair<double, double>
pCLs_toys(
double nSigma = std::numeric_limits<double>::quiet_NaN())
197 if (fNullVal() == fAltVal())
198 return std::pair(1, 0);
199 auto null = pNull_toys(nSigma);
200 auto alt = pAlt_toys(nSigma);
201 double nom = (null.first == 0) ? 0 : null.first / alt.first;
208 return std::make_pair(nom, (alt.first - alt.second <= 0)
209 ? std::numeric_limits<double>::infinity()
210 : (sqrt(pow(null.second, 2) + pow(alt.second * nom, 2)) / alt.first));
213 std::pair<double, double>
214 ts_toys(
double nSigma = std::numeric_limits<double>::quiet_NaN());
223 addNullToys(
int nToys = 1,
int seed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
224 double target_nSigma = std::numeric_limits<double>::quiet_NaN());
226 addAltToys(
int nToys = 1,
int seed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
227 double target_nSigma = std::numeric_limits<double>::quiet_NaN());
229 addCLsToys(
int nToys = 1,
int seed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
230 double target_nSigma = std::numeric_limits<double>::quiet_NaN());
236 std::shared_ptr<xRooHypoPoint>
237 asimov(
bool readOnly =
241 const char *fPOIName();
247 std::shared_ptr<const RooAbsCollection>
coords;
249 std::shared_ptr<const RooFitResult> fUfit, fNull_cfit,
fAlt_cfit, fLbound_cfit;
251 bool isExpected =
false;
253 std::shared_ptr<xRooHypoPoint>
257 std::vector<std::tuple<int, double, double>>
nullToys;
259 std::vector<std::tuple<int, double, double>>
altToys;
261 std::shared_ptr<xRooNLLVar> nllVar =
nullptr;
262 std::shared_ptr<RooStats::HypoTestResult> hypoTestResult =
nullptr;
263 std::shared_ptr<const RooFitResult> retrieveFit(
int type);
265 TString tsTitle(
bool inWords =
false)
const;
268 std::pair<double, double> pX_toys(
bool alt,
double nSigma = std::numeric_limits<double>::quiet_NaN());
269 size_t addToys(
bool alt,
int nToys,
int initialSeed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
270 double target_nSigma = std::numeric_limits<double>::quiet_NaN(),
bool targetCLs =
false,
271 double relErrThreshold = 2.,
size_t maxToys = 10000);
276 double alt_value = std::numeric_limits<double>::quiet_NaN(),
281 xRooHypoPoint hypoPoint(
double value,
double alt_value = std::numeric_limits<double>::quiet_NaN(),
288 public std::vector<xRooHypoPoint> {
294 bool AddModel(
const xRooNode &pdf,
const char *validity =
"");
296 void LoadFits(
const char *apath);
299 int AddPoints(
const char *parName,
size_t nPoints,
double low,
double high);
301 void Print(
Option_t *opt =
"")
const override;
306 std::shared_ptr<RooArgSet>
pars()
const {
return fPars; };
320 std::shared_ptr<TGraphErrors>
graph(
const char *opt)
const;
323 std::shared_ptr<TMultiGraph> graphs(
const char *opt);
326 xValueWithError findlimit(
const char *opt,
double relUncert = std::numeric_limits<double>::infinity(),
327 unsigned int maxTries = 20);
330 xValueWithError limit(
const char *
type =
"cls",
double nSigma = std::numeric_limits<double>::quiet_NaN())
const;
331 int scan(
const char *
type,
size_t nPoints,
double low = std::numeric_limits<double>::quiet_NaN(),
332 double high = std::numeric_limits<double>::quiet_NaN(),
333 const std::vector<double> &nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
334 double relUncert = 0.1);
336 const std::vector<double> &nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
337 double relUncert = 0.1)
339 return scan(
type, 0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
342 int scan(
const char *
type,
double nSigma,
double relUncert = 0.1)
344 return scan(
type, std::vector<double>{nSigma}, relUncert);
349 std::map<std::string, std::pair<double, double>>
350 limits(
const char *opt =
"cls",
351 const std::vector<double> &nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
352 double relUncert = std::numeric_limits<double>::infinity());
355 std::shared_ptr<xRooNode> pdf(
const char *parValues =
"")
const;
364 static std::pair<double, double>
365 GetLimit(
const TGraph &pValues,
double target = std::numeric_limits<double>::quiet_NaN());
372 std::map<std::shared_ptr<xRooNode>, std::shared_ptr<xRooNLLVar>>
fNlls;
374 std::set<std::pair<std::shared_ptr<RooArgList>, std::shared_ptr<xRooNode>>>
fPdfs;
377 xRooHypoSpace hypoSpace(
const char *parName,
int nPoints,
double low,
double high,
378 double alt_value = std::numeric_limits<double>::quiet_NaN(),
382 double alt_value = std::numeric_limits<double>::quiet_NaN());
383 xRooHypoSpace hypoSpace(
int nPoints,
double low,
double high,
384 double alt_value = std::numeric_limits<double>::quiet_NaN(),
388 return hypoSpace(parName,
int(tsType), nPoints, -std::numeric_limits<double>::infinity(),
389 std::numeric_limits<double>::infinity());
392 std::shared_ptr<RooArgSet> pars(
bool stripGlobalObs =
true)
const;
396 TObject *Scan(
const RooArgList &scanPars,
const std::vector<std::vector<double>> &coords,
398 TObject *Scan(
const char *scanPars,
const std::vector<std::vector<double>> &coords,
400 TObject *
Scan(
const char *scanPars,
size_t nPoints,
double low,
double high,
size_t nPointsY,
double ylow,
403 std::vector<std::vector<double>> coords;
405 double step = (high - low) / (nPoints);
406 for (
size_t i = 0; i < nPoints; i++) {
407 std::vector<double> coord({low + step * i});
409 double stepy = (yhigh - ylow) / (nPointsY);
410 for (
size_t j = 0; j < nPointsY; j++) {
411 coord.push_back({ylow + stepy * j});
412 coords.push_back(coord);
416 coords.push_back(coord);
420 return Scan(scanPars, coords, profilePars);
425 return Scan(scanPars, nPoints, low, high, 0, 0, 0, profilePars);
428 std::shared_ptr<RooAbsReal> func()
const;
429 std::shared_ptr<RooAbsPdf>
pdf()
const {
return fPdf; }
442 double getEntryVal(
size_t entry)
const;
443 double extendedTerm()
const;
444 double simTerm()
const;
445 double binnedDataTerm()
const;
446 double getEntryBinWidth(
size_t entry)
const;
449 double saturatedVal()
const;
450 double saturatedConstraintTerm()
const;
451 double saturatedNllTerm()
const;
455 bool setData(
const std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>> &_data);
456 bool setData(
const std::shared_ptr<RooAbsData> &
data,
const std::shared_ptr<const RooAbsCollection> &globs)
458 return setData(std::make_pair(
data, globs));
464 std::shared_ptr<RooAbsPdf>
fPdf;
466 std::shared_ptr<const RooAbsCollection>
fGlobs;
468 std::shared_ptr<RooLinkedList>
fOpts;
476 bool kReuseNLL =
true;
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 char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t target
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t result
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void value
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h Atom_t Int_t ULong_t ULong_t unsigned char prop_list Atom_t Atom_t Atom_t Time_t type
double impact(const char *poi, const char *np, bool up=true, bool prefit=false, bool approx=false)
std::shared_ptr< xRooNLLVar > fNll
RooArgList ranknp(bool up=true, bool prefit=false, double approxThreshold=std::numeric_limits< double >::infinity())
std::shared_ptr< xRooNLLVar > nll() const
std::shared_ptr< xRooNode > fNode
double impact(const char *np, bool up=true, bool prefit=false, bool approx=false)
std::shared_ptr< std::map< std::string, xRooFitResult > > fCfits
std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > fData
static std::set< int > allowedStatusCodes
std::vector< std::tuple< int, double, double > > altToys
std::shared_ptr< const RooAbsCollection > coords
std::vector< std::tuple< int, double, double > > nullToys
std::shared_ptr< const RooFitResult > fAlt_cfit
std::pair< double, double > pCLs_toys(double nSigma=std::numeric_limits< double >::quiet_NaN())
std::shared_ptr< const RooFitResult > fGenFit
std::shared_ptr< xRooHypoPoint > fAsimov
std::shared_ptr< const RooFitResult > gfit()
std::shared_ptr< RooArgSet > pars() const
xRooHypoPoint & point(size_t i)
int scan(const char *type="cls", const std::vector< double > &nSigmas={0, 1, 2, -1, -2, std::numeric_limits< double >::quiet_NaN()}, double relUncert=0.1)
std::map< std::shared_ptr< xRooNode >, std::shared_ptr< xRooNLLVar > > fNlls
int scan(const char *type, double nSigma, double relUncert=0.1)
std::shared_ptr< RooArgSet > fPars
std::set< std::pair< std::shared_ptr< RooArgList >, std::shared_ptr< xRooNode > > > fPdfs
This xRooNLLVar object has several special methods, e.g.
std::shared_ptr< RooAbsCollection > fFuncGlobs
std::shared_ptr< const RooAbsCollection > fGlobs
bool setData(const std::shared_ptr< RooAbsData > &data, const std::shared_ptr< const RooAbsCollection > &globs)
xRooHypoPoint hypoPoint(const char *parValues, double alt_value, const xRooFit::Asymptotics::PLLType &pllType)
std::shared_ptr< RooLinkedList > fOpts
std::shared_ptr< ROOT::Fit::FitConfig > fFitConfig
void SetFitConfig(const std::shared_ptr< ROOT::Fit::FitConfig > &in)
xRooHypoSpace hypoSpace(const char *parName, xRooFit::TestStatistic::Type tsType, int nPoints=0)
std::shared_ptr< RooAbsCollection > fConstVars
std::shared_ptr< RooAbsPdf > pdf() const
RooAbsReal * operator->() const
TObject * Scan(const char *scanPars, size_t nPoints, double low, double high, size_t nPointsY, double ylow, double yhigh, const RooArgList &profilePars=RooArgList())
const RooAbsCollection * globs() const
std::string fFuncCreationLog
std::shared_ptr< RooAbsCollection > fFuncVars
std::shared_ptr< RooAbsData > fData
std::shared_ptr< RooAbsPdf > fPdf
TObject * Scan(const char *scanPars, size_t nPoints, double low, double high, const RooArgList &profilePars=RooArgList())
The xRooNode class is designed to wrap over a TObject and provide functionality to aid with interacti...
Generic interface for defining configuration options of a numerical algorithm.
Abstract container object that can hold multiple RooAbsArg objects.
Storage_t const & get() const
Const access to the underlying stl container.
Abstract base class for binned and unbinned datasets.
Abstract interface for all probability density functions.
Abstract base class for objects that represent a real value and implements functionality common to al...
RooArgList is a container object that can hold multiple RooAbsArg objects.
Named container for two doubles, two integers two object points and three string pointers that can be...
Calculates the sum of the -(log) likelihoods of a set of RooAbsPfs that represent constraint function...
RooFitResult is a container class to hold the input and output of a PDF fit to a dataset.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
Class RooNLLVar implements a -log(likelihood) calculation from a dataset and a PDF.
RooRealVar represents a variable that can be changed from the outside.
HypoTestInverterResult class holds the array of hypothesis test results and compute a confidence inte...
HypoTestResult is a base class for results from hypothesis tests.
Fill Area Attributes class.
A TGraphErrors is a TGraph with error bars.
A TGraph is an object made of two arrays X and Y with npoints each.
A TMultiGraph is a collection of TGraph (or derived) objects.
The TNamed class is the base class for all named ROOT classes.
Mother of all ROOT objects.
Namespace for the RooStats classes.
#define BEGIN_XROOFIT_NAMESPACE
#define END_XROOFIT_NAMESPACE
xValueWithError(const std::pair< double, double > &in)