The Gaudi Framework  v33r0 (d5ea422b)
NTuple.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDIKERNEL_NTUPLE_H
12 #define GAUDIKERNEL_NTUPLE_H
13 // ============================================================================
14 // STL include files
15 // ============================================================================
16 #include <algorithm>
17 #include <cfloat>
18 #include <limits>
19 #include <stdexcept>
20 #include <string>
21 // ============================================================================
22 // Framework include files
23 // ============================================================================
24 #include "GaudiKernel/DataObject.h"
26 #include "GaudiKernel/INTuple.h"
29 // ============================================================================
30 // Forward declarations
31 // ============================================================================
32 class NTupleFile;
33 class NTupleDirectory;
34 // ============================================================================
43 namespace NTuple {
44  // local forward declarations
45  template <class TYP>
46  class Range;
47  template <class TYP>
48  class _Data;
49  template <class TYP>
50  class _Item;
51  template <class TYP>
52  class _Array;
53  template <class TYP>
54  class _Matrix;
55  template <class TYP>
56  class _Accessor;
57  template <class TYP>
58  class Item;
59  template <class TYP>
60  class Array;
61  template <class TYP>
62  class Matrix;
63  // ==========================================================================
65  template <class TYP>
66  class Range {
68  /*const*/ TYP m_lower;
70  /*const*/ TYP m_upper;
71 
72  public:
74  Range( TYP low, TYP upper ) : m_lower( std::move( low ) ), m_upper( std::move( upper ) ) {}
76  Range( const Range<TYP>& copy ) : m_lower( copy.m_lower ), m_upper( copy.m_upper ) {}
78  Range& operator=( const Range<TYP>& copy ) {
79  m_lower = copy.m_lower;
80  m_upper = copy.m_upper;
81  return *this;
82  }
84  virtual ~Range() = default;
86  TYP lower() const { return m_lower; }
88  TYP upper() const { return m_upper; }
90  TYP distance() const { return m_upper - m_lower; }
92  static TYP min() { return std::numeric_limits<TYP>::min(); }
94  static TYP max() { return std::numeric_limits<TYP>::max(); }
95  };
96  // ==========================================================================
97  template <>
98  class Range<bool> {
99  public:
101  Range( const bool /* low */, const bool /* upper */ ) {}
103  Range( const Range<bool>& /* copy */ ) {}
105  virtual ~Range() = default;
107  bool lower() const { return false; }
109  bool upper() const { return true; }
111  bool distance() const { return true; }
113  static bool min() { return false; }
115  static bool max() { return true; }
116  };
117  // ==========================================================================
118  template <>
120  return (IOpaqueAddress*)0x0;
121  }
122  template <>
124  return (IOpaqueAddress*)0xffffffff;
125  }
126  // ==========================================================================
129  template <class TYP>
130  class GAUDI_API _Data : virtual public INTupleItem {
131  protected:
133  TYP* m_buffer = nullptr;
134 
135  public:
139  virtual void setDefault( const TYP d ) = 0;
141  virtual const ItemRange& range() const = 0;
142  };
143  // ==========================================================================
146  template <class TYP>
147  class GAUDI_API _Item : virtual public _Data<TYP> {
148  public:
150  static _Item* create( INTuple* tup, const std::string& name, const std::type_info& info, TYP min, TYP max,
151  TYP def );
153  template <class T>
154  _Item<TYP>& operator=( const _Item<T>& copy ) {
155  *this->m_buffer = copy.get();
156  return *this;
157  }
159  void set( const TYP& item ) { *this->m_buffer = item; }
161  virtual TYP get() const { return *this->m_buffer; }
162  };
163  // ==========================================================================
166  template <class TYP>
167  class GAUDI_API _Array : virtual public _Data<TYP> {
168  public:
170  static _Array* create( INTuple* tup, const std::string& name, const std::type_info& info, const std::string& index,
171  long len, TYP min, TYP max, TYP def );
173  template <class T>
174  _Array<TYP>& operator=( const _Array<T>& copy ) {
175  long len = this->length();
176  if ( len == copy.length() ) {
177  const T* source = (const T*)copy.buffer();
178  std::copy_n( source, len, this->m_buffer );
179  return *this;
180  }
181  throw std::out_of_range( "N-tuple matrix cannot be copied! The index range does not match!" );
182  return *this;
183  }
185  const TYP& data( long i ) const { return this->m_buffer[i]; }
187  TYP& data( long i ) { return this->m_buffer[i]; }
188 
189  TYP* begin() { return this->m_buffer; }
190  TYP* end() { return this->m_buffer + this->length(); }
191  };
192  // ==========================================================================
195  template <class TYP>
196  class GAUDI_API _Matrix : virtual public _Data<TYP> {
197  protected:
199  long m_rows;
200 
201  public:
203  static _Matrix* create( INTuple* tup, const std::string& name, const std::type_info& info, const std::string& index,
204  long ncol, long nrow, TYP min, TYP max, TYP def );
206  template <class T>
208  long len = this->length();
209  if ( len == copy.length() ) {
210  const T* source = (const T*)copy.buffer();
211  std::copy_n( source, len, this->m_buffer );
212  return *this;
213  }
214  throw std::out_of_range( "N-tuple matrix cannot be copied! The index range does not match!" );
215  return *this;
216  }
218  TYP* column( long i ) { return this->m_buffer + i * m_rows; }
220  const TYP* column( long i ) const { return this->m_buffer + i * m_rows; }
221  };
222  // ==========================================================================
225  template <class TYP>
226  class _Accessor {
227  friend class Tuple;
228 
229  private:
230  _Accessor<TYP>& operator=( const _Accessor<TYP>& ) { return *this; }
231 
232  protected:
234  mutable TYP* m_ptr = nullptr;
235 
236  public:
238  _Accessor() = default;
240  virtual ~_Accessor() = default;
242  bool operator!() const { return m_ptr != 0; }
244  operator const void*() const { return m_ptr; }
246  TYP* operator->() { return m_ptr; }
248  const TYP* operator->() const { return m_ptr; }
250  const Range<TYP>& range() const { return m_ptr->range(); }
251  };
252  // ==========================================================================
255  template <class TYP>
256  class Item : virtual public _Accessor<_Item<TYP>> {
257  typedef Item<TYP> _My;
258 
259  public:
261  Item() = default;
263  operator const TYP() const { return this->m_ptr->get(); }
265  TYP operator*() { return this->m_ptr->get(); }
267  const TYP operator*() const { return this->m_ptr->get(); }
268  // Arithmetic operators defined on NTuple column entries
269  Item& operator++() { return *this += TYP( 1 ); }
270  Item& operator++( int ) { return *this += TYP( 1 ); }
271  Item& operator--() { return *this -= TYP( 1 ); }
272  Item& operator--( int ) { return *this -= TYP( 1 ); }
274  Item& operator=( const TYP data ) {
275  this->m_ptr->set( data );
276  return *this;
277  }
279  template <class T>
280  Item& operator=( const Item<T>& data ) {
281  this->m_ptr->set( data->get() );
282  return *this;
283  }
284  Item<TYP>& operator+=( const TYP data ) {
285  this->m_ptr->set( this->m_ptr->get() + data );
286  return *this;
287  }
288  Item<TYP>& operator-=( const TYP data ) {
289  this->m_ptr->set( this->m_ptr->get() - data );
290  return *this;
291  }
292  Item<TYP>& operator*=( const TYP data ) {
293  this->m_ptr->set( this->m_ptr->get() * data );
294  return *this;
295  }
296  Item<TYP>& operator/=( const TYP data ) {
297  this->m_ptr->set( this->m_ptr->get() / data );
298  return *this;
299  }
300  };
301  // ==========================================================================
304  template <>
305  class Item<bool> : virtual public _Accessor<_Item<bool>> {
306  typedef Item<bool> _My;
307 
308  public:
310  Item() = default;
312  operator bool() const { return this->m_ptr->get(); }
314  Item& operator=( const bool data ) {
315  this->m_ptr->set( data );
316  return *this;
317  }
319  template <class T>
320  Item& operator=( const Item<T>& data ) {
321  this->m_ptr->set( data->get() );
322  return *this;
323  }
324  };
325  // ==========================================================================
328  template <class TYP>
329  class Array : virtual public _Accessor<_Array<TYP>> {
330  public:
332  Array() = default;
334  template <class T>
335  Array& operator=( const Array<T>& copy ) {
336  *( this->m_ptr ) = *( copy.operator->() );
337  return *this;
338  }
340  template <class T>
341  TYP& operator[]( const T i ) {
342  return this->m_ptr->data( i );
343  }
345  template <class T>
346  const TYP& operator[]( const T i ) const {
347  return this->m_ptr->data( i );
348  }
349 
350  TYP* begin() { return this->m_ptr->begin(); }
351  TYP* end() { return this->m_ptr->end(); }
352  };
353  // =========================================================================
356  template <class TYP>
357  class Matrix : virtual public _Accessor<_Matrix<TYP>> {
358  public:
360  Matrix() = default;
362  template <class T>
363  Matrix& operator=( const Matrix<T>& copy ) {
364  *( this->m_ptr ) = *( copy.operator->() );
365  return *this;
366  }
368  template <class T>
369  TYP* operator[]( const T i ) {
370  return this->m_ptr->column( i );
371  }
373  template <class T>
374  const TYP* operator[]( const T i ) const {
375  return this->m_ptr->column( i );
376  }
377  };
378  // =========================================================================
385  class Tuple : public DataObject, virtual public INTuple {
386 
387  protected:
389  template <class TYPE>
390  StatusCode i_item( const std::string& name, _Item<TYPE>*& result ) const {
391  try {
392  result = dynamic_cast<_Item<TYPE>*>( i_find( name ) );
393  } catch ( ... ) { result = nullptr; }
394  return result ? StatusCode::SUCCESS : StatusCode::FAILURE;
395  }
397  template <class TYPE>
398  StatusCode i_item( const std::string& name, _Item<TYPE*>*& result ) const {
399  try {
400  _Item<void*>* p = dynamic_cast<_Item<void*>*>( i_find( name ) );
401  result = (_Item<TYPE*>*)p;
402  } catch ( ... ) { result = nullptr; }
403  return result ? StatusCode::SUCCESS : StatusCode::FAILURE;
404  }
407  try {
408  result = dynamic_cast<_Item<IOpaqueAddress*>*>( i_find( name ) );
409  } catch ( ... ) { result = nullptr; }
410  return result ? StatusCode::SUCCESS : StatusCode::FAILURE;
411  }
413  template <class TYPE>
414  StatusCode i_item( const std::string& name, _Array<TYPE>*& result ) const {
415  try {
416  if ( clID() == CLID_ColumnWiseTuple ) { result = dynamic_cast<_Array<TYPE>*>( i_find( name ) ); }
417  } catch ( ... ) { result = nullptr; }
418  return result ? StatusCode::SUCCESS : StatusCode::FAILURE;
419  }
421  template <class TYPE>
422  StatusCode i_item( const std::string& name, _Matrix<TYPE>*& result ) const {
423  try {
424  if ( clID() == CLID_ColumnWiseTuple ) { result = dynamic_cast<_Matrix<TYPE>*>( i_find( name ) ); }
425  } catch ( ... ) { result = nullptr; }
426  return result ? StatusCode::SUCCESS : StatusCode::FAILURE;
427  }
429  template <class TYPE>
430  StatusCode i_addItem( const std::string& name, long, const std::string&, TYPE low, TYPE high,
431  _Item<TYPE>*& result ) {
432  if ( !i_find( name ) ) {
433  TYPE nil;
434  nil = 0;
435  return add( result = _Item<TYPE>::create( this, name, typeid( TYPE ), low, high, nil ) );
436  }
437  return StatusCode::FAILURE;
438  }
440  template <class TYPE>
441  StatusCode i_addItem( const std::string& name, long dim, const std::string& index, TYPE low, TYPE high,
442  _Array<TYPE>*& result ) {
443  if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
444  return add( result = _Array<TYPE>::create( this, name, typeid( TYPE ), index, dim, low, high, TYPE( 0 ) ) );
445  }
446  return StatusCode::FAILURE;
447  }
449  template <class TYPE>
450  StatusCode i_addItem( const std::string& name, long dim1, long dim2, const std::string& index, TYPE low, TYPE high,
451  _Matrix<TYPE>*& result ) {
452  if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
453  return add( result =
454  _Matrix<TYPE>::create( this, name, typeid( TYPE ), index, dim1, dim2, low, high, TYPE( 0 ) ) );
455  }
456  return StatusCode::FAILURE;
457  }
458  template <class TYPE>
459  StatusCode i_addObject( const std::string& name, _Item<TYPE*>*& result, const std::type_info& /* typ */ ) {
460  if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
461  return add( result = (_Item<TYPE*>*)_Item<void*>::create( this, name, typeid( TYPE ), 0, 0, 0 ) );
462  }
463  return StatusCode::FAILURE;
464  }
465 
466  public:
468  template <class TYPE>
470  return i_item( name, result.m_ptr );
471  }
473  template <class TYPE>
474  StatusCode item( const std::string& name, const Item<TYPE>& result ) const {
475  return i_item( name, result.m_ptr );
476  }
478  template <class TYPE>
480  return i_item( name, result.m_ptr );
481  }
483  template <class TYPE>
484  StatusCode item( const std::string& name, const Array<TYPE>& result ) const {
485  return i_item( name, result.m_ptr );
486  }
488  template <class TYPE>
490  return i_item( name, result.m_ptr );
491  }
492 
494  template <class TYPE>
495  StatusCode item( const std::string& name, const Matrix<TYPE>& result ) const {
496  return i_item( name, result.m_ptr );
497  }
498 
512  template <class TYPE>
514  typedef Range<TYPE> _R;
515  return i_addItem( name, 1, "", _R::min(), _R::max(), itm.m_ptr );
516  }
517 
526  template <class TYPE>
528  return i_addObject( name, itm.m_ptr, typeid( TYPE ) );
529  }
530 
540  typedef Range<IOpaqueAddress*> _R;
541  return i_addItem( name, 1, "", _R::min(), _R::max(), itm.m_ptr );
542  }
543 
561  template <class TYPE, class RANGE>
562  StatusCode addItem( const std::string& name, Item<TYPE>& itm, const RANGE low, const RANGE high ) {
563  return i_addItem( name, 1, "", TYPE( low ), TYPE( high ), itm.m_ptr );
564  }
565 
579  template <class TYPE>
581  return i_addItem( name, dim, "", Range<TYPE>::min(), Range<TYPE>::max(), array.m_ptr );
582  }
583 
603  template <class TYPE, class RANGE>
604  StatusCode addItem( const std::string& name, long dim, Array<TYPE>& array, const RANGE low, const RANGE high ) {
605  return i_addItem( name, dim, "", TYPE( low ), TYPE( high ), array.m_ptr );
606  }
607 
638  template <class TYPE, class INDEX, class RANGE>
639  StatusCode addItem( const std::string& name, Item<INDEX>& index, Array<TYPE>& array, const RANGE low,
640  const RANGE high ) {
641  return i_addItem( name, index->range().distance(), index->name(), TYPE( low ), TYPE( high ), array.m_ptr );
642  }
643 
669  template <class TYPE, class INDEX, class RANGE>
671  const RANGE high ) {
672  return i_addItem( name, index->range().distance(), index->name(), TYPE( low ), TYPE( high ), array.m_ptr );
673  }
674 
699  template <class TYPE, class INDEX>
701  return i_addItem( name, index->range().distance(), index->name(), Range<TYPE>::min(), Range<TYPE>::max(),
702  array.m_ptr );
703  }
704 
724  template <class TYPE, class INDEX>
726  return i_addItem( name, index->range().distance(), index->name(), Range<TYPE>::min(), Range<TYPE>::max(),
727  array.m_ptr );
728  }
729 
747  template <class TYPE>
748  StatusCode addItem( const std::string& name, long cols, long rows, Matrix<TYPE>& matrix ) {
749  return i_addItem( name, cols, rows, "", Range<TYPE>::min(), Range<TYPE>::max(), matrix.m_ptr );
750  }
751 
774  template <class TYPE, class RANGE>
775  StatusCode addItem( const std::string& name, long cols, long rows, Matrix<TYPE>& result, const RANGE low,
776  const RANGE high ) {
777  return i_addItem( name, cols, rows, "", TYPE( low ), TYPE( high ), result.m_ptr );
778  }
779 
805  template <class TYPE, class INDEX>
806  StatusCode addItem( const std::string& name, Item<INDEX>& index, Matrix<TYPE>& matrix, long rows ) {
807  return i_addItem( name, index->range().distance(), rows, index->name(), Range<TYPE>::min(), Range<TYPE>::max(),
808  matrix.m_ptr );
809  }
810 
831  template <class TYPE, class INDEX>
832  StatusCode addIndexedItem( const std::string& name, Item<INDEX>& col_index, long rows, Matrix<TYPE>& matrix ) {
833  return i_addItem( name, col_index->range().distance(), rows, col_index->name(), Range<TYPE>::min(),
834  Range<TYPE>::max(), matrix.m_ptr );
835  }
836 
869  template <class TYPE, class INDEX, class RANGE>
870  StatusCode addItem( const std::string& name, Item<INDEX>& index, Matrix<TYPE>& matrix, long rows, const RANGE low,
871  const RANGE high ) {
872  return i_addItem( name, index->range().distance(), rows, index->name(), TYPE( low ), TYPE( high ), matrix.m_ptr );
873  }
874 
902  template <class TYPE, class INDEX, class RANGE>
903  StatusCode addIndexedItem( const std::string& name, Item<INDEX>& index, long rows, Matrix<TYPE>& matrix,
904  const RANGE low, const RANGE high ) {
905  return i_addItem( name, index->range().distance(), rows, index->name(), TYPE( low ), TYPE( high ), matrix.m_ptr );
906  }
907  };
908 
913  static const CLID& classID() { return CLID_NTupleDirectory; }
915  const CLID& clID() const override { return classID(); }
916  };
917 
920  class File : public Directory {
921  protected:
927  long m_type = 0;
929  bool m_isOpen = false;
930 
931  public:
932  File() = default;
935  : m_name( std::move( name ) ), m_logName( std::move( logName ) ), m_type( type ) {}
936 
938  static const CLID& classID() { return CLID_NTupleFile; }
940  const CLID& clID() const override { return classID(); }
942  void setType( const long typ ) { m_type = typ; }
944  long type() const { return m_type; }
946  const std::string& name() const { return m_name; }
948  void setName( std::string nam ) { m_name = std::move( nam ); }
950  const std::string& logicalName() const { return m_logName; }
954  void setOpen( bool flag ) { m_isOpen = flag; }
956  bool isOpen() const { return m_isOpen; }
957  };
958  // =========================================================================
959  // inhibit certain types by defining specialized templates which do not
960  // allow for construction.
961  template <>
963  Array() = delete;
964 
965  public:
966  virtual ~Array() = default;
967  virtual void dummy() = 0;
968  };
969  template <>
971  Matrix() = delete;
972 
973  public:
974  virtual ~Matrix() = default;
975  virtual void dummy() = 0;
976  };
977 // =========================================================================
978 #ifndef ALLOW_ALL_TYPES
979 #else
980  typedef Item<bool> BoolItem;
981  typedef Item<char> CharItem;
982  typedef Item<unsigned char> UCharItem;
983  typedef Item<short> ShortItem;
984  typedef Item<unsigned short> UShortItem;
985  typedef Item<long> LongItem;
986  typedef Item<long long> LongLongItem;
987  typedef Item<unsigned long> ULongItem;
988  typedef Item<unsigned long long> ULongLongItem;
989  typedef Item<int> IntItem;
990  typedef Item<unsigned int> UIntItem;
991  typedef Item<float> FloatItem;
992  typedef Item<double> DoubleItem;
993  typedef Array<bool> BoolArray;
994  typedef Array<char> CharArray;
995  typedef Array<unsigned char> UCharArray;
996  typedef Array<short> ShortArray;
997  typedef Array<unsigned short> UShortArray;
998  typedef Array<long> LongArray;
999  typedef Array<unsigned long> ULongArray;
1000  typedef Array<int> IntArray;
1001  typedef Array<unsigned int> UIntArray;
1002  typedef Array<float> FloatArray;
1003  typedef Array<double> DoubleArray;
1004  typedef Matrix<bool> BoolMatrix;
1005  typedef Matrix<char> CharMatrix;
1006  typedef Matrix<unsigned char> UCharMatrix;
1007  typedef Matrix<short> ShortMatrix;
1008  typedef Matrix<unsigned short> UShortMatrix;
1009  typedef Matrix<long> LongMatrix;
1010  typedef Matrix<unsigned long> ULongMatrix;
1011  typedef Matrix<int> IntMatrix;
1012  typedef Matrix<unsigned int> UIntMatrix;
1013  typedef Matrix<float> FloatMatrix;
1014  typedef Matrix<double> DoubleMatrix;
1015 #endif
1016 
1017  template <class T>
1018  inline std::ostream& operator<<( std::ostream& s, const Item<T>& obj ) {
1019  return s << T( obj );
1020  }
1021 } // end of namespace NTuple
1022 
1023 // Useful:
1027 
1028 #endif // GAUDIKERNEL_NTUPLE_H
Item< TYP > & operator *=(const TYP data)
Definition: NTuple.h:292
const TYP * column(long i) const
Access to data by reference (CONST)
Definition: NTuple.h:220
StatusCode addItem(const std::string &name, Item< INDEX > &index, Matrix< TYPE > &matrix, long rows, const RANGE low, const RANGE high)
Add an variable size Matrix of data to a column wise N tuple.
Definition: NTuple.h:870
Item< bool > _My
Definition: NTuple.h:306
const TYP & data(long i) const
Access to data by reference (CONST)
Definition: NTuple.h:185
Item< TYP > & operator/=(const TYP data)
Definition: NTuple.h:296
Item< TYP > & operator+=(const TYP data)
Definition: NTuple.h:284
void setOpen(bool flag)
Set "open" flag.
Definition: NTuple.h:954
File(long type, std::string name, std::string logName)
Standard constructor.
Definition: NTuple.h:934
const TYP * operator->() const
Dereference operator (CONST)
Definition: NTuple.h:248
std::ostream & operator<<(std::ostream &s, const Item< T > &obj)
Definition: NTuple.h:1018
Item & operator--(int)
Definition: NTuple.h:272
TYP m_lower
Lower boundary of range.
Definition: NTuple.h:68
bool lower() const
Lower boundary of range.
Definition: NTuple.h:107
StatusCode addItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array)
Add an indexed Array of data to a column wise N tuple.
Definition: NTuple.h:700
StatusCode i_item(const std::string &name, _Matrix< TYPE > *&result) const
Locate a _Matrix of data to the N tuple type safe.
Definition: NTuple.h:422
bool operator!() const
Check if column is present.
Definition: NTuple.h:242
_Accessor()=default
Standard Constructor.
Matrix()=default
Standard Constructor.
bool distance() const
Distance between lower and upper range.
Definition: NTuple.h:111
std::string m_logName
Logical file name.
Definition: NTuple.h:925
StatusCode addItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array, const RANGE low, const RANGE high)
Add an indexed Array of data to a column wise N tuple with a range.
Definition: NTuple.h:639
StatusCode addIndexedItem(const std::string &name, Item< INDEX > &index, long rows, Matrix< TYPE > &matrix, const RANGE low, const RANGE high)
Add an variable size Matrix of data to a column wise N tuple.
Definition: NTuple.h:903
Abstract class describing a matrix column in a N tuple.
Definition: NTuple.h:54
StatusCode item(const std::string &name, const Array< TYPE > &result) const
Locate a Array of data to the N tuple type safe (CONST)
Definition: NTuple.h:484
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:62
StatusCode i_addItem(const std::string &name, long dim1, long dim2, const std::string &index, TYPE low, TYPE high, _Matrix< TYPE > *&result)
Add a _Item of data to the N tuple.
Definition: NTuple.h:450
Item & operator++(int)
Definition: NTuple.h:270
long m_type
Access type.
Definition: NTuple.h:927
Abstract class describing a column in a N tuple.
Definition: NTuple.h:50
Range< TYP > ItemRange
Set type definition to make life more easy easy.
Definition: NTuple.h:137
TYP & operator[](const T i)
Array operator.
Definition: NTuple.h:341
SmartDataPtr< NTuple::File > NTupleFilePtr
Definition: NTuple.h:1026
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:212
virtual StatusCode add(INTupleItem *item)=0
Add an item row to the N tuple.
_Array< TYP > & operator=(const _Array< T > &copy)
Assignment operator.
Definition: NTuple.h:174
TYP * begin()
Definition: NTuple.h:189
static TYP min()
Minimal number of data.
Definition: NTuple.h:92
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
TYP * operator->()
Dereference operator.
Definition: NTuple.h:246
STL namespace.
StatusCode addItem(const std::string &name, long cols, long rows, Matrix< TYPE > &matrix)
Add an fixed size Matrix of data to a column wise N tuple.
Definition: NTuple.h:748
Item & operator--()
Definition: NTuple.h:271
TYP * column(long i)
Access to data by reference.
Definition: NTuple.h:218
T copy_n(T... args)
_Matrix< TYP > & operator=(const _Matrix< T > &copy)
Assignment operator.
Definition: NTuple.h:207
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
Definition: EventIDBase.h:225
SmartDataPtr< NTuple::Tuple > NTuplePtr
Definition: NTuple.h:1024
StatusCode item(const std::string &name, const Item< TYPE > &result) const
Locate a scalar Item of data to the N tuple type safe (CONST)
Definition: NTuple.h:474
const std::string & name() const
Retrun physical file name.
Definition: NTuple.h:946
StatusCode addIndexedItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array, const RANGE low, const RANGE high)
Add an indexed Array of data to a column wise N tuple with a range.
Definition: NTuple.h:670
const TYP * operator[](const T i) const
Array operator.
Definition: NTuple.h:374
NTuple name space.
Definition: INTupleSvc.h:19
StatusCode addItem(const std::string &name, Item< INDEX > &index, Matrix< TYPE > &matrix, long rows)
Add an variable size Matrix of data to a column wise N tuple.
Definition: NTuple.h:806
static const CLID & classID()
class ID of the object
Definition: NTuple.h:938
STL class.
void set(const TYP &item)
Access to data by reference.
Definition: NTuple.h:159
T min(T... args)
NTuple interface class definition.
Definition: INTuple.h:91
Matrix & operator=(const Matrix< T > &copy)
Assignment operator.
Definition: NTuple.h:363
StatusCode addIndexedItem(const std::string &name, Item< INDEX > &col_index, long rows, Matrix< TYPE > &matrix)
Add an variable size Matrix of data to a column wise N tuple.
Definition: NTuple.h:832
StatusCode addIndexedItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array)
Add an indexed Array of data to a column wise N tuple.
Definition: NTuple.h:725
StatusCode i_item(const std::string &name, _Item< TYPE * > *&result) const
Locate a _Column of data to the N tuple type unsafe for objects.
Definition: NTuple.h:398
File()=default
Item< TYP > & operator-=(const TYP data)
Definition: NTuple.h:288
NTuple interface class definition.
Definition: INTuple.h:37
TYP distance() const
Distance between lower and upper range.
Definition: NTuple.h:90
const CLID & clID() const override
class ID of the object
Definition: NTuple.h:940
static const CLID & classID()
class ID of the object
Definition: NTuple.h:913
Class acting as a smart pointer holding a N tuple entry.
Definition: NTuple.h:56
StatusCode i_item(const std::string &name, _Array< TYPE > *&result) const
Locate a _Array of data to the N tuple type safe.
Definition: NTuple.h:414
const Range< TYP > & range() const
Access the range.
Definition: NTuple.h:250
static bool max()
Maximal number of data.
Definition: NTuple.h:115
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
_Item< TYP > & operator=(const _Item< T > &copy)
Assignment operator.
Definition: NTuple.h:154
virtual ~Range()=default
Destructor.
StatusCode addItem(const std::string &name, Item< TYPE > &itm, const RANGE low, const RANGE high)
Add a scalar data item a N tuple with a range.
Definition: NTuple.h:562
void setName(std::string nam)
Set access type.
Definition: NTuple.h:948
StatusCode addItem(const std::string &name, long cols, long rows, Matrix< TYPE > &result, const RANGE low, const RANGE high)
Add an fixed size Matrix of data to a column wise N tuple.
Definition: NTuple.h:775
void setLogicalName(std::string l)
Definition: NTuple.h:952
static TYP max()
Maximal number of data.
Definition: NTuple.h:94
Item & operator=(const Item< T > &data)
Assignment operator.
Definition: NTuple.h:320
std::string m_name
Physical file name.
Definition: NTuple.h:923
StatusCode i_addObject(const std::string &name, _Item< TYPE * > *&result, const std::type_info &)
Definition: NTuple.h:459
Specialization acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:305
StatusCode addItem(const std::string &name, long dim, Array< TYPE > &array)
Add an fixed-size Array of data to a column wise N tuple.
Definition: NTuple.h:580
Abstract class describing basic data in an Ntuple.
Definition: NTuple.h:48
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
T max(T... args)
StatusCode addItem(const std::string &name, Item< IOpaqueAddress * > &itm)
Add an address object item to an N tuple: specialized call.
Definition: NTuple.h:539
Range(const Range< TYP > &copy)
Copy constructor.
Definition: NTuple.h:76
StatusCode i_item(const std::string &name, _Item< IOpaqueAddress * > *&result) const
Locate a _Column of data to the N tuple type safe.
Definition: NTuple.h:406
T move(T... args)
virtual TYP get() const
Access to data by reference (CONST)
Definition: NTuple.h:161
const std::string & logicalName() const
Definition: NTuple.h:950
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:385
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Definition: DataObject.cpp:72
void setType(const long typ)
Set access type.
Definition: NTuple.h:942
dictionary l
Definition: gaudirun.py:543
bool m_isOpen
Flag to indicate wether the file was opened already.
Definition: NTuple.h:929
std::vector< Row > Matrix
Definition: Vector.h:30
TYP * end()
Definition: NTuple.h:351
TYP * m_ptr
Pointer to instance.
Definition: NTuple.h:234
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
StatusCode item(const std::string &name, const Matrix< TYPE > &result) const
Locate a Matrix of data to the N tuple type safe (CONST)
Definition: NTuple.h:495
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Definition: DataObject.cpp:66
StatusCode addItem(const std::string &name, Item< TYPE * > &itm)
Add an simple object item to an N tuple.
Definition: NTuple.h:527
StatusCode i_addItem(const std::string &name, long dim, const std::string &index, TYPE low, TYPE high, _Array< TYPE > *&result)
Add a _Item of data to the N tuple.
Definition: NTuple.h:441
Item< TYP > _My
Definition: NTuple.h:257
Item & operator=(const bool data)
Assignment operator.
Definition: NTuple.h:314
StatusCode item(const std::string &name, Array< TYPE > &result)
Locate a Array of data to the N tuple type safe.
Definition: NTuple.h:479
Item & operator=(const Item< T > &data)
Assignment operator.
Definition: NTuple.h:280
TYP * begin()
Definition: NTuple.h:350
const CLID & clID() const override
class ID of the object
Definition: NTuple.h:915
TYP * operator[](const T i)
Array operator.
Definition: NTuple.h:369
virtual INTupleItem * i_find(const std::string &name) const =0
Internally used by abstract classes.
Item & operator=(const TYP data)
Assignment operator.
Definition: NTuple.h:274
string s
Definition: gaudirun.py:328
A small class used to access easily (and efficiently) data items residing in data stores.
Definition: SmartDataPtr.h:57
StatusCode addItem(const std::string &name, Item< TYPE > &itm)
Add a scalar data item a N tuple.
Definition: NTuple.h:513
constexpr static const auto FAILURE
Definition: StatusCode.h:97
long m_rows
Number of rows per column.
Definition: NTuple.h:199
TYP m_upper
Upper boundary of range.
Definition: NTuple.h:70
Class defining a range.
Definition: NTuple.h:46
Range(const Range< bool > &)
Copy constructor.
Definition: NTuple.h:103
SmartDataPtr< NTuple::Directory > NTupleDirPtr
Definition: NTuple.h:1025
const TYP & operator[](const T i) const
Array operator.
Definition: NTuple.h:346
TYP lower() const
Lower boundary of range.
Definition: NTuple.h:86
Small class representing an N tuple directory in the transient store.
Definition: NTuple.h:911
bool isOpen() const
Access "open" flag.
Definition: NTuple.h:956
TYP operator *()
Dereference operator for pointers.
Definition: NTuple.h:265
Array & operator=(const Array< T > &copy)
Assignment operator.
Definition: NTuple.h:335
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
Range(const bool, const bool)
Standard constructor.
Definition: NTuple.h:101
StatusCode item(const std::string &name, Item< TYPE > &result)
Locate a scalar Item of data to the N tuple type safe.
Definition: NTuple.h:469
StatusCode i_item(const std::string &name, _Item< TYPE > *&result) const
Locate a _Column of data to the N tuple type safe.
Definition: NTuple.h:390
Opaque address interface definition.
Item()=default
Standard Constructor.
StatusCode addItem(const std::string &name, long dim, Array< TYPE > &array, const RANGE low, const RANGE high)
Add an fixed-size Array of data to a column wise N tuple with a range.
Definition: NTuple.h:604
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:58
KeyedObjectManager< array > Array
Forward declaration of specialized redirection array object manager.
Array()=default
Standard Constructor.
Class acting as a smart pointer holding a N tuple _Item.
Definition: NTuple.h:60
static bool min()
Minimal number of data.
Definition: NTuple.h:113
#define GAUDI_API
Definition: Kernel.h:81
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
_Accessor< TYP > & operator=(const _Accessor< TYP > &)
Definition: NTuple.h:230
TYP * end()
Definition: NTuple.h:190
Item & operator++()
Definition: NTuple.h:269
STL class.
StatusCode item(const std::string &name, Matrix< TYPE > &result)
Locate a Matrix of data to the N tuple type safe.
Definition: NTuple.h:489
StatusCode i_addItem(const std::string &name, long, const std::string &, TYPE low, TYPE high, _Item< TYPE > *&result)
Add a _Item of data to the N tuple.
Definition: NTuple.h:430
TYP & data(long i)
Access to data by reference (CONST)
Definition: NTuple.h:187
TYP upper() const
Upper boundary of range.
Definition: NTuple.h:88
long type() const
Return access type.
Definition: NTuple.h:944
Range & operator=(const Range< TYP > &copy)
Adjust ranges.
Definition: NTuple.h:78
Small class representing an N tuple file in the transient store.
Definition: NTuple.h:920
virtual ~_Accessor()=default
Standard Destructor.
Range(TYP low, TYP upper)
Standard constructor.
Definition: NTuple.h:74
bool upper() const
Upper boundary of range.
Definition: NTuple.h:109
Abstract class describing a column-array in a N tuple.
Definition: NTuple.h:52