17 #ifndef ROO_FACTORY_WS_TOOL
18 #define ROO_FACTORY_WS_TOOL
28 class RooAbsRealLValue ;
35 class RooSimultaneous ;
39 class RooFactoryWSToolSpec ;
40 class RooAbsCategoryLValue ;
41 class RooAbsCategory ;
42 class RooResolutionModel ;
47 class RooFactoryWSTool :
public TNamed,
public RooPrintable {
52 RooFactoryWSTool(RooWorkspace& ws) ;
53 virtual ~RooFactoryWSTool() ;
58 RooRealVar* createVariable(
const char* name, Double_t xmin, Double_t xmax) ;
59 RooCategory* createCategory(
const char* name,
const char* stateNameList=0) ;
62 RooAbsArg* createArg(
const char* className,
const char* objName,
const char* varList) ;
65 RooAddPdf* add(
const char *objName,
const char* specList, Bool_t recursiveCoefs=kFALSE) ;
66 RooRealSumPdf* amplAdd(
const char *objName,
const char* specList) ;
67 RooProdPdf* prod(
const char *objName,
const char* pdfList) ;
68 RooSimultaneous* simul(
const char* objName,
const char* indexCat,
const char* pdfMap) ;
71 RooAddition* addfunc(
const char *objName,
const char* specList) ;
72 RooProduct* prodfunc(
const char *objName,
const char* pdfList) ;
74 RooWorkspace& ws() {
return *_ws ; }
79 RooAbsArg* process(
const char* expr) ;
80 std::string processExpression(
const char* expr) ;
81 std::vector<std::string> splitFunctionArgs(
const char* funcExpr) ;
87 static RooAbsArg& as_ARG(UInt_t idx) { checkIndex(idx) ;
return of()->of()->asARG(of()->_args[idx].c_str()) ; }
89 static RooAbsPdf& as_PDF(UInt_t idx) { checkIndex(idx) ;
return of()->asPDF(of()->_args[idx].c_str()) ; }
90 static RooAbsReal& as_FUNC(UInt_t idx) { checkIndex(idx) ;
return of()->asFUNC(of()->_args[idx].c_str()) ; }
91 static RooRealVar& as_VAR(UInt_t idx) { checkIndex(idx) ;
return of()->asVAR(of()->_args[idx].c_str()) ; }
92 static RooAbsRealLValue& as_VARLV(UInt_t idx) { checkIndex(idx) ;
return of()->asVARLV(of()->_args[idx].c_str()) ; }
93 static RooResolutionModel& as_RMODEL(UInt_t idx) { checkIndex(idx) ;
return of()->asRMODEL(of()->_args[idx].c_str()) ; }
95 static RooCategory& as_CAT(UInt_t idx) { checkIndex(idx) ;
return of()->asCAT(of()->_args[idx].c_str()) ; }
96 static RooAbsCategoryLValue& as_CATLV(UInt_t idx) { checkIndex(idx) ;
return of()->asCATLV(of()->_args[idx].c_str()) ; }
97 static RooAbsCategory& as_CATFUNC(UInt_t idx) { checkIndex(idx) ;
return of()->asCATFUNC(of()->_args[idx].c_str()) ; }
99 static RooArgSet as_SET(UInt_t idx) { checkIndex(idx) ;
return of()->asSET(of()->_args[idx].c_str()) ; }
100 static RooArgList as_LIST(UInt_t idx) { checkIndex(idx) ;
return of()->asLIST(of()->_args[idx].c_str()) ; }
102 static RooAbsData& as_DATA(UInt_t idx) { checkIndex(idx) ;
return of()->asDATA(of()->_args[idx].c_str()) ; }
103 static RooDataHist& as_DHIST(UInt_t idx) { checkIndex(idx) ;
return of()->asDHIST(of()->_args[idx].c_str()) ; }
104 static RooDataSet& as_DSET(UInt_t idx) { checkIndex(idx) ;
return of()->asDSET(of()->_args[idx].c_str()) ; }
106 static TObject& as_OBJ(UInt_t idx) { checkIndex(idx) ;
return of()->asOBJ(of()->_args[idx].c_str()) ; }
108 static const char* as_STRING(UInt_t idx) { checkIndex(idx) ;
return of()->asSTRING(of()->_args[idx].c_str()) ; }
109 static Int_t as_INT(UInt_t idx) { checkIndex(idx) ;
return of()->asINT(of()->_args[idx].c_str()) ; }
110 static Double_t as_DOUBLE(UInt_t idx) { checkIndex(idx) ;
return of()->asDOUBLE(of()->_args[idx].c_str()) ; }
111 static Int_t as_INT(UInt_t idx, Int_t defVal) { checkIndex(idx) ;
if (idx>of()->_args.size()-1)
return defVal ;
return of()->asINT(of()->_args[idx].c_str()) ; }
112 static Double_t as_DOUBLE(UInt_t idx, Double_t defVal) { checkIndex(idx) ;
if (idx>of()->_args.size()-1)
return defVal ;
return of()->asDOUBLE(of()->_args[idx].c_str()) ; }
114 RooAbsArg& asARG(
const char*) ;
116 RooAbsPdf& asPDF(
const char*) ;
117 RooAbsReal& asFUNC(
const char*) ;
118 RooRealVar& asVAR(
const char*) ;
119 RooAbsRealLValue& asVARLV(
const char*) ;
120 RooResolutionModel& asRMODEL(
const char*) ;
122 RooCategory& asCAT(
const char*) ;
123 RooAbsCategoryLValue& asCATLV(
const char*) ;
124 RooAbsCategory& asCATFUNC(
const char*) ;
126 RooArgSet asSET(
const char*) ;
127 RooArgList asLIST(
const char*) ;
129 RooAbsData& asDATA(
const char*) ;
130 RooDataHist& asDHIST(
const char*) ;
131 RooDataSet& asDSET(
const char*) ;
133 TObject& asOBJ(
const char*) ;
135 const char* asSTRING(
const char*) ;
136 Int_t asINT(
const char*) ;
137 Double_t asDOUBLE(
const char*) ;
141 virtual ~IFace() {} ;
142 virtual std::string create(RooFactoryWSTool& ft,
const char* typeName,
const char* instanceName, std::vector<std::string> args) = 0 ;
145 class SpecialsIFace :
public IFace {
147 virtual ~SpecialsIFace() {} ;
148 std::string create(RooFactoryWSTool& ft,
const char* typeName,
const char* instanceName, std::vector<std::string> args) ;
151 static void registerSpecial(
const char* typeName, RooFactoryWSTool::IFace* iface) ;
153 void logError() { _errorCount++ ; }
155 const char* autoClassNamePostFix()
const {
return _autoClassPostFix.c_str() ; }
156 void setAutoClassNamePostFix(
const char* pfix) { _autoClassPostFix = pfix ; }
160 Bool_t checkSyntax(
const char* arg) ;
162 std::string varTag(std::string& func, std::vector<std::string>& args) ;
164 std::stack<std::string> _autoNamePrefix ;
165 std::map<std::string,std::string> _typeAliases ;
167 static void checkIndex(UInt_t index) ;
170 std::string processCompositeExpression(
const char* arg) ;
171 std::string processSingleExpression(
const char* arg) ;
172 std::string processListExpression(
const char* arg) ;
173 std::string processAliasExpression(
const char* arg) ;
175 std::string processCreateVar(std::string& func, std::vector<std::string>& args) ;
176 std::string processCreateArg(std::string& func, std::vector<std::string>& args) ;
177 std::string processMetaArg(std::string& func, std::vector<std::string>& args) ;
179 TClass* resolveClassName(
const char* className) ;
182 static RooFactoryWSTool* of() ;
183 static RooFactoryWSTool* _of ;
184 std::vector<std::string> _args ;
187 static std::map<std::string,IFace*>& hooks() ;
188 static std::map<std::string,IFace*>* _hooks ;
192 void clearError() { _errorCount = 0 ; }
193 Int_t errorCount() {
return _errorCount ; }
197 std::string _autoClassPostFix ;
199 RooFactoryWSTool(
const RooFactoryWSTool&) ;
201 ClassDef(RooFactoryWSTool,0)