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
51class xRooNode :
public TNamed,
public std::vector<std::shared_ptr<xRooNode>> {
57 static std::map<std::string, std::tuple<std::function<
double(
double,
double,
double)>,
bool>>
auxFunctions;
59 static void SetAuxFunction(
const char *title,
const std::function<
double(
double,
double,
double)> &func,
60 bool symmetrize =
false);
64 static inline bool isNull(
const std::shared_ptr<xRooNode> &
x) {
return x ==
nullptr; }
76 if (
auto x = get<TNamed>();
x) {
80 xRooNode(
const char *
name =
"",
const std::shared_ptr<TObject> &comp =
nullptr,
81 const std::shared_ptr<xRooNode> &parent =
nullptr);
101 xRooNode(
const TObject &comp,
const std::shared_ptr<xRooNode> &parent =
nullptr);
105 xRooNode(
const std::shared_ptr<TObject> &comp,
const std::shared_ptr<xRooNode> &parent =
nullptr);
106 template <
typename T>
108 xRooNode(
const std::shared_ptr<T> &comp,
const std::shared_ptr<xRooNode> &parent =
nullptr)
113 template <
typename T>
119 template <
typename T>
120 xRooNode(
const std::shared_ptr<const T> &comp,
const std::shared_ptr<xRooNode> &parent =
nullptr)
121 :
xRooNode(std::dynamic_pointer_cast<
TObject>(std::const_pointer_cast<T>(comp)), parent)
125 template <
typename T>
127 :
xRooNode(std::dynamic_pointer_cast<
TObject>(std::const_pointer_cast<T>(comp)),
137 void SetTitle(
const char *title)
override;
140 const char *GetNodeType()
const;
143 explicit operator bool()
const {
return strlen(GetName()) || get(); }
146 const std::shared_ptr<xRooNode> &
at(
size_t idx,
bool browseResult =
true)
const
149 auto &out = std::vector<std::shared_ptr<xRooNode>>::at(idx);
150 if (browseResult && out)
154 std::shared_ptr<xRooNode> at(
const std::string &
name,
bool browseResult =
true)
const;
158 std::shared_ptr<xRooNode>
159 find(
const std::string &
name,
bool browseResult =
true)
const;
160 bool contains(
const std::string &
name)
const;
163 std::shared_ptr<xRooNode>
operator[](
size_t idx) {
return at(idx); }
164 std::shared_ptr<xRooNode> operator[](
const std::string &
name);
170 : std::vector<std::shared_ptr<
xRooNode>>::const_iterator(itr)
173 decltype(
auto)
operator*()
const
175 const std::shared_ptr<xRooNode> &out = std::vector<std::shared_ptr<xRooNode>>::const_iterator::operator*();
176 if (out->get() && out->empty()) {
179 return std::vector<std::shared_ptr<xRooNode>>::const_iterator::operator*();
183 const std::vector<std::shared_ptr<xRooNode>>::const_iterator &aa = (*this);
184 const std::vector<std::shared_ptr<xRooNode>>::const_iterator &bb =
b;
189 std::vector<std::shared_ptr<xRooNode>>::const_iterator::operator++();
194 const std::vector<std::shared_ptr<xRooNode>>::const_iterator &aa = (*this);
195 const std::vector<std::shared_ptr<xRooNode>>::const_iterator &bb =
b;
212 void Browse(
TBrowser *
b =
nullptr)
override;
214 bool IsFolder()
const override;
216 const char *GetIconName()
const override;
217 void Inspect()
const override;
223 std::string GetPath()
const;
224 void Print(
Option_t *opt =
"")
const override;
231 template <
typename T>
234 return dynamic_cast<T *
>(get());
238 template <
typename T>
241 for (
auto &
c : fBrowsables) {
242 if (strcmp(
c->GetName(),
".memory") == 0) {
254 std::shared_ptr<TObject>
255 acquire(
const std::shared_ptr<TObject> &arg,
bool checkFactory =
false,
bool mustBeNew =
false);
258 template <
typename T,
typename... Args>
261 return std::dynamic_pointer_cast<T>(acquire(std::make_shared<T>(std::forward<Args>(args)...)));
264 template <
typename T,
typename T2,
typename... Args>
269 return std::dynamic_pointer_cast<T>(acquire(std::make_shared<T2>(std::forward<Args>(args)...)));
272 template <
typename T,
typename... Args>
275 return std::dynamic_pointer_cast<T>(acquire(std::make_shared<T>(std::forward<Args>(args)...),
false,
true));
278 std::shared_ptr<TObject> getObject(
const std::string &
name,
const std::string &
type =
"")
const;
280 template <
typename T>
283 return std::dynamic_pointer_cast<T>(getObject(
name, T::Class_Name()));
287 xRooNode shallowCopy(
const std::string &
name, std::shared_ptr<xRooNode> parent =
nullptr);
289 std::shared_ptr<TObject> convertForAcquisition(
xRooNode &acquirer,
const char *opt =
"")
const;
307 xRooNode coords(
bool setVals =
true)
const;
326 xRooNode reduced(
const std::string &range =
"",
bool invert =
false)
331 void _Add_(
const char *
name,
const char *opt);
335 void _Vary_(
const char *
what);
339 void _ShowVars_(
bool set =
true);
341 bool _IsShowVars_()
const;
343 void SetHidden(
bool set =
true);
344 bool IsHidden()
const;
351 bool SetData(
const TObject &obj,
const char *dataName =
"obsData");
353 bool SetContent(
double value);
360 bool SetBinError(
int bin,
double value);
361 bool SetBinContent(
int bin,
double value,
const char *par =
nullptr,
double parVal = 1);
362 bool SetBinData(
int bin,
double value,
const char *dataName =
"obsData");
365 void _SetContent_(
double value);
367 void _SetBinContent_(
int bin,
double value,
const char *par =
"",
double parVal = 1);
370 bool SetXaxis(
TAxis *ax);
371 bool SetXaxis(
const char *
name,
const char *title,
int nbins,
double low,
double high);
372 bool SetXaxis(
const char *
name,
const char *title,
int nbins,
const double *bins);
373 bool SetXaxis(
const char *title,
int nbins,
double low,
double high)
375 return SetXaxis(
"xaxis", title, nbins, low, high);
377 bool SetXaxis(
const char *title,
int nbins,
const double *bins) {
return SetXaxis(
"xaxis", title, nbins, bins); }
378 bool SetXaxis(
int nbins,
double low,
double high) {
return SetXaxis(
"xaxis",
"", nbins, low, high); }
379 bool SetXaxis(
int nbins,
const double *bins) {
return SetXaxis(
"xaxis",
"", nbins, bins); }
381 std::shared_ptr<TStyle>
style(
TObject *initObject =
nullptr,
bool autoCreate =
true)
const;
383 TAxis *GetXaxis()
const;
385 double GetBinData(
int bin,
const char *dataName =
"obsData");
386 double GetBinContent(
int bin)
const {
return GetBinContents(bin, bin).at(0); }
387 std::vector<double> GetBinContents(
int binStart = 1,
int binEnd = 0)
const;
388 double GetBinError(
int bin,
const xRooNode &fr =
"")
const;
389 std::vector<double> GetBinErrors(
int binStart = 1,
int binEnd = 0,
const xRooNode &fr =
"")
const;
390 std::pair<double, double> IntegralAndError(
const xRooNode &fr =
"",
const char *rangeName =
nullptr)
const;
393 double GetContent()
const {
return GetBinContent(fBinNumber); }
396 return (fBinNumber == -1) ? IntegralAndError(fr).second : GetBinError(fBinNumber, fr);
398 double GetData(
const char *dataName =
"obsData") {
return GetBinData(fBinNumber, dataName); }
400 xRooNLLVar nll(
const xRooNode &_data, std::initializer_list<RooCmdArg> nllOpts)
const;
404 xRooNode fitResult(
const char *opt =
"")
const;
407 void SetFitResult(
const xRooNode &fr);
410 generate(
const xRooNode &fr =
"",
bool expected =
false,
414 void _fit_(
const char *constParValues =
"");
416 void _generate_(
const char *
name =
"",
bool expected =
false);
418 void _scan_(
const char *
what =
"plr",
double nToys = 0,
const char *xvar =
"",
int nPointsX = 0,
double lowX = 0,
420 const char *constParValues =
"");
437 void Checked(
TObject *obj,
bool val);
446 TH1 *BuildHistogram(
RooAbsLValue *
v =
nullptr,
bool empty =
false,
bool errors =
false,
int binStart = 1,
447 int binEnd = 0,
const xRooNode &fr =
"")
const;
458 static void Interactive_PLLPlot();
459 static void Interactive_Pull();
467 mutable std::shared_ptr<TObject>
fComp;
471 std::string fFolder =
"";
473 void SetRange(
const char *range,
double low = std::numeric_limits<double>::quiet_NaN(),
474 double high = std::numeric_limits<double>::quiet_NaN());
479 mutable std::shared_ptr<TAxis>
482 mutable bool fInterrupted =
false;
484 bool fAcquirer =
false;
487 std::shared_ptr<xRooNode> parentPdf()
const;
490 void sterilize()
const;
496 std::shared_ptr<xRooNode> getBrowsable(
const char *
name)
const;
502std::string printValue(
const xRooNode* val);
#define ClassDef(name, id)
#define ClassDefOverride(name, id)
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 filename
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 Int_t Int_t Window_t child
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
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.
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)
bool SetXaxis(int nbins, double low, double high)
xRooNode(const std::shared_ptr< const T > &comp, const std::shared_ptr< xRooNode > &parent=nullptr)
static InteractiveObject * gIntObj
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
bool SetXaxis(int nbins, const double *bins)
std::shared_ptr< xRooNode > operator[](size_t idx)
double GetContent() const
std::shared_ptr< T > acquireNew(Args &&...args)
std::shared_ptr< T > acquire2(Args &&...args)
std::shared_ptr< T > getObject(const std::string &name) 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::shared_ptr< xRooNode > fProvider
TObject * operator->() const
std::shared_ptr< TAxis > fXAxis
only here so can have char* GetRange return so can return nullptr for no range set (required for RooC...
static std::map< std::string, std::tuple< std::function< double(double, double, double)>, bool > > auxFunctions
xRooNode(const char *name, const std::shared_ptr< TObject > &comp, const xRooNode &parent)
xRooNode(const char *name, const TObject &comp, const xRooNode &parent)
bool SetContents(const TObject &obj)
std::shared_ptr< TObject > fComp
void SetFitResult(const std::shared_ptr< const RooFitResult > &fr)
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)
xRooNode(const char *name, const char *title)
double GetBinContent(int bin) const
auto begin() const -> xRooNodeIterator
void SetChecked(bool val=true)
std::shared_ptr< xRooNode > fParent
auto end() const -> xRooNodeIterator
xRooNode _Constrain_(const char *what)
double GetData(const char *dataName="obsData")
double GetError(const xRooNode &fr="") const
bool SetXaxis(const char *title, int nbins, const double *bins)
bool SetContents(const TObject &obj, const char *par, double parVal)
RooAbsBinning is the 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.
RooLinkedList is an collection class for internal use, storing a collection of RooAbsArg pointers in ...
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.
A TGraph is an object made of two arrays X and Y with npoints each.
TH1 is the base class of all histogram classes in ROOT.
The TNamed class is the base class for all named ROOT classes.
virtual void SetNameTitle(const char *name, const char *title)
Set all the TNamed parameters (name and title).
Mother of all ROOT objects.
This is the ROOT implementation of the Qt object communication mechanism (see also http://www....
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.
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