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 {
return fNll; }
108 ?
RooArgList(*std::unique_ptr<RooAbsCollection>(
get()->floatParsFinal().selectByAttrib(
"poi",
true)))
114 xRooFitResult cfit(
const char *poiValues,
const char *alias =
nullptr);
118 double impact(
const char *
poi,
const char *
np,
bool up =
true,
bool prefit =
false,
bool approx =
false);
119 double impact(
const char *
np,
bool up =
true,
bool prefit =
false,
bool approx =
false)
122 if (_poi.size() != 1)
123 throw std::runtime_error(
"xRooFitResult::impact: not one POI");
124 return impact(
poi().contentsString().c_str(),
np, up, prefit, approx);
130 double conditionalError(
const char *poi,
const char *nps,
bool up =
true,
bool approx =
false);
135 RooArgList ranknp(
const char *poi,
bool up =
true,
bool prefit =
false,
136 double approxThreshold = std::numeric_limits<double>::infinity());
139 ranknp(
bool up =
true,
bool prefit =
false,
double approxThreshold = std::numeric_limits<double>::infinity())
142 if (_poi.size() != 1)
143 throw std::runtime_error(
"xRooFitResult::ranknp: not one POI");
144 return ranknp(
poi().contentsString().c_str(), up, prefit, approxThreshold);
148 std::shared_ptr<xRooNLLVar>
fNll;
150 std::shared_ptr<std::map<std::string, xRooFitResult>>
fCfits;
156 std::shared_ptr<ROOT::Fit::FitConfig> fitConfig();
172 std::shared_ptr<const RooFitResult>
ufit(
bool readOnly =
false);
173 std::shared_ptr<const RooFitResult>
cfit_null(
bool readOnly =
false);
174 std::shared_ptr<const RooFitResult>
cfit_alt(
bool readOnly =
false);
175 std::shared_ptr<const RooFitResult>
cfit_lbound(
bool readOnly =
false);
178 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
fData;
179 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
data();
194 return std::pair<double, double>(1, 0);
197 double nom = (null.first == 0) ? 0 : null.first / alt.first;
204 return std::pair<double, double>(nom, (alt.first - alt.second <= 0)
205 ? std::numeric_limits<double>::infinity()
206 : (sqrt(pow(null.second, 2) + pow(alt.second * nom, 2)) / alt.first));
209 xValueWithError ts_toys(
double nSigma = std::numeric_limits<double>::quiet_NaN());
218 addNullToys(
int nToys = 1,
int seed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
219 double target_nSigma = std::numeric_limits<double>::quiet_NaN());
221 addAltToys(
int nToys = 1,
int seed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
222 double target_nSigma = std::numeric_limits<double>::quiet_NaN());
224 addCLsToys(
int nToys = 1,
int seed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
225 double target_nSigma = std::numeric_limits<double>::quiet_NaN());
231 std::shared_ptr<xRooHypoPoint>
232 asimov(
bool readOnly =
236 const char *fPOIName();
242 std::shared_ptr<const RooAbsCollection>
coords;
248 std::shared_ptr<xRooHypoPoint>
252 std::vector<std::tuple<int, double, double>>
nullToys;
254 std::vector<std::tuple<int, double, double>>
altToys;
256 std::shared_ptr<xRooNLLVar>
nllVar =
nullptr;
264 size_t addToys(
bool alt,
int nToys,
int initialSeed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
265 double target_nSigma = std::numeric_limits<double>::quiet_NaN(),
bool targetCLs =
false,
266 double relErrThreshold = 2.,
size_t maxToys = 10000);
271 double alt_value = std::numeric_limits<double>::quiet_NaN(),
283 public std::vector<xRooHypoPoint> {
294 int AddPoints(
const char *parName,
size_t nPoints,
double low,
double high);
301 std::shared_ptr<RooArgSet>
pars()
const {
return fPars; };
315 std::shared_ptr<TGraphErrors>
graph(
const char *opt)
const;
318 std::shared_ptr<TMultiGraph> graphs(
const char *opt);
321 xValueWithError findlimit(
const char *opt,
double relUncert = std::numeric_limits<double>::infinity(),
322 unsigned int maxTries = 20);
325 xValueWithError limit(
const char *
type =
"cls",
double nSigma = std::numeric_limits<double>::quiet_NaN())
const;
326 int scan(
const char *
type,
size_t nPoints,
double low = std::numeric_limits<double>::quiet_NaN(),
327 double high = std::numeric_limits<double>::quiet_NaN(),
328 const std::vector<double> &nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
329 double relUncert = 0.1);
331 const std::vector<double> &nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
332 double relUncert = 0.1)
334 return scan(
type, 0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
337 int scan(
const char *
type,
double nSigma,
double relUncert = 0.1)
339 return scan(
type, std::vector<double>{nSigma}, relUncert);
344 std::map<std::string, xValueWithError>
345 limits(
const char *opt =
"cls",
346 const std::vector<double> &nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
347 double relUncert = std::numeric_limits<double>::infinity());
350 std::shared_ptr<xRooNode> pdf(
const char *parValues =
"")
const;
359 static xValueWithError GetLimit(
const TGraph &pValues,
double target = std::numeric_limits<double>::quiet_NaN());
366 std::map<std::shared_ptr<xRooNode>, std::shared_ptr<xRooNLLVar>>
fNlls;
368 std::set<std::pair<std::shared_ptr<RooArgList>, std::shared_ptr<xRooNode>>>
fPdfs;
372 double alt_value = std::numeric_limits<double>::quiet_NaN(),
376 double alt_value = std::numeric_limits<double>::quiet_NaN());
378 double alt_value = std::numeric_limits<double>::quiet_NaN(),
382 return hypoSpace(parName,
int(tsType), nPoints, -std::numeric_limits<double>::infinity(),
383 std::numeric_limits<double>::infinity());
386 std::shared_ptr<RooArgSet> pars(
bool stripGlobalObs =
true)
const;
390 TObject *Scan(
const RooArgList &scanPars,
const std::vector<std::vector<double>> &coords,
392 TObject *Scan(
const char *scanPars,
const std::vector<std::vector<double>> &coords,
394 TObject *
Scan(
const char *scanPars,
size_t nPoints,
double low,
double high,
size_t nPointsY,
double ylow,
397 std::vector<std::vector<double>> coords;
399 double step = (high - low) / (nPoints);
400 for (
size_t i = 0;
i < nPoints;
i++) {
401 std::vector<double> coord({low + step *
i});
403 double stepy = (yhigh - ylow) / (nPointsY);
404 for (
size_t j = 0; j < nPointsY; j++) {
405 coord.push_back({ylow + stepy * j});
406 coords.push_back(coord);
410 coords.push_back(coord);
414 return Scan(scanPars, coords, profilePars);
419 return Scan(scanPars, nPoints, low, high, 0, 0, 0, profilePars);
422 std::shared_ptr<RooAbsReal> func()
const;
423 std::shared_ptr<RooAbsPdf>
pdf()
const {
return fPdf; }
436 double getEntryVal(
size_t entry)
const;
437 double extendedTerm()
const;
438 double simTerm()
const;
439 double binnedDataTerm()
const;
440 double getEntryBinWidth(
size_t entry)
const;
443 double saturatedVal()
const;
444 double saturatedConstraintTerm()
const;
445 double saturatedMainTerm()
const;
447 double mainTermPgof()
const;
448 double mainTermNdof()
const;
450 std::set<std::string> binnedChannels()
const;
453 bool setData(
const std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>> &
_data);
454 bool setData(
const std::shared_ptr<RooAbsData> &
data,
const std::shared_ptr<const RooAbsCollection> &
globs)
462 std::shared_ptr<RooAbsPdf>
fPdf;
464 std::shared_ptr<const RooAbsCollection>
fGlobs;
466 std::shared_ptr<RooLinkedList>
fOpts;
479std::string printValue(
const std::map<std::string, xRooNLLVar::xValueWithError> *
m);
RooAbsData * _data
Pointer to original input dataset.
bool setData(RooAbsData &data, bool cloneData=true) override
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 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 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
void Print(GNN_Data &d, std::string txt="")
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())
xRooFitResult(const std::shared_ptr< xRooNode > &in, const std::shared_ptr< xRooNLLVar > &nll=nullptr)
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
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
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
xValueWithError pAlt_toys(double nSigma=std::numeric_limits< double >::quiet_NaN())
std::shared_ptr< const RooFitResult > ufit(bool readOnly=false)
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
static std::set< int > allowedStatusCodes
std::shared_ptr< xRooHypoPoint > fAsimov
xValueWithError pCLs_toys(double nSigma=std::numeric_limits< double >::quiet_NaN())
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="")
std::map< std::shared_ptr< xRooNode >, std::shared_ptr< xRooNLLVar > > fNlls
int scan(const char *type, double nSigma, double relUncert=0.1)
int AddPoints(const char *parName, size_t nPoints, double low, double high)
std::shared_ptr< RooArgSet > fPars
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
void LoadFits(const char *apath)
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< 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)
TObject * Scan(const RooArgList &scanPars, const std::vector< std::vector< double > > &coords, const RooArgList &profilePars=RooArgList())
xRooHypoSpace hypoSpace(const char *parName, xRooFit::TestStatistic::Type tsType, int nPoints=0)
std::shared_ptr< RooAbsCollection > fConstVars
xRooNLLVar(RooAbsPdf &pdf, const std::pair< RooAbsData *, const RooAbsCollection * > &data, const RooLinkedList &nllOpts=RooLinkedList())
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())
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...
Implements a -log(likelihood) calculation from a dataset and a PDF.
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.
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})