1 #ifndef GAUDIKERNEL_NTUPLE_H 2 #define GAUDIKERNEL_NTUPLE_H 23 class NTupleDirectory;
66 Range( TYP low, TYP
upper ) : m_lower(
std::move( low ) ), m_upper(
std::move( upper ) ) {}
68 Range(
const Range<TYP>& copy ) : m_lower( copy.m_lower ), m_upper( copy.m_upper ) {}
77 virtual ~Range() =
default;
95 Range(
const bool ,
const bool ) {}
99 virtual ~Range() =
default;
101 bool lower()
const {
return false; }
107 static bool min() {
return false; }
109 static bool max() {
return true; }
130 TYP* m_buffer =
nullptr;
136 virtual void setDefault(
const TYP d ) = 0;
138 virtual const ItemRange&
range()
const = 0;
148 ~
_Item()
override =
default;
156 *this->m_buffer = copy.
get();
160 void set(
const TYP& item ) { *this->m_buffer = item; }
162 virtual TYP
get()
const {
return *this->m_buffer; }
168 class GAUDI_API _Array :
virtual public _Data<TYP>
173 long len, TYP
min, TYP
max, TYP def );
178 long len = this->length();
179 if ( len == copy.
length() ) {
180 const T* source = (
const T*)copy.
buffer();
184 throw std::out_of_range(
"N-tuple matrix cannot be copied! The index range does not match!" );
188 const TYP&
data(
long i )
const {
return this->m_buffer[i]; }
190 TYP&
data(
long i ) {
return this->m_buffer[i]; }
192 TYP*
begin() {
return this->m_buffer; }
193 TYP*
end() {
return this->m_buffer + this->length(); }
199 class GAUDI_API _Matrix :
virtual public _Data<TYP>
208 long ncol,
long nrow, TYP
min, TYP
max, TYP def );
213 long len = this->length();
214 if ( len == copy.
length() ) {
215 const T* source = (
const T*)copy.
buffer();
219 throw std::out_of_range(
"N-tuple matrix cannot be copied! The index range does not match!" );
223 TYP*
column(
long i ) {
return this->m_buffer + i * m_rows; }
225 const TYP*
column(
long i )
const {
return this->m_buffer + i * m_rows; }
240 mutable TYP* m_ptr =
nullptr;
250 operator const void*()
const {
return m_ptr; }
270 operator const TYP()
const {
return this->m_ptr->get(); }
274 const TYP
operator*()
const {
return this->m_ptr->get(); }
283 this->m_ptr->set( data );
290 this->m_ptr->set( data->get() );
295 this->m_ptr->set( this->m_ptr->get() + data );
300 this->m_ptr->set( this->m_ptr->get() - data );
305 this->m_ptr->set( this->m_ptr->get() * data );
310 this->m_ptr->set( this->m_ptr->get() / data );
326 operator bool()
const {
return this->m_ptr->get(); }
330 this->m_ptr->set( data );
337 this->m_ptr->set( data->get() );
354 *( this->m_ptr ) = *( copy.operator->() );
361 return this->m_ptr->data( i );
367 return this->m_ptr->data( i );
370 TYP*
begin() {
return this->m_ptr->begin(); }
371 TYP*
end() {
return this->m_ptr->end(); }
373 ~
Array()
override =
default;
388 *( this->m_ptr ) = *( copy.operator->() );
395 return this->m_ptr->column( i );
401 return this->m_ptr->column( i );
403 ~
Matrix()
override =
default;
417 template <
class TYPE>
421 result =
dynamic_cast<_Item<TYPE>*
>( i_find( name ) );
428 template <
class TYPE>
450 template <
class TYPE>
454 if ( clID() == CLID_ColumnWiseTuple ) {
463 template <
class TYPE>
467 if ( clID() == CLID_ColumnWiseTuple ) {
476 template <
class TYPE>
479 if ( !i_find( name ) ) {
487 template <
class TYPE>
491 if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
497 template <
class TYPE>
501 if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
507 template <
class TYPE>
510 if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
518 ~
Tuple()
override =
default;
521 template <
class TYPE>
524 return i_item( name, result.
m_ptr );
527 template <
class TYPE>
530 return i_item( name, result.
m_ptr );
533 template <
class TYPE>
536 return i_item( name, result.
m_ptr );
539 template <
class TYPE>
542 return i_item( name, result.
m_ptr );
545 template <
class TYPE>
548 return i_item( name, result.
m_ptr );
552 template <
class TYPE>
555 return i_item( name, result.
m_ptr );
571 template <
class TYPE>
575 return i_addItem( name, 1,
"", _R::min(), _R::max(), itm.
m_ptr );
586 template <
class TYPE>
589 return i_addObject( name, itm.
m_ptr,
typeid( TYPE ) );
603 return i_addItem( name, 1,
"", _R::min(), _R::max(), itm.
m_ptr );
623 template <
class TYPE,
class RANGE>
626 return i_addItem( name, 1,
"", TYPE( low ), TYPE( high ), itm.
m_ptr );
642 template <
class TYPE>
667 template <
class TYPE,
class RANGE>
670 return i_addItem( name, dim,
"", TYPE( low ), TYPE( high ), array.
m_ptr );
703 template <
class TYPE,
class INDEX,
class RANGE>
707 return i_addItem( name, index->
range().distance(), index->name(), TYPE( low ), TYPE( high ), array.
m_ptr );
735 template <
class TYPE,
class INDEX,
class RANGE>
739 return i_addItem( name, index->
range().distance(), index->name(), TYPE( low ), TYPE( high ), array.
m_ptr );
766 template <
class TYPE,
class INDEX>
792 template <
class TYPE,
class INDEX>
816 template <
class TYPE>
844 template <
class TYPE,
class RANGE>
848 return i_addItem( name, cols, rows,
"", TYPE( low ), TYPE( high ), result.
m_ptr );
876 template <
class TYPE,
class INDEX>
903 template <
class TYPE,
class INDEX>
942 template <
class TYPE,
class INDEX,
class RANGE>
946 return i_addItem( name, index->
range().distance(), rows, index->name(), TYPE( low ), TYPE( high ), matrix.
m_ptr );
976 template <
class TYPE,
class INDEX,
class RANGE>
978 const RANGE low,
const RANGE high )
980 return i_addItem( name, index->
range().distance(), rows, index->name(), TYPE( low ), TYPE( high ), matrix.
m_ptr );
997 const CLID&
clID()
const override {
return classID(); }
1012 bool m_isOpen =
false;
1018 : m_name(
std::move( name ) ), m_logName(
std::move( logName ) ), m_type( type )
1022 ~
File()
override =
default;
1027 const CLID&
clID()
const override {
return classID(); }
1031 long type()
const {
return m_type; }
1054 virtual ~
Array() =
default;
1055 virtual void dummy() = 0;
1063 virtual ~
Matrix() =
default;
1064 virtual void dummy() = 0;
1067 #ifndef ALLOW_ALL_TYPES 1109 return s << T( obj );
1118 #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.
Item< TYP > & operator/=(const TYP data)
Item< TYP > & operator+=(const TYP data)
void setOpen(bool flag)
Set "open" flag.
File(long type, std::string name, std::string logName)
Standard constructor.
TYP m_lower
Lower boundary of range.
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.
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.
TYP & operator[](const T i)
Array operator.
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.
const TYP * operator[](const T i) const
Array 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.
Item< TYP > & operator-=(const TYP data)
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.
decltype(auto) range(Args &&...args)
Zips multiple containers together to form a single range.
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.
const TYP & operator[](const T i) const
Array operator.
Abstract base class which allows the user to interact with the actual N tuple implementation.
bool operator!() const
Check if column is present.
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)
TYP * operator[](const T i)
Array operator.
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
Item< TYP > & operator*=(const TYP data)
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.
KeyedObjectManager< array > Array
Forward declaration of specialized redirection array object manager.
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.