@@ -197,7 +197,23 @@ class xRooNode : public TNamed, public std::vector<std::shared_ptr<xRooNode>> {
197197 return aa == bb;
198198 };
199199 };
200- auto begin () const -> xRooNodeIterator { return xRooNodeIterator (std::vector<std::shared_ptr<xRooNode>>::begin ()); }
200+ auto begin () const -> xRooNodeIterator
201+ {
202+ // this update is to resolve need for calling browse() before iterating, e.g.
203+ // for(auto a : xRooNode(b).browse()) ...
204+ // can now become the more natural:
205+ // for(auto a : xRooNode(b)) ...
206+ // but would still need e.g. xRooNode(s).browse().size() rather than xRooNode(s).size() which would give 0 for
207+ // unpopulated case
208+ static bool browseLock =
209+ false ; // need for blocking recursive calls to browse (since browse method uses the iterators)
210+ if (!browseLock && get () && empty ()) {
211+ browseLock = true ;
212+ const_cast <xRooNode &>(*this ).browse ();
213+ browseLock = false ;
214+ }
215+ return xRooNodeIterator (std::vector<std::shared_ptr<xRooNode>>::begin ());
216+ }
201217 auto end () const -> xRooNodeIterator { return xRooNodeIterator (std::vector<std::shared_ptr<xRooNode>>::end ()); }
202218
203219 // needed in pyROOT to avoid it creating iterators that follow the 'get' to death
@@ -312,6 +328,9 @@ class xRooNode : public TNamed, public std::vector<std::shared_ptr<xRooNode>> {
312328 xRooNode datasets ()
313329 const ; // datasets corresponding to this pdf (parent nodes that do observable selections automatically applied)
314330
331+ xRooNode parents () const ; // the clients of this node
332+ xRooNode args () const ; // all the nodes underneath this node
333+
315334 xRooNode Replace (const xRooNode &node); // use to replace a node in the tree at the location of this node
316335 xRooNode Remove (const xRooNode &child);
317336 xRooNode
@@ -326,6 +345,7 @@ class xRooNode : public TNamed, public std::vector<std::shared_ptr<xRooNode>> {
326345
327346 xRooNode reduced (const std::string &range = " " , bool invert = false )
328347 const ; // return a node representing reduced version of this node, will use the SetRange to reduce if blank
348+ xRooNode reduced (const std::function<bool (const xRooNode &)> selector) const ;
329349
330350 // following versions are for the menu in the GUI
331351 /* * @private */
@@ -537,10 +557,17 @@ class xRooNode : public TNamed, public std::vector<std::shared_ptr<xRooNode>> {
537557 ClassDefOverride (xRooNode, 0 )
538558};
539559
560+ END_XROOFIT_NAMESPACE
561+
562+ #ifndef XROOFIT_NAMESPACE_NAME
563+ #ifdef XROOFIT_NAMESPACE
564+ #define XROOFIT_NAMESPACE_NAME XROOFIT_NAMESPACE
565+ #else
566+ #define XROOFIT_NAMESPACE_NAME
567+ #endif
568+ #endif
540569namespace cling {
541- std::string printValue (const xRooNode *val);
570+ std::string printValue (const XROOFIT_NAMESPACE_NAME :: xRooNode *val);
542571}
543572
544- END_XROOFIT_NAMESPACE
545-
546573#endif // include guard
0 commit comments