Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-09-17 09:15:06

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 Experimental {
0058 class CodegenContext;
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   /// \anchor clientServerInterface
0130   /// \name Client-Server Interface
0131   /// These functions allow RooFit to figure out who is serving values to whom.
0132   /// @{
0133 
0134   /// List of all clients of this object.
0135   const RefCountList_t& clients() const {
0136     return _clientList;
0137   }
0138   /// List of all value clients of this object. Value clients receive value updates.
0139   const RefCountList_t& valueClients() const {
0140     return _clientListValue;
0141   }
0142   /// List of all shape clients of this object. Shape clients receive property information such as
0143   /// changes of a value range.
0144   const RefCountList_t& shapeClients() const {
0145     return _clientListShape;
0146   }
0147 
0148   /// List of all servers of this object.
0149   const RefCountList_t& servers() const {
0150     return _serverList;
0151   }
0152   /// Return server of `this` with name `name`. Returns nullptr if not found.
0153   inline RooAbsArg* findServer(const char *name) const {
0154     const auto serverIt = _serverList.findByName(name);
0155     return serverIt != _serverList.end() ? *serverIt : nullptr;
0156   }
0157   /// Return server of `this` that has the same name as `arg`. Returns `nullptr` if not found.
0158   inline RooAbsArg* findServer(const RooAbsArg& arg) const {
0159     return _serverList.findByNamePointer(&arg);
0160   }
0161   /// Return i-th server from server list.
0162   inline RooAbsArg* findServer(Int_t index) const {
0163     return _serverList.containedObjects()[index];
0164   }
0165   /// Check if `this` is serving values to `arg`.
0166   inline bool isValueServer(const RooAbsArg& arg) const {
0167     return _clientListValue.containsByNamePtr(&arg);
0168   }
0169   /// Check if `this` is serving values to an object with name `name`.
0170   inline bool isValueServer(const char* name) const {
0171     return _clientListValue.containsSameName(name);
0172   }
0173   /// Check if `this` is serving shape to `arg`.
0174   inline bool isShapeServer(const RooAbsArg& arg) const {
0175     return _clientListShape.containsByNamePtr(&arg);
0176   }
0177   /// Check if `this` is serving shape to an object with name `name`.
0178   inline bool isShapeServer(const char* name) const {
0179     return _clientListShape.containsSameName(name);
0180   }
0181   void leafNodeServerList(RooAbsCollection* list, const RooAbsArg* arg=nullptr, bool recurseNonDerived=false) const ;
0182   void branchNodeServerList(RooAbsCollection* list, const RooAbsArg* arg=nullptr, bool recurseNonDerived=false) const ;
0183   void treeNodeServerList(RooAbsCollection* list, const RooAbsArg* arg=nullptr,
0184            bool doBranch=true, bool doLeaf=true,
0185            bool valueOnly=false, bool recurseNonDerived=false) const ;
0186 
0187 
0188   /// Is this object a fundamental type that can be added to a dataset?
0189   /// Fundamental-type subclasses override this method to return true.
0190   /// Note that this test is subtlely different from the dynamic isDerived()
0191   /// test, e.g. a constant is not derived but is also not fundamental.
0192   inline virtual bool isFundamental() const {
0193     return false;
0194   }
0195 
0196   /// Create a fundamental-type object that stores our type of value. The
0197   /// created object will have a valid value, but not necessarily the same
0198   /// as our value. The caller is responsible for deleting the returned object.
0199   virtual RooFit::OwningPtr<RooAbsArg> createFundamental(const char* newname=nullptr) const = 0;
0200 
0201   /// Is this argument an l-value, i.e., can it appear on the left-hand side
0202   /// of an assignment expression? LValues are also special since they can
0203   /// potentially be analytically integrated and generated.
0204   inline virtual bool isLValue() const {
0205     return false;
0206   }
0207 
0208 
0209   // Server redirection interface
0210   bool redirectServers(const RooAbsCollection& newServerList, bool mustReplaceAll=false, bool nameChange=false, bool isRecursionStep=false) ;
0211   bool redirectServers(std::unordered_map<RooAbsArg*, RooAbsArg*> const& replacements);
0212   bool recursiveRedirectServers(const RooAbsCollection& newServerList, bool mustReplaceAll=false, bool nameChange=false, bool recurseInNewSet=true) ;
0213 
0214   virtual bool redirectServersHook(const RooAbsCollection & newServerList, bool mustReplaceAll,
0215                                    bool nameChange, bool isRecursiveStep);
0216 
0217   virtual void serverNameChangeHook(const RooAbsArg* /*oldServer*/, const RooAbsArg* /*newServer*/) { } ;
0218 
0219   void addServer(RooAbsArg& server, bool valueProp=true, bool shapeProp=false, std::size_t refCount = 1);
0220   void addServerList(RooAbsCollection& serverList, bool valueProp=true, bool shapeProp=false) ;
0221   void
0222   R__SUGGEST_ALTERNATIVE("This interface is unsafe! Use RooAbsArg::redirectServers()")
0223   replaceServer(RooAbsArg& oldServer, RooAbsArg& newServer, bool valueProp, bool shapeProp) ;
0224   void changeServer(RooAbsArg& server, bool valueProp, bool shapeProp) ;
0225   void removeServer(RooAbsArg& server, bool force=false) ;
0226   RooAbsArg *findNewServer(const RooAbsCollection &newSet, bool nameChange) const;
0227 
0228 
0229   /// @}
0230   ///////////////////////////////////////////////////////////////////////////////
0231 
0232 
0233   // Parameter & observable interpretation of servers
0234   RooFit::OwningPtr<RooArgSet> getVariables(bool stripDisconnected=true) const ;
0235   RooFit::OwningPtr<RooArgSet> getParameters(const RooAbsData* data, bool stripDisconnected=true) const;
0236   RooFit::OwningPtr<RooArgSet> getParameters(const RooAbsData& data, bool stripDisconnected=true) const;
0237   RooFit::OwningPtr<RooArgSet> getParameters(const RooArgSet& observables, bool stripDisconnected=true) const;
0238   RooFit::OwningPtr<RooArgSet> getParameters(const RooArgSet* observables, bool stripDisconnected=true) const;
0239   virtual bool getParameters(const RooArgSet* observables, RooArgSet& outputSet, bool stripDisconnected=true) const;
0240   RooFit::OwningPtr<RooArgSet> getObservables(const RooArgSet& set, bool valueOnly=true) const;
0241   RooFit::OwningPtr<RooArgSet> getObservables(const RooAbsData* data) const;
0242   RooFit::OwningPtr<RooArgSet> getObservables(const RooAbsData& data) const;
0243   RooFit::OwningPtr<RooArgSet> getObservables(const RooArgSet* depList, bool valueOnly=true) const;
0244   bool getObservables(const RooAbsCollection* depList, RooArgSet& outputSet, bool valueOnly=true) const;
0245   bool observableOverlaps(const RooAbsData* dset, const RooAbsArg& testArg) const ;
0246   bool observableOverlaps(const RooArgSet* depList, const RooAbsArg& testArg) const ;
0247   virtual bool checkObservables(const RooArgSet* nset) const ;
0248   bool recursiveCheckObservables(const RooArgSet* nset) const ;
0249   RooFit::OwningPtr<RooArgSet> getComponents() const ;
0250 
0251 
0252 
0253   void attachArgs(const RooAbsCollection &set);
0254   void attachDataSet(const RooAbsData &set);
0255   void attachDataStore(const RooAbsDataStore &set);
0256 
0257   // I/O streaming interface (machine readable)
0258   virtual bool readFromStream(std::istream& is, bool compact, bool verbose=false) = 0 ;
0259   virtual void writeToStream(std::ostream& os, bool compact) const = 0 ;
0260 
0261   /// Print the object to the defaultPrintStream().
0262   /// \param[in] options **V** print verbose. **T** print a tree structure with all children.
0263   void Print(Option_t *options= nullptr) const override {
0264     // Printing interface (human readable)
0265     printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
0266   }
0267 
0268   void printName(std::ostream& os) const override ;
0269   void printTitle(std::ostream& os) const override ;
0270   void printClassName(std::ostream& os) const override ;
0271   void printAddress(std::ostream& os) const override ;
0272   void printArgs(std::ostream& os) const override ;
0273   virtual void printMetaArgs(std::ostream& /*os*/) const {} ;
0274   void printMultiline(std::ostream& os, Int_t contents, bool verbose=false, TString indent="") const override;
0275   void printTree(std::ostream& os, TString indent="") const override ;
0276 
0277   Int_t defaultPrintContents(Option_t* opt) const override ;
0278 
0279   // Accessors to attributes
0280   void setAttribute(const Text_t* name, bool value=true) ;
0281   bool getAttribute(const Text_t* name) const ;
0282   inline const std::set<std::string>& attributes() const {
0283     // Returns set of names of boolean attributes defined
0284     return _boolAttrib ;
0285   }
0286 
0287   void setStringAttribute(const Text_t* key, const Text_t* value) ;
0288   void removeStringAttribute(const Text_t* key) ;
0289   const Text_t* getStringAttribute(const Text_t* key) const ;
0290   inline const std::map<std::string,std::string>& stringAttributes() const {
0291     // Returns std::map<string,string> with all string attributes defined
0292     return _stringAttrib ;
0293   }
0294 
0295   // Accessors to transient attributes
0296   void setTransientAttribute(const Text_t* name, bool value=true) ;
0297   bool getTransientAttribute(const Text_t* name) const ;
0298   inline const std::set<std::string>& transientAttributes() const {
0299     // Return set of transient boolean attributes
0300     return _boolAttribTransient ;
0301   }
0302 
0303   /// Check if the "Constant" attribute is set.
0304   inline bool isConstant() const {
0305     return _isConstant ; //getAttribute("Constant") ;
0306   }
0307 
0308   // Sorting
0309   Int_t Compare(const TObject* other) const override ;
0310   bool IsSortable() const override {
0311     // Object is sortable in ROOT container class
0312     return true ;
0313   }
0314 
0315   virtual bool operator==(const RooAbsArg& other) const = 0 ;
0316   virtual bool isIdentical(const RooAbsArg& other, bool assumeSameType=false) const = 0 ;
0317 
0318   // Range management
0319   virtual bool inRange(const char*) const {
0320     // Is value in range (dummy interface always returns true)
0321     return true ;
0322   }
0323   virtual bool hasRange(const char*) const {
0324     // Has this argument a defined range (dummy interface always returns false)
0325     return false ;
0326   }
0327 
0328 
0329   enum ConstOpCode { Activate=0, DeActivate=1, ConfigChange=2, ValueChange=3 } ;
0330   enum CacheMode { Always=0, NotAdvised=1, Never=2 } ;
0331   enum OperMode { Auto=0, AClean=1, ADirty=2 } ;
0332 
0333   ////////////////////////////////////////////////////////////////////////////
0334   /// \anchor optimisationInterface
0335   /// \name Optimisation interface
0336   /// These functions allow RooFit to optimise a computation graph, to keep track
0337   /// of cached values, and to invalidate caches.
0338   /// @{
0339 
0340   // Cache mode optimization (tracks changes & do lazy evaluation vs evaluate always)
0341   virtual void optimizeCacheMode(const RooArgSet& observables) ;
0342   virtual void optimizeCacheMode(const RooArgSet& observables, RooArgSet& optNodes, RooLinkedList& processedNodes) ;
0343 
0344 
0345   // Find constant terms in expression
0346   bool findConstantNodes(const RooArgSet& observables, RooArgSet& cacheList) ;
0347   bool findConstantNodes(const RooArgSet& observables, RooArgSet& cacheList, RooLinkedList& processedNodes) ;
0348 
0349 
0350   // constant term optimization
0351   virtual void constOptimizeTestStatistic(ConstOpCode opcode, bool doAlsoTrackingOpt=true) ;
0352 
0353   virtual CacheMode canNodeBeCached() const { return Always ; }
0354   virtual void setCacheAndTrackHints(RooArgSet& /*trackNodes*/ ) {} ;
0355 
0356   // Dirty state accessor
0357   inline bool isShapeDirty() const {
0358     // Return true is shape has been invalidated by server value change
0359     return isDerived()?_shapeDirty:false ;
0360   }
0361 
0362   inline bool isValueDirty() const {
0363     // Returns true of value has been invalidated by server value change
0364     if (inhibitDirty()) return true ;
0365     switch(_operMode) {
0366     case AClean:
0367       return false ;
0368     case ADirty:
0369       return true ;
0370     case Auto:
0371       if (_valueDirty) return isDerived() ;
0372       return false ;
0373     }
0374     return true ; // we should never get here
0375   }
0376 
0377   inline bool isValueDirtyAndClear() const {
0378     // Returns true of value has been invalidated by server value change
0379     if (inhibitDirty()) return true ;
0380     switch(_operMode) {
0381     case AClean:
0382       return false ;
0383     case ADirty:
0384       return true ;
0385     case Auto:
0386       if (_valueDirty) {
0387    _valueDirty = false ;
0388    return isDerived();
0389       }
0390       return false ;
0391     }
0392     return true ; // But we should never get here
0393   }
0394 
0395 
0396   inline bool isValueOrShapeDirtyAndClear() const {
0397     // Returns true of value has been invalidated by server value change
0398 
0399     if (inhibitDirty()) return true ;
0400     switch(_operMode) {
0401     case AClean:
0402       return false ;
0403     case ADirty:
0404       return true ;
0405     case Auto:
0406       if (_valueDirty || _shapeDirty) {
0407    _shapeDirty = false ;
0408    _valueDirty = false ;
0409    return isDerived();
0410       }
0411       _shapeDirty = false ;
0412       _valueDirty = false ;
0413       return false ;
0414     }
0415     return true ; // But we should never get here
0416   }
0417 
0418   // Cache management
0419   void registerCache(RooAbsCache& cache) ;
0420   void unRegisterCache(RooAbsCache& cache) ;
0421   Int_t numCaches() const ;
0422   RooAbsCache* getCache(Int_t index) const ;
0423 
0424   /// Query the operation mode of this node.
0425   inline OperMode operMode() const { return _operMode  ; }
0426   /// Set the operation mode of this node.
0427   void setOperMode(OperMode mode, bool recurseADirty=true) ;
0428 
0429   // Dirty state modifiers
0430   /// Mark the element dirty. This forces a re-evaluation when a value is requested.
0431   void setValueDirty() {
0432     if (_operMode == Auto && !inhibitDirty())
0433       setValueDirty(nullptr);
0434   }
0435   /// Notify that a shape-like property (*e.g.* binning) has changed.
0436   void setShapeDirty() { setShapeDirty(nullptr); }
0437 
0438   const char* aggregateCacheUniqueSuffix() const ;
0439   virtual const char* cacheUniqueSuffix() const { return nullptr ; }
0440 
0441   void wireAllCaches() ;
0442 
0443   RooExpensiveObjectCache& expensiveObjectCache() const ;
0444   virtual void setExpensiveObjectCache(RooExpensiveObjectCache &cache) { _eocache = &cache; }
0445 
0446   /// Overwrite the current value stored in this object, making it look like this object computed that value.
0447   // \param[in] value Value to store.
0448   // \param[in] notifyClients Notify users of this object that they need to
0449   /// recompute their values.
0450   virtual void setCachedValue(double /*value*/, bool /*notifyClients*/ = true) {};
0451 
0452   /// @}
0453   ////////////////////////////////////////////////////////////////////////////
0454 
0455   //Debug hooks
0456   static void verboseDirty(bool flag) ;
0457   void printDirty(bool depth=true) const ;
0458   static void setDirtyInhibit(bool flag) ;
0459 
0460   void graphVizTree(const char* fileName, const char* delimiter="\n", bool useTitle=false, bool useLatex=false) ;
0461   void graphVizTree(std::ostream& os, const char* delimiter="\n", bool useTitle=false, bool useLatex=false) ;
0462 
0463   void printComponentTree(const char* indent="",const char* namePat=nullptr, Int_t nLevel=999) ;
0464   void printCompactTree(const char* indent="",const char* fileName=nullptr, const char* namePat=nullptr, RooAbsArg* client=nullptr) ;
0465   void printCompactTree(std::ostream& os, const char* indent="", const char* namePat=nullptr, RooAbsArg* client=nullptr) ;
0466   virtual void printCompactTreeHook(std::ostream& os, const char *ind="") ;
0467 
0468   // We want to support three cases here:
0469   //   * passing a RooArgSet
0470   //   * passing a RooArgList
0471   //   * passing an initializer list
0472   // Before, there was only an overload taking a RooArg set, which caused an
0473   // implicit creation of a RooArgSet when a RooArgList was passed. This needs
0474   // to be avoided, because if the passed RooArgList is owning the arguments,
0475   // this information will be lost with the copy. The solution is to have one
0476   // overload that takes a general RooAbsCollection, and one overload for
0477   // RooArgList that is invoked in the case of passing an initializer list.
0478   bool addOwnedComponents(const RooAbsCollection& comps) ;
0479   bool addOwnedComponents(RooAbsCollection&& comps) ;
0480   bool addOwnedComponents(RooArgList&& comps) ;
0481 
0482   // Transfer the ownership of one or more other RooAbsArgs to this RooAbsArg
0483   // via a `std::unique_ptr`.
0484   template<typename... Args_t>
0485   bool addOwnedComponents(std::unique_ptr<Args_t>... comps) {
0486     return addOwnedComponents({*comps.release() ...});
0487   }
0488   const RooArgSet* ownedComponents() const { return _ownedComponents ; }
0489 
0490   void setProhibitServerRedirect(bool flag) { _prohibitServerRedirect = flag ; }
0491 
0492   void setWorkspace(RooWorkspace &ws) { _myws = &ws; }
0493   inline RooWorkspace* workspace() const { return _myws; }
0494 
0495   RooAbsProxy* getProxy(Int_t index) const ;
0496   Int_t numProxies() const ;
0497 
0498   /// De-duplicated pointer to this object's name.
0499   /// This can be used for fast name comparisons.
0500   /// like `if (namePtr() == other.namePtr())`.
0501   /// \note TNamed::GetName() will return a pointer that's
0502   /// different for each object, but namePtr() always points
0503   /// to a unique instance.
0504   inline const TNamed* namePtr() const {
0505     return _namePtr ;
0506   }
0507 
0508   void SetName(const char* name) override ;
0509   void SetNameTitle(const char *name, const char *title) override ;
0510 
0511   virtual bool importWorkspaceHook(RooWorkspace &ws)
0512   {
0513      _myws = &ws;
0514      return false;
0515   };
0516 
0517   virtual bool canComputeBatchWithCuda() const { return false; }
0518   virtual bool isReducerNode() const { return false; }
0519 
0520   virtual void applyWeightSquared(bool flag);
0521 
0522   virtual std::unique_ptr<RooAbsArg> compileForNormSet(RooArgSet const &normSet, RooFit::Detail::CompileContext & ctx) const;
0523 
0524   virtual bool isCategory() const { return false; }
0525 
0526 protected:
0527    void graphVizAddConnections(std::set<std::pair<RooAbsArg*,RooAbsArg*> >&) ;
0528 
0529    virtual void operModeHook() {} ;
0530 
0531    virtual void optimizeDirtyHook(const RooArgSet* /*obs*/) {} ;
0532 
0533    virtual bool isValid() const ;
0534 
0535    virtual void getParametersHook(const RooArgSet* /*nset*/, RooArgSet* /*list*/, bool /*stripDisconnected*/) const {} ;
0536    virtual void getObservablesHook(const RooArgSet* /*nset*/, RooArgSet* /*list*/) const {} ;
0537 
0538    void clearValueAndShapeDirty() const {
0539      _valueDirty=false ;
0540      _shapeDirty=false ;
0541    }
0542 
0543    void clearValueDirty() const {
0544      _valueDirty=false ;
0545    }
0546    void clearShapeDirty() const {
0547      _shapeDirty=false ;
0548    }
0549 
0550    /// Force element to re-evaluate itself when a value is requested.
0551    void setValueDirty(const RooAbsArg* source);
0552    /// Notify that a shape-like property (*e.g.* binning) has changed.
0553    void setShapeDirty(const RooAbsArg* source);
0554 
0555    virtual void ioStreamerPass2() ;
0556    static void ioStreamerPass2Finalize() ;
0557 
0558 
0559 private:
0560   void addParameters(RooAbsCollection& params, const RooArgSet* nset = nullptr, bool stripDisconnected = true) const;
0561   std::size_t getParametersSizeEstimate(const RooArgSet* nset = nullptr) const;
0562 
0563   RefCountListLegacyIterator_t * makeLegacyIterator(const RefCountList_t& list) const;
0564 
0565 
0566  protected:
0567   friend class RooAbsReal;
0568 
0569   // Client-Server relation and Proxy management
0570   friend class RooAbsCollection ;
0571   friend class RooWorkspace ;
0572   friend class RooRealIntegral ;
0573   RefCountList_t _serverList       ; // list of server objects
0574   RefCountList_t _clientList; // list of client objects
0575   RefCountList_t _clientListShape; // subset of clients that requested shape dirty flag propagation
0576   RefCountList_t _clientListValue; // subset of clients that requested value dirty flag propagation
0577 
0578   RooRefArray _proxyList        ; // list of proxies
0579 
0580   std::vector<RooAbsCache*> _cacheList ; //! list of caches
0581 
0582 
0583   // Proxy management
0584   friend class RooArgProxy ;
0585   template<class RooCollection_t>
0586   friend class RooCollectionProxy;
0587   friend class RooHistPdf ;
0588   friend class RooHistFunc ;
0589   void registerProxy(RooArgProxy& proxy) ;
0590   void registerProxy(RooSetProxy& proxy) ;
0591   void registerProxy(RooListProxy& proxy) ;
0592   void unRegisterProxy(RooArgProxy& proxy) ;
0593   void unRegisterProxy(RooSetProxy& proxy) ;
0594   void unRegisterProxy(RooListProxy& proxy) ;
0595   void setProxyNormSet(const RooArgSet* nset) ;
0596 
0597   // Attribute list
0598   std::set<std::string> _boolAttrib ; // Boolean attributes
0599   std::map<std::string,std::string> _stringAttrib ; // String attributes
0600   std::set<std::string> _boolAttribTransient ; //! Transient boolean attributes (not copied in ctor)
0601 
0602   void printAttribList(std::ostream& os) const;
0603 
0604   // Hooks for RooTreeData interface
0605   friend class RooCompositeDataStore ;
0606   friend class RooTreeDataStore ;
0607   friend class RooVectorDataStore ;
0608   friend class RooDataSet ;
0609   friend class RooRealMPFE ;
0610   virtual void syncCache(const RooArgSet* nset=nullptr) = 0 ;
0611   virtual void copyCache(const RooAbsArg* source, bool valueOnly=false, bool setValDirty=true) = 0 ;
0612 
0613   virtual void attachToTree(TTree& t, Int_t bufSize=32000) = 0 ;
0614   virtual void attachToVStore(RooVectorDataStore& vstore) = 0 ;
0615   /// Attach this argument to the data store such that it reads data from there.
0616   void attachToStore(RooAbsDataStore& store) ;
0617 
0618   virtual void setTreeBranchStatus(TTree& t, bool active) = 0 ;
0619   virtual void fillTreeBranch(TTree& t) = 0 ;
0620   TString cleanBranchName() const ;
0621 
0622   // Global
0623   friend std::ostream& operator<<(std::ostream& os, const RooAbsArg &arg);
0624   friend std::istream& operator>>(std::istream& is, RooAbsArg &arg) ;
0625   friend void RooRefArray::Streamer(TBuffer&);
0626 
0627   struct ProxyListCache {
0628     std::vector<RooAbsProxy*> cache;
0629     bool isDirty = true;
0630   };
0631   ProxyListCache _proxyListCache; //! cache of the list of proxies. Avoids type casting.
0632 
0633   // Debug stuff
0634   static bool _verboseDirty ; // Static flag controlling verbose messaging for dirty state changes
0635   static bool _inhibitDirty ; // Static flag controlling global inhibit of dirty state propagation
0636   bool _deleteWatch = false; //! Delete watch flag
0637 
0638   bool inhibitDirty() const ;
0639 
0640  public:
0641   void setLocalNoDirtyInhibit(bool flag) const { _localNoInhibitDirty = flag ; }
0642   bool localNoDirtyInhibit() const { return _localNoInhibitDirty ; }
0643 
0644   /// Returns the token for retrieving results in the BatchMode. For internal use only.
0645   std::size_t dataToken() const { return _dataToken; }
0646   bool hasDataToken() const { return _dataToken != std::numeric_limits<std::size_t>::max(); }
0647   void setDataToken(std::size_t index);
0648   void resetDataToken() { _dataToken = std::numeric_limits<std::size_t>::max(); }
0649  protected:
0650 
0651 
0652   mutable bool _valueDirty = true;  // Flag set if value needs recalculating because input values modified
0653   mutable bool _shapeDirty = true;  // Flag set if value needs recalculating because input shapes modified
0654 
0655   mutable OperMode _operMode = Auto; // Dirty state propagation mode
0656   mutable bool _fast = false; // Allow fast access mode in getVal() and proxies
0657 
0658   // Owned components
0659   RooArgSet* _ownedComponents = nullptr; //! Set of owned component
0660 
0661   mutable bool _prohibitServerRedirect = false; //! Prohibit server redirects -- Debugging tool
0662 
0663   mutable RooExpensiveObjectCache* _eocache{nullptr}; //! Pointer to global cache manager for any expensive components created by this object
0664 
0665   mutable const TNamed * _namePtr = nullptr; //! De-duplicated name pointer. This will be equal for all objects with the same name.
0666   bool _isConstant = false; //! Cached isConstant status
0667 
0668   mutable bool _localNoInhibitDirty = false; //! Prevent 'AlwaysDirty' mode for this node
0669 
0670 /*   RooArgSet _leafNodeCache ; //! Cached leaf nodes */
0671 /*   RooArgSet _branchNodeCache //! Cached branch nodes     */
0672 
0673   mutable RooWorkspace *_myws = nullptr; //! In which workspace do I live, if any
0674 
0675   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
0676 
0677   /// \cond ROOFIT_INTERNAL
0678   // Legacy streamers need the following statics:
0679   friend class RooFitResult;
0680 
0681  public:
0682   static std::map<RooAbsArg*,std::unique_ptr<TRefArray>> _ioEvoList; // temporary holding list for proxies needed in schema evolution
0683  protected:
0684   static std::stack<RooAbsArg*> _ioReadStack ; // reading stack
0685   /// \endcond
0686 
0687  private:
0688   void substituteServer(RooAbsArg *oldServer, RooAbsArg *newServer);
0689   bool callRedirectServersHook(RooAbsCollection const& newSet, bool mustReplaceAll, bool nameChange, bool isRecursionStep);
0690 
0691   ClassDefOverride(RooAbsArg,9) // Abstract variable
0692 };
0693 
0694 std::ostream& operator<<(std::ostream& os, const RooAbsArg &arg);
0695 std::istream& operator>>(std::istream& is, RooAbsArg &arg);
0696 
0697 
0698 #endif