1 #ifndef GAUDIKERNEL_NTUPLE_H 2 #define GAUDIKERNEL_NTUPLE_H 23 class NTupleDirectory;
64 Range( TYP low, TYP
upper ) : m_lower(
std::move( low ) ), m_upper(
std::move( upper ) ) {}
66 Range(
const Range<TYP>& copy ) : m_lower( copy.m_lower ), m_upper( copy.m_upper ) {}
74 virtual ~Range() =
default;
91 Range(
const bool ,
const bool ) {}
95 virtual ~Range() =
default;
97 bool lower()
const {
return false; }
99 bool upper()
const {
return true; }
103 static bool min() {
return false; }
105 static bool max() {
return true; }
123 TYP* m_buffer =
nullptr;
129 virtual void setDefault(
const TYP d ) = 0;
131 virtual const ItemRange&
range()
const = 0;
145 *this->m_buffer = copy.
get();
149 void set(
const TYP& item ) { *this->m_buffer = item; }
151 virtual TYP
get()
const {
return *this->m_buffer; }
157 class GAUDI_API _Array :
virtual public _Data<TYP> {
161 long len, TYP
min, TYP
max, TYP def );
165 long len = this->length();
166 if ( len == copy.
length() ) {
167 const T* source = (
const T*)copy.
buffer();
171 throw std::out_of_range(
"N-tuple matrix cannot be copied! The index range does not match!" );
175 const TYP&
data(
long i )
const {
return this->m_buffer[i]; }
177 TYP&
data(
long i ) {
return this->m_buffer[i]; }
179 TYP*
begin() {
return this->m_buffer; }
180 TYP*
end() {
return this->m_buffer + this->length(); }
186 class GAUDI_API _Matrix :
virtual public _Data<TYP> {
194 long ncol,
long nrow, TYP
min, TYP
max, TYP def );
198 long len = this->length();
199 if ( len == copy.
length() ) {
200 const T* source = (
const T*)copy.
buffer();
204 throw std::out_of_range(
"N-tuple matrix cannot be copied! The index range does not match!" );
208 TYP*
column(
long i ) {
return this->m_buffer + i * m_rows; }
210 const TYP*
column(
long i )
const {
return this->m_buffer + i * m_rows; }
224 mutable TYP* m_ptr =
nullptr;
234 operator const void*()
const {
return m_ptr; }
253 operator const TYP()
const {
return this->m_ptr->get(); }
257 const TYP
operator*()
const {
return this->m_ptr->get(); }
265 this->m_ptr->set( data );
271 this->m_ptr->set( data->get() );
275 this->m_ptr->set( this->m_ptr->get() + data );
279 this->m_ptr->set( this->m_ptr->get() - data );
283 this->m_ptr->set( this->m_ptr->get() * data );
287 this->m_ptr->set( this->m_ptr->get() / data );
302 operator bool()
const {
return this->m_ptr->get(); }
305 this->m_ptr->set( data );
311 this->m_ptr->set( data->get() );
326 *( this->m_ptr ) = *( copy.operator->() );
332 return this->m_ptr->data( i );
337 return this->m_ptr->data( i );
340 TYP*
begin() {
return this->m_ptr->begin(); }
341 TYP*
end() {
return this->m_ptr->end(); }
354 *( this->m_ptr ) = *( copy.operator->() );
360 return this->m_ptr->column( i );
365 return this->m_ptr->column( i );
379 template <
class TYPE>
382 result =
dynamic_cast<_Item<TYPE>*
>( i_find( name ) );
383 }
catch ( ... ) { result =
nullptr; }
387 template <
class TYPE>
392 }
catch ( ... ) { result =
nullptr; }
399 }
catch ( ... ) { result =
nullptr; }
403 template <
class TYPE>
406 if ( clID() == CLID_ColumnWiseTuple ) { result =
dynamic_cast<_Array<TYPE>*
>( i_find( name ) ); }
407 }
catch ( ... ) { result =
nullptr; }
411 template <
class TYPE>
414 if ( clID() == CLID_ColumnWiseTuple ) { result =
dynamic_cast<_Matrix<TYPE>*
>( i_find( name ) ); }
415 }
catch ( ... ) { result =
nullptr; }
419 template <
class TYPE>
422 if ( !i_find( name ) ) {
430 template <
class TYPE>
433 if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
439 template <
class TYPE>
442 if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
448 template <
class TYPE>
450 if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
458 template <
class TYPE>
460 return i_item( name, result.
m_ptr );
463 template <
class TYPE>
465 return i_item( name, result.
m_ptr );
468 template <
class TYPE>
470 return i_item( name, result.
m_ptr );
473 template <
class TYPE>
475 return i_item( name, result.
m_ptr );
478 template <
class TYPE>
480 return i_item( name, result.
m_ptr );
484 template <
class TYPE>
486 return i_item( name, result.
m_ptr );
502 template <
class TYPE>
516 template <
class TYPE>
518 return i_addObject( name, itm.
m_ptr,
typeid( TYPE ) );
551 template <
class TYPE,
class RANGE>
553 return i_addItem( name, 1,
"", TYPE( low ), TYPE( high ), itm.
m_ptr );
569 template <
class TYPE>
593 template <
class TYPE,
class RANGE>
595 return i_addItem( name, dim,
"", TYPE( low ), TYPE( high ), array.
m_ptr );
628 template <
class TYPE,
class INDEX,
class RANGE>
631 return i_addItem( name, index->
range().distance(), index->name(), TYPE( low ), TYPE( high ), array.
m_ptr );
659 template <
class TYPE,
class INDEX,
class RANGE>
662 return i_addItem( name, index->
range().distance(), index->name(), TYPE( low ), TYPE( high ), array.
m_ptr );
689 template <
class TYPE,
class INDEX>
714 template <
class TYPE,
class INDEX>
737 template <
class TYPE>
764 template <
class TYPE,
class RANGE>
767 return i_addItem( name, cols, rows,
"", TYPE( low ), TYPE( high ), result.
m_ptr );
795 template <
class TYPE,
class INDEX>
821 template <
class TYPE,
class INDEX>
859 template <
class TYPE,
class INDEX,
class RANGE>
862 return i_addItem( name, index->
range().distance(), rows, index->name(), TYPE( low ), TYPE( high ), matrix.
m_ptr );
892 template <
class TYPE,
class INDEX,
class RANGE>
894 const RANGE low,
const RANGE high ) {
895 return i_addItem( name, index->
range().distance(), rows, index->name(), TYPE( low ), TYPE( high ), matrix.
m_ptr );
905 const CLID&
clID()
const override {
return classID(); }
919 bool m_isOpen =
false;
925 : m_name(
std::move( name ) ), m_logName(
std::move( logName ) ), m_type( type ) {}
930 const CLID&
clID()
const override {
return classID(); }
932 void setType(
const long typ ) { m_type = typ; }
934 long type()
const {
return m_type; }
944 void setOpen(
bool flag ) { m_isOpen = flag; }
956 virtual ~
Array() =
default;
957 virtual void dummy() = 0;
964 virtual ~
Matrix() =
default;
965 virtual void dummy() = 0;
968 #ifndef ALLOW_ALL_TYPES 1009 return s << T( obj );
1018 #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
EventIDBase min(const EventIDBase &lhs, const EventIDBase &rhs)
_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.
constexpr static const auto SUCCESS
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.
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
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.
static const CLID & classID()
class ID of the object
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.
constexpr static const auto FAILURE
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)
Small class representing an N tuple directory in the transient store.
Array & operator=(const Array< T > ©)
Assignment operator.
const CLID & clID() const override
class ID of the object
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.
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.
_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.
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.
Range(TYP low, TYP upper)
Standard constructor.
Abstract class describing a column-array in a N tuple.