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;
153 xRooFitResult minimize(
const std::shared_ptr<ROOT::Fit::FitConfig> & =
nullptr);
155 void SetFitConfig(
const std::shared_ptr<ROOT::Fit::FitConfig> &in) { fFitConfig = in; }
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);
176 std::shared_ptr<const RooFitResult>
gfit() {
return fGenFit; }
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();
184 xValueWithError pNull_asymp(
double nSigma = std::numeric_limits<double>::quiet_NaN());
185 xValueWithError pAlt_asymp(
double nSigma = std::numeric_limits<double>::quiet_NaN());
186 xValueWithError pCLs_asymp(
double nSigma = std::numeric_limits<double>::quiet_NaN());
187 xValueWithError ts_asymp(
double nSigma = std::numeric_limits<double>::quiet_NaN());
189 xValueWithError pNull_toys(
double nSigma = std::numeric_limits<double>::quiet_NaN());
190 xValueWithError pAlt_toys(
double nSigma = std::numeric_limits<double>::quiet_NaN());
193 if (fNullVal() == fAltVal())
194 return std::pair<double, double>(1, 0);
195 auto null = pNull_toys(nSigma);
196 auto alt = pAlt_toys(nSigma);
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;
244 std::shared_ptr<const RooFitResult> fUfit, fNull_cfit,
fAlt_cfit, fLbound_cfit;
246 bool isExpected =
false;
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;
257 std::shared_ptr<RooStats::HypoTestResult> hypoTestResult =
nullptr;
258 std::shared_ptr<const RooFitResult> retrieveFit(
int type);
260 TString tsTitle(
bool inWords =
false)
const;
263 xValueWithError pX_toys(
bool alt,
double nSigma = std::numeric_limits<double>::quiet_NaN());
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(),
276 xRooHypoPoint hypoPoint(
double value,
double alt_value = std::numeric_limits<double>::quiet_NaN(),
283 public std::vector<xRooHypoPoint> {
289 bool AddModel(
const xRooNode &pdf,
const char *validity =
"");
291 void LoadFits(
const char *apath);
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;
371 xRooHypoSpace hypoSpace(
const char *parName,
int nPoints,
double low,
double high,
372 double alt_value = std::numeric_limits<double>::quiet_NaN(),
376 double alt_value = std::numeric_limits<double>::quiet_NaN());
377 xRooHypoSpace hypoSpace(
int nPoints,
double low,
double high,
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)
456 return setData(std::make_pair(
data, globs));
462 std::shared_ptr<RooAbsPdf>
fPdf;
464 std::shared_ptr<const RooAbsCollection>
fGlobs;
466 std::shared_ptr<RooLinkedList>
fOpts;
474 bool kReuseNLL =
true;
479std::string printValue(
const std::map<std::string, xRooNLLVar::xValueWithError> *
m);
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
std::vector< std::tuple< int, double, double > > nullToys
std::shared_ptr< const RooFitResult > fAlt_cfit
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())
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.
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.
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={0, 0})