File indexing completed on 2025-01-18 10:11:16
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016 #ifndef ROO_ABS_CATEGORY_LVALUE
0017 #define ROO_ABS_CATEGORY_LVALUE
0018
0019 #include <RooAbsCategory.h>
0020 #include <RooAbsLValue.h>
0021
0022 #include <list>
0023 #include <string>
0024 #include <utility> // for std::pair
0025
0026 class RooAbsCategoryLValue : public RooAbsCategory, public RooAbsLValue {
0027 public:
0028
0029 RooAbsCategoryLValue() {
0030
0031 }
0032 RooAbsCategoryLValue(const char *name, const char *title);
0033 RooAbsCategoryLValue(const RooAbsCategoryLValue& other, const char* name=nullptr) ;
0034
0035
0036
0037
0038
0039
0040
0041 virtual bool setIndex(value_type index, bool printError = true) = 0;
0042
0043
0044
0045
0046
0047
0048 bool setIndex(const std::pair<std::string,value_type>& nameIdxPair, bool printError = true) {
0049 return setIndex(nameIdxPair.second, printError);
0050 }
0051 bool setOrdinal(unsigned int index);
0052
0053
0054
0055
0056
0057
0058 virtual bool setLabel(const char* label, bool printError=true) = 0;
0059
0060 bool setLabel(const std::string& label, bool printError = true) {
0061 return setLabel(label.c_str(), printError);
0062 }
0063
0064
0065
0066
0067
0068
0069 bool setLabel(const std::pair<std::string,value_type>& nameIdxPair, bool printError = true) {
0070 return setLabel(nameIdxPair.first.c_str(), printError);
0071 }
0072
0073
0074 RooAbsArg& operator=(int index) ;
0075 RooAbsArg& operator=(const char* label) ;
0076 RooAbsArg& operator=(const RooAbsCategory& other) ;
0077
0078
0079 void setBin(Int_t ibin, const char* rangeName=nullptr) override ;
0080
0081 Int_t getBin(const char* =nullptr) const override {
0082 return getCurrentOrdinalNumber();
0083 }
0084 Int_t numBins(const char* rangeName=nullptr) const override ;
0085 double getBinWidth(Int_t , const char* =nullptr) const override {
0086
0087 return 1.0 ;
0088 }
0089 double volume(const char* rangeName) const override {
0090
0091 return numTypes(rangeName) ;
0092 }
0093 void randomize(const char* rangeName=nullptr) override;
0094
0095 const RooAbsBinning* getBinningPtr(const char* ) const override { return nullptr ; }
0096 std::list<std::string> getBinningNames() const override { return std::list<std::string>(1, "") ; }
0097 Int_t getBin(const RooAbsBinning* ) const override { return getBin((const char*)nullptr) ; }
0098
0099
0100 inline void setConstant(bool value= true) {
0101
0102 setAttribute("Constant",value);
0103 }
0104
0105 inline bool isLValue() const override {
0106
0107 return true;
0108 }
0109
0110 protected:
0111
0112 friend class RooSimGenContext ;
0113 friend class RooSimSplitGenContext ;
0114
0115
0116 virtual void setIndexFast(Int_t index) {
0117 _currentIndex = index;
0118 }
0119
0120
0121 void copyCache(const RooAbsArg* source, bool valueOnly=false, bool setValDirty=true) override ;
0122
0123 ClassDefOverride(RooAbsCategoryLValue,1)
0124 };
0125
0126 #endif