56 mutable std::map<Int_t, RooAbsCategory::value_type>
_map;
64 for (
const auto& inCat : *parent.
_inputCat) {
65 const std::string& inKey = inCat.first;
68 for (
const auto& strAndEntry : parent.
_mapArray) {
69 if (strAndEntry.second.match(inKey.c_str())) {
71 _map[inCat.second] = strAndEntry.second.outCat();
97 RooAbsCategory(other,
name), _inputCat(
"input",this,other._inputCat), _mapArray(other._mapArray),
121 if (!inKeyRegExp || !outKey)
return kTRUE ;
126 << inKeyRegExp <<
" already mapped" << std::endl ;
142 <<
"): ERROR, unable to define category for output type " << outKey << std::endl ;
147 Entry e(inKeyRegExp, catIdx);
150 <<
"): ERROR, expression " << inKeyRegExp <<
" didn't compile" << std::endl ;
185 os <<
indent <<
"--- RooMappedCategory ---" << std::endl
186 <<
indent <<
" Maps from " ;
191 os <<
indent <<
" Mapping rules:" << std::endl;
192 for (
const auto& strAndEntry :
_mapArray) {
193 os <<
indent <<
" " << strAndEntry.first <<
" -> " << strAndEntry.second.outCat() << std::endl ;
215 TString token,errorPrefix(
"RooMappedCategory::readFromStream(") ;
226 if (readToken) token=parser.
readToken() ;
227 if (token.
IsNull()) break ;
239 if (
map(srcKey,destKey))
return kTRUE ;
266 if (iter.second.outCat() != prevOutCat) {
267 if (!
first) { os <<
" " ; }
270 os << iter.second.outCat() <<
":" << iter.first ;
271 prevOutCat = iter.second.outCat();
273 os <<
"," << iter.first ;
277 if (!
first) { os <<
" " ; }
299 if (iter.second.outCat() != prevOutCat) {
300 if (!
first) { os <<
" " ; }
303 os << iter.second.outCat() <<
"<-" << iter.first ;
304 prevOutCat = iter.second.outCat();
306 os <<
"," << iter.first ;
310 if (!
first) { os <<
" " ; }
328 _expr(
exp), _regexp(nullptr), _catIdx(cat) {}
330 _expr(other._expr), _regexp(nullptr), _catIdx(other._catIdx) {}
338 if (&other==
this)
return *this ;
340 _expr = other.
_expr ;
361 const char *
c =
exp ;
372 _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...
RooAbsArg * _owner
Pointer to owning RooAbsArg.
A space to attach TBranches.
virtual value_type getCurrentIndex() const
Return index number of current state.
void printMultiline(std::ostream &os, Int_t contents, Bool_t verbose=kFALSE, TString indent="") const override
Print info about this object to the specified stream.
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.
static const decltype(_stateNames) ::value_type & invalidCategory()
A category state to signify an invalid category.
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
Bool_t redirectServersHook(const RooAbsCollection &, Bool_t, Bool_t, Bool_t) override
Interface for server redirect calls.
void wireCache() override
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 ...
value_type _defCat
Default (unmapped) output type.
const RooMappedCategoryCache * getOrCreateCache() const
RooCategoryProxy _inputCat
Input category.
void printMetaArgs(std::ostream &os) const override
Customized printing of arguments of a RooMappedCategory to more intuitively reflect the contents of t...
std::map< std::string, RooMappedCategory::Entry > _mapArray
List of mapping rules.
void recomputeShape() override
When the input category changes states, the cached state mappings are invalidated.
friend class RooMappedCategoryCache
void writeToStream(std::ostream &os, Bool_t compact) const override
Write object contents to ostream.
Bool_t readFromStream(std::istream &is, Bool_t compact, Bool_t verbose=kFALSE) override
Read object contents from stream (dummy for now)
Bool_t map(const char *inKeyRegExp, const char *outKeyName, Int_t outKeyNum=NoCatIdx)
static constexpr value_type NoCatIdx
void printMultiline(std::ostream &os, Int_t content, Bool_t verbose=kFALSE, TString indent="") const override
Print info about this object to the specified stream.
RooMappedCategoryCache * _mapcache
! transient member: cache the mapping
~RooMappedCategory() override
value_type evaluate() const override
Evaluate the category state and return.
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.
const char * GetName() const override
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)
RooCmdArg Index(RooCategory &icat)
RVec< PromoteType< T > > exp(const RVec< T > &v)
static constexpr double second