Logo ROOT  
Reference Guide
 
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Loading...
Searching...
No Matches
RooDataHistSliceIter.cxx
Go to the documentation of this file.
1/*****************************************************************************
2 * Project: RooFit *
3 * Package: RooFitCore *
4 * @(#)root/roofitcore:$Id$
5 * Authors: *
6 * WV, Wouter Verkerke, UC Santa Barbara, verkerke@slac.stanford.edu *
7 * DK, David Kirkby, UC Irvine, dkirkby@uci.edu *
8 * *
9 * Copyright (c) 2000-2005, Regents of the University of California *
10 * and Stanford University. All rights reserved. *
11 * *
12 * Redistribution and use in source and binary forms, *
13 * with or without modification, are permitted according to the terms *
14 * listed in LICENSE (http://roofit.sourceforge.net/license.txt) *
15 *****************************************************************************/
16
17/**
18\file RooDataHistSliceIter.cxx
19\class RooDataHistSliceIter
20\ingroup Roofitcore
21
22Iterates over all bins in a RooDataHist that occur in a slice defined by the
23bin coordinates of the input sliceSet.
24**/
25
26#include "RooDataHist.h"
27#include "RooArgSet.h"
28#include "RooAbsLValue.h"
30
31
32////////////////////////////////////////////////////////////////////////////////
33/// Construct an iterator over all bins of RooDataHist 'hist' in the slice defined
34/// by the values of the arguments in 'sliceArg'
35
37{
38 // Calculate base index (for 0th bin) for slice
39 RooAbsArg* sliceArgInt = hist.get()->find(sliceArg.GetName()) ;
40 dynamic_cast<RooAbsLValue&>(*sliceArgInt).setBin(0) ;
41
42 if (hist._vars.size()>1) {
43 _baseIndex = hist.calcTreeIndex(hist._vars, true);
44 } else {
45 _baseIndex = 0 ;
46 }
47
48 _nStep = dynamic_cast<RooAbsLValue&>(*sliceArgInt).numBins() ;
49
50// std::cout << "RooDataHistSliceIter" << std::endl ;
51// hist.Print() ;
52// std::cout << "hist._iterator = " << hist._iterator << std::endl ;
53
54 Int_t i=0 ;
55 for (const auto arg : hist._vars) {
56 if (arg==sliceArgInt) break ;
57 i++ ;
58 }
59 _stepSize = hist._idxMult[i] ;
60 _curStep = 0 ;
61
62}
63
64
65
66////////////////////////////////////////////////////////////////////////////////
67/// Copy constructor
68
71 _hist(other._hist),
72 _sliceArg(other._sliceArg),
73 _baseIndex(other._baseIndex),
74 _stepSize(other._stepSize),
75 _nStep(other._nStep),
76 _curStep(other._curStep)
77{
78}
79
80
81
82////////////////////////////////////////////////////////////////////////////////
83/// Destructor
84
88
89
90
91////////////////////////////////////////////////////////////////////////////////
92/// Dummy
93
95{
96 return nullptr ;
97}
98
99
100
101
102////////////////////////////////////////////////////////////////////////////////
103/// Iterator increment operator
104
106{
107 if (_curStep==_nStep) {
108 return nullptr ;
109 }
110
111 // Select appropriate entry in RooDataHist
113
114 // Increment iterator position
115 _curStep++ ;
116
117 return _sliceArg ;
118}
119
120
121
122////////////////////////////////////////////////////////////////////////////////
123/// Reset iterator position to beginning
124
126{
127 _curStep=0 ;
128}
129
130
131
132////////////////////////////////////////////////////////////////////////////////
133/// Iterator dereference operator, not functional for this iterator
134
136{
137 Int_t step = _curStep == 0 ? _curStep : _curStep - 1;
138 // Select appropriate entry in RooDataHist
139 _hist->get(_baseIndex + step*_stepSize) ;
140
141 return _sliceArg ;
142}
143
144
145////////////////////////////////////////////////////////////////////////////////
146/// Returns true if position of this iterator differs from position
147/// of iterator 'aIter'
148
150{
151 if ((aIter.IsA() == RooDataHistSliceIter::Class())) {
152 const RooDataHistSliceIter &iter(dynamic_cast<const RooDataHistSliceIter &>(aIter));
153 return (_curStep != iter._curStep);
154 }
155
156 return false;
157}
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
Common abstract base class for objects that represent a value and a "shape" in RooFit.
Definition RooAbsArg.h:77
Storage_t::size_type size() const
RooArgSet _vars
Dimensions of this data set.
Definition RooAbsData.h:350
Abstract base class for objects that are lvalues, i.e.
virtual Int_t numBins(const char *rangeName=nullptr) const =0
virtual void setBin(Int_t ibin, const char *rangeName=nullptr)=0
Iterates over all bins in a RooDataHist that occur in a slice defined by the bin coordinates of the i...
RooDataHistSliceIter(const RooDataHistSliceIter &other)
Copy constructor.
~RooDataHistSliceIter() override
Destructor.
TObject * Next() override
Iterator increment operator.
void Reset() override
Reset iterator position to beginning.
const TCollection * GetCollection() const override
Dummy.
static TClass * Class()
bool operator!=(const TIterator &aIter) const override
Returns true if position of this iterator differs from position of iterator 'aIter'.
TObject * operator*() const override
Iterator dereference operator, not functional for this iterator.
Container class to hold N-dimensional binned data.
Definition RooDataHist.h:40
std::size_t calcTreeIndex(const RooAbsCollection &coords, bool fast) const
Calculate the bin index corresponding to the coordinates passed as argument.
std::vector< Int_t > _idxMult
const RooArgSet * get() const override
Get bin centre of current bin.
Definition RooDataHist.h:82
Collection abstract base class.
Definition TCollection.h:65
Iterator abstract base class.
Definition TIterator.h:30
Mother of all ROOT objects.
Definition TObject.h:41