00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026 #include "RooFit.h"
00027
00028 #if ROOT_VERSION_CODE <= ROOT_VERSION(5,19,04)
00029 #ifndef nullptr
00030 #define nullptr 0
00031 #endif
00032 #endif
00033
00034 #include "RooDataHist.h"
00035 #include "RooArgSet.h"
00036 #include "RooAbsLValue.h"
00037 #include "RooDataHistSliceIter.h"
00038
00039 ClassImp(RooDataHistSliceIter)
00040 ;
00041
00042
00043
00044
00045 RooDataHistSliceIter::RooDataHistSliceIter(RooDataHist& hist, RooAbsArg& sliceArg) : _hist(&hist), _sliceArg(&sliceArg)
00046 {
00047
00048
00049
00050
00051 RooAbsArg* sliceArgInt = hist.get()->find(sliceArg.GetName()) ;
00052 dynamic_cast<RooAbsLValue&>(*sliceArgInt).setBin(0) ;
00053
00054 if (hist._vars.getSize()>1) {
00055 _baseIndex = hist.calcTreeIndex() ;
00056 } else {
00057 _baseIndex = 0 ;
00058 }
00059
00060 _nStep = dynamic_cast<RooAbsLValue&>(*sliceArgInt).numBins() ;
00061
00062 hist._iterator->Reset() ;
00063 RooAbsArg* arg ;
00064 Int_t i=0 ;
00065 while((arg=(RooAbsArg*)hist._iterator->Next())) {
00066 if (arg==sliceArgInt) break ;
00067 i++ ;
00068 }
00069 _stepSize = hist._idxMult[i] ;
00070 _curStep = 0 ;
00071
00072 }
00073
00074
00075
00076
00077 RooDataHistSliceIter::RooDataHistSliceIter(const RooDataHistSliceIter& other) :
00078 TIterator(other),
00079 _hist(other._hist),
00080 _sliceArg(other._sliceArg),
00081 _baseIndex(other._baseIndex),
00082 _stepSize(other._stepSize),
00083 _nStep(other._nStep),
00084 _curStep(other._curStep)
00085 {
00086
00087 }
00088
00089
00090
00091
00092 RooDataHistSliceIter::~RooDataHistSliceIter()
00093 {
00094
00095 }
00096
00097
00098
00099
00100 const TCollection* RooDataHistSliceIter::GetCollection() const
00101 {
00102
00103 return 0 ;
00104 }
00105
00106
00107
00108
00109
00110 TObject* RooDataHistSliceIter::Next()
00111 {
00112
00113
00114 if (_curStep==_nStep) {
00115 return 0 ;
00116 }
00117
00118
00119 _hist->get(_baseIndex + _curStep*_stepSize) ;
00120
00121
00122 _curStep++ ;
00123
00124 return _sliceArg ;
00125 }
00126
00127
00128
00129
00130 void RooDataHistSliceIter::Reset()
00131 {
00132
00133 _curStep=0 ;
00134 }
00135
00136
00137
00138
00139 TObject *RooDataHistSliceIter::operator*() const
00140 {
00141
00142
00143 Int_t step = _curStep == 0 ? _curStep : _curStep - 1;
00144
00145 _hist->get(_baseIndex + step*_stepSize) ;
00146
00147 return _sliceArg ;
00148 }
00149
00150
00151
00152 bool RooDataHistSliceIter::operator!=(const TIterator &aIter) const
00153 {
00154
00155
00156
00157 if (nullptr == &aIter)
00158 return false;
00159
00160 if ((aIter.IsA() == RooDataHistSliceIter::Class())) {
00161 const RooDataHistSliceIter &iter(dynamic_cast<const RooDataHistSliceIter &>(aIter));
00162 return (_curStep != iter._curStep);
00163 }
00164
00165 return false;
00166 }