#ifndef ROO_ABS_ARG
#define ROO_ABS_ARG
#include <assert.h>
#include "TNamed.h"
#include "THashList.h"
#include "TRefArray.h"
#include "RooPrintable.h"
#include "RooRefCountList.h"
#include "RooAbsCache.h"
#include "RooLinkedListIter.h"
#include "RooNameReg.h"
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <iostream>
#include "TClass.h"
class TTree ;
class RooArgSet ;
class RooAbsCollection ;
class RooTreeData ;
class RooTreeDataStore ;
class RooVectorDataStore ;
class RooAbsData ;
class RooAbsDataStore ;
class RooAbsProxy ;
class RooArgProxy ;
class RooSetProxy ;
class RooListProxy ;
class RooExpensiveObjectCache ;
class RooWorkspace ;
class RooRealProxy ;
class RooRefArray : public TObjArray {
public:
RooRefArray() : TObjArray() {
} ;
RooRefArray(const RooRefArray& other) : TObjArray(other) {
}
virtual ~RooRefArray() {} ;
protected:
ClassDef(RooRefArray,1)
} ;
class RooAbsArg : public TNamed, public RooPrintable {
public:
RooAbsArg() ;
virtual ~RooAbsArg();
RooAbsArg(const char *name, const char *title);
RooAbsArg(const RooAbsArg& other, const char* name=0) ;
virtual TObject* clone(const char* newname=0) const = 0 ;
virtual TObject* Clone(const char* newname=0) const {
return clone(newname) ;
}
virtual RooAbsArg* cloneTree(const char* newname=0) const ;
virtual Bool_t isDerived() const {
return kTRUE ;
}
Bool_t isCloneOf(const RooAbsArg& other) const ;
Bool_t dependsOnValue(const RooAbsCollection& serverList, const RooAbsArg* ignoreArg=0) const {
return dependsOn(serverList,ignoreArg,kTRUE) ;
}
Bool_t dependsOnValue(const RooAbsArg& server, const RooAbsArg* ignoreArg=0) const {
return dependsOn(server,ignoreArg,kTRUE) ;
}
Bool_t dependsOn(const RooAbsCollection& serverList, const RooAbsArg* ignoreArg=0, Bool_t valueOnly=kFALSE) const ;
Bool_t dependsOn(const RooAbsArg& server, const RooAbsArg* ignoreArg=0, Bool_t valueOnly=kFALSE) const ;
Bool_t overlaps(const RooAbsArg& testArg, Bool_t valueOnly=kFALSE) const ;
Bool_t hasClients() const { return _clientList.GetSize()>0 ? kTRUE : kFALSE ; }
inline TIterator* clientIterator() const {
return _clientList.MakeIterator() ;
}
inline TIterator* valueClientIterator() const {
return _clientListValue.MakeIterator() ;
}
inline TIterator* shapeClientIterator() const {
return _clientListShape.MakeIterator() ;
}
inline TIterator* serverIterator() const {
return _serverList.MakeIterator() ;
}
inline RooFIter valueClientMIterator() const { return _clientListValue.fwdIterator() ; }
inline RooFIter shapeClientMIterator() const { return _clientListShape.fwdIterator() ; }
inline RooFIter serverMIterator() const { return _serverList.fwdIterator() ; }
inline RooAbsArg* findServer(const char *name) const {
return (RooAbsArg*)_serverList.FindObject(name);
}
inline RooAbsArg* findServer(const RooAbsArg& arg) const {
return (RooAbsArg*)_serverList.findArg(&arg);
}
inline RooAbsArg* findServer(Int_t index) const {
return (RooAbsArg*)_serverList.At(index);
}
inline Bool_t isValueServer(const RooAbsArg& arg) const {
return _clientListValue.findArg(&arg)?kTRUE:kFALSE ;
}
inline Bool_t isValueServer(const char* name) const {
return _clientListValue.FindObject(name)?kTRUE:kFALSE ;
}
inline Bool_t isShapeServer(const RooAbsArg& arg) const {
return _clientListShape.findArg(&arg)?kTRUE:kFALSE ;
}
inline Bool_t isShapeServer(const char* name) const {
return _clientListShape.FindObject(name)?kTRUE:kFALSE ;
}
void leafNodeServerList(RooAbsCollection* list, const RooAbsArg* arg=0, Bool_t recurseNonDerived=kFALSE) const ;
void branchNodeServerList(RooAbsCollection* list, const RooAbsArg* arg=0, Bool_t recurseNonDerived=kFALSE) const ;
void treeNodeServerList(RooAbsCollection* list, const RooAbsArg* arg=0,
Bool_t doBranch=kTRUE, Bool_t doLeaf=kTRUE,
Bool_t valueOnly=kFALSE, Bool_t recurseNonDerived=kFALSE) const ;
inline virtual Bool_t isFundamental() const {
return kFALSE;
}
virtual RooAbsArg *createFundamental(const char* newname=0) const = 0;
inline virtual Bool_t isLValue() const {
return kFALSE;
}
void addParameters(RooArgSet& params, const RooArgSet* nset=0, Bool_t stripDisconnected=kTRUE) const ;
friend class RooProdPdf ;
friend class RooAddPdf ;
friend class RooAddPdfOrig ;
RooArgSet* getVariables(Bool_t stripDisconnected=kTRUE) const ;
RooArgSet* getParameters(const RooAbsData* data, Bool_t stripDisconnected=kTRUE) const ;
RooArgSet* getParameters(const RooAbsData& data, Bool_t stripDisconnected=kTRUE) const {
return getParameters(&data,stripDisconnected) ;
}
RooArgSet* getParameters(const RooArgSet& set, Bool_t stripDisconnected=kTRUE) const {
return getParameters(&set,stripDisconnected) ;
}
virtual RooArgSet* getParameters(const RooArgSet* depList, Bool_t stripDisconnected=kTRUE) const ;
RooArgSet* getObservables(const RooArgSet& set, Bool_t valueOnly=kTRUE) const {
return getObservables(&set,valueOnly) ;
}
RooArgSet* getObservables(const RooAbsData* data) const ;
RooArgSet* getObservables(const RooAbsData& data) const {
return getObservables(&data) ;
}
RooArgSet* getObservables(const RooArgSet* depList, Bool_t valueOnly=kTRUE) const ;
Bool_t observableOverlaps(const RooAbsData* dset, const RooAbsArg& testArg) const ;
Bool_t observableOverlaps(const RooArgSet* depList, const RooAbsArg& testArg) const ;
virtual Bool_t checkObservables(const RooArgSet* nset) const ;
Bool_t recursiveCheckObservables(const RooArgSet* nset) const ;
RooArgSet* getComponents() const ;
inline RooArgSet* getDependents(const RooArgSet& set) const { return getObservables(set) ; }
inline RooArgSet* getDependents(const RooAbsData* set) const { return getObservables(set) ; }
inline RooArgSet* getDependents(const RooArgSet* depList) const { return getObservables(depList) ; }
inline Bool_t dependentOverlaps(const RooAbsData* dset, const RooAbsArg& testArg) const { return observableOverlaps(dset,testArg) ; }
inline Bool_t dependentOverlaps(const RooArgSet* depList, const RooAbsArg& testArg) const { return observableOverlaps(depList, testArg) ; }
inline Bool_t checkDependents(const RooArgSet* nset) const { return checkObservables(nset) ; }
inline Bool_t recursiveCheckDependents(const RooArgSet* nset) const { return recursiveCheckObservables(nset) ; }
void attachDataSet(const RooAbsData &set);
void attachDataStore(const RooAbsDataStore &set);
virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) = 0 ;
virtual void writeToStream(std::ostream& os, Bool_t compact) const = 0 ;
inline virtual void Print(Option_t *options= 0) const {
printStream(defaultPrintStream(),defaultPrintContents(options),defaultPrintStyle(options));
}
virtual void printName(std::ostream& os) const ;
virtual void printTitle(std::ostream& os) const ;
virtual void printClassName(std::ostream& os) const ;
virtual void printAddress(std::ostream& os) const ;
virtual void printArgs(std::ostream& os) const ;
virtual void printMetaArgs(std::ostream& ) const {} ;
virtual void printMultiline(std::ostream& os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const;
virtual void printTree(std::ostream& os, TString indent="") const ;
virtual Int_t defaultPrintContents(Option_t* opt) const ;
void setAttribute(const Text_t* name, Bool_t value=kTRUE) ;
Bool_t getAttribute(const Text_t* name) const ;
inline const std::set<std::string>& attributes() const {
return _boolAttrib ;
}
void setStringAttribute(const Text_t* key, const Text_t* value) ;
const Text_t* getStringAttribute(const Text_t* key) const ;
inline const std::map<std::string,std::string>& stringAttributes() const {
return _stringAttrib ;
}
void setTransientAttribute(const Text_t* name, Bool_t value=kTRUE) ;
Bool_t getTransientAttribute(const Text_t* name) const ;
inline const std::set<std::string>& transientAttributes() const {
return _boolAttribTransient ;
}
inline Bool_t isConstant() const {
return _isConstant ;
}
RooLinkedList getCloningAncestors() const ;
Int_t Compare(const TObject* other) const ;
virtual Bool_t IsSortable() const {
return kTRUE ;
}
static void verboseDirty(Bool_t flag) ;
void printDirty(Bool_t depth=kTRUE) const ;
static void setDirtyInhibit(Bool_t flag) ;
virtual Bool_t operator==(const RooAbsArg& other) = 0 ;
virtual Bool_t isIdentical(const RooAbsArg& other, Bool_t assumeSameType=kFALSE) = 0 ;
virtual Bool_t inRange(const char*) const {
return kTRUE ;
}
virtual Bool_t hasRange(const char*) const {
return kFALSE ;
}
enum ConstOpCode { Activate=0, DeActivate=1, ConfigChange=2, ValueChange=3 } ;
friend class RooMinuit ;
virtual void optimizeCacheMode(const RooArgSet& observables) ;
virtual void optimizeCacheMode(const RooArgSet& observables, RooArgSet& optNodes, RooLinkedList& processedNodes) ;
Bool_t findConstantNodes(const RooArgSet& observables, RooArgSet& cacheList) ;
Bool_t findConstantNodes(const RooArgSet& observables, RooArgSet& cacheList, RooLinkedList& processedNodes) ;
virtual void constOptimizeTestStatistic(ConstOpCode opcode, Bool_t doAlsoTrackingOpt=kTRUE) ;
enum CacheMode { Always=0, NotAdvised=1, Never=2 } ;
virtual CacheMode canNodeBeCached() const { return Always ; }
virtual void setCacheAndTrackHints(RooArgSet& ) {} ;
void graphVizTree(const char* fileName, const char* delimiter="\n", bool useTitle=false, bool useLatex=false) ;
void graphVizTree(std::ostream& os, const char* delimiter="\n", bool useTitle=false, bool useLatex=false) ;
void printComponentTree(const char* indent="",const char* namePat=0, Int_t nLevel=999) ;
void printCompactTree(const char* indent="",const char* fileName=0, const char* namePat=0, RooAbsArg* client=0) ;
void printCompactTree(std::ostream& os, const char* indent="", const char* namePat=0, RooAbsArg* client=0) ;
virtual void printCompactTreeHook(std::ostream& os, const char *ind="") ;
inline Bool_t isShapeDirty() const {
return isDerived()?_shapeDirty:kFALSE ;
}
inline Bool_t isValueDirty() const {
if (inhibitDirty()) return kTRUE ;
switch(_operMode) {
case AClean:
return kFALSE ;
case ADirty:
return kTRUE ;
case Auto:
if (_valueDirty) return isDerived() ;
return kFALSE ;
}
return kTRUE ;
}
inline Bool_t isValueDirtyAndClear() const {
if (inhibitDirty()) return kTRUE ;
switch(_operMode) {
case AClean:
return kFALSE ;
case ADirty:
return kTRUE ;
case Auto:
if (_valueDirty) {
_valueDirty = kFALSE ;
return isDerived();
}
return kFALSE ;
}
return kTRUE ;
}
inline Bool_t isValueOrShapeDirtyAndClear() const {
if (inhibitDirty()) return kTRUE ;
switch(_operMode) {
case AClean:
return kFALSE ;
case ADirty:
return kTRUE ;
case Auto:
if (_valueDirty || _shapeDirty) {
_shapeDirty = kFALSE ;
_valueDirty = kFALSE ;
return isDerived();
}
_shapeDirty = kFALSE ;
_valueDirty = kFALSE ;
return kFALSE ;
}
return kTRUE ;
}
void registerCache(RooAbsCache& cache) ;
void unRegisterCache(RooAbsCache& cache) ;
Int_t numCaches() const ;
RooAbsCache* getCache(Int_t index) const ;
enum OperMode { Auto=0, AClean=1, ADirty=2 } ;
inline OperMode operMode() const { return _operMode ; }
void setOperMode(OperMode mode, Bool_t recurseADirty=kTRUE) ;
static UInt_t crc32(const char* data);
static UInt_t crc32(const char* data, ULong_t sz, UInt_t crc = 0);
static const UInt_t fnv1a32start = 2166136261u;
static UInt_t fnv1a32(const char* data);
static UInt_t fnv1a32(const char* data, ULong_t sz, UInt_t hash = fnv1a32start);
static const ULong64_t fnv1a64start = (ULong64_t(3421674724u) << 32) | ULong64_t(2216829733u);
static ULong64_t fnv1a64(const char* data);
static ULong64_t fnv1a64(const char* data, ULong_t sz, ULong64_t hash = fnv1a64start);
Bool_t addOwnedComponents(const RooArgSet& comps) ;
const RooArgSet* ownedComponents() const { return _ownedComponents ; }
void setProhibitServerRedirect(Bool_t flag) { _prohibitServerRedirect = flag ; }
protected:
void graphVizAddConnections(std::set<std::pair<RooAbsArg*,RooAbsArg*> >&) ;
friend class RooExtendPdf ;
friend class RooRealIntegral ;
friend class RooAbsReal ;
friend class RooProjectedPdf ;
virtual void operModeHook() {} ;
virtual void optimizeDirtyHook(const RooArgSet* ) {} ;
virtual Bool_t isValid() const ;
virtual void getParametersHook(const RooArgSet* , RooArgSet* , Bool_t ) const {} ;
virtual void getObservablesHook(const RooArgSet* , RooArgSet* ) const {} ;
public:
inline void setValueDirty() const { if (_operMode==Auto && !inhibitDirty()) setValueDirty(0) ; }
inline void setShapeDirty() const { setShapeDirty(0) ; }
inline void clearValueAndShapeDirty() const {
_valueDirty=kFALSE ;
_shapeDirty=kFALSE ;
}
inline void clearValueDirty() const {
_valueDirty=kFALSE ;
}
inline void clearShapeDirty() const {
_shapeDirty=kFALSE ;
}
const char* aggregateCacheUniqueSuffix() const ;
virtual const char* cacheUniqueSuffix() const { return 0 ; }
void wireAllCaches() ;
inline const TNamed* namePtr() const {
return _namePtr ;
}
void SetName(const char* name) ;
void SetNameTitle(const char *name, const char *title) ;
protected:
friend class RooArgSet ;
friend class RooAbsCollection ;
friend class RooCustomizer ;
friend class RooWorkspace ;
RooRefCountList _serverList ;
RooRefCountList _clientList ;
RooRefCountList _clientListShape ;
RooRefCountList _clientListValue ;
RooRefArray _proxyList ;
std::deque<RooAbsCache*> _cacheList ;
TIterator* _clientShapeIter ;
TIterator* _clientValueIter ;
public:
Bool_t redirectServers(const RooAbsCollection& newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t isRecursionStep=kFALSE) ;
Bool_t recursiveRedirectServers(const RooAbsCollection& newServerList, Bool_t mustReplaceAll=kFALSE, Bool_t nameChange=kFALSE, Bool_t recurseInNewSet=kTRUE) ;
virtual Bool_t redirectServersHook(const RooAbsCollection& , Bool_t , Bool_t , Bool_t ) { return kFALSE ; } ;
virtual void serverNameChangeHook(const RooAbsArg* , const RooAbsArg* ) { } ;
void addServer(RooAbsArg& server, Bool_t valueProp=kTRUE, Bool_t shapeProp=kFALSE) ;
void addServerList(RooAbsCollection& serverList, Bool_t valueProp=kTRUE, Bool_t shapeProp=kFALSE) ;
void replaceServer(RooAbsArg& oldServer, RooAbsArg& newServer, Bool_t valueProp, Bool_t shapeProp) ;
void changeServer(RooAbsArg& server, Bool_t valueProp, Bool_t shapeProp) ;
void removeServer(RooAbsArg& server, Bool_t force=kFALSE) ;
RooAbsArg *findNewServer(const RooAbsCollection &newSet, Bool_t nameChange) const;
RooExpensiveObjectCache& expensiveObjectCache() const ;
virtual void setExpensiveObjectCache(RooExpensiveObjectCache& cache) { _eocache = &cache ; }
virtual Bool_t importWorkspaceHook(RooWorkspace&) { return kFALSE ; } ;
protected:
friend class RooAddModel ;
friend class RooArgProxy ;
friend class RooSetProxy ;
friend class RooListProxy ;
friend class RooObjectFactory ;
friend class RooHistPdf ;
friend class RooHistFunc ;
friend class RooHistFunc2 ;
void registerProxy(RooArgProxy& proxy) ;
void registerProxy(RooSetProxy& proxy) ;
void registerProxy(RooListProxy& proxy) ;
void unRegisterProxy(RooArgProxy& proxy) ;
void unRegisterProxy(RooSetProxy& proxy) ;
void unRegisterProxy(RooListProxy& proxy) ;
RooAbsProxy* getProxy(Int_t index) const ;
void setProxyNormSet(const RooArgSet* nset) ;
Int_t numProxies() const ;
std::set<std::string> _boolAttrib ;
std::map<std::string,std::string> _stringAttrib ;
std::set<std::string> _boolAttribTransient ;
void printAttribList(std::ostream& os) const;
friend class RooCompositeDataStore ;
friend class RooTreeDataStore ;
friend class RooVectorDataStore ;
friend class RooTreeData ;
friend class RooDataSet ;
friend class RooRealMPFE ;
virtual void syncCache(const RooArgSet* nset=0) = 0 ;
virtual void copyCache(const RooAbsArg* source, Bool_t valueOnly=kFALSE, Bool_t setValDirty=kTRUE) = 0 ;
virtual void attachToTree(TTree& t, Int_t bufSize=32000) = 0 ;
virtual void attachToVStore(RooVectorDataStore& vstore) = 0 ;
void attachToStore(RooAbsDataStore& store) ;
virtual void setTreeBranchStatus(TTree& t, Bool_t active) = 0 ;
virtual void fillTreeBranch(TTree& t) = 0 ;
TString cleanBranchName() const ;
friend std::ostream& operator<<(std::ostream& os, const RooAbsArg &arg);
friend std::istream& operator>>(std::istream& is, RooAbsArg &arg) ;
static Bool_t _verboseDirty ;
static Bool_t _inhibitDirty ;
Bool_t _deleteWatch ;
Bool_t inhibitDirty() const ;
public:
void setLocalNoDirtyInhibit(Bool_t flag) const { _localNoInhibitDirty = flag ; }
Bool_t localNoDirtyInhibit() const { return _localNoInhibitDirty ; }
protected:
void setValueDirty(const RooAbsArg* source) const ;
void setShapeDirty(const RooAbsArg* source) const ;
mutable Bool_t _valueDirty ;
mutable Bool_t _shapeDirty ;
friend class RooRealProxy ;
mutable OperMode _operMode ;
mutable Bool_t _fast ;
RooArgSet* _ownedComponents ;
mutable Bool_t _prohibitServerRedirect ;
mutable RooExpensiveObjectCache* _eocache ;
mutable TNamed* _namePtr ;
Bool_t _isConstant ;
mutable Bool_t _localNoInhibitDirty ;
public:
virtual void ioStreamerPass2() ;
static void ioStreamerPass2Finalize() ;
static std::map<RooAbsArg*,TRefArray*> _ioEvoList ;
static std::stack<RooAbsArg*> _ioReadStack ;
ClassDef(RooAbsArg,6)
};
std::ostream& operator<<(std::ostream& os, const RooAbsArg &arg);
std::istream& operator>>(std::istream& is, RooAbsArg &arg) ;
#endif