// RooDataHistSliceIter iterates over all bins in a RooDataHist that
// occur in a slice defined by the bin coordinates of the input
// sliceSet.
// END_HTML
#include "RooFit.h"
#include "RooDataHist.h"
#include "RooArgSet.h"
#include "RooAbsLValue.h"
#include "RooDataHistSliceIter.h"
ClassImp(RooDataHistSliceIter)
;
RooDataHistSliceIter::RooDataHistSliceIter(RooDataHist& hist, RooAbsArg& sliceArg) : _hist(&hist), _sliceArg(&sliceArg)
{
RooAbsArg* sliceArgInt = hist.get()->find(sliceArg.GetName()) ;
dynamic_cast<RooAbsLValue&>(*sliceArgInt).setBin(0,hist.bname()) ;
_baseIndex = hist.calcTreeIndex() ;
_nStep = dynamic_cast<RooAbsLValue&>(*sliceArgInt).numBins(hist.bname()) ;
hist._iterator->Reset() ;
RooAbsArg* arg ;
Int_t i=0 ;
while((arg=(RooAbsArg*)hist._iterator->Next())) {
if (arg==sliceArgInt) break ;
i++ ;
}
_stepSize = hist._idxMult[i] ;
_curStep = 0 ;
}
RooDataHistSliceIter::RooDataHistSliceIter(const RooDataHistSliceIter& other) :
TIterator(other),
_hist(other._hist),
_sliceArg(other._sliceArg),
_nStep(other._nStep),
_curStep(other._curStep)
{
}
RooDataHistSliceIter::~RooDataHistSliceIter()
{
}
const TCollection* RooDataHistSliceIter::GetCollection() const
{
return 0 ;
}
TObject* RooDataHistSliceIter::Next()
{
if (_curStep==_nStep) return 0 ;
_hist->get(_baseIndex + _curStep*_stepSize) ;
_curStep++ ;
return _sliceArg ;
}
void RooDataHistSliceIter::Reset()
{
_curStep=0 ;
}
TObject *RooDataHistSliceIter::operator*() const
{
Int_t step = _curStep == 0 ? _curStep : _curStep - 1;
_hist->get(_baseIndex + step*_stepSize) ;
return _sliceArg ;
}
bool RooDataHistSliceIter::operator!=(const TIterator &aIter) const
{
if (nullptr == &aIter)
return false;
if ((aIter.IsA() == RooDataHistSliceIter::Class())) {
const RooDataHistSliceIter &iter(dynamic_cast<const RooDataHistSliceIter &>(aIter));
return (_curStep != iter._curStep);
}
return false;
}
Last change: Wed Jun 25 08:32:31 2008
Last generated: 2008-06-25 08:32
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.