57 mutable std::map<Int_t, RooAbsCategory::value_type>
_map;
65 for (
const auto& inCat : *parent.
_inputCat) {
66 const std::string& inKey = inCat.first;
69 for (
const auto& strAndEntry : parent.
_mapArray) {
70 if (strAndEntry.second.match(inKey.c_str())) {
72 _map[inCat.second] = strAndEntry.second.outCat();
98 RooAbsCategory(other,
name), _inputCat(
"input",this,other._inputCat), _mapArray(other._mapArray),
122 if (!inKeyRegExp || !outKey)
return kTRUE ;
126 coutE(InputArguments) <<
"RooMappedCategory::map(" <<
GetName() <<
"): ERROR expression "
127 << inKeyRegExp <<
" already mapped" << std::endl ;
142 coutE(InputArguments) <<
"RooMappedCategory::map(" <<
GetName()
143 <<
"): ERROR, unable to define category for output type " << outKey << std::endl ;
148 Entry e(inKeyRegExp, catIdx);
150 coutE(InputArguments) <<
"RooMappedCategory::map(" <<
GetName()
151 <<
"): ERROR, expression " << inKeyRegExp <<
" didn't compile" << std::endl ;
186 os <<
indent <<
"--- RooMappedCategory ---" << std::endl
187 <<
indent <<
" Maps from " ;
192 os <<
indent <<
" Mapping rules:" << std::endl;
193 for (
const auto& strAndEntry :
_mapArray) {
194 os <<
indent <<
" " << strAndEntry.first <<
" -> " << strAndEntry.second.outCat() << std::endl ;
204 coutE(InputArguments) <<
"RooMappedCategory::readFromSteam(" <<
GetName() <<
"): can't read in compact mode" << std::endl ;
216 TString token,errorPrefix(
"RooMappedCategory::readFromStream(") ;
227 if (readToken) token=parser.
readToken() ;
228 if (token.
IsNull()) break ;
240 if (
map(srcKey,destKey))
return kTRUE ;
267 if (iter.second.outCat() != prevOutCat) {
268 if (!
first) { os <<
" " ; }
271 os << iter.second.outCat() <<
":" << iter.first ;
272 prevOutCat = iter.second.outCat();
274 os <<
"," << iter.first ;
278 if (!
first) { os <<
" " ; }
300 if (iter.second.outCat() != prevOutCat) {
301 if (!
first) { os <<
" " ; }
304 os << iter.second.outCat() <<
"<-" << iter.first ;
305 prevOutCat = iter.second.outCat();
307 os <<
"," << iter.first ;
311 if (!
first) { os <<
" " ; }
329 _expr(exp), _regexp(nullptr), _catIdx(cat) {}
331 _expr(other._expr), _regexp(nullptr), _catIdx(other._catIdx) {}
339 if (&other==
this)
return *this ;
341 _expr = other.
_expr ;
353 return (
TString(testPattern).Index(*regexp())>=0);
362 const char *
c = exp ;
373 _regexp =
new TRegexp(mangle(_expr),
true);
static void indent(ostringstream &buf, int indent_level)
RooAbsArg is the common abstract base class for objects that represent a value and a "shape" in RooFi...
RooAbsCache is the abstract base class for data members of RooAbsArgs that cache other (composite) Ro...
RooAbsCategory is the base class for objects that represent a discrete value with a finite number of ...
virtual value_type getCurrentIndex() const
Return index number of current state.
virtual const char * getCurrentLabel() const
Return label string of current state.
const std::string & lookupName(value_type index) const
Get the name corresponding to the given index.
virtual const std::map< std::string, RooAbsCategory::value_type >::value_type & defineState(const std::string &label)
Define a new state with given label.
virtual void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const
Print info about this object to the specified stream.
static const decltype(_stateNames) ::value_type & invalidCategory()
Is this category attached to a tree?
value_type lookupIndex(const std::string &stateName) const
Find the index number corresponding to the state name.
void clearTypes()
Delete all currently defined states.
RooAbsCollection is an abstract container object that can hold multiple RooAbsArg objects.
RooAbsCategory::value_type lookup(Int_t idx) const
virtual Bool_t redirectServersHook(const RooAbsCollection &, Bool_t, Bool_t, Bool_t)
Interface for server redirect calls.
RooMappedCategoryCache(const RooAbsCache &, RooAbsArg *owner)
RooMappedCategoryCache(RooAbsArg *owner)
std::map< Int_t, RooAbsCategory::value_type > _map
Entry & operator=(const Entry &other)
const TRegexp * regexp() const
TString mangle(const char *exp) const
Mangle name : escape regexp character '+'.
RooAbsCategory::value_type _catIdx
Bool_t match(const char *testPattern) const
RooMappedCategory provides a category-to-category mapping defined by pattern matching on their state ...
virtual ~RooMappedCategory()
const RooMappedCategoryCache * getOrCreateCache() const
RooCategoryProxy _inputCat
virtual value_type evaluate() const
transient member: cache the mapping
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read object contents from stream (dummy for now)
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to ostream.
std::map< std::string, RooMappedCategory::Entry > _mapArray
friend class RooMappedCategoryCache
Bool_t map(const char *inKeyRegExp, const char *outKeyName, Int_t outKeyNum=NoCatIdx)
void printMetaArgs(std::ostream &os) const
Customized printing of arguments of a RooMappedCategory to more intuitively reflect the contents of t...
static constexpr value_type NoCatIdx
RooMappedCategoryCache * _mapcache
void recomputeShape()
When the input category changes states, the cached state mappings are invalidated.
void printMultiline(std::ostream &os, Int_t content, Bool_t verbose=kFALSE, TString indent="") const
Print info about this object to the specified stream.
virtual void printStream(std::ostream &os, Int_t contents, StyleOption style, TString indent="") const
Print description of object on ostream, printing contents set by contents integer,...
void setPunctuation(const TString &punct)
Change list of characters interpreted as punctuation.
Bool_t expectToken(const TString &expected, Bool_t zapOnError=kFALSE)
Read the next token and return kTRUE if it is identical to the given 'expected' token.
TString readToken()
Read one token separated by any of the know punctuation characters This function recognizes and handl...
const T & arg() const
Return reference to object held in proxy.
virtual const char * GetName() const
Returns name of object.
Regular expression class.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
const char * Data() const
TString & Append(const char *cs)