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)))
124 if (_poi.size() != 1)
125 throw std::runtime_error(
"xRooFitResult::impact: not one POI");
132 double conditionalError(
const char *poi,
const char *
nps,
bool up =
true,
bool approx =
false);
144 if (_poi.size() != 1)
145 throw std::runtime_error(
"xRooFitResult::ranknp: not one POI");
150 std::shared_ptr<xRooNLLVar>
fNll;
152 std::shared_ptr<std::map<std::string, xRooFitResult>>
fCfits;
155 xRooFitResult minimize(
const std::shared_ptr<ROOT::Fit::FitConfig> & =
nullptr);
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);
178 std::shared_ptr<const RooFitResult>
gfit() {
return fGenFit; }
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();
195 if (fNullVal() == fAltVal())
196 return std::pair<double, double>(1, 0);
197 auto null = pNull_toys(
nSigma);
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));
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>
238 const char *fPOIName();
244 void setNullVal(
double val);
245 void setAltVal(
double val);
250 fPllType = xRooFit::Asymptotics::Unknown;
254 fPllType = xRooFit::Asymptotics::Unknown;
255 nullToys.emplace_back(std::make_tuple(seed,
value, weight));
259 fPllType = xRooFit::Asymptotics::Unknown;
260 altToys.emplace_back(std::make_tuple(seed,
value, weight));
263 std::shared_ptr<const RooAbsCollection>
coords;
265 std::shared_ptr<const RooFitResult> fUfit, fNull_cfit,
fAlt_cfit, fLbound_cfit;
267 bool isExpected =
false;
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;
280 std::shared_ptr<RooStats::HypoTestResult> hypoTestResult =
nullptr;
281 std::shared_ptr<const RooFitResult> retrieveFit(
int type);
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);
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()},
355 const std::vector<double> &
nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
358 return scan(
type, 0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
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;
421 TObject *Scan(
const char *
scanPars,
const std::vector<std::vector<double>> &coords,
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});
435 coords.push_back(
coord);
439 coords.push_back(
coord);
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;
478 return saturatedConstraintTermVal();
480 double saturatedConstraintTermVal()
const;
481 [[deprecated(
"Use saturatedMainTermVal()")]]
double saturatedMainTerm()
const {
return saturatedMainTermVal(); }
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)
493 return setData(std::make_pair(
data, globs));
499 std::shared_ptr<RooAbsPdf>
fPdf;
501 std::shared_ptr<const RooAbsCollection>
fGlobs;
503 std::shared_ptr<RooLinkedList>
fOpts;
511 bool kReuseNLL =
true;
516std::string printValue(
const std::map<std::string, xRooNLLVar::xValueWithError> *
m);
const char Option_t
Option string (const char)
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
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
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
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
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::vector< std::tuple< int, double, double > > nullToys
void setObsTS(double val, double err)
std::shared_ptr< const RooFitResult > fAlt_cfit
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())
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)
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
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 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< ROOT::Fit::FitConfig > fFitConfig
void SetFitConfig(const std::shared_ptr< ROOT::Fit::FitConfig > &in)
std::shared_ptr< RooAbsCollection > fConstVars
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
std::string fFuncCreationLog
std::shared_ptr< RooAbsCollection > fFuncVars
double saturatedConstraintTerm() const
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.
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.
Fill Area Attributes class.
Describe directory structure in memory.
A ROOT file is an on-disk file, usually with extension .root, that stores objects in a file-system-li...
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={0, 0})