16 #ifndef ROO_MAPPED_CATEGORY
17 #define ROO_MAPPED_CATEGORY
27 class RooMappedCategoryCache;
29 class RooMappedCategory :
public RooAbsCategory {
32 enum CatIdx { NoCatIdx=-99999 } ;
33 inline RooMappedCategory() : _defCat(0), _mapcache(0) { }
34 RooMappedCategory(
const char *name,
const char *title, RooAbsCategory& inputCat,
const char* defCatName=
"NotMapped", Int_t defCatIdx=NoCatIdx);
35 RooMappedCategory(
const RooMappedCategory& other,
const char *name=0) ;
36 virtual TObject* clone(
const char* newname)
const {
return new RooMappedCategory(*
this,newname); }
37 virtual ~RooMappedCategory();
40 Bool_t map(
const char* inKeyRegExp,
const char* outKeyName, Int_t outKeyNum=NoCatIdx) ;
43 void printMultiline(std::ostream& os, Int_t content, Bool_t verbose=kFALSE, TString indent=
"")
const ;
44 void printMetaArgs(std::ostream& os)
const ;
47 virtual Bool_t readFromStream(std::istream& is, Bool_t compact, Bool_t verbose=kFALSE) ;
48 virtual void writeToStream(std::ostream& os, Bool_t compact)
const ;
53 inline Entry() : _regexp(0), _cat() {}
54 virtual ~Entry() {
delete _regexp ; } ;
55 Entry(
const char* exp,
const RooCatType* cat) : _expr(exp), _regexp(new TRegexp(mangle(exp),kTRUE)), _cat(*cat) {}
56 Entry(
const Entry& other) : _expr(other._expr), _regexp(new TRegexp(mangle(other._expr.Data()),kTRUE)), _cat(other._cat) {}
57 inline Bool_t ok() {
return (_regexp->Status()==TRegexp::kOK) ; }
58 Bool_t match(
const char* testPattern)
const {
return (TString(testPattern).Index(*_regexp)>=0) ; }
59 inline const RooCatType& outCat()
const {
return _cat ; }
60 Entry& operator=(
const Entry& other);
64 TString mangle(
const char* exp)
const ;
76 RooCategoryProxy _inputCat ;
77 std::map<std::string,RooMappedCategory::Entry> _mapArray ;
78 mutable RooMappedCategoryCache* _mapcache;
80 virtual RooCatType evaluate()
const ;
81 const RooMappedCategoryCache* getOrCreateCache()
const;
83 friend class RooMappedCategoryCache;
85 ClassDef(RooMappedCategory,1)