48 RooAbsCache(other, owner)
62 mutable std::map<Int_t, const RooCatType*>
_map;
69 std::unique_ptr<TIterator> tit(static_cast<const RooAbsCategory&>(
71 for (
const RooCatType* inCat = static_cast<const RooCatType*>(tit->Next());
72 inCat; inCat =
static_cast<const RooCatType*
>(tit->Next())) {
73 const char* inKey = inCat->
GetName();
76 for (std::map<std::string, RooMappedCategory::Entry>::const_iterator
79 if (
iter->second.match(inKey)) {
81 _map[inCat->getVal()] = &(
iter->second.outCat());
85 if (!found) _map[inCat->getVal()] = parent.
_defCat;
91 RooAbsCategory(name, title), _inputCat(
"input",
"Input category",this,inputCat),
105 RooAbsCategory(other,name), _inputCat(
"input",this,other._inputCat), _mapArray(other._mapArray),
129 if (!inKeyRegExp || !outKey)
return kTRUE ;
134 << inKeyRegExp <<
" already mapped" << std::endl ;
149 <<
"): ERROR, unable to output type " << outKey << std::endl ;
154 Entry e(inKeyRegExp,outType) ;
157 <<
"): ERROR, expression " << inKeyRegExp <<
" didn't compile" << std::endl ;
176 const_cast<RooMappedCategory*>(
this));
192 os << indent <<
"--- RooMappedCategory ---" << std::endl
193 << indent <<
" Maps from " ;
196 os << indent <<
" Default value is ";
199 os << indent <<
" Mapping rules:" << std::endl;
201 os << indent <<
" " <<
iter->first <<
" -> " <<
iter->second.outCat().GetName() << std::endl ;
223 TString token,errorPrefix(
"RooMappedCategory::readFromStream(") ;
234 if (readToken) token=parser.
readToken() ;
235 if (token.
IsNull())
break ;
247 if (
map(srcKey,destKey))
return kTRUE ;
274 if (
iter->second.outCat().getVal()!=prevOutCat.
getVal()) {
275 if (!first) { os <<
" " ; }
278 os <<
iter->second.outCat().GetName() <<
":" <<
iter->first ;
279 prevOutCat=
iter->second.outCat() ;
281 os <<
"," <<
iter->first ;
285 if (!first) { os <<
" " ; }
307 if (
iter->second.outCat().getVal()!=prevOutCat.
getVal()) {
308 if (!first) { os <<
" " ; }
311 os <<
iter->second.outCat().GetName() <<
"<-" <<
iter->first ;
312 prevOutCat=
iter->second.outCat() ;
314 os <<
"," <<
iter->first ;
318 if (!first) { os <<
" " ; }
330 if (&other==
this)
return *this ;
332 _expr = other.
_expr ;
351 const char *
c =
exp ;
353 if (*c==
'+') t.
Append(
'\\') ;
364 void RooMappedCategory::Entry::Streamer(
TBuffer &R__b)
366 typedef ::RooMappedCategory::Entry ThisClass;
376 _cat.Streamer(R__b) ;
387 _cat.Streamer(R__b) ;
RooMappedCategoryCache(const RooAbsCache &other, RooAbsArg *owner=0)
RooMappedCategoryCache * _mapcache
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, which is interpreted as an OR of 'enum ContentsOptions' values and in the style given by 'enum StyleOption'.
const RooMappedCategoryCache * getOrCreateCache() const
virtual ~RooMappedCategory()
Buffer base class used for serializing objects.
Regular expression class.
void clearTypes()
Delete all currently defined states.
virtual Int_t CheckByteCount(UInt_t startpos, UInt_t bcnt, const TClass *clss)=0
virtual void writeToStream(std::ostream &os, Bool_t compact) const
Write object contents to ostream.
Entry & operator=(const Entry &other)
TString mangle(const char *exp) const
Mangle name : escape regexp character '+'.
virtual UInt_t WriteVersion(const TClass *cl, Bool_t useBcnt=kFALSE)=0
friend class RooMappedCategoryCache
virtual RooCatType evaluate() const
transient member: cache the mapping
std::map< std::string, std::string >::const_iterator iter
TString & Append(const char *cs)
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.
const RooCatType * defineType(const char *label)
Define a new state with given name.
void printMultiline(std::ostream &os, Int_t content, Bool_t verbose=kFALSE, TString indent="") const
Print info about this object to the specified stream.
Bool_t map(const char *inKeyRegExp, const char *outKeyName, Int_t outKeyNum=NoCatIdx)
ClassImp(RooMappedCategory) ClassImp(RooMappedCategory
TString readToken()
Read one token separated by any of the know punctuation characters This function recognizes and handl...
virtual const char * GetName() const
Returns name of object.
virtual void SetByteCount(UInt_t cntpos, Bool_t packInVersion=kFALSE)=0
std::map< Int_t, const RooCatType * > _map
static void indent(ostringstream &buf, int indent_level)
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.
virtual Bool_t redirectServersHook(const RooAbsCollection &, Bool_t, Bool_t, Bool_t)
const RooCatType * lookup(Int_t idx) const
std::map< std::string, RooMappedCategory::Entry > _mapArray
void printMetaArgs(std::ostream &os) const
Customized printing of arguments of a RooMappedCategory to more intuitively reflect the contents of t...
virtual Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE)
Read object contents from stream (dummy for now)
void setPunctuation(const TString &punct)
Change list of characters interpreted as punctuation.
RooCategoryProxy _inputCat
virtual const char * getLabel() const
Return label string of current state.
const RooAbsCategory & arg() const
RooAbsArg is the common abstract base class for objects that represent a value (of arbitrary type) an...
virtual const Text_t * GetName() const
Returns name of object.
int CompareTo(const char *cs, ECaseCompare cmp=kExact) const
Compare a string to char *cs2.
virtual Version_t ReadVersion(UInt_t *start=0, UInt_t *bcnt=0, const TClass *cl=0)=0
const RooCatType * lookupType(Int_t index, Bool_t printError=kFALSE) const
Find our type corresponding to the specified index, or return 0 for no match.