49 ClassImp(RooSuperCategory);
58 RooSuperCategory::RooSuperCategory(
const char *name,
const char *title,
const RooArgSet& inInputCatList) :
59 RooAbsCategoryLValue(name, title), _catSet(
"input",
"Input category set",this,kTRUE,kTRUE)
62 TIterator* iter = inInputCatList.createIterator() ;
64 while ((arg=(RooAbsArg*)iter->Next())) {
65 if (!arg->IsA()->InheritsFrom(RooAbsCategoryLValue::Class())) {
66 coutE(InputArguments) <<
"RooSuperCategory::RooSuperCategory(" << GetName() <<
"): input category " << arg->GetName()
67 <<
" is not an lvalue" << endl ;
81 RooSuperCategory::RooSuperCategory(
const RooSuperCategory& other,
const char *name) :
82 RooAbsCategoryLValue(other,name), _catSet(
"input",this,other._catSet)
85 setIndex(other.getIndex()) ;
93 RooSuperCategory::~RooSuperCategory()
104 TIterator* RooSuperCategory::MakeIterator()
const
106 return new RooMultiCatIter(_catSet) ;
114 void RooSuperCategory::updateIndexList()
118 RooMultiCatIter mcIter(_catSet) ;
121 while((obj = (TObjString*) mcIter.Next())) {
123 defineTypeUnchecked(obj->String(),i++) ;
136 TString RooSuperCategory::currentLabel()
const
141 Bool_t first(kTRUE) ;
142 for (
const auto c : _catSet) {
143 auto cat =
static_cast<RooAbsCategory*
>(c);
145 label.Append(first?
"{":
";") ;
146 label.Append(cat->getLabel()) ;
159 RooCatType RooSuperCategory::evaluate()
const
161 if (isShapeDirty()) {
162 const_cast<RooSuperCategory*
>(
this)->updateIndexList() ;
164 const RooCatType* ret = lookupType(currentLabel(),kTRUE) ;
166 coutE(Eval) <<
"RooSuperCat::evaluate(" <<
this <<
") error: current state not defined: '" << currentLabel() <<
"'" << endl ;
167 printStream(ccoutE(Eval),0,kVerbose) ;
168 return RooCatType() ;
179 Bool_t RooSuperCategory::setIndex(Int_t index, Bool_t )
181 const RooCatType* type = lookupType(index,kTRUE) ;
182 if (!type)
return kTRUE ;
183 return setType(type) ;
192 Bool_t RooSuperCategory::setLabel(
const char* label, Bool_t )
194 const RooCatType* type = lookupType(label,kTRUE) ;
195 if (!type)
return kTRUE ;
196 return setType(type) ;
205 Bool_t RooSuperCategory::setType(
const RooCatType* type, Bool_t )
208 strlcpy(buf,type->GetName(),1024) ;
210 Bool_t error(kFALSE) ;
215 for (
const auto c : _catSet) {
216 auto arg =
static_cast<RooAbsCategoryLValue*
>(c);
229 }
else if (*ptr==
'}') {
235 ptr = strtok(ptr,
";}") ;
239 error |= arg->setLabel(token) ;
251 void RooSuperCategory::printMultiline(ostream& os, Int_t content, Bool_t verbose, TString indent)
const
253 RooAbsCategory::printMultiline(os,content,verbose,indent) ;
256 os << indent <<
"--- RooSuperCategory ---" << endl;
257 os << indent <<
" Input category list:" << endl ;
258 TString moreIndent(indent) ;
259 os << moreIndent << _catSet << endl ;
268 Bool_t RooSuperCategory::readFromStream(istream& , Bool_t , Bool_t )
278 void RooSuperCategory::writeToStream(ostream& os, Bool_t compact)
const
280 RooAbsCategory::writeToStream(os,compact) ;
288 Bool_t RooSuperCategory::inRange(
const char* rangeName)
const
290 for (
const auto c : _catSet) {
291 auto cat =
static_cast<RooAbsCategoryLValue*
>(c);
292 if (!cat->inRange(rangeName)) {
305 Bool_t RooSuperCategory::hasRange(
const char* rangeName)
const
307 for (
const auto c : _catSet) {
308 auto cat =
static_cast<RooAbsCategoryLValue*
>(c);
309 if (cat->hasRange(rangeName))
return kTRUE ;