Warning, file /include/root/RooFactoryWSTool.h was not indexed
or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017 #ifndef ROO_FACTORY_WS_TOOL
0018 #define ROO_FACTORY_WS_TOOL
0019
0020 #include "RooArgSet.h"
0021 #include "RooArgList.h"
0022 #include <string>
0023 #include <vector>
0024 #include <stack>
0025 #include <map>
0026
0027 class RooAbsReal ;
0028 class RooAbsRealLValue ;
0029 class RooAbsPdf ;
0030 class RooWorkspace ;
0031 class RooRealVar ;
0032 class RooCategory ;
0033 class RooAddPdf ;
0034 class RooProdPdf ;
0035 class RooSimultaneous ;
0036 class RooDataHist ;
0037 class RooDataSet ;
0038 class RooAbsData ;
0039 class RooFactoryWSToolSpec ;
0040 class RooAbsCategoryLValue ;
0041 class RooAbsCategory ;
0042 class RooResolutionModel ;
0043 class RooAddition ;
0044 class RooProduct ;
0045 class RooRealSumPdf ;
0046
0047 class RooFactoryWSTool : public TNamed, public RooPrintable {
0048
0049 public:
0050
0051
0052 RooFactoryWSTool(RooWorkspace& ws) : _ws{&ws} {}
0053
0054 RooFactoryWSTool(const RooFactoryWSTool&) = delete;
0055
0056
0057
0058
0059 RooRealVar* createVariable(const char* name, double xmin, double xmax) ;
0060 RooCategory* createCategory(const char* name, const char* stateNameList=nullptr) ;
0061
0062
0063 RooAbsArg* createArg(const char* className, const char* objName, const char* varList) ;
0064
0065
0066 RooAddPdf* add(const char *objName, const char* specList, bool recursiveCoefs=false) ;
0067 RooRealSumPdf* amplAdd(const char *objName, const char* specList) ;
0068 RooProdPdf* prod(const char *objName, const char* pdfList) ;
0069 RooSimultaneous* simul(const char* objName, const char* indexCat, const char* pdfMap) ;
0070
0071
0072 RooAddition* addfunc(const char *objName, const char* specList) ;
0073 RooProduct* prodfunc(const char *objName, const char* pdfList) ;
0074
0075 RooWorkspace& ws() { return *_ws ; }
0076
0077
0078
0079
0080 RooAbsArg* process(const char* expr) ;
0081 std::string processExpression(const char* expr) ;
0082 std::vector<std::string> splitFunctionArgs(const char* funcExpr) ;
0083
0084
0085
0086
0087
0088 static RooAbsArg& as_ARG(UInt_t idx) { checkIndex(idx) ; return of()->of()->asARG(of()->_args[idx].c_str()) ; }
0089
0090 static RooAbsPdf& as_PDF(UInt_t idx) { checkIndex(idx) ; return of()->asPDF(of()->_args[idx].c_str()) ; }
0091 static RooAbsReal& as_FUNC(UInt_t idx) { checkIndex(idx) ; return of()->asFUNC(of()->_args[idx].c_str()) ; }
0092 static RooRealVar& as_VAR(UInt_t idx) { checkIndex(idx) ; return of()->asVAR(of()->_args[idx].c_str()) ; }
0093 static RooAbsRealLValue& as_VARLV(UInt_t idx) { checkIndex(idx) ; return of()->asVARLV(of()->_args[idx].c_str()) ; }
0094 static RooResolutionModel& as_RMODEL(UInt_t idx) { checkIndex(idx) ; return of()->asRMODEL(of()->_args[idx].c_str()) ; }
0095
0096 static RooCategory& as_CAT(UInt_t idx) { checkIndex(idx) ; return of()->asCAT(of()->_args[idx].c_str()) ; }
0097 static RooAbsCategoryLValue& as_CATLV(UInt_t idx) { checkIndex(idx) ; return of()->asCATLV(of()->_args[idx].c_str()) ; }
0098 static RooAbsCategory& as_CATFUNC(UInt_t idx) { checkIndex(idx) ; return of()->asCATFUNC(of()->_args[idx].c_str()) ; }
0099
0100 static RooArgSet as_SET(UInt_t idx) { checkIndex(idx) ; return of()->asSET(of()->_args[idx].c_str()) ; }
0101 static RooArgList as_LIST(UInt_t idx) { checkIndex(idx) ; return of()->asLIST(of()->_args[idx].c_str()) ; }
0102
0103 static RooAbsData& as_DATA(UInt_t idx) { checkIndex(idx) ; return of()->asDATA(of()->_args[idx].c_str()) ; }
0104 static RooDataHist& as_DHIST(UInt_t idx) { checkIndex(idx) ; return of()->asDHIST(of()->_args[idx].c_str()) ; }
0105 static RooDataSet& as_DSET(UInt_t idx) { checkIndex(idx) ; return of()->asDSET(of()->_args[idx].c_str()) ; }
0106
0107 static TObject& as_OBJ(UInt_t idx) { checkIndex(idx) ; return of()->asOBJ(of()->_args[idx].c_str()) ; }
0108
0109 static const char* as_STRING(UInt_t idx) { checkIndex(idx) ; return of()->asSTRING(of()->_args[idx].c_str()) ; }
0110 static Int_t as_INT(UInt_t idx) { checkIndex(idx) ; return of()->asINT(of()->_args[idx].c_str()) ; }
0111 static double as_DOUBLE(UInt_t idx) { checkIndex(idx) ; return of()->asDOUBLE(of()->_args[idx].c_str()) ; }
0112 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()) ; }
0113 static double as_DOUBLE(UInt_t idx, double defVal) { checkIndex(idx) ; if (idx>of()->_args.size()-1) return defVal ; return of()->asDOUBLE(of()->_args[idx].c_str()) ; }
0114
0115 RooAbsArg& asARG(const char*) ;
0116
0117 RooAbsPdf& asPDF(const char*) ;
0118 RooAbsReal& asFUNC(const char*) ;
0119 RooRealVar& asVAR(const char*) ;
0120 RooAbsRealLValue& asVARLV(const char*) ;
0121 RooResolutionModel& asRMODEL(const char*) ;
0122
0123 RooCategory& asCAT(const char*) ;
0124 RooAbsCategoryLValue& asCATLV(const char*) ;
0125 RooAbsCategory& asCATFUNC(const char*) ;
0126
0127 RooArgSet asSET(const char*) ;
0128 RooArgList asLIST(const char*) ;
0129
0130 RooAbsData& asDATA(const char*) ;
0131 RooDataHist& asDHIST(const char*) ;
0132 RooDataSet& asDSET(const char*) ;
0133
0134 TObject& asOBJ(const char*) ;
0135
0136 const char* asSTRING(const char*) ;
0137 Int_t asINT(const char*) ;
0138 double asDOUBLE(const char*) ;
0139
0140 class IFace {
0141 public:
0142 virtual ~IFace() {} ;
0143 virtual std::string create(RooFactoryWSTool& ft, const char* typeName, const char* instanceName, std::vector<std::string> args) = 0 ;
0144 } ;
0145
0146 class SpecialsIFace : public IFace {
0147 public:
0148 std::string create(RooFactoryWSTool& ft, const char* typeName, const char* instanceName, std::vector<std::string> args) override ;
0149 } ;
0150
0151 static void registerSpecial(const char* typeName, RooFactoryWSTool::IFace* iface) ;
0152
0153 void logError() { _errorCount++ ; }
0154
0155 const char* autoClassNamePostFix() const { return _autoClassPostFix.c_str() ; }
0156 void setAutoClassNamePostFix(const char* pfix) { _autoClassPostFix = pfix ; }
0157
0158 protected:
0159
0160 bool checkSyntax(const char* arg) ;
0161
0162 std::string varTag(std::string& func, std::vector<std::string>& args) ;
0163
0164 std::stack<std::string> _autoNamePrefix ;
0165 std::map<std::string,std::string> _typeAliases ;
0166
0167 static void checkIndex(UInt_t index) ;
0168
0169
0170 std::string processCompositeExpression(const char* arg) ;
0171 std::string processSingleExpression(const char* arg) ;
0172 std::string processListExpression(const char* arg) ;
0173 std::string processAliasExpression(const char* arg) ;
0174
0175 std::string processCreateVar(std::string& func, std::vector<std::string>& args) ;
0176 std::string processCreateArg(std::string& func, std::vector<std::string>& args) ;
0177 std::string processMetaArg(std::string& func, std::vector<std::string>& args) ;
0178
0179 TClass* resolveClassName(const char* className) ;
0180
0181
0182 static RooFactoryWSTool* of() ;
0183 static RooFactoryWSTool* _of ;
0184 std::vector<std::string> _args ;
0185
0186
0187 static std::map<std::string,IFace*>& hooks() ;
0188 static std::map<std::string,IFace*>* _hooks ;
0189
0190 RooWorkspace* _ws ;
0191
0192 void clearError() { _errorCount = 0 ; }
0193 Int_t errorCount() { return _errorCount ; }
0194
0195 Int_t _errorCount = 0;
0196
0197 std::string _autoClassPostFix;
0198
0199 ClassDefOverride(RooFactoryWSTool,0)
0200
0201 } ;
0202
0203
0204
0205 #endif