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