94using std::endl, std::istream, std::ostream;
141 _ranges(
other._ranges)
167 coutE(InputArguments) <<
"RooCategory: Trying to set invalid state " <<
index <<
" for category " <<
GetName() << std::endl;
195 coutE(InputArguments) <<
"Trying to set invalid state label '" << label <<
"' for category " <<
GetName() << std::endl;
210 if (label.find(
';') != std::string::npos) {
211 coutE(InputArguments) <<
"RooCategory::defineType(" <<
GetName()
212 <<
"): semicolons not allowed in label name" << std::endl ;
226 if (label.find(
';') != std::string::npos) {
227 coutE(InputArguments) <<
"RooCategory::defineType(" <<
GetName()
228 <<
"): semicolons not allowed in label name" << std::endl ;
322 std::map<std::string, std::vector<value_type>>::iterator item =
_ranges->find(
name);
325 coutE(InputArguments) <<
"RooCategory::clearRange(" <<
GetName() <<
") ERROR: must specify valid range name" << std::endl ;
351 coutE(Contents) <<
"RooCategory::addToRange(" <<
GetName()
352 <<
"): Need valid range name." << std::endl;
356 item =
_ranges->emplace(
name, std::vector<value_type>()).first;
357 coutI(Contents) <<
"RooCategory::setRange(" <<
GetName()
358 <<
") new range named '" <<
name <<
"' created for state " <<
stateIndex << std::endl ;
374 coutE(InputArguments) <<
"RooCategory::setRange(" <<
GetName() <<
") ERROR: must specify valid name and state name list" << std::endl ;
384 coutW(InputArguments) <<
"RooCategory::setRange(" <<
GetName() <<
") WARNING: Ignoring invalid state name '"
385 <<
token <<
"' in state name list" << std::endl ;
396 if (rangeName ==
nullptr ||
_ranges->empty())
399 const auto item =
_ranges->find(rangeName);
403 const std::vector<value_type>&
vec = item->second;
421 coutE(InputArguments) <<
"RooCategory::isStateInRange(" <<
GetName() <<
") ERROR: must specify valid state name" << std::endl ;
435 if (
R__b.IsReading()) {
448 }
else if (
R__v == 2) {
452 auto props = std::make_unique<RooCategorySharedProperties>();
490 _ranges = std::make_unique<std::map<std::string, std::vector<value_type>>>();
521 if (
a.size() !=
b.size())
524 for (
const auto&
itemA :
a) {
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
const_iterator end() const
void setShapeDirty()
Notify that a shape-like property (e.g. binning) has changed.
friend void RooRefArray::Streamer(TBuffer &)
void setValueDirty()
Mark the element dirty. This forces a re-evaluation when a value is requested.
Abstract base class for objects that represent a discrete value that can be set from the outside,...
virtual const char * getCurrentLabel() const
Return label string of current state.
value_type _currentIndex
Current category state.
value_type nextAvailableStateIndex() const
static const decltype(_stateNames) ::value_type & invalidCategory()
A category state to signify an invalid category.
std::map< std::string, value_type >::const_iterator end() const
Iterator for category state names. Points to pairs of index and name.
virtual const std::map< std::string, RooAbsCategory::value_type >::value_type & defineState(const std::string &label)
Define a new state with given label.
std::vector< std::string > _insertionOrder
Keeps track in which order state numbers have been inserted. Make sure this is updated in recomputeSh...
const std::map< std::string, value_type > & stateNames() const
Access the map of state names to index numbers.
bool hasIndex(value_type index) const
Check if a state with index index exists.
value_type lookupIndex(const std::string &stateName) const
Find the index number corresponding to the state name.
Object to represent discrete states.
RangeMap_t * _rangesPointerForIO
Pointer to the same object as _ranges, but not shared for I/O.
void addToRange(const char *rangeName, RooAbsCategory::value_type stateIndex)
Add the given state to the given range.
bool setIndex(Int_t index, bool printError=true) override
Set value by specifying the index code of the desired state.
void setRange(const char *rangeName, const char *stateNameList)
void defineTypes(const std::map< std::string, int > &allowedStates)
Define multiple states in a single call.
void writeToStream(std::ostream &os, bool compact) const override
compact only at the moment
static std::map< std::string, std::weak_ptr< RangeMap_t > > _sharedRangeIOHelper
Helper for restoring shared ranges from current versions of this class read from files....
TClass * IsA() const override
void installSharedRange(std::unique_ptr< RangeMap_t > &&rangeMap)
In current versions of the class, a map with ranges can be shared between instances.
bool defineType(const std::string &label)
Define a state with given name.
void clearRange(const char *name, bool silent)
Clear the named range.
std::shared_ptr< RangeMap_t > _ranges
Map range names to allowed category states.
static std::map< RooSharedProperties::UUID, std::weak_ptr< RangeMap_t > > _uuidToSharedRangeIOHelper
Helper for restoring shared ranges from old versions of this class read from files....
value_type & operator[](const std::string &stateName)
Access a named state.
bool readFromStream(std::istream &is, bool compact, bool verbose=false) override
Read object contents from given stream.
bool setLabel(const char *label, bool printError=true) override
Set value by specifying the name of the desired state.
std::map< std::string, RooAbsCategory::value_type > & states()
Return a reference to the map of state names to index states.
bool isStateInRange(const char *rangeName, RooAbsCategory::value_type stateIndex) const
Check if the state is in the given range.
value_type getCurrentIndex() const final
Return current index.
std::map< std::string, std::vector< value_type > > RangeMap_t
void installLegacySharedProp(const RooCategorySharedProperties *sp)
When reading old versions of the class, we get instances of shared properties.
~RooCategory() override
Destructor.
TString readToken()
Read one token separated by any of the know punctuation characters This function recognizes and handl...
Buffer base class used for serializing objects.
const char * GetName() const override
Returns name of object.
std::vector< std::string > Split(std::string_view str, std::string_view delims, bool skipEmpty=false)
Splits a string at each character in delims.