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);
98 const std::shared_ptr<xRooNLLVar> &nll =
nullptr);
104 std::shared_ptr<xRooNLLVar>
nll()
const {
return fNll; }
109 ?
RooArgList(*std::unique_ptr<RooAbsCollection>(get()->floatParsFinal().selectByAttrib(
"poi",
true)))
123 if (_poi.size() != 1)
124 throw std::runtime_error(
"xRooFitResult::impact: not one POI");
131 double conditionalError(
const char *poi,
const char *
nps,
bool up =
true,
bool approx =
false);
143 if (_poi.size() != 1)
144 throw std::runtime_error(
"xRooFitResult::ranknp: not one POI");
149 std::shared_ptr<xRooNLLVar>
fNll;
151 std::shared_ptr<std::map<std::string, xRooFitResult>>
fCfits;
154 xRooFitResult minimize(
const std::shared_ptr<ROOT::Fit::FitConfig> & =
nullptr);
156 void SetFitConfig(
const std::shared_ptr<ROOT::Fit::FitConfig> &in) { fFitConfig = in; }
157 std::shared_ptr<ROOT::Fit::FitConfig> fitConfig();
173 std::shared_ptr<const RooFitResult> ufit(
bool readOnly =
false);
174 std::shared_ptr<const RooFitResult> cfit_null(
bool readOnly =
false);
175 std::shared_ptr<const RooFitResult> cfit_alt(
bool readOnly =
false);
176 std::shared_ptr<const RooFitResult> cfit_lbound(
bool readOnly =
false);
177 std::shared_ptr<const RooFitResult>
gfit() {
return fGenFit; }
179 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
fData;
180 std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>>
data();
194 if (fNullVal() == fAltVal())
195 return std::pair<double, double>(1, 0);
196 auto null = pNull_toys(
nSigma);
198 double nom = (null.first == 0) ? 0 : null.first /
alt.first;
205 return std::pair<double, double>(
nom, (
alt.first -
alt.second <= 0)
206 ? std::numeric_limits<double>::infinity()
207 : (sqrt(pow(null.second, 2) + pow(
alt.second *
nom, 2)) /
alt.first));
219 addNullToys(
int nToys = 1,
int seed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
220 double target_nSigma = std::numeric_limits<double>::quiet_NaN());
222 addAltToys(
int nToys = 1,
int seed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
223 double target_nSigma = std::numeric_limits<double>::quiet_NaN());
225 addCLsToys(
int nToys = 1,
int seed = 0,
double target = std::numeric_limits<double>::quiet_NaN(),
226 double target_nSigma = std::numeric_limits<double>::quiet_NaN());
232 std::shared_ptr<xRooHypoPoint>
237 const char *fPOIName();
243 std::shared_ptr<const RooAbsCollection>
coords;
245 std::shared_ptr<const RooFitResult> fUfit, fNull_cfit,
fAlt_cfit, fLbound_cfit;
247 bool isExpected =
false;
249 std::shared_ptr<xRooHypoPoint>
253 std::vector<std::tuple<int, double, double>>
nullToys;
255 std::vector<std::tuple<int, double, double>>
altToys;
257 std::shared_ptr<xRooNLLVar> nllVar =
nullptr;
258 std::shared_ptr<RooStats::HypoTestResult> hypoTestResult =
nullptr;
259 std::shared_ptr<const RooFitResult> retrieveFit(
int type);
272 double alt_value = std::numeric_limits<double>::quiet_NaN(),
284 public std::vector<xRooHypoPoint> {
292 void LoadFits(
const char *
apath);
295 int AddPoints(
const char *
parName,
size_t nPoints,
double low,
double high);
302 std::shared_ptr<RooArgSet>
pars()
const {
return fPars; };
316 std::shared_ptr<TGraphErrors> graph(
const char *opt)
const;
319 std::shared_ptr<TMultiGraph> graphs(
const char *opt);
327 int scan(
const char *
type,
size_t nPoints,
double low = std::numeric_limits<double>::quiet_NaN(),
328 double high = std::numeric_limits<double>::quiet_NaN(),
329 const std::vector<double> &
nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
332 const std::vector<double> &
nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
335 return scan(
type, 0, std::numeric_limits<double>::quiet_NaN(), std::numeric_limits<double>::quiet_NaN(),
345 std::map<std::string, xValueWithError>
346 limits(
const char *opt =
"cls",
347 const std::vector<double> &
nSigmas = {0, 1, 2, -1, -2, std::numeric_limits<double>::quiet_NaN()},
348 double relUncert = std::numeric_limits<double>::infinity());
351 std::shared_ptr<xRooNode> pdf(
const char *
parValues =
"")
const;
360 static xValueWithError GetLimit(
const TGraph &
pValues,
double target = std::numeric_limits<double>::quiet_NaN());
367 std::map<std::shared_ptr<xRooNode>, std::shared_ptr<xRooNLLVar>>
fNlls;
369 std::set<std::pair<std::shared_ptr<RooArgList>, std::shared_ptr<xRooNode>>>
fPdfs;
375 double alt_value = std::numeric_limits<double>::quiet_NaN(),
379 double alt_value = std::numeric_limits<double>::quiet_NaN());
381 double alt_value = std::numeric_limits<double>::quiet_NaN(),
386 std::numeric_limits<double>::infinity());
389 std::shared_ptr<RooArgSet> pars(
bool stripGlobalObs =
true)
const;
395 TObject *Scan(
const char *
scanPars,
const std::vector<std::vector<double>> &coords,
400 std::vector<std::vector<double>> coords;
402 double step = (high - low) / (
nPoints);
403 for (
size_t i = 0; i <
nPoints; i++) {
404 std::vector<double>
coord({low + step * i});
409 coords.push_back(
coord);
413 coords.push_back(
coord);
425 std::shared_ptr<RooAbsReal> func()
const;
426 std::shared_ptr<RooAbsPdf>
pdf()
const {
return fPdf; }
439 double mainTermVal()
const;
440 double constraintTermVal()
const;
442 double getEntryVal(
size_t entry)
const;
443 double extendedTermVal()
const;
444 double simTermVal()
const;
445 double binnedDataTermVal()
const;
446 double getEntryBinWidth(
size_t entry)
const;
449 double saturatedVal()
const;
452 return saturatedConstraintTermVal();
454 double saturatedConstraintTermVal()
const;
455 [[deprecated(
"Use saturatedMainTermVal()")]]
double saturatedMainTerm()
const {
return saturatedMainTermVal(); }
456 double saturatedMainTermVal()
const;
458 double mainTermPgof()
const;
459 double mainTermNdof()
const;
461 std::set<std::string> binnedChannels()
const;
464 bool setData(
const std::pair<std::shared_ptr<RooAbsData>, std::shared_ptr<const RooAbsCollection>> &_data);
465 bool setData(
const std::shared_ptr<RooAbsData> &
data,
const std::shared_ptr<const RooAbsCollection> &globs)
467 return setData(std::make_pair(
data, globs));
473 std::shared_ptr<RooAbsPdf>
fPdf;
475 std::shared_ptr<const RooAbsCollection>
fGlobs;
477 std::shared_ptr<RooLinkedList>
fOpts;
485 bool kReuseNLL =
true;
490std::string printValue(
const std::map<std::string, xRooNLLVar::xValueWithError> *
m);
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
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::shared_ptr< TFile > 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)
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
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.
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})