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,
89 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
91 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
92 generate(
bool expected =
false,
int seed = 0);
99 const std::shared_ptr<xRooNLLVar> &
nll =
nullptr);
105 std::shared_ptr<xRooNLLVar>
nll()
const {
return fNll; }
110 ?
RooArgList(*std::unique_ptr<RooAbsCollection>(
get()->floatParsFinal().selectByAttrib(
"poi",
true)))
116 xRooFitResult cfit(
const char *poiValues,
const char *alias =
nullptr);
120 double impact(
const char *
poi,
const char *
np,
bool up =
true,
bool prefit =
false,
bool approx =
false);
121 double impact(
const char *
np,
bool up =
true,
bool prefit =
false,
bool approx =
false)
124 if (_poi.size() != 1)
125 throw std::runtime_error(
"xRooFitResult::impact: not one POI");
126 return impact(
poi().contentsString().c_str(),
np, up, prefit, approx);
132 double conditionalError(
const char *poi,
const char *nps,
bool up =
true,
bool approx =
false);
137 RooArgList ranknp(
const char *poi,
bool up =
true,
bool prefit =
false,
138 double approxThreshold = std::numeric_limits<double>::infinity());
141 ranknp(
bool up =
true,
bool prefit =
false,
double approxThreshold = std::numeric_limits<double>::infinity())
144 if (_poi.size() != 1)
145 throw std::runtime_error(
"xRooFitResult::ranknp: not one POI");
146 return ranknp(
poi().contentsString().c_str(), up, prefit, approxThreshold);
150 std::shared_ptr<xRooNLLVar>
fNll;
152 std::shared_ptr<std::map<std::string, xRooFitResult>>
fCfits;
158 std::shared_ptr<ROOT::Fit::FitConfig> fitConfig();
174 std::shared_ptr<const RooFitResult>
ufit(
bool readOnly =
false);
175 std::shared_ptr<const RooFitResult>
cfit_null(
bool readOnly =
false);
176 std::shared_ptr<const RooFitResult>
cfit_alt(
bool readOnly =
false);
177 std::shared_ptr<const RooFitResult>
cfit_lbound(
bool readOnly =
false);
180 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
fData;
181 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
data();
196 return std::pair<double, double>(1, 0);
199 double nom = (null.first == 0) ? 0 : null.first / alt.first;
206 return std::pair<double, double>(nom, (alt.first - alt.second <= 0)
207 ? std::numeric_limits<double>::infinity()
208 : (sqrt(pow(null.second, 2) + pow(alt.second * nom, 2)) / alt.first));
211 xValueWithError ts_toys(
double nSigma = std::numeric_limits<double>::quiet_NaN());
220 addNullToys(
int nToys = 1,
int seed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
221 double target_nSigma = std::numeric_limits<double>::quiet_NaN());
223 addAltToys(
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 addCLsToys(
int nToys = 1,
int seed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
227 double target_nSigma = std::numeric_limits<double>::quiet_NaN());
233 std::shared_ptr<xRooHypoPoint>
234 asimov(
bool readOnly =
238 const char *fPOIName();
260 altToys.emplace_back(std::make_tuple(seed,
value, weight));
263 std::shared_ptr<const RooAbsCollection>
coords;
268 double obs_ts = std::numeric_limits<double>::quiet_NaN();
269 double obs_ts_err = std::numeric_limits<double>::quiet_NaN();
271 std::shared_ptr<xRooHypoPoint>
275 std::vector<std::tuple<int, double, double>>
nullToys;
277 std::vector<std::tuple<int, double, double>>
altToys;
279 std::shared_ptr<xRooNLLVar>
nllVar =
nullptr;
287 size_t addToys(
bool alt,
int nToys,
int initialSeed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
288 double target_nSigma = std::numeric_limits<double>::quiet_NaN(),
bool targetCLs =
false,
289 double relErrThreshold = 2.,
size_t maxToys = 10000);
294 double alt_value = std::numeric_limits<double>::quiet_NaN(),
306 public std::vector<xRooHypoPoint> {
318 int AddPoints(
const char *parName,
size_t nPoints,
double low,
double high);
325 std::shared_ptr<RooArgSet>
pars()
const {
return fPars; };
339 std::shared_ptr<TGraphErrors> graph(
const char *opt)
const;
342 std::shared_ptr<TMultiGraph> graphs(
const char *opt);
345 xValueWithError findlimit(
const char *opt,
double relUncert = std::numeric_limits<double>::infinity(),
346 unsigned int maxTries = 20);
349 xValueWithError limit(
const char *
type =
"cls",
double nSigma = std::numeric_limits<double>::quiet_NaN())
const;
350 int scan(
const char *
type,
size_t nPoints,
double low = std::numeric_limits<double>::quiet_NaN(),
351 double high = std::numeric_limits<double>::quiet_NaN(),
352 const std::vector<double> &nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
353 double relUncert = 0.1);
355 const std::vector<double> &nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
356 double relUncert = 0.1)
358 return scan(
type, 0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
361 int scan(
const char *
type,
double nSigma,
double relUncert = 0.1)
363 return scan(
type, std::vector<double>{nSigma}, relUncert);
368 std::map<std::string, xValueWithError>
369 limits(
const char *opt =
"cls",
370 const std::vector<double> &nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
371 double relUncert = std::numeric_limits<double>::infinity());
374 std::shared_ptr<xRooNode> pdf(
const char *parValues =
"")
const;
383 static xValueWithError GetLimit(
const TGraph &pValues,
double target = std::numeric_limits<double>::quiet_NaN());
390 std::map<std::shared_ptr<xRooNode>, std::shared_ptr<xRooNLLVar>>
fNlls;
392 std::set<std::pair<std::shared_ptr<RooArgList>, std::shared_ptr<xRooNode>>>
fPdfs;
398 double alt_value = std::numeric_limits<double>::quiet_NaN(),
403 double alt_value = std::numeric_limits<double>::quiet_NaN());
405 double alt_value = std::numeric_limits<double>::quiet_NaN(),
408 double low = -std::numeric_limits<double>::infinity(),
409 double high = std::numeric_limits<double>::infinity(),
410 double alt_value = std::numeric_limits<double>::quiet_NaN())
415 std::shared_ptr<RooArgSet> pars(
bool stripGlobalObs =
true)
const;
419 TObject *Scan(
const RooArgList &scanPars,
const std::vector<std::vector<double>> &coords,
421 TObject *Scan(
const char *scanPars,
const std::vector<std::vector<double>> &coords,
423 TObject *
Scan(
const char *scanPars,
size_t nPoints,
double low,
double high,
size_t nPointsY,
double ylow,
426 std::vector<std::vector<double>> coords;
428 double step = (high - low) / (nPoints);
429 for (
size_t i = 0; i < nPoints; i++) {
430 std::vector<double> coord({low + step * i});
432 double stepy = (yhigh - ylow) / (nPointsY);
433 for (
size_t j = 0; j < nPointsY; j++) {
434 coord.push_back({ylow + stepy * j});
435 coords.push_back(coord);
439 coords.push_back(coord);
443 return Scan(scanPars, coords, profilePars);
448 return Scan(scanPars, nPoints, low, high, 0, 0, 0, profilePars);
451 std::shared_ptr<RooAbsReal> func()
const;
452 std::shared_ptr<RooAbsPdf>
pdf()
const {
return fPdf; }
465 double mainTermVal()
const;
466 double constraintTermVal()
const;
468 double getEntryVal(
size_t entry)
const;
469 double extendedTermVal()
const;
470 double simTermVal()
const;
471 double binnedDataTermVal()
const;
472 double getEntryBinWidth(
size_t entry)
const;
475 double saturatedVal()
const;
480 double saturatedConstraintTermVal()
const;
482 double saturatedMainTermVal()
const;
484 double mainTermPgof()
const;
485 double mainTermNdof()
const;
487 std::set<std::string> binnedChannels()
const;
490 bool setData(
const std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>> &_data);
491 bool setData(
const std::shared_ptr<RooAbsData> &
data,
const std::shared_ptr<const RooAbsCollection> &
globs)
499 std::shared_ptr<RooAbsPdf>
fPdf;
501 std::shared_ptr<const RooAbsCollection>
fGlobs;
503 std::shared_ptr<RooLinkedList>
fOpts;
516std::string printValue(
const std::map<std::string, xRooNLLVar::xValueWithError> *
m);
const char Option_t
Option string (const char)
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
const RooFitResult * operator->() const
RooArgList ranknp(bool up=true, bool prefit=false, double approxThreshold=std::numeric_limits< double >::infinity())
std::shared_ptr< xRooNLLVar > nll() const
RooArgList ranknp(const char *poi, bool up=true, bool prefit=false, double approxThreshold=std::numeric_limits< double >::infinity())
std::shared_ptr< xRooNode > fNode
double impact(const char *np, bool up=true, bool prefit=false, bool approx=false)
xRooFitResult(const RooFitResult &fr)
std::shared_ptr< std::map< std::string, xRooFitResult > > fCfits
xValueWithError pll(bool readOnly=false)
std::shared_ptr< RooStats::HypoTestResult > hypoTestResult
std::shared_ptr< const RooFitResult > retrieveFit(int type)
std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > fData
std::vector< std::tuple< int, double, double > > altToys
std::shared_ptr< const RooAbsCollection > coords
void addNullToy(double value, double weight=1., int seed=0)
std::shared_ptr< const RooFitResult > fLbound_cfit
std::shared_ptr< const RooFitResult > cfit_lbound(bool readOnly=false)
std::shared_ptr< xRooNLLVar > nllVar
std::shared_ptr< const RooFitResult > fNull_cfit
TString tsTitle(bool inWords=false) const
std::shared_ptr< const RooFitResult > fUfit
xRooHypoPoint(std::shared_ptr< RooStats::HypoTestResult > htr=nullptr, const RooAbsCollection *_coords=nullptr)
xRooFit::Asymptotics::PLLType fPllType
xValueWithError sigma_mu(bool readOnly=false)
xValueWithError pAlt_asymp(double nSigma=std::numeric_limits< double >::quiet_NaN())
std::vector< std::tuple< int, double, double > > nullToys
void setAltVal(double val)
void setObsTS(double val, double err)
xValueWithError pAlt_toys(double nSigma=std::numeric_limits< double >::quiet_NaN())
std::shared_ptr< const RooFitResult > ufit(bool readOnly=false)
void Print(Option_t *opt="") const override
Print TNamed name and title.
std::shared_ptr< const RooFitResult > cfit_null(bool readOnly=false)
xValueWithError pCLs_asymp(double nSigma=std::numeric_limits< double >::quiet_NaN())
std::shared_ptr< const RooFitResult > cfit_alt(bool readOnly=false)
size_t addToys(bool alt, int nToys, int initialSeed=0, double target=std::numeric_limits< double >::quiet_NaN(), double target_nSigma=std::numeric_limits< double >::quiet_NaN(), bool targetCLs=false, double relErrThreshold=2., size_t maxToys=10000)
std::shared_ptr< const RooFitResult > fAlt_cfit
xValueWithError pX_toys(bool alt, double nSigma=std::numeric_limits< double >::quiet_NaN())
std::shared_ptr< const RooFitResult > fGenFit
void addAltToy(double value, double weight=1., int seed=0)
static std::set< int > allowedStatusCodes
std::shared_ptr< xRooHypoPoint > fAsimov
xValueWithError pCLs_toys(double nSigma=std::numeric_limits< double >::quiet_NaN())
void setNullVal(double val)
xValueWithError ts_asymp(double nSigma=std::numeric_limits< double >::quiet_NaN())
xValueWithError getVal(const char *what)
xValueWithError pNull_asymp(double nSigma=std::numeric_limits< double >::quiet_NaN())
xValueWithError pNull_toys(double nSigma=std::numeric_limits< double >::quiet_NaN())
std::shared_ptr< const RooFitResult > gfit()
std::shared_ptr< RooArgSet > pars() const
xRooFit::Asymptotics::PLLType fTestStatType
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)
RooStats::HypoTestInverterResult * result()
bool AddModel(const xRooNode &pdf, const char *validity="")
TDirectory * fitCache() const
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::shared_ptr< TDirectory > fFitDb
xRooHypoSpace(const char *name="", const char *title="")
int scan(const char *type, size_t nPoints, double low=std::numeric_limits< double >::quiet_NaN(), double high=std::numeric_limits< double >::quiet_NaN(), const std::vector< double > &nSigmas={0, 1, 2, -1, -2, std::numeric_limits< double >::quiet_NaN()}, double relUncert=0.1)
std::shared_ptr< xRooNode > pdf(const RooAbsCollection &parValues) const
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
double saturatedConstraintTermVal() const
double saturatedMainTerm() const
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< RooAbsReal > func() const
RooAbsData * data() const
std::shared_ptr< ROOT::Fit::FitConfig > fFitConfig
void SetFitConfig(const std::shared_ptr< ROOT::Fit::FitConfig > &in)
xRooHypoSpace hypoSpace(const char *parName, int nPoints, double low, double high, double alt_value=std::numeric_limits< double >::quiet_NaN(), const xRooFit::Asymptotics::PLLType &pllType=xRooFit::Asymptotics::Unknown, int tsType=0)
TObject * Scan(const RooArgList &scanPars, const std::vector< std::vector< double > > &coords, const RooArgList &profilePars=RooArgList())
std::shared_ptr< RooAbsCollection > fConstVars
xRooNLLVar(RooAbsPdf &pdf, const std::pair< RooAbsData *, const RooAbsCollection * > &data, const RooLinkedList &nllOpts=RooLinkedList())
xRooHypoSpace hypoSpace(const char *parName, xRooFit::TestStatistic::Type tsType, int nPoints=0, double low=-std::numeric_limits< double >::infinity(), double high=std::numeric_limits< double >::infinity(), double alt_value=std::numeric_limits< double >::quiet_NaN())
std::shared_ptr< RooAbsPdf > pdf() const
void AddOption(const RooCmdArg &opt)
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
void Print(Option_t *opt="")
std::string fFuncCreationLog
double saturatedMainTermVal() const
std::shared_ptr< RooAbsCollection > fFuncVars
double saturatedConstraintTerm() const
void SetOption(const RooCmdArg &opt)
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())
bool setData(const std::pair< std::shared_ptr< RooAbsData >, std::shared_ptr< const RooAbsCollection > > &_data)
xRooHypoPoint hypoPoint(const char *parName, double value, double alt_value=std::numeric_limits< double >::quiet_NaN(), const xRooFit::Asymptotics::PLLType &pllType=xRooFit::Asymptotics::Unknown)
xRooFitResult minimize(const std::shared_ptr< ROOT::Fit::FitConfig > &=nullptr)
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.
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.
Collection class for internal use, storing a collection of RooAbsArg pointers in a doubly linked list...
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.
TAttFill()
AttFill default constructor.
TAttLine()
AttLine default constructor.
TAttMarker()
TAttMarker default constructor.
Describe directory structure in memory.
A file, usually with extension .root, that stores data and code in the form of serialized objects in ...
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.
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={0, 0})