#include "RooFit.h"
#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())) {
    RooAbsCategory *cat= dynamic_cast<RooAbsCategoryLValue*>(obj);
    if(0 == cat) {
      cout << "RooMultiCatIter:: list element " << obj->GetName() 
	   << " is not a RooAbsCategoryLValue, ignored" << endl ;
      continue ;
    }
    _catList.add(*cat) ;
  }
  delete catIter ;
  
  
  _nIter = catList.getSize() ;
  _iterList   = new pTIterator[_nIter] ;
  _catPtrList = new pRooCategory[_nIter] ;
  _curTypeList = new RooCatType[_nIter] ;
  
  _curIter = 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) {
    return 0 ;
  }
  RooCatType* next = (RooCatType*) _iterList[_curIter]->Next() ;
  if (next) { 
    
    _curTypeList[_curIter] = *next ;
    
    
    if (_curIter>0) _curIter=0 ;
    return compositeLabel() ;    
  } else {
    
    _iterList[_curIter]->Reset() ;
    next = (RooCatType*) _iterList[_curIter]->Next() ;
    if (next) _curTypeList[_curIter] = *next ; 
    
    
    _curIter++ ;
    return Next() ;
  }
}
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 ;
}
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.