Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /include/root/RooAbsArg.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

0001 /*****************************************************************************
0002  * Project: RooFit                                                           *
0003  * Package: RooFitCore                                                       *
0004  *    File: $Id: RooAbsArg.h,v 1.93 2007/07/16 21:04:28 wouter Exp $
0005  * Authors:                                                                  *
0006  *   WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu       *
0007  *   DK, David Kirkby,    UC Irvine,         dkirkby@uci.edu                 *
0008  *                                                                           *
0009  * Copyright (c) 2000-2005, Regents of the University of California          *
0010  *                          and Stanford University. All rights reserved.    *
0011  *                                                                           *
0012  * Redistribution and use in source and binary forms,                        *
0013  * with or without modification, are permitted according to the terms        *
0014  * listed in LICENSE (http://roofit.sourceforge.net/license.txt)             *
0015  *****************************************************************************/
0016 #ifndef ROO_ABS_ARG
0017 #define ROO_ABS_ARG
0018 
0019 #include <RooAbsCache.h>
0020 #include <RooFit/Config.h>
0021 #include <RooFit/Detail/NormalizationHelpers.h>
0022 #include <RooLinkedListIter.h>
0023 #include <RooNameReg.h>
0024 #include <RooPrintable.h>
0025 #include <RooSTLRefCountList.h>
0026 #include <RooStringView.h>
0027 
0028 #include <TNamed.h>
0029 #include <TObjArray.h>
0030 #include <TRefArray.h>
0031 
0032 #include <deque>
0033 #include <iostream>
0034 #include <map>
0035 #include <memory>
0036 #include <set>
0037 #include <stack>
0038 #include <string>
0039 #include <unordered_map>
0040 
0041 
0042 class TTree ;
0043 class RooArgSet ;
0044 class RooAbsCollection ;
0045 class RooVectorDataStore ;
0046 class RooAbsData ;
0047 class RooAbsDataStore ;
0048 class RooAbsProxy ;
0049 class RooArgProxy ;
0050 template<class RooCollection_t>
0051 class RooCollectionProxy;
0052 using RooSetProxy = RooCollectionProxy<RooArgSet>;
0053 using RooListProxy = RooCollectionProxy<RooArgList>;
0054 class RooExpensiveObjectCache ;
0055 class RooWorkspace ;
0056 namespace RooFit {
0057 namespace Detail {
0058 class CodeSquashContext;
0059 }
0060 }
0061 
0062 class RooRefArray : public TObjArray {
0063  public:
0064     RooRefArray() = default;
0065     RooRefArray(const RooRefArray &other) : TObjArray(other) {}
0066     RooRefArray &operator=(const RooRefArray &other) = default;
0067  protected:
0068   ClassDefOverride(RooRefArray,1) // Helper class for proxy lists
0069 } ;
0070 
0071 class RooAbsArg;
0072 /// Print at the prompt
0073 namespace cling {
0074 std::string printValue(RooAbsArg*);
0075 }
0076 
0077 class RooAbsArg : public TNamed, public RooPrintable {
0078 public:
0079   using RefCountList_t = RooSTLRefCountList<RooAbsArg>;
0080   using RefCountListLegacyIterator_t = TIteratorToSTLInterface<RefCountList_t::Container_t>;
0081 
0082   // Constructors, cloning and assignment
0083   RooAbsArg() ;
0084   ~RooAbsArg() override;
0085   RooAbsArg(const char *name, const char *title);
0086   RooAbsArg(const RooAbsArg& other, const char* name=nullptr) ;
0087   RooAbsArg& operator=(const RooAbsArg& other) = delete;
0088   virtual TObject* clone(const char* newname=nullptr) const = 0 ;
0089   TObject* Clone(const char* newname = nullptr) const override {
0090     return clone(newname && newname[0] != '\0' ? newname : nullptr);
0091   }
0092   virtual RooAbsArg* cloneTree(const char* newname=nullptr) const ;
0093 
0094   // Accessors to client-server relation information
0095 
0096   /// Does value or shape of this arg depend on any other arg?
0097   virtual bool isDerived() const {
0098     return true ;
0099   }
0100 
0101   /// Check whether this object depends on values from an element in the `serverList`.
0102   ///
0103   /// @param serverList Test if one of the elements in this list serves values to `this`.
0104   /// @param ignoreArg Ignore values served by this object.
0105   /// @return True if values are served.
0106   bool dependsOnValue(const RooAbsCollection& serverList, const RooAbsArg* ignoreArg=nullptr) const {
0107     return dependsOn(serverList,ignoreArg,true) ;
0108   }
0109   /// Check whether this object depends on values served from the object passed as `server`.
0110   ///
0111   /// @param server Test if `server` serves values to `this`.
0112   /// @param ignoreArg Ignore values served by this object.
0113   /// @return True if values are served.
0114   bool dependsOnValue(const RooAbsArg& server, const RooAbsArg* ignoreArg=nullptr) const {
0115     return dependsOn(server,ignoreArg,true) ;
0116   }
0117   bool dependsOn(const RooAbsCollection& serverList, const RooAbsArg* ignoreArg=nullptr, bool valueOnly=false) const ;
0118   /// Test whether we depend on (ie, are served by) the specified object.
0119   /// Note that RooAbsArg objects are considered equivalent if they have
0120   /// the same name.
0121   inline bool dependsOn(const RooAbsArg& server, const RooAbsArg* ignoreArg=nullptr, bool valueOnly=false) const {
0122     return dependsOn(server.namePtr(), ignoreArg, valueOnly);
0123   }
0124   bool dependsOn(TNamed const* namePtr, const RooAbsArg* ignoreArg=nullptr, bool valueOnly=false) const ;
0125   bool overlaps(const RooAbsArg& testArg, bool valueOnly=false) const ;
0126   bool hasClients() const { return !_clientList.empty(); }
0127 
0128   ////////////////////////////////////////////////////////////////////////////
0129   /// \name Legacy RooFit interface.
0130   /// This is a collection of functions that remain supported, but more elegant
0131   /// interfaces are usually available.
0132   /// @{
0133 
0134   /// Retrieve a client iterator.
0135   inline TIterator* clientIterator() const
0136   R__DEPRECATED(6,34, "Use clients() and begin(), end() or range-based loops.") {
0137     // Return iterator over all client RooAbsArgs
0138     return makeLegacyIterator(_clientList);
0139   }
0140   inline TIterator* valueClientIterator() const
0141   R__DEPRECATED(6,34, "Use valueClients() and begin(), end() or range-based loops.") {
0142     // Return iterator over all shape client RooAbsArgs
0143     return makeLegacyIterator(_clientListValue);
0144   }
0145   inline TIterator* shapeClientIterator() const
0146   R__DEPRECATED(6,34, "Use shapeClients() and begin(), end() or range-based loops.") {
0147     // Return iterator over all shape client RooAbsArgs
0148     return makeLegacyIterator(_clientListShape);
0149   }
0150   inline TIterator* serverIterator() const
0151   R__DEPRECATED(6,34, "Use servers() and begin(), end() or range-based loops.") {
0152     // Return iterator over all server RooAbsArgs
0153     return makeLegacyIterator(_serverList);
0154   }
0155 
0156   inline RooFIter valueClientMIterator() const
0157   R__DEPRECATED(6,34, "Use valueClients() and begin(), end() or range-based loops.") {
0158     return RooFIter(std::unique_ptr<RefCountListLegacyIterator_t>(makeLegacyIterator(_clientListValue)));
0159   }
0160   inline RooFIter shapeClientMIterator() const
0161   R__DEPRECATED(6,34, "Use shapeClients() and begin(), end() or range-based loops.") {
0162     return RooFIter(std::unique_ptr<RefCountListLegacyIterator_t>(makeLegacyIterator(_clientListShape)));
0163   }
0164   inline RooFIter serverMIterator() const
0165   R__DEPRECATED(6,34, "Use servers() and begin(), end() or range-based loops.") {
0166     return RooFIter(std::unique_ptr<RefCountListLegacyIterator_t>(makeLegacyIterator(_serverList)));
0167   }
0168 
0169   // --- Obsolete functions for backward compatibility
0170   RooFit::OwningPtr<RooArgSet> getDependents(const RooArgSet& set) const;
0171   RooFit::OwningPtr<RooArgSet> getDependents(const RooAbsData* set) const;
0172   RooFit::OwningPtr<RooArgSet> getDependents(const RooArgSet* depList) const;
0173   /// \deprecated Use observableOverlaps()
0174   inline bool dependentOverlaps(const RooAbsData* dset, const RooAbsArg& testArg) const { return observableOverlaps(dset,testArg) ; }
0175   /// \deprecated Use observableOverlaps()
0176   inline bool dependentOverlaps(const RooArgSet* depList, const RooAbsArg& testArg) const { return observableOverlaps(depList, testArg) ; }
0177   /// \deprecated Use checkObservables()
0178   inline bool checkDependents(const RooArgSet* nset) const { return checkObservables(nset) ; }
0179   /// \deprecated Use recursiveCheckObservables()
0180   inline bool recursiveCheckDependents(const RooArgSet* nset) const { return recursiveCheckObservables(nset) ; }
0181   // --- End obsolete functions for backward compatibility
0182   /// @}
0183   ////////////////////////////////////////////////////////////////////////////
0184 
0185   ////////////////////////////////////////////////////////////////////////////
0186   /// \anchor clientServerInterface
0187   /// \name Client-Server Interface
0188   /// These functions allow RooFit to figure out who is serving values to whom.
0189   /// @{
0190 
0191   /// List of all clients of this object.
0192   const RefCountList_t& clients() const {
0193     return _clientList;
0194   }
0195   /// List of all value clients of this object. Value clients receive value updates.
0196   const RefCountList_t& valueClients() const {
0197     return _clientListValue;
0198   }
0199   /// List of all shape clients of this object. Shape clients receive property information such as
0200   /// changes of a value range.
0201   const RefCountList_t& shapeClients() const {
0202     return _clientListShape;
0203   }
0204 
0205   /// List of all servers of this object.
0206   const RefCountList_t& servers() const {
0207     return _serverList;
0208   }
0209   /// Return server of `this` with name `name`. Returns nullptr if not found.
0210   inline RooAbsArg* findServer(const char *name) const {
0211     const auto serverIt = _serverList.findByName(name);
0212     return serverIt != _serverList.end() ? *serverIt : nullptr;
0213   }
0214   /// Return server of `this` that has the same name as `arg`. Returns `nullptr` if not found.
0215   inline RooAbsArg* findServer(const RooAbsArg& arg) const {
0216     return _serverList.findByNamePointer(&arg);
0217   }
0218   /// Return i-th server from server list.
0219   inline RooAbsArg* findServer(Int_t index) const {
0220     return _serverList.containedObjects()[index];
0221   }
0222   /// Check if `this` is serving values to `arg`.
0223   inline bool isValueServer(const RooAbsArg& arg) const {
0224     return _clientListValue.containsByNamePtr(&arg);
0225   }
0226   /// Check if `this` is serving values to an object with name `name`.
0227   inline bool isValueServer(const char* name) const {
0228     return _clientListValue.containsSameName(name);
0229   }
0230   /// Check if `this` is serving shape to `arg`.
0231   inline bool isShapeServer(const RooAbsArg& arg) const {
0232     return _clientListShape.containsByNamePtr(&arg);
0233   }
0234   /// Check if `this` is serving shape to an object with name `name`.
0235   inline bool isShapeServer(const char* name) const {
0236     return _clientListShape.containsSameName(name);
0237   }
0238   void leafNodeServerList(RooAbsCollection* list, const RooAbsArg* arg=nullptr, bool recurseNonDerived=false) const ;
0239   void branchNodeServerList(RooAbsCollection* list, const RooAbsArg* arg=nullptr, bool recurseNonDerived=false) const ;
0240   void treeNodeServerList(RooAbsCollection* list, const RooAbsArg* arg=nullptr,
0241            bool doBranch=true, bool doLeaf=true,
0242            bool valueOnly=false, bool recurseNonDerived=false) const ;
0243 
0244 
0245   /// Is this object a fundamental type that can be added to a dataset?
0246   /// Fundamental-type subclasses override this method to return true.
0247   /// Note that this test is subtlely different from the dynamic isDerived()
0248   /// test, e.g. a constant is not derived but is also not fundamental.
0249   inline virtual bool isFundamental() const {
0250     return false;
0251   }
0252 
0253   /// Create a fundamental-type object that stores our type of value. The
0254   /// created object will have a valid value, but not necessarily the same
0255   /// as our value. The caller is responsible for deleting the returned object.
0256   virtual RooFit::OwningPtr<RooAbsArg> createFundamental(const char* newname=nullptr) const = 0;
0257 
0258   /// Is this argument an l-value, i.e., can it appear on the left-hand side
0259   /// of an assignment expression? LValues are also special since they can
0260   /// potentially be analytically integrated and generated.
0261   inline virtual bool isLValue() const {
0262     return false;
0263   }
0264 
0265 
0266   // Server redirection interface
0267   bool redirectServers(const RooAbsCollection& newServerList, bool mustReplaceAll=false, bool nameChange=false, bool isRecursionStep=false) ;
0268   bool redirectServers(std::unordered_map<RooAbsArg*, RooAbsArg*> const& replacements);
0269   bool recursiveRedirectServers(const RooAbsCollection& newServerList, bool mustReplaceAll=false, bool nameChange=false, bool recurseInNewSet=true) ;
0270 
0271   virtual bool redirectServersHook(const RooAbsCollection & newServerList, bool mustReplaceAll,
0272                                    bool nameChange, bool isRecursiveStep);
0273 
0274   virtual void serverNameChangeHook(const RooAbsArg* /*oldServer*/, const RooAbsArg* /*newServer*/) { } ;
0275 
0276   void addServer(RooAbsArg& server, bool valueProp=true, bool shapeProp=false, std::size_t refCount = 1);
0277   void addServerList(RooAbsCollection& serverList, bool valueProp=true, bool shapeProp=false) ;
0278   void
0279   R__SUGGEST_ALTERNATIVE("This interface is unsafe! Use RooAbsArg::redirectServers()")
0280   replaceServer(RooAbsArg& oldServer, RooAbsArg& newServer, bool valueProp, bool shapeProp) ;
0281   void changeServer(RooAbsArg& server, bool valueProp, bool shapeProp) ;
0282   void removeServer(RooAbsArg& server, bool force=false) ;
0283   RooAbsArg *findNewServer(const RooAbsCollection &newSet, bool nameChange) const;
0284 
0285 
0286   /// @}
0287   ///////////////////////////////////////////////////////////////////////////////
0288 
0289 
0290   // Parameter & observable interpretation of servers
0291   RooFit::OwningPtr<RooArgSet> getVariables(bool stripDisconnected=true) const ;
0292   RooFit::OwningPtr<RooArgSet> getParameters(const RooAbsData* data, bool stripDisconnected=true) const;
0293   RooFit::OwningPtr<RooArgSet> getParameters(const RooAbsData& data, bool stripDisconnected=true) const;
0294   RooFit::OwningPtr<RooArgSet> getParameters(const RooArgSet& observables, bool stripDisconnected=true) const;
0295   RooFit::OwningPtr<RooArgSet> getParameters(const RooArgSet* observables, bool stripDisconnected=true) const;
0296   virtual bool getParameters(const RooArgSet* observables, RooArgSet& outputSet, bool stripDisconnected=true) const;
0297   RooFit::OwningPtr<RooArgSet> getObservables(const RooArgSet& set, bool valueOnly=true) const;
0298   RooFit::OwningPtr<RooArgSet> getObservables(const RooAbsData* data) const;
0299   RooFit::OwningPtr<RooArgSet> getObservables(const RooAbsData& data) const;
0300   RooFit::OwningPtr<RooArgSet> getObservables(const RooArgSet* depList, bool valueOnly=true) const;
0301   bool getObservables(const RooAbsCollection* depList, RooArgSet& outputSet, bool valueOnly=true) const;
0302   bool observableOverlaps(const RooAbsData* dset, const RooAbsArg& testArg) const ;
0303   bool observableOverlaps(const RooArgSet* depList, const RooAbsArg& testArg) const ;
0304   virtual bool checkObservables(const RooArgSet* nset) const ;
0305   bool recursiveCheckObservables(const RooArgSet* nset) const ;
0306   RooFit::OwningPtr<RooArgSet> getComponents() const ;
0307 
0308 
0309 
0310   void attachArgs(const RooAbsCollection &set);
0311   void attachDataSet(const RooAbsData &set);
0312   void attachDataStore(const RooAbsDataStore &set);
0313 
0314   // I/O streaming interface (machine readable)
0315   virtual bool readFromStream(std::istream& is, bool compact, bool verbose=false) = 0 ;
0316   virtual void writeToStream(std::ostream& os, bool compact) const = 0 ;
0317 
0318   /// Print the object to the defaultPrintStream().
0319   /// \param[in] options **V** print verbose. **T** print a tree structure with all children.
0320   void Print(Option_t *options= nullptr) const override {
0321     // Printing interface (human readable)
0322     printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
0323   }
0324 
0325   void printName(std::ostream& os) const override ;
0326   void printTitle(std::ostream& os) const override ;
0327   void printClassName(std::ostream& os) const override ;
0328   void printAddress(std::ostream& os) const override ;
0329   void printArgs(std::ostream& os) const override ;
0330   virtual void printMetaArgs(std::ostream& /*os*/) const {} ;
0331   void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override;
0332   void printTree(std::ostream& os, TString indent="") const override ;
0333 
0334   Int_t defaultPrintContents(Option_t* opt) const override ;
0335 
0336   // Accessors to attributes
0337   void setAttribute(const Text_t* name, bool value=true) ;
0338   bool getAttribute(const Text_t* name) const ;
0339   inline const std::set<std::string>& attributes() const {
0340     // Returns set of names of boolean attributes defined
0341     return _boolAttrib ;
0342   }
0343 
0344   void setStringAttribute(const Text_t* key, const Text_t* value) ;
0345   void removeStringAttribute(const Text_t* key) ;
0346   const Text_t* getStringAttribute(const Text_t* key) const ;
0347   inline const std::map<std::string,std::string>& stringAttributes() const {
0348     // Returns std::map<string,string> with all string attributes defined
0349     return _stringAttrib ;
0350   }
0351 
0352   // Accessors to transient attributes
0353   void setTransientAttribute(const Text_t* name, bool value=true) ;
0354   bool getTransientAttribute(const Text_t* name) const ;
0355   inline const std::set<std::string>& transientAttributes() const {
0356     // Return set of transient boolean attributes
0357     return _boolAttribTransient ;
0358   }
0359 
0360   /// Check if the "Constant" attribute is set.
0361   inline bool isConstant() const {
0362     return _isConstant ; //getAttribute("Constant") ;
0363   }
0364 
0365   // Sorting
0366   Int_t Compare(const TObject* other) const override ;
0367   bool IsSortable() const override {
0368     // Object is sortable in ROOT container class
0369     return true ;
0370   }
0371 
0372   virtual bool operator==(const RooAbsArg& other) const = 0 ;
0373   virtual bool isIdentical(const RooAbsArg& other, bool assumeSameType=false) const = 0 ;
0374 
0375   // Range management
0376   virtual bool inRange(const char*) const {
0377     // Is value in range (dummy interface always returns true)
0378     return true ;
0379   }
0380   virtual bool hasRange(const char*) const {
0381     // Has this argument a defined range (dummy interface always returns false)
0382     return false ;
0383   }
0384 
0385 
0386   enum ConstOpCode { Activate=0, DeActivate=1, ConfigChange=2, ValueChange=3 } ;
0387   enum CacheMode { Always=0, NotAdvised=1, Never=2 } ;
0388   enum OperMode { Auto=0, AClean=1, ADirty=2 } ;
0389 
0390   ////////////////////////////////////////////////////////////////////////////
0391   /// \anchor optimisationInterface
0392   /// \name Optimisation interface
0393   /// These functions allow RooFit to optimise a computation graph, to keep track
0394   /// of cached values, and to invalidate caches.
0395   /// @{
0396 
0397   // Cache mode optimization (tracks changes & do lazy evaluation vs evaluate always)
0398   virtual void optimizeCacheMode(const RooArgSet& observables) ;
0399   virtual void optimizeCacheMode(const RooArgSet& observables, RooArgSet& optNodes, RooLinkedList& processedNodes) ;
0400 
0401 
0402   // Find constant terms in expression
0403   bool findConstantNodes(const RooArgSet& observables, RooArgSet& cacheList) ;
0404   bool findConstantNodes(const RooArgSet& observables, RooArgSet& cacheList, RooLinkedList& processedNodes) ;
0405 
0406 
0407   // constant term optimization
0408   virtual void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTrackingOpt=true) ;
0409 
0410   virtual CacheMode canNodeBeCached() const { return Always ; }
0411   virtual void setCacheAndTrackHints(RooArgSet& /*trackNodes*/ ) {} ;
0412 
0413   // Dirty state accessor
0414   inline bool isShapeDirty() const {
0415     // Return true is shape has been invalidated by server value change
0416     return isDerived()?_shapeDirty:false ;
0417   }
0418 
0419   inline bool isValueDirty() const {
0420     // Returns true of value has been invalidated by server value change
0421     if (inhibitDirty()) return true ;
0422     switch(_operMode) {
0423     case AClean:
0424       return false ;
0425     case ADirty:
0426       return true ;
0427     case Auto:
0428       if (_valueDirty) return isDerived() ;
0429       return false ;
0430     }
0431     return true ; // we should never get here
0432   }
0433 
0434   inline bool isValueDirtyAndClear() const {
0435     // Returns true of value has been invalidated by server value change
0436     if (inhibitDirty()) return true ;
0437     switch(_operMode) {
0438     case AClean:
0439       return false ;
0440     case ADirty:
0441       return true ;
0442     case Auto:
0443       if (_valueDirty) {
0444    _valueDirty = false ;
0445    return isDerived();
0446       }
0447       return false ;
0448     }
0449     return true ; // But we should never get here
0450   }
0451 
0452 
0453   inline bool isValueOrShapeDirtyAndClear() const {
0454     // Returns true of value has been invalidated by server value change
0455 
0456     if (inhibitDirty()) return true ;
0457     switch(_operMode) {
0458     case AClean:
0459       return false ;
0460     case ADirty:
0461       return true ;
0462     case Auto:
0463       if (_valueDirty || _shapeDirty) {
0464    _shapeDirty = false ;
0465    _valueDirty = false ;
0466    return isDerived();
0467       }
0468       _shapeDirty = false ;
0469       _valueDirty = false ;
0470       return false ;
0471     }
0472     return true ; // But we should never get here
0473   }
0474 
0475   // Cache management
0476   void registerCache(RooAbsCache& cache) ;
0477   void unRegisterCache(RooAbsCache& cache) ;
0478   Int_t numCaches() const ;
0479   RooAbsCache* getCache(Int_t index) const ;
0480 
0481   /// Query the operation mode of this node.
0482   inline OperMode operMode() const { return _operMode  ; }
0483   /// Set the operation mode of this node.
0484   void setOperMode(OperMode mode, bool recurseADirty=true) ;
0485 
0486   // Dirty state modifiers
0487   /// Mark the element dirty. This forces a re-evaluation when a value is requested.
0488   void setValueDirty() {
0489     if (_operMode == Auto && !inhibitDirty())
0490       setValueDirty(nullptr);
0491   }
0492   /// Notify that a shape-like property (*e.g.* binning) has changed.
0493   void setShapeDirty() { setShapeDirty(nullptr); }
0494 
0495   const char* aggregateCacheUniqueSuffix() const ;
0496   virtual const char* cacheUniqueSuffix() const { return nullptr ; }
0497 
0498   void wireAllCaches() ;
0499 
0500   RooExpensiveObjectCache& expensiveObjectCache() const ;
0501   virtual void setExpensiveObjectCache(RooExpensiveObjectCache &cache) { _eocache = &cache; }
0502 
0503   /// Overwrite the current value stored in this object, making it look like this object computed that value.
0504   // \param[in] value Value to store.
0505   // \param[in] notifyClients Notify users of this object that they need to
0506   /// recompute their values.
0507   virtual void setCachedValue(double /*value*/, bool /*notifyClients*/ = true) {};
0508 
0509   /// @}
0510   ////////////////////////////////////////////////////////////////////////////
0511 
0512   //Debug hooks
0513   static void verboseDirty(bool flag) ;
0514   void printDirty(bool depth=true) const ;
0515   static void setDirtyInhibit(bool flag) ;
0516 
0517   void graphVizTree(const char* fileName, const char* delimiter="\n", bool useTitle=false, bool useLatex=false) ;
0518   void graphVizTree(std::ostream& os, const char* delimiter="\n", bool useTitle=false, bool useLatex=false) ;
0519 
0520   void printComponentTree(const char* indent="",const char* namePat=nullptr, Int_t nLevel=999) ;
0521   void printCompactTree(const char* indent="",const char* fileName=nullptr, const char* namePat=nullptr, RooAbsArg* client=nullptr) ;
0522   void printCompactTree(std::ostream& os, const char* indent="", const char* namePat=nullptr, RooAbsArg* client=nullptr) ;
0523   virtual void printCompactTreeHook(std::ostream& os, const char *ind="") ;
0524 
0525   // We want to support three cases here:
0526   //   * passing a RooArgSet
0527   //   * passing a RooArgList
0528   //   * passing an initializer list
0529   // Before, there was only an overload taking a RooArg set, which caused an
0530   // implicit creation of a RooArgSet when a RooArgList was passed. This needs
0531   // to be avoided, because if the passed RooArgList is owning the arguments,
0532   // this information will be lost with the copy. The solution is to have one
0533   // overload that takes a general RooAbsCollection, and one overload for
0534   // RooArgList that is invoked in the case of passing an initializer list.
0535   bool addOwnedComponents(const RooAbsCollection& comps) ;
0536   bool addOwnedComponents(RooAbsCollection&& comps) ;
0537   bool addOwnedComponents(RooArgList&& comps) ;
0538 
0539   // Transfer the ownership of one or more other RooAbsArgs to this RooAbsArg
0540   // via a `std::unique_ptr`.
0541   template<typename... Args_t>
0542   bool addOwnedComponents(std::unique_ptr<Args_t>... comps) {
0543     return addOwnedComponents({*comps.release() ...});
0544   }
0545   const RooArgSet* ownedComponents() const { return _ownedComponents ; }
0546 
0547   void setProhibitServerRedirect(bool flag) { _prohibitServerRedirect = flag ; }
0548 
0549   void setWorkspace(RooWorkspace &ws) { _myws = &ws; }
0550   inline RooWorkspace* workspace() const { return _myws; }
0551 
0552   RooAbsProxy* getProxy(Int_t index) const ;
0553   Int_t numProxies() const ;
0554 
0555   /// De-duplicated pointer to this object's name.
0556   /// This can be used for fast name comparisons.
0557   /// like `if (namePtr() == other.namePtr())`.
0558   /// \note TNamed::GetName() will return a pointer that's
0559   /// different for each object, but namePtr() always points
0560   /// to a unique instance.
0561   inline const TNamed* namePtr() const {
0562     return _namePtr ;
0563   }
0564 
0565   void SetName(const char* name) override ;
0566   void SetNameTitle(const char *name, const char *title) override ;
0567 
0568   virtual bool importWorkspaceHook(RooWorkspace &ws)
0569   {
0570      _myws = &ws;
0571      return false;
0572   };
0573 
0574   virtual bool canComputeBatchWithCuda() const { return false; }
0575   virtual bool isReducerNode() const { return false; }
0576 
0577   virtual void applyWeightSquared(bool flag);
0578 
0579   virtual std::unique_ptr<RooAbsArg> compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext & ctx) const;
0580 
0581   virtual bool isCategory() const { return false; }
0582 
0583   virtual void translate(RooFit::Detail::CodeSquashContext &ctx) const;
0584 
0585 protected:
0586    void graphVizAddConnections(std::set<std::pair<RooAbsArg*,RooAbsArg*> >&) ;
0587 
0588    virtual void operModeHook() {} ;
0589 
0590    virtual void optimizeDirtyHook(const RooArgSet* /*obs*/) {} ;
0591 
0592    virtual bool isValid() const ;
0593 
0594    virtual void getParametersHook(const RooArgSet* /*nset*/, RooArgSet* /*list*/, bool /*stripDisconnected*/) const {} ;
0595    virtual void getObservablesHook(const RooArgSet* /*nset*/, RooArgSet* /*list*/) const {} ;
0596 
0597    void clearValueAndShapeDirty() const {
0598      _valueDirty=false ;
0599      _shapeDirty=false ;
0600    }
0601 
0602    void clearValueDirty() const {
0603      _valueDirty=false ;
0604    }
0605    void clearShapeDirty() const {
0606      _shapeDirty=false ;
0607    }
0608 
0609    /// Force element to re-evaluate itself when a value is requested.
0610    void setValueDirty(const RooAbsArg* source);
0611    /// Notify that a shape-like property (*e.g.* binning) has changed.
0612    void setShapeDirty(const RooAbsArg* source);
0613 
0614    virtual void ioStreamerPass2() ;
0615    static void ioStreamerPass2Finalize() ;
0616 
0617 
0618 private:
0619   void addParameters(RooAbsCollection& params, const RooArgSet* nset = nullptr, bool stripDisconnected = true) const;
0620   std::size_t getParametersSizeEstimate(const RooArgSet* nset = nullptr) const;
0621 
0622   RefCountListLegacyIterator_t * makeLegacyIterator(const RefCountList_t& list) const;
0623 
0624 
0625  protected:
0626   friend class RooAbsReal;
0627 
0628   // Client-Server relation and Proxy management
0629   friend class RooAbsCollection ;
0630   friend class RooWorkspace ;
0631   friend class RooRealIntegral ;
0632   RefCountList_t _serverList       ; // list of server objects
0633   RefCountList_t _clientList; // list of client objects
0634   RefCountList_t _clientListShape; // subset of clients that requested shape dirty flag propagation
0635   RefCountList_t _clientListValue; // subset of clients that requested value dirty flag propagation
0636 
0637   RooRefArray _proxyList        ; // list of proxies
0638 
0639   std::vector<RooAbsCache*> _cacheList ; //! list of caches
0640 
0641 
0642   // Proxy management
0643   friend class RooArgProxy ;
0644   template<class RooCollection_t>
0645   friend class RooCollectionProxy;
0646   friend class RooHistPdf ;
0647   friend class RooHistFunc ;
0648   void registerProxy(RooArgProxy& proxy) ;
0649   void registerProxy(RooSetProxy& proxy) ;
0650   void registerProxy(RooListProxy& proxy) ;
0651   void unRegisterProxy(RooArgProxy& proxy) ;
0652   void unRegisterProxy(RooSetProxy& proxy) ;
0653   void unRegisterProxy(RooListProxy& proxy) ;
0654   void setProxyNormSet(const RooArgSet* nset) ;
0655 
0656   // Attribute list
0657   std::set<std::string> _boolAttrib ; // Boolean attributes
0658   std::map<std::string,std::string> _stringAttrib ; // String attributes
0659   std::set<std::string> _boolAttribTransient ; //! Transient boolean attributes (not copied in ctor)
0660 
0661   void printAttribList(std::ostream& os) const;
0662 
0663   // Hooks for RooTreeData interface
0664   friend class RooCompositeDataStore ;
0665   friend class RooTreeDataStore ;
0666   friend class RooVectorDataStore ;
0667   friend class RooDataSet ;
0668   friend class RooRealMPFE ;
0669   virtual void syncCache(const RooArgSet* nset=nullptr) = 0 ;
0670   virtual void copyCache(const RooAbsArg* source, bool valueOnly=false, bool setValDirty=true) = 0 ;
0671 
0672   virtual void attachToTree(TTree& t, Int_t bufSize=32000) = 0 ;
0673   virtual void attachToVStore(RooVectorDataStore& vstore) = 0 ;
0674   /// Attach this argument to the data store such that it reads data from there.
0675   void attachToStore(RooAbsDataStore& store) ;
0676 
0677   virtual void setTreeBranchStatus(TTree& t, bool active) = 0 ;
0678   virtual void fillTreeBranch(TTree& t) = 0 ;
0679   TString cleanBranchName() const ;
0680 
0681   // Global
0682   friend std::ostream& operator<<(std::ostream& os, const RooAbsArg &arg);
0683   friend std::istream& operator>>(std::istream& is, RooAbsArg &arg) ;
0684   friend void RooRefArray::Streamer(TBuffer&);
0685 
0686   struct ProxyListCache {
0687     std::vector<RooAbsProxy*> cache;
0688     bool isDirty = true;
0689   };
0690   ProxyListCache _proxyListCache; //! cache of the list of proxies. Avoids type casting.
0691 
0692   // Debug stuff
0693   static bool _verboseDirty ; // Static flag controlling verbose messaging for dirty state changes
0694   static bool _inhibitDirty ; // Static flag controlling global inhibit of dirty state propagation
0695   bool _deleteWatch = false; //! Delete watch flag
0696 
0697   bool inhibitDirty() const ;
0698 
0699  public:
0700   void setLocalNoDirtyInhibit(bool flag) const { _localNoInhibitDirty = flag ; }
0701   bool localNoDirtyInhibit() const { return _localNoInhibitDirty ; }
0702 
0703   /// Returns the token for retrieving results in the BatchMode. For internal use only.
0704   std::size_t dataToken() const { return _dataToken; }
0705   bool hasDataToken() const { return _dataToken != std::numeric_limits<std::size_t>::max(); }
0706   void setDataToken(std::size_t index);
0707   void resetDataToken() { _dataToken = std::numeric_limits<std::size_t>::max(); }
0708  protected:
0709 
0710 
0711   mutable bool _valueDirty = true;  // Flag set if value needs recalculating because input values modified
0712   mutable bool _shapeDirty = true;  // Flag set if value needs recalculating because input shapes modified
0713 
0714   mutable OperMode _operMode = Auto; // Dirty state propagation mode
0715   mutable bool _fast = false; // Allow fast access mode in getVal() and proxies
0716 
0717   // Owned components
0718   RooArgSet* _ownedComponents = nullptr; //! Set of owned component
0719 
0720   mutable bool _prohibitServerRedirect = false; //! Prohibit server redirects -- Debugging tool
0721 
0722   mutable RooExpensiveObjectCache* _eocache{nullptr}; //! Pointer to global cache manager for any expensive components created by this object
0723 
0724   mutable const TNamed * _namePtr = nullptr; //! De-duplicated name pointer. This will be equal for all objects with the same name.
0725   bool _isConstant = false; //! Cached isConstant status
0726 
0727   mutable bool _localNoInhibitDirty = false; //! Prevent 'AlwaysDirty' mode for this node
0728 
0729 /*   RooArgSet _leafNodeCache ; //! Cached leaf nodes */
0730 /*   RooArgSet _branchNodeCache //! Cached branch nodes     */
0731 
0732   mutable RooWorkspace *_myws = nullptr; //! In which workspace do I live, if any
0733 
0734   std::size_t _dataToken = std::numeric_limits<std::size_t>::max(); //! Set by the RooFitDriver for this arg to retrieve its result in the run context
0735 
0736   /// \cond ROOFIT_INTERNAL
0737   // Legacy streamers need the following statics:
0738   friend class RooFitResult;
0739 
0740  public:
0741   static std::map<RooAbsArg*,std::unique_ptr<TRefArray>> _ioEvoList; // temporary holding list for proxies needed in schema evolution
0742  protected:
0743   static std::stack<RooAbsArg*> _ioReadStack ; // reading stack
0744   /// \endcond
0745 
0746  private:
0747   void substituteServer(RooAbsArg *oldServer, RooAbsArg *newServer);
0748   bool callRedirectServersHook(RooAbsCollection const& newSet, bool mustReplaceAll, bool nameChange, bool isRecursionStep);
0749 
0750   ClassDefOverride(RooAbsArg,9) // Abstract variable
0751 };
0752 
0753 std::ostream& operator<<(std::ostream& os, const RooAbsArg &arg);
0754 std::istream& operator>>(std::istream& is, RooAbsArg &arg);
0755 
0756 
0757 #endif