File indexing completed on 2025-01-18 10:11:27
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROO_STRING_VAR
0017 #define ROO_STRING_VAR
0018
0019 #include "RooAbsArg.h"
0020
0021 #include <string>
0022
0023 class RooStringVar final : public RooAbsArg {
0024 public:
0025
0026 RooStringVar() { }
0027 RooStringVar(const char *name, const char *title, const char* value, Int_t size=1024) ;
0028 RooStringVar(const RooStringVar& other, const char* name=nullptr);
0029 TObject* clone(const char* newname) const override { return new RooStringVar(*this,newname); }
0030
0031
0032 virtual operator TString() {return TString(_string.c_str()); }
0033 const char* getVal() const { clearValueDirty(); return _string.c_str(); }
0034 void setVal(const char* newVal) { _string = newVal ? newVal : ""; setValueDirty(); }
0035 virtual RooAbsArg& operator=(const char* newVal) { setVal(newVal); return *this; }
0036
0037
0038 bool isFundamental() const override { return true; }
0039
0040
0041 bool readFromStream(std::istream& is, bool compact, bool verbose) override;
0042 void writeToStream(std::ostream& os, bool ) const override { os << _string; }
0043
0044
0045 bool operator==(const char* val) const { return _string == val; }
0046 bool operator==(const RooAbsArg& other) const override {
0047 auto otherStr = dynamic_cast<const RooStringVar*>(&other);
0048 return otherStr && _string == otherStr->_string;
0049 }
0050 bool isIdentical(const RooAbsArg& other, bool ) const override { return *this == other; }
0051
0052
0053 void printValue(std::ostream& os) const override { os << _string; }
0054
0055
0056 RooFit::OwningPtr<RooAbsArg> createFundamental(const char *newname = nullptr) const override
0057 {
0058 return RooFit::makeOwningPtr<RooAbsArg>(
0059 std::make_unique<RooStringVar>(newname ? newname : GetName(), GetTitle(), "", 1));
0060 }
0061
0062 protected:
0063
0064 bool isValid() const override { return true; }
0065 virtual bool isValidString(const char*, bool ) const { return true; }
0066
0067 void syncCache(const RooArgSet* = nullptr) override { }
0068 void copyCache(const RooAbsArg* source, bool valueOnly=false, bool setValDiry=true) override;
0069 void attachToTree(TTree& t, Int_t bufSize=32000) override;
0070 void attachToVStore(RooVectorDataStore&) override { }
0071 void fillTreeBranch(TTree& t) override;
0072 void setTreeBranchStatus(TTree& t, bool active) override;
0073
0074 private:
0075 std::string _string;
0076 std::string* _stringAddr;
0077 ClassDefOverride(RooStringVar,2)
0078 };
0079
0080 #endif