// RooMultiCatIter iterators over all state permutations of a list of categories.
// It serves as the state iterator for a RooSuperCategory or a RooMultiCategory.
// Since this iterator only constructs state labels and does not change the value
// of its input categories, it is not required that its inputs are LValues.
// For cases where all inputs are LValues (such as for RooSuperCategory) the
// values of the input can be changes by assigning the super category the
// string label generated by this iterator
// END_HTML
#include "RooFit.h"
#if ROOT_VERSION_CODE <= ROOT_VERSION(5,19,04)
#ifndef nullptr
#define nullptr 0
#endif
#endif
#include "RooAbsCategoryLValue.h"
#include "RooAbsCategoryLValue.h"
#include "RooMultiCatIter.h"
ClassImp(RooMultiCatIter)
;
RooMultiCatIter::RooMultiCatIter(const RooArgSet& catList, const char* rangeName) : _catList("catList")
{
if (rangeName) {
_rangeName = rangeName ;
}
initialize(catList) ;
}
RooMultiCatIter::RooMultiCatIter(const RooMultiCatIter& other) : TIterator(other), _catList("catList")
{
initialize(other._catList) ;
}
void RooMultiCatIter::initialize(const RooArgSet& catList)
{
TIterator* catIter = catList.createIterator() ;
TObject* obj ;
while ((obj = catIter->Next())) {
_catList.add((RooAbsArg&)*obj) ;
}
delete catIter ;
_nIter = catList.getSize() ;
_iterList = new pTIterator[_nIter] ;
_catPtrList = new pRooCategory[_nIter] ;
_curTypeList = new RooCatType[_nIter] ;
_curIter = 0 ;
_curItem = 0 ;
TIterator* cIter = _catList.createIterator() ;
RooAbsCategoryLValue* cat ;
while((cat=(RooAbsCategoryLValue*)cIter->Next())) {
_catPtrList[_curIter] = cat ;
_iterList[_curIter++] = cat->typeIterator() ;
}
delete cIter ;
Reset() ;
}
RooMultiCatIter::~RooMultiCatIter()
{
for (_curIter=0 ; _curIter<_nIter ; _curIter++) {
delete _iterList[_curIter] ;
}
delete[] _iterList ;
delete[] _catPtrList ;
delete[] _curTypeList ;
}
const TCollection* RooMultiCatIter::GetCollection() const
{
return 0 ;
}
TObjString* RooMultiCatIter::compositeLabel()
{
TString& str = _compositeLabel.String() ;
str = "{" ;
Int_t i ;
for (i=0 ; i<_nIter ; i++) {
if (i>0) str.Append(";") ;
str.Append(_curTypeList[i].GetName()) ;
}
str.Append("}") ;
return &_compositeLabel ;
}
TObject* RooMultiCatIter::Next()
{
if (_curIter==_nIter) {
_curItem = 0;
return 0 ;
}
RooCatType* next = (RooCatType*) _iterList[_curIter]->Next() ;
if (next) {
_curTypeList[_curIter] = *next ;
if (_curIter>0) _curIter=0 ;
_curItem = compositeLabel() ;
return _curItem ;
} else {
_iterList[_curIter]->Reset() ;
next = (RooCatType*) _iterList[_curIter]->Next() ;
if (next) _curTypeList[_curIter] = *next ;
_curIter++ ;
_curItem = Next() ;
return _curItem ;
}
}
void RooMultiCatIter::Reset()
{
for (_curIter=0 ; _curIter<_nIter ; _curIter++) {
TIterator* cIter = _iterList[_curIter] ;
cIter->Reset() ;
RooCatType* first = (RooCatType*) cIter->Next() ;
if (first) {
if (_curIter==0) cIter->Reset() ;
_curTypeList[_curIter] = *first ;
}
}
_curIter=0 ;
}
TObject *RooMultiCatIter::operator*() const
{
return _curItem ;
}
bool RooMultiCatIter::operator!=(const TIterator &aIter) const
{
if (nullptr == &aIter)
return false;
if ((aIter.IsA() == RooMultiCatIter::Class())) {
const RooMultiCatIter &iter(dynamic_cast<const RooMultiCatIter &>(aIter));
return (_curItem != iter._curItem);
}
return false;
}
Last change: Mon Sep 15 14:12:08 2008
Last generated: 2008-09-15 14:12
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.