46 ClassImp(RooAbsCategoryLValue);
53 RooAbsCategoryLValue::RooAbsCategoryLValue(
const char *name,
const char *title) :
54 RooAbsCategory(name,title)
65 RooAbsCategoryLValue::RooAbsCategoryLValue(
const RooAbsCategoryLValue& other,
const char* name) :
66 RooAbsCategory(other, name), RooAbsLValue(other)
75 RooAbsCategoryLValue::~RooAbsCategoryLValue()
84 RooAbsArg& RooAbsCategoryLValue::operator=(Int_t index)
86 setIndex(index,kTRUE) ;
95 RooAbsArg& RooAbsCategoryLValue::operator=(
const char *label)
106 RooAbsArg& RooAbsCategoryLValue::operator=(
const RooAbsCategory& other)
108 if (&other==
this)
return *this ;
110 const RooCatType* type = lookupType(other.getLabel(),kTRUE) ;
111 if (!type)
return *this ;
124 Bool_t RooAbsCategoryLValue::setOrdinal(UInt_t n,
const char* rangeName)
126 const RooCatType *newValue= getOrdinal(n,rangeName);
128 return setIndex(newValue->getVal());
143 void RooAbsCategoryLValue::copyCache(
const RooAbsArg* source, Bool_t valueOnly, Bool_t setValDirty)
145 RooAbsCategory::copyCache(source,valueOnly,setValDirty) ;
146 if (isValid(_value)) {
147 setIndex(_value.getVal()) ;
156 Bool_t RooAbsCategoryLValue::readFromStream(istream&, Bool_t, Bool_t)
166 void RooAbsCategoryLValue::writeToStream(ostream&, Bool_t)
const
175 void RooAbsCategoryLValue::randomize(
const char* rangeName)
177 UInt_t ordinal= RooRandom::integer(numTypes(rangeName));
178 setOrdinal(ordinal,rangeName);
186 void RooAbsCategoryLValue::setBin(Int_t ibin,
const char* rangeName)
189 if (ibin<0 || ibin>=numBins(rangeName)) {
190 coutE(InputArguments) <<
"RooAbsCategoryLValue::setBin(" << GetName() <<
") ERROR: bin index " << ibin
191 <<
" is out of range (0," << numBins(rangeName)-1 <<
")" << endl ;
196 const RooCatType* type = getOrdinal(ibin,rangeName) ;
199 setIndex(type->getVal()) ;
207 Int_t RooAbsCategoryLValue::getBin(
const char* )
const
213 std::string theName = _value.GetName();
214 auto item = std::find_if(_types.begin(), _types.end(), [&theName](
const RooCatType* cat){
215 return cat->GetName() == theName;
218 return item - _types.begin();
226 Int_t RooAbsCategoryLValue::numBins(
const char* rangeName)
const
228 return numTypes(rangeName) ;