|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #ifndef MUONCALIBIDENTIFIER_MULTIDIMARRAY_H
6 #define MUONCALIBIDENTIFIER_MULTIDIMARRAY_H
29 template <
class T,
unsigned int I>
72 template <
class T,
unsigned int N>
113 void dump( std::ostream&
os = std::cout )
const;
115 void dump(
const std::string&
prefix, std::ostream&
os = std::cout )
const;
131 #ifdef MULTIDIMARRAY_DEBUG
132 static unsigned int s_objectCount;
136 template <
class T,
unsigned int I>
146 template <
class T,
unsigned int N>
151 template <
class T,
unsigned int N>
156 template <
class T,
unsigned int N>
158 return s_invalidSubType;
161 template <
class T,
unsigned int N>
163 :
m_data(0), m_minIndex(0), m_size(0)
165 #ifdef MULTIDIMARRAY_DEBUG
168 log<<
MSG::DEBUG<<
"Creating MultiDimArray<" <<
N <<
">" <<
" at " <<
this <<
" #objects: " << s_objectCount<<
endmsg;
172 template <
class T,
unsigned int N>
174 #ifdef MULTIDIMARRAY_DEBUG
177 log<<
MSG::DEBUG<<
"Deleting MultiDimArray<" <<
N <<
">" <<
" at " <<
this <<
" #objects: " << s_objectCount<<
endmsg;
182 template <
class T,
unsigned int N>
184 :
m_data(0), m_minIndex(0), m_size(0)
186 #ifdef MULTIDIMARRAY_DEBUG
189 log<<
MSG::DEBUG<<
"Copying MultiDimArray<" <<
N <<
">" <<
" at " <<
this <<
" #objects: " << s_objectCount<<
endmsg;
194 template <
class T,
unsigned int N>
202 template <
class T,
unsigned int N>
207 template <
class T,
unsigned int N>
209 return m_minIndex + m_size - 1;
212 template <
class T,
unsigned int N>
217 template <
class T,
unsigned int N>
222 template <
class T,
unsigned int N>
224 return index >= minIndex() &&
index <= maxIndex();
227 template <
class T,
unsigned int N>
229 #ifdef MULTIDIMARRAY_DEBUG
231 log<<
MSG::DEBUG<<
"Assigning MultiDimArray<" <<
N <<
">" <<
" to " <<
this <<
" from " << &rhs<<
endmsg;
234 if ( m_size != rhs.
m_size ) {
251 template <
class T,
unsigned int N>
253 if ( !isInRange(
index ) ) {
255 log<<MSG::WARNING<<
"MultiDimArray<" <<
N <<
">::operator["<<
index <<
"]" <<
" index out of range (" << minIndex() <<
"," << maxIndex() <<
")"<<
endmsg;
256 return s_invalidSubType;
261 template <
class T,
unsigned int N>
263 #ifdef MULTIDIMARRAY_DEBUG
265 #endif if ( !m_data ) {
269 m_data[0] = s_invalidSubType;
270 #ifdef MULTIDIMARRAY_DEBUG
271 log<<
MSG::DEBUG<<
"MultiDimArray<" <<
N <<
">::operator["<<
index <<
"]" <<
" at " <<
this <<
":" <<
" new data array. size=" << m_size <<
" range=(" << minIndex() <<
"," << maxIndex() <<
")"<<
endmsg;
273 }
else if (
index > maxIndex() ) {
275 unsigned int oldSize = m_size;
276 int nAdd =
index - maxIndex();
278 SubType* newData =
new SubType[m_size];
281 for ( ;
i < oldSize; ++
i ) newData[
i] =
m_data[
i];
282 for ( ;
i < m_size ; ++
i ) newData[
i] = s_invalidSubType;
285 #ifdef MULTIDIMARRAY_DEBUG
286 log<<
MSG::DEBUG<<
"MultiDimArray<" <<
N <<
">::operator["<<
index <<
"]" <<
" at " <<
this <<
":" <<
" added " << nAdd <<
" at back. size=" << m_size <<
" range=(" << minIndex() <<
"," << maxIndex() <<
")"<<
endmsg;
288 }
else if (
index < minIndex() ) {
290 unsigned int nAdd = minIndex() -
index;
292 SubType* newData =
new SubType[m_size];
295 for ( ;
i < nAdd ; ++
i ) newData[
i] = s_invalidSubType;
296 for ( ;
i < m_size; ++
i ) newData[
i] =
m_data[
i-nAdd];
300 #ifdef MULTIDIMARRAY_DEBUG
301 log<<
MSG::DEBUG<<
"MultiDimArray<" <<
N <<
">::operator["<<
index <<
"]" <<
" at " <<
this <<
":" <<
" added " << nAdd <<
" at front. size=" << m_size <<
" range=(" << minIndex() <<
"," << maxIndex() <<
")"<<
endmsg;
309 template <
class T,
unsigned int N>
311 unsigned int nTotal = 0;
314 for (
int idx = idxMin;
idx <= idxMax; ++
idx ) {
320 template <
class T,
unsigned int N>
322 unsigned int nTotal = 0;
325 for (
int idx = idxMin;
idx <= idxMax; ++
idx ) {
326 nTotal += validSize( ht[
idx] );
338 unsigned int cnt = 0;
341 for (
int idx = idxMin;
idx <= idxMax; ++
idx ) {
347 template <
class T,
unsigned int N>
349 return ::totalSize( *
this );
352 template <
class T,
unsigned int N>
354 return ::validSize( *
this );
357 template <
class T,
unsigned int N>
359 const std::string&
prefix =
"(" ) {
362 for (
int idx = idxMin;
idx <= idxMax; ++
idx ) {
363 std::ostringstream oss;
371 const std::string&
prefix =
"(" ) {
374 for (
int idx = idxMin;
idx <= idxMax; ++
idx ) {
379 template <
class T,
unsigned int N>
385 template <
class T,
unsigned int N>
391 template <
class T,
unsigned int N>
393 std::ostringstream oss;
398 template <
class T,
unsigned int N>
400 std::ostringstream oss;
405 template <
class T,
unsigned int N,
class K>
407 std::ostream&
os = std::cout,
const std::string&
prefix =
"(" ) {
409 std::ostringstream oss;
414 template<
class T,
class K>
416 std::ostream&
os = std::cout,
const std::string&
prefix =
"(" ) {
421 template <
class T,
unsigned int N>
427 template <
class T,
unsigned int N>
430 std::ostringstream oss;
436 template <
class T,
unsigned int N>
445 template <
class T,
unsigned int N>
448 #ifdef MULTIDIMARRAY_DEBUG
449 template <
class T,
unsigned int N>
456 #endif // MUONCALIBIDENTIFIER_MULTIDIMARRAY_H
static const SubType & invalidSubType()
unsigned int size() const
Size of this field.
static ThisType defaultThisType()
MultiDimArray< T, 1 > ThisType
define ThisType as a MultiDimArray<T,N> with N=1
void dump(const std::string &prefix, std::ostream &os=std::cout) const
Dump the complete table to an output stream, with an additional prefix before each line.
unsigned int depth() const
Depth of this field, i.e.
std::pair< long int, long int > indices
bool isInRange(int index) const
Check that an index is in the range of the this field.
SubType & operator[](int index)
std::string dumpToString(const std::string &prefix) const
Dump the complete table into a string, with an additional prefix before each line.
unsigned int validSize() const
The total number of valid (=non-default) elements from this field downwards.
MultiDimArray< T, I > ThisType
define ThisType as a MultiDimArray<T,I>
IMessageSvc * getMessageSvc(bool quiet=false)
std::string dumpOneEntryToString(const K &indices) const
Dump one entry with given indices into a string.
General recursive subtyping trait.
MultiDimArray< T, N > ThisType
const SubType & operator[](int index) const
unsigned int totalSize() const
The total number of elements, including invalid (=default) holes, from this field downwards.
void dumpOneEntry(const K &indices, std::ostream &os=std::cout) const
Dump one entry with given indices to an output stream.
static ValueType defaultValueType()
MultiDimArrayTypes< T, 0 >::ThisType SubType
define the SubType as MultiDimArrayTypes<T,0>::ThisType
void dumpOneEntry(const MultiDimArray< T, N > &idh, const K &indices, std::ostream &os=std::cout, const std::string &prefix="(")
void dump(std::ostream &os=std::cout) const
Dump the complete table to an output stream.
T::ValueType ThisType
define ThisType as T::ValueType
void dump(const MultiDimArray< T, N > &idh, std::ostream &os=std::cout, const std::string &prefix="(")
static SubType s_invalidSubType
std::string dumpToString() const
Dump the complete table into a string.
MultiDimArray< T, I-1 > SubType
define the SubType as MultiDimArrayTypes<T,I-1>
MultiDimArray(const MultiDimArray &)
std::ostream & operator<<(std::ostream &os, const MultiDimArray< T, N > &idh)
static SubType defaultSubType()
MultiDimArray & operator=(const MultiDimArray &)
Multi-dimensional array with a compile-time number of dimensions, and a run-time complete freedom ove...
MultiDimArrayTypes< T, N >::SubType SubType
static ThisType defaultThisType()