#ifndef ROO_WORKSPACE
#define ROO_WORKSPACE
#include "RooPrintable.h"
#include "RooArgSet.h"
#include "RooLinkedList.h"
#include "RooCmdArg.h"
#include "RooExpensiveObjectCache.h"
#include "TUUID.h"
#include <map>
#include <list>
#include <string>
class TClass ;
class RooAbsPdf ;
class RooAbsData ;
class RooRealVar ;
class RooCategory ;
class RooAbsReal ;
class RooAbsCategory ;
class RooFactoryWSTool ;
class RooAbsStudy ;
#include "TNamed.h"
#include "TDirectoryFile.h"
class RooWorkspace : public TNamed {
public:
RooWorkspace() ;
RooWorkspace(const char* name, Bool_t doCINTExport) ;
RooWorkspace(const char* name, const char* title=0) ;
RooWorkspace(const RooWorkspace& other) ;
~RooWorkspace() ;
void exportToCint(const char* namespaceName=0) ;
Bool_t importClassCode(const char* pat="*", Bool_t doReplace=kFALSE) ;
Bool_t importClassCode(TClass* theClass, Bool_t doReplace=kFALSE) ;
Bool_t import(const RooAbsArg& arg,
const RooCmdArg& arg1=RooCmdArg(),const RooCmdArg& arg2=RooCmdArg(),const RooCmdArg& arg3=RooCmdArg(),
const RooCmdArg& arg4=RooCmdArg(),const RooCmdArg& arg5=RooCmdArg(),const RooCmdArg& arg6=RooCmdArg(),
const RooCmdArg& arg7=RooCmdArg(),const RooCmdArg& arg8=RooCmdArg(),const RooCmdArg& arg9=RooCmdArg()) ;
Bool_t import(const RooArgSet& args,
const RooCmdArg& arg1=RooCmdArg(),const RooCmdArg& arg2=RooCmdArg(),const RooCmdArg& arg3=RooCmdArg(),
const RooCmdArg& arg4=RooCmdArg(),const RooCmdArg& arg5=RooCmdArg(),const RooCmdArg& arg6=RooCmdArg(),
const RooCmdArg& arg7=RooCmdArg(),const RooCmdArg& arg8=RooCmdArg(),const RooCmdArg& arg9=RooCmdArg()) ;
Bool_t import(RooAbsData& data,
const RooCmdArg& arg1=RooCmdArg(),const RooCmdArg& arg2=RooCmdArg(),const RooCmdArg& arg3=RooCmdArg(),
const RooCmdArg& arg4=RooCmdArg(),const RooCmdArg& arg5=RooCmdArg(),const RooCmdArg& arg6=RooCmdArg(),
const RooCmdArg& arg7=RooCmdArg(),const RooCmdArg& arg8=RooCmdArg(),const RooCmdArg& arg9=RooCmdArg()) ;
Bool_t import(const char *fileSpec,
const RooCmdArg& arg1=RooCmdArg(),const RooCmdArg& arg2=RooCmdArg(),const RooCmdArg& arg3=RooCmdArg(),
const RooCmdArg& arg4=RooCmdArg(),const RooCmdArg& arg5=RooCmdArg(),const RooCmdArg& arg6=RooCmdArg(),
const RooCmdArg& arg7=RooCmdArg(),const RooCmdArg& arg8=RooCmdArg(),const RooCmdArg& arg9=RooCmdArg()) ;
Bool_t import(TObject& object, Bool_t replaceExisting=kFALSE) ;
Bool_t import(TObject& object, const char* aliasName, Bool_t replaceExisting=kFALSE) ;
Bool_t startTransaction() ;
Bool_t cancelTransaction() ;
Bool_t commitTransaction() ;
Bool_t defineSet(const char* name, const RooArgSet& aset, Bool_t importMissing=kFALSE) ;
Bool_t defineSet(const char* name, const char* contentList) ;
Bool_t extendSet(const char* name, const char* newContents) ;
Bool_t renameSet(const char* name, const char* newName) ;
Bool_t removeSet(const char* name) ;
const RooArgSet* set(const char* name) ;
Bool_t saveSnapshot(const char* name, const char* paramNames) ;
Bool_t saveSnapshot(const char* name, const RooArgSet& params, Bool_t importValues=kFALSE) ;
Bool_t loadSnapshot(const char* name) ;
const RooArgSet* getSnapshot(const char* name) const ;
void merge(const RooWorkspace& ) {} ;
RooAbsPdf* pdf(const char* name) const ;
RooAbsReal* function(const char* name) const ;
RooRealVar* var(const char* name) const ;
RooCategory* cat(const char* name) const ;
RooAbsCategory* catfunc(const char* name) const ;
RooAbsData* data(const char* name) const ;
RooAbsData* embeddedData(const char* name) const ;
RooAbsArg* arg(const char* name) const ;
RooAbsArg* fundArg(const char* name) const ;
RooArgSet argSet(const char* nameList) const ;
TIterator* componentIterator() const { return _allOwnedNodes.createIterator() ; }
const RooArgSet& components() const { return _allOwnedNodes ; }
TObject* genobj(const char* name) const ;
TObject* obj(const char* name) const ;
RooArgSet allVars() const;
RooArgSet allCats() const ;
RooArgSet allFunctions() const ;
RooArgSet allCatFunctions() const ;
RooArgSet allPdfs() const ;
RooArgSet allResolutionModels() const ;
std::list<RooAbsData*> allData() const ;
std::list<RooAbsData*> allEmbeddedData() const ;
std::list<TObject*> allGenericObjects() const ;
Bool_t makeDir() ;
Bool_t cd(const char* path = 0) ;
Bool_t writeToFile(const char* fileName, Bool_t recreate=kTRUE) ;
RooFactoryWSTool& factory() ;
RooAbsArg* factory(const char* expr) ;
Bool_t addStudy(RooAbsStudy& study) ;
TIterator* studyIterator() { return _studyMods.MakeIterator() ; }
void clearStudies() ;
void Print(Option_t* opts=0) const ;
static void autoImportClassCode(Bool_t flag) ;
static void addClassDeclImportDir(const char* dir) ;
static void addClassImplImportDir(const char* dir) ;
static void setClassFileExportDir(const char* dir=0) ;
const TUUID& uuid() const { return _uuid ; }
RooExpensiveObjectCache& expensiveObjectCache() { return _eocache ; }
class CodeRepo : public TObject {
public:
CodeRepo(RooWorkspace* wspace=0) : _wspace(wspace), _compiledOK(kTRUE) {} ;
CodeRepo(const CodeRepo& other, RooWorkspace* wspace=0) : TObject(other) ,
_wspace(wspace?wspace:other._wspace),
_c2fmap(other._c2fmap),
_fmap(other._fmap),
_ehmap(other._ehmap),
_compiledOK(other._compiledOK) {} ;
virtual ~CodeRepo() {} ;
Bool_t autoImportClass(TClass* tc, Bool_t doReplace=kFALSE) ;
Bool_t compileClasses() ;
Bool_t compiledOK() const { return _compiledOK ; }
std::string listOfClassNames() const ;
class ClassRelInfo {
public:
TString _baseName;
TString _fileBase ;
} ;
class ClassFiles {
public:
ClassFiles() : _extracted(kFALSE) {}
TString _hext ;
TString _hfile ;
TString _cxxfile ;
Bool_t _extracted ;
} ;
class ExtraHeader {
public:
TString _hname ;
TString _hfile ;
} ;
protected:
RooWorkspace* _wspace ;
std::map<TString,ClassRelInfo> _c2fmap ;
std::map<TString,ClassFiles> _fmap ;
std::map<TString,ExtraHeader> _ehmap ;
Bool_t _compiledOK ;
ClassDef(CodeRepo,2) ;
} ;
class WSDir : public TDirectoryFile {
public:
WSDir(const char* name, const char* title, RooWorkspace* wspace) :
TDirectoryFile(name,title,"RooWorkspace::WSDir",0),
_wspace(wspace)
{
}
virtual ~WSDir() { Clear("nodelete") ; } ;
#if ROOT_VERSION_CODE <= 332546
virtual void Add(TObject*) ;
virtual void Append(TObject*) ;
#else
virtual void Add(TObject*,Bool_t) ;
virtual void Append(TObject*,Bool_t) ;
#endif
protected:
friend class RooWorkspace ;
void InternalAppend(TObject* obj) ;
RooWorkspace* _wspace ;
ClassDef(WSDir,1) ;
} ;
private:
Bool_t isValidCPPID(const char* name) ;
void exportObj(TObject* obj) ;
void unExport() ;
friend class CodeRepo ;
static std::list<std::string> _classDeclDirList ;
static std::list<std::string> _classImplDirList ;
static std::string _classFileExportDir ;
TUUID _uuid ;
static Bool_t _autoClass ;
CodeRepo _classes ;
RooArgSet _allOwnedNodes ;
RooLinkedList _dataList ;
RooLinkedList _embeddedDataList ;
RooLinkedList _views ;
RooLinkedList _snapshots ;
RooLinkedList _genObjects ;
RooLinkedList _studyMods ;
std::map<std::string,RooArgSet> _namedSets ;
WSDir* _dir ;
RooExpensiveObjectCache _eocache ;
RooFactoryWSTool* _factory ;
Bool_t _doExport ;
std::string _exportNSName ;
Bool_t _openTrans ;
RooArgSet _sandboxNodes ;
ClassDef(RooWorkspace,8)
} ;
#endif