1 #ifndef GAUDIKERNEL_NTUPLE_H 2 #define GAUDIKERNEL_NTUPLE_H 23 class NTupleDirectory;
36 template <
class TYP>
class Range;
37 template <
class TYP>
class _Data;
38 template <
class TYP>
class _Item;
42 template <
class TYP>
class Item;
43 template <
class TYP>
class Array;
59 m_upper(copy.m_upper) {
68 virtual ~Range() =
default;
85 Range(
const bool ,
const bool ) {}
89 virtual ~Range() =
default;
91 bool lower()
const {
return false; }
93 bool upper()
const {
return true; }
97 static bool min() {
return false; }
99 static bool max() {
return true; }
114 TYP* m_buffer =
nullptr;
119 virtual void setDefault(
const TYP d) = 0;
121 virtual const ItemRange&
range()
const = 0;
126 template <
class TYP>
class GAUDI_API _Item :
virtual public _Data<TYP> {
129 ~
_Item()
override =
default;
140 *this->m_buffer = copy.
get();
144 void set(
const TYP& item) { *this->m_buffer = item; }
146 virtual TYP
get()
const {
return *this->m_buffer; }
151 template <
class TYP>
class GAUDI_API _Array :
virtual public _Data<TYP> {
154 static _Array* create(
INTuple* tup,
165 long len = this->length();
166 if ( len == copy.
length() ) {
167 const T* source = (
const T*)copy.
buffer();
172 (
"N-tuple matrix cannot be copied! The index range does not match!");
176 const TYP&
data(
long i)
const {
return this->m_buffer[i]; }
178 TYP&
data(
long i) {
return this->m_buffer[i]; }
180 TYP*
begin() {
return this->m_buffer; }
181 TYP*
end() {
return this->m_buffer+this->length(); }
186 template <
class TYP>
class GAUDI_API _Matrix :
virtual public _Data<TYP> {
192 static _Matrix* create(
INTuple* tup,
204 long len = this->length();
205 if ( len == copy.
length() ) {
206 const T* source = (
const T*)copy.
buffer();
211 (
"N-tuple matrix cannot be copied! The index range does not match!");
215 TYP*
column(
long i) {
return this->m_buffer + i*m_rows; }
217 const TYP*
column(
long i)
const {
return this->m_buffer + i*m_rows; }
230 mutable TYP* m_ptr =
nullptr;
239 operator const void*()
const {
return m_ptr; }
250 template <
class TYP>
class Item :
virtual public _Accessor< _Item<TYP> > {
256 operator const TYP ()
const {
return this->m_ptr->get(); }
260 const TYP
operator*()
const {
return this->m_ptr->get(); }
262 Item& operator ++ () {
return *
this += TYP(1); }
263 Item& operator ++ (
int) {
return *
this += TYP(1); }
264 Item& operator -- () {
return *
this -= TYP(1); }
265 Item& operator -- (
int) {
return *
this -= TYP(1); }
268 this->m_ptr->set( data );
274 this->m_ptr->set( data->get() );
278 this->m_ptr->set ( this->m_ptr->get() + data );
282 this->m_ptr->set ( this->m_ptr->get() - data );
286 this->m_ptr->set ( this->m_ptr->get() * data );
290 this->m_ptr->set ( this->m_ptr->get() / data );
303 operator bool ()
const {
return this->m_ptr->get(); }
306 this->m_ptr->set( data );
312 this->m_ptr->set( data->get() );
319 template <
class TYP>
class Array :
virtual public _Accessor < _Array<TYP> > {
326 *(this->m_ptr) = *(copy.operator->());
331 TYP& operator[] (
const T i) {
return this->m_ptr->data(i); }
334 const TYP& operator[] (
const T i)
const {
return this->m_ptr->data(i); }
336 TYP*
begin() {
return this->m_ptr->begin(); }
337 TYP*
end() {
return this->m_ptr->end(); }
340 ~
Array()
override =
default;
345 template <
class TYP>
class Matrix :
virtual public _Accessor< _Matrix<TYP> > {
352 *(this->m_ptr) = *(copy.operator->());
357 TYP* operator[] (
const T i) {
return this->m_ptr->column(i); }
360 const TYP* operator[] (
const T i)
const {
return this->m_ptr->column(i); }
361 ~
Matrix()
override =
default;
377 result =
dynamic_cast< _Item<TYPE>*
> (i_find(name));
411 if ( clID() == CLID_ColumnWiseTuple ) {
424 if ( clID() == CLID_ColumnWiseTuple ) {
434 template <
class TYPE>
441 if ( !i_find(name) ) {
449 template <
class TYPE>
456 if ( !i_find(name) && clID() == CLID_ColumnWiseTuple ) {
469 template <
class TYPE>
477 if ( !i_find(name) && clID() == CLID_ColumnWiseTuple ) {
492 if ( !i_find(name) && clID() == CLID_ColumnWiseTuple ) {
500 ~
Tuple()
override =
default;
506 return i_item(name, result.
m_ptr);
512 return i_item(name, result.
m_ptr);
518 return i_item(name, result.
m_ptr);
524 return i_item(name, result.
m_ptr);
530 return i_item(name, result.
m_ptr);
537 return i_item(name, result.
m_ptr);
556 return i_addItem(name, 1,
"", _R::min(), _R::max(), itm.
m_ptr);
569 return i_addObject(name,itm.
m_ptr,
typeid(TYPE));
583 return i_addItem(name, 1,
"", _R::min(), _R::max(), itm.
m_ptr);
609 return i_addItem( name, 1,
"", TYPE(low), TYPE(high), itm.
m_ptr);
630 return i_addItem(name,
664 return i_addItem(name,
702 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode 709 return i_addItem( name,
710 index->
range().distance(),
742 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode 749 return i_addItem( name,
750 index->
range().distance(),
786 return i_addItem( name,
787 index->
range().distance(),
818 return i_addItem( name,
819 index->
range().distance(),
849 return i_addItem(name,
888 return i_addItem(name,
928 return i_addItem( name,
929 index->
range().distance(),
963 return i_addItem( name,
964 col_index->
range().distance(),
1004 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode 1012 return i_addItem( name,
1013 index->
range().distance(),
1048 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode 1056 return i_addItem( name,
1057 index->
range().distance(),
1078 return CLID_NTupleDirectory;
1097 bool m_isOpen =
false;
1102 : m_name(
std::move(name)), m_logName(
std::move(logName)), m_type(type) {
1109 return CLID_NTupleFile;
1156 virtual ~
Array() =
default;
1157 virtual void dummy() = 0;
1164 virtual ~
Matrix() =
default;
1165 virtual void dummy() = 0;
1168 #ifndef ALLOW_ALL_TYPES 1219 #endif // GAUDIKERNEL_NTUPLE_H 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.
const std::string & name() const
Retrun physical file name.
bool lower() const
Lower boundary of range.
void setOpen(bool flag)
Set "open" flag.
File(long type, std::string name, std::string logName)
Standard constructor.
KeyedObjectManager< array > Array
Forward declaration of specialized redirection array object manager.
TYP m_lower
Lower boundary of range.
bool operator!(const Gaudi::Time &t)
StatusCode addItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array)
Add an indexed Array of data to a column wise N tuple.
std::string m_logName
Logical file name.
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.
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.
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
Abstract class describing a matrix column in a N tuple.
Class acting as a smart pointer holding a N tuple _Item.
StatusCode i_item(const std::string &name, _Item< TYPE > *&result) const
Locate a _Column of data to the N tuple type safe.
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.
Abstract class describing a column in a N tuple.
Range< TYP > ItemRange
Set type definition to make life more easy easy.
SmartDataPtr< NTuple::File > NTupleFilePtr
_Array< TYP > & operator=(const _Array< T > ©)
Assignment operator.
StatusCode item(const std::string &name, const Item< TYPE > &result) const
Locate a scalar Item of data to the N tuple type safe (CONST)
static TYP min()
Minimal number of data.
TYP * operator->()
Dereference operator.
StatusCode item(const std::string &name, const Matrix< TYPE > &result) const
Locate a Matrix of data to the N tuple type safe (CONST)
const TYP operator*() const
Dereference operator for pointers(CONST)
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.
StatusCode item(const std::string &name, const Array< TYPE > &result) const
Locate a Array of data to the N tuple type safe (CONST)
TYP * column(long i)
Access to data by reference.
_Matrix< TYP > & operator=(const _Matrix< T > ©)
Assignment operator.
SmartDataPtr< NTuple::Tuple > NTuplePtr
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.
const Range< TYP > & range() const
Access the range.
virtual TYP get() const
Access to data by reference (CONST)
long type() const
Return access type.
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.
static const CLID & classID()
class ID of the object
NTuple interface class definition.
Matrix & operator=(const Matrix< T > ©)
Assignment operator.
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.
StatusCode addIndexedItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array)
Add an indexed Array of data to a column wise N tuple.
StatusCode i_item(const std::string &name, _Matrix< TYPE > *&result) const
Locate a _Matrix of data to the N tuple type safe.
NTuple interface class definition.
Class acting as a smart pointer holding a N tuple entry.
virtual long length() const =0
Access the buffer length.
static bool max()
Maximal number of data.
This class is used for returning status codes from appropriate routines.
_Item< TYP > & operator=(const _Item< T > ©)
Assignment operator.
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.
void setName(std::string nam)
Set access type.
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.
void setLogicalName(std::string l)
static TYP max()
Maximal number of data.
Item & operator=(const Item< T > &data)
Assignment operator.
bool upper() const
Upper boundary of range.
std::string m_name
Physical file name.
StatusCode i_addObject(const std::string &name, _Item< TYPE * > *&result, const std::type_info &)
Specialization acting as a smart pointer holding a N tuple _Item.
StatusCode addItem(const std::string &name, long dim, Array< TYPE > &array)
Add an fixed-size Array of data to a column wise N tuple.
TYP upper() const
Upper boundary of range.
Abstract class describing basic data in an Ntuple.
bool isOpen() const
Access "open" flag.
unsigned int CLID
Class ID definition.
StatusCode addItem(const std::string &name, Item< IOpaqueAddress * > &itm)
Add an address object item to an N tuple: specialized call.
Range(const Range< TYP > ©)
Copy constructor.
Abstract base class which allows the user to interact with the actual N tuple implementation.
void setType(const long typ)
Set access type.
virtual const void * buffer() const =0
Access data buffer (CONST)
std::vector< Row > Matrix
TYP distance() const
Distance between lower and upper range.
_Item< TYP > * m_ptr
Pointer to instance.
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
StatusCode addItem(const std::string &name, Item< TYPE * > &itm)
Add an simple object item to an N tuple.
const TYP * column(long i) const
Access to data by reference (CONST)
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.
Item & operator=(const bool data)
Assignment operator.
StatusCode item(const std::string &name, Array< TYPE > &result)
Locate a Array of data to the N tuple type safe.
Item & operator=(const Item< T > &data)
Assignment operator.
const TYP & data(long i) const
Access to data by reference (CONST)
Item & operator=(const TYP data)
Assignment operator.
A small class used to access easily (and efficiently) data items residing in data stores...
StatusCode addItem(const std::string &name, Item< TYPE > &itm)
Add a scalar data item a N tuple.
long m_rows
Number of rows per column.
TYP m_upper
Upper boundary of range.
Range(const Range< bool > &)
Copy constructor.
SmartDataPtr< NTuple::Directory > NTupleDirPtr
Array & operator=(const Array< T > ©)
Assignment operator.
const TYP * operator->() const
Dereference operator (CONST)
Range(const bool, const bool)
Standard constructor.
StatusCode item(const std::string &name, Item< TYPE > &result)
Locate a scalar Item of data to the N tuple type safe.
Directory()
Standard constructor.
Opaque address interface definition.
const CLID & clID() const override
class ID of the object
StatusCode i_item(const std::string &name, _Item< TYPE * > *&result) const
Locate a _Column of data to the N tuple type unsafe for objects.
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.
Class acting as a smart pointer holding a N tuple _Item.
StatusCode i_item(const std::string &name, _Item< IOpaqueAddress * > *&result) const
Locate a _Column of data to the N tuple type safe.
Class acting as a smart pointer holding a N tuple _Item.
static bool min()
Minimal number of data.
A DataObject is the base class of any identifiable object on any data store.
Small class representing an N tuple directory in the transient store.
_Accessor< TYP > & operator=(const _Accessor< TYP > &)
bool distance() const
Distance between lower and upper range.
StatusCode item(const std::string &name, Matrix< TYPE > &result)
Locate a Matrix of data to the N tuple type safe.
const std::string & logicalName() const
TYP operator*()
Dereference operator for pointers.
TYP lower() const
Lower boundary of range.
StatusCode i_item(const std::string &name, _Array< TYPE > *&result) const
Locate a _Array of data to the N tuple type safe.
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.
const CLID & clID() const override
class ID of the object
TYP & data(long i)
Access to data by reference (CONST)
Range & operator=(const Range< TYP > ©)
Adjust ranges.
Small class representing an N tuple file in the transient store.
static const CLID & classID()
class ID of the object
Range(TYP low, TYP upper)
Standard constructor.
Abstract class describing a column-array in a N tuple.