15#ifdef XROOFIT_USE_PRAGMA_ONCE
18#if !defined(XROOFIT_XROONODE_H) || defined(XROOFIT_USE_PRAGMA_ONCE)
19#ifndef XROOFIT_USE_PRAGMA_ONCE
20#define XROOFIT_XROONODE_H
52class xRooNode :
public TNamed,
public std::vector<std::shared_ptr<xRooNode>> {
58 static std::map<std::string, std::tuple<std::function<
double(
double,
double,
double)>,
bool>>
auxFunctions;
60 static void SetAuxFunction(
const char *title,
const std::function<
double(
double,
double,
double)> &func,
61 bool symmetrize =
false);
65 static inline bool isNull(
const std::shared_ptr<xRooNode> &
x) {
return x ==
nullptr; }
78 x->SetNameTitle(
name, title);
81 xRooNode(
const char *
name =
"",
const std::shared_ptr<TObject> &comp =
nullptr,
82 const std::shared_ptr<xRooNode> &parent =
nullptr);
102 xRooNode(
const TObject &comp,
const std::shared_ptr<xRooNode> &parent =
nullptr);
106 xRooNode(
const std::shared_ptr<TObject> &comp,
const std::shared_ptr<xRooNode> &parent =
nullptr);
107 template <
typename T>
109 xRooNode(
const std::shared_ptr<T> &comp,
const std::shared_ptr<xRooNode> &parent =
nullptr)
114 template <
typename T>
120 template <
typename T>
121 xRooNode(
const std::shared_ptr<const T> &comp,
const std::shared_ptr<xRooNode> &parent =
nullptr)
122 :
xRooNode(std::dynamic_pointer_cast<
TObject>(std::const_pointer_cast<T>(comp)), parent)
126 template <
typename T>
128 :
xRooNode(std::dynamic_pointer_cast<
TObject>(std::const_pointer_cast<T>(comp)),
138 void SetTitle(
const char *title)
override;
141 const char *GetNodeType()
const;
147 const std::shared_ptr<xRooNode> &
at(
size_t idx,
bool browseResult =
true)
const
150 auto &out = std::vector<std::shared_ptr<xRooNode>>
::at(idx);
151 if (browseResult && out)
155 std::shared_ptr<xRooNode> at(
const std::string &
name,
bool browseResult =
true)
const;
159 std::shared_ptr<xRooNode>
160 find(
const std::string &
name,
bool browseResult =
true)
const;
165 std::shared_ptr<xRooNode> operator[](
const std::string &
name);
174 std::iterator_traits<const std::shared_ptr<xRooNode> *>::reference
operator*()
const
176 const std::shared_ptr<xRooNode> &out = std::vector<std::shared_ptr<xRooNode>>::const_iterator::operator*();
177 if (out->get() && out->empty()) {
180 return std::vector<std::shared_ptr<xRooNode>>::const_iterator::operator*();
184 const std::vector<std::shared_ptr<xRooNode>>::const_iterator &aa = (*this);
185 const std::vector<std::shared_ptr<xRooNode>>::const_iterator &bb =
b;
190 std::vector<std::shared_ptr<xRooNode>>::const_iterator::operator++();
195 const std::vector<std::shared_ptr<xRooNode>>::const_iterator &aa = (*this);
196 const std::vector<std::shared_ptr<xRooNode>>::const_iterator &bb =
b;
213 void Browse(
TBrowser *
b =
nullptr)
override;
215 bool IsFolder()
const override;
217 const char *GetIconName()
const override;
218 void Inspect()
const override;
224 std::string GetPath()
const;
225 void Print(
Option_t *opt =
"")
const override;
232 template <
typename T>
235 return dynamic_cast<T *
>(
get());
239 template <
typename T>
243 if (strcmp(
c->GetName(),
".memory") == 0) {
255 std::shared_ptr<TObject>
256 acquire(
const std::shared_ptr<TObject> &arg,
bool checkFactory =
false,
bool mustBeNew =
false);
259 template <
typename T,
typename... Args>
262 return std::dynamic_pointer_cast<T>(
acquire(std::make_shared<T>(std::forward<Args>(args)...)));
265 template <
typename T,
typename T2,
typename... Args>
270 return std::dynamic_pointer_cast<T>(
acquire(std::make_shared<T2>(std::forward<Args>(args)...)));
273 template <
typename T,
typename... Args>
276 return std::dynamic_pointer_cast<T>(
acquire(std::make_shared<T>(std::forward<Args>(args)...),
false,
true));
279 std::shared_ptr<TObject> getObject(
const std::string &
name,
const std::string &
type =
"")
const;
281 template <
typename T>
284 return std::dynamic_pointer_cast<T>(
getObject(
name, T::Class_Name()));
288 xRooNode shallowCopy(
const std::string &
name, std::shared_ptr<xRooNode> parent =
nullptr);
290 std::shared_ptr<TObject> convertForAcquisition(
xRooNode &acquirer,
const char *opt =
"")
const;
307 xRooNode coefs(
bool recurse =
false)
const;
308 xRooNode coords(
bool setVals =
true)
const;
327 xRooNode reduced(
const std::string &range =
"",
bool invert =
false)
332 void _Add_(
const char *
name,
const char *opt);
336 void _Vary_(
const char *
what);
340 void _ShowVars_(
bool set =
true);
342 bool _IsShowVars_()
const;
344 void _SetAttribute_(
const char *
name,
const char *value =
nullptr);
346 void SetHidden(
bool set =
true);
347 bool IsHidden()
const;
356 bool SetContent(
double value);
357 bool SetContent(
double value,
const char *par,
double parVal = 1);
363 bool SetBinError(
int bin,
double value);
364 bool SetBinContent(
int bin,
double value,
const char *par =
nullptr,
double parVal = 1);
365 bool SetBinData(
int bin,
double value,
const xRooNode &data =
"obsData");
368 void _SetContent_(
double value);
370 void _SetBinContent_(
int bin,
double value,
const char *par =
"",
double parVal = 1);
373 bool SetXaxis(
TAxis *ax);
374 bool SetXaxis(
const char *
name,
const char *title,
int nbins,
double low,
double high);
375 bool SetXaxis(
const char *
name,
const char *title,
int nbins,
const double *bins);
376 bool SetXaxis(
const char *title,
int nbins,
double low,
double high)
378 return SetXaxis(
"xaxis", title, nbins, low, high);
381 bool SetXaxis(
int nbins,
double low,
double high) {
return SetXaxis(
"xaxis",
"", nbins, low, high); }
384 std::shared_ptr<TStyle>
385 style(
TObject *initObject =
nullptr,
bool autoCreate =
true)
const;
386 xRooNode styles(
TObject *initObject =
nullptr,
bool autoCreate =
true)
const;
388 TAxis *GetXaxis()
const;
390 double GetBinData(
int bin,
const xRooNode &data =
"obsData");
392 std::vector<double> GetBinContents(
int binStart = 1,
int binEnd = 0)
const;
394 GetBinError(
int bin,
const xRooNode &fr =
"",
int nToys = 0,
bool errorsHi =
false,
bool errorsLo =
false)
const;
395 std::vector<double> GetBinErrors(
int binStart = 1,
int binEnd = 0,
const xRooNode &fr =
"",
int nToys = 0,
396 bool errorsHi =
false,
bool errorsLo =
false)
const;
397 std::pair<double, double> IntegralAndError(
const xRooNode &fr =
"",
const char *rangeName =
nullptr,
int nToys = 0,
398 bool errorsHi =
false,
bool errorsLo =
false)
const;
402 return GetBinErrors(binStart, binEnd, fr, nToys,
true,
false);
406 return GetBinErrors(binStart, binEnd, fr, nToys,
false,
true);
419 double GetError(
const xRooNode &fr =
"",
int nToys = 0,
bool errorsHi =
false,
bool errorsLo =
false)
const
429 std::vector<double> contents()
const;
431 xRooNLLVar nll(
const xRooNode &_data, std::initializer_list<RooCmdArg> nllOpts)
const;
436 nll(
const char *_data,
437 std::initializer_list<RooCmdArg> nllOpts = {})
const;
440 xRooNode fitResult(
const char *opt =
"")
const;
443 void SetFitResult(
const xRooNode &fr);
446 generate(
const xRooNode &fr =
"",
bool expected =
false,
450 void _fit_(
const char *constParValues =
"",
const char *options =
"GoF");
452 void _generate_(
const char *
name =
"",
bool expected =
false);
454 void _scan_(
const char *
what =
"plr",
double nToys = 0,
const char *xvar =
"",
int nPointsX = 0,
double lowX = 0,
456 const char *constParValues =
"",
const char *options =
"");
473 void Checked(
TObject *obj,
bool val);
478 bool stack =
true,
bool errorsHi =
false,
bool errorsLo =
false,
int nErrorToys = 0)
const;
483 TH1 *BuildHistogram(
RooAbsLValue *
v =
nullptr,
bool empty =
false,
bool errors =
false,
int binStart = 1,
484 int binEnd = 0,
const xRooNode &fr =
"",
bool errorsHi =
false,
bool errorsLo =
false,
485 int nErrorToys = 0,
TH1 *templateHist =
nullptr,
bool nostack =
true,
486 bool setInterp =
false)
const;
490 void SaveAs(
const char *filename =
"",
Option_t *
option =
"")
const override;
497 static void Interactive_PLLPlot();
498 static void Interactive_Pull();
506 mutable std::shared_ptr<TObject>
fComp;
512 void SetRange(
const char *range,
double low = std::numeric_limits<double>::quiet_NaN(),
513 double high = std::numeric_limits<double>::quiet_NaN());
518 mutable std::shared_ptr<TAxis>
526 std::shared_ptr<xRooNode>
parentPdf()
const;
541std::string printValue(
const xRooNode *val);
int Int_t
Signed integer 4 bytes (int).
const char Option_t
Option string (const char).
#define ClassDefOverride(name, id)
TMatrixTSym< Double_t > TMatrixDSym
Binding & operator=(OUT(*fun)(void))
static void GetRange(const char *comments, Double_t &xmin, Double_t &xmax, Double_t &factor)
Parse comments to search for a range specifier of the style: [xmin,xmax] or [xmin,...
This xRooNLLVar object has several special methods, e.g.
void Interactive_PLLPlot(TVirtualPad *pad, TObject *obj, Int_t x, Int_t y)
std::iterator_traits< conststd::shared_ptr< xRooNode > * >::reference operator*() const
xRooNodeIterator(std::vector< std::shared_ptr< xRooNode > >::const_iterator itr)
bool operator==(xRooNodeIterator const &b) const
bool operator!=(xRooNodeIterator const &b) const
xRooNodeIterator const & operator++()
The xRooNode class is designed to wrap over a TObject and provide functionality to aid with interacti...
xRooNode(const std::shared_ptr< T > &comp, const xRooNode &parent)
xRooNode _Multiply_(const char *what)
std::vector< std::shared_ptr< xRooNode > > fBrowsables
std::shared_ptr< T > acquire(Args &&...args)
xRooNLLVar nll(const xRooNode &_data, std::initializer_list< RooCmdArg > nllOpts) const
bool SetXaxis(int nbins, double low, double high)
xRooNode(const std::shared_ptr< const T > &comp, const std::shared_ptr< xRooNode > &parent=nullptr)
xRooNode Multiply(const xRooNode &child, Option_t *opt="")
double GetBinErrorHi(int bin, const xRooNode &fr="", int nToys=0) const
xRooNode(const std::shared_ptr< T > &comp, const std::shared_ptr< xRooNode > &parent=nullptr)
xRooNode(const TObject &comp, const xRooNode &parent)
xRooNode(const char *type, const char *name, const char *title="")
const std::shared_ptr< xRooNode > & at(size_t idx, bool browseResult=true) const
xRooNLLVar nll(const xRooNode &_data, const RooLinkedList &nllOpts) const
double GetBinErrorLo(int bin, const xRooNode &fr="", int nToys=0) const
bool SetXaxis(int nbins, const double *bins)
std::shared_ptr< xRooNode > operator[](size_t idx)
void Checked(TObject *obj, bool val)
double GetContent() const
std::shared_ptr< T > acquireNew(Args &&...args)
std::shared_ptr< T > acquire2(Args &&...args)
xRooNode bins() const
bins of a channel or sample, or channels of a multi-channel pdf
std::shared_ptr< T > getObject(const std::string &name) const
std::shared_ptr< xRooNode > getBrowsable(const char *name) const
bool SetXaxis(const RooAbsBinning &binning)
double GetBinError(int bin, const xRooNode &fr="", int nToys=0, bool errorsHi=false, bool errorsLo=false) const
bool SetXaxis(const char *title, int nbins, double low, double high)
xRooNode(const std::shared_ptr< const T > &comp, const xRooNode &parent)
std::function< xRooNode(xRooNode *)> fBrowseOperation
std::vector< double > GetBinContents(int binStart=1, int binEnd=0) const
static InteractiveObject * gIntObj
double GetError(const xRooNode &fr="", int nToys=0, bool errorsHi=false, bool errorsLo=false) const
std::shared_ptr< xRooNode > fProvider
! like a parent but only for use by getObject
TObject * operator->() const
std::shared_ptr< TAxis > fXAxis
! appears that if was fXaxis then dialog box for SetXaxis will take as current value
double GetErrorLo(const xRooNode &fr="", int nToys=0) const
xRooNode Constrain(const xRooNode &child)
static std::map< std::string, std::tuple< std::function< double(double, double, double)>, bool > > auxFunctions
double GetErrorHi(const xRooNode &fr="", int nToys=0) const
bool IsFolder() const override
Returns kTRUE in case object contains browsable objects (like containers or lists of other objects).
double GetBinData(int bin, const xRooNode &data="obsData")
xRooNode(const char *name, const std::shared_ptr< TObject > &comp, const xRooNode &parent)
xRooNode(const char *name, const TObject &comp, const xRooNode &parent)
std::vector< double > GetBinErrorsHi(int binStart=1, int binEnd=0, const xRooNode &fr="", int nToys=0) const
bool SetContents(const TObject &obj)
std::shared_ptr< TObject > fComp
!
void SetFitResult(const std::shared_ptr< const RooFitResult > &fr)
std::pair< double, double > IntegralAndError(const xRooNode &fr="", const char *rangeName=nullptr, int nToys=0, bool errorsHi=false, bool errorsLo=false) const
double GetData(const xRooNode &data="obsData")
static bool isNull(const std::shared_ptr< xRooNode > &x)
xRooNode(const char *name, const TObject &comp, const std::shared_ptr< xRooNode > &parent)
bool SetContent(double value, const char *par, double parVal=1)
std::shared_ptr< TObject > getObject(const std::string &name, const std::string &type="") const
xRooNode(const char *name, const char *title)
double GetBinContent(int bin) const
xRooNode variations() const
std::vector< double > GetBinErrors(int binStart=1, int binEnd=0, const xRooNode &fr="", int nToys=0, bool errorsHi=false, bool errorsLo=false) const
auto begin() const -> xRooNodeIterator
std::shared_ptr< xRooNode > parentPdf() const
void SetChecked(bool val=true)
std::shared_ptr< xRooNode > fParent
!
auto end() const -> xRooNodeIterator
std::shared_ptr< TObject > acquire(const std::shared_ptr< TObject > &arg, bool checkFactory=false, bool mustBeNew=false)
std::vector< double > GetBinErrorsLo(int binStart=1, int binEnd=0, const xRooNode &fr="", int nToys=0) const
void SetRange(const char *range, double low=std::numeric_limits< double >::quiet_NaN(), double high=std::numeric_limits< double >::quiet_NaN())
xRooNode _Constrain_(const char *what)
static void SetAuxFunction(const char *title, const std::function< double(double, double, double)> &func, bool symmetrize=false)
bool SetXaxis(const char *title, int nbins, const double *bins)
bool SetContents(const TObject &obj, const char *par, double parVal)
Abstract base class for RooRealVar binning definitions.
Abstract base class for objects that are lvalues, i.e.
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.
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...
Persistable container for RooFit projects.
Class to manage histogram axis.
Using a TBrowser one can browse all ROOT objects.
A list tree is a widget that can contain a number of items arranged in a tree structure.
TH1 is the base class of all histogram classes in ROOT.
const char * GetName() const override
Returns name of object.
Mother of all ROOT objects.
TObject()
TObject constructor.
TQObject(const TQObject &)=delete
const char * Data() const
static TString Format(const char *fmt,...)
Static method which formats a string using a printf style format descriptor and return a TString.
TStyle objects may be created to define special styles.
TVirtualPad is an abstract base class for the Pad and Canvas classes.
The namespace of The Lean Mean C++ Option Parser.
TMatrixT< Element > & Add(TMatrixT< Element > &target, Element scalar, const TMatrixT< Element > &source)
Modify addition: target += scalar * source.
#define BEGIN_XROOFIT_NAMESPACE
#define END_XROOFIT_NAMESPACE