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;
154 *this->m_buffer = copy.
get();
158 void set(
const TYP& item ) { *this->m_buffer = item; }
160 virtual TYP
get()
const {
return *this->m_buffer; }
166 class GAUDI_API _Array :
virtual public _Data<TYP>
171 long len, TYP
min, TYP
max, TYP def );
176 long len = this->length();
177 if ( len == copy.
length() ) {
178 const T* source = (
const T*)copy.
buffer();
182 throw std::out_of_range(
"N-tuple matrix cannot be copied! The index range does not match!" );
186 const TYP&
data(
long i )
const {
return this->m_buffer[i]; }
188 TYP&
data(
long i ) {
return this->m_buffer[i]; }
190 TYP*
begin() {
return this->m_buffer; }
191 TYP*
end() {
return this->m_buffer + this->length(); }
197 class GAUDI_API _Matrix :
virtual public _Data<TYP>
206 long ncol,
long nrow, TYP
min, TYP
max, TYP def );
211 long len = this->length();
212 if ( len == copy.
length() ) {
213 const T* source = (
const T*)copy.
buffer();
217 throw std::out_of_range(
"N-tuple matrix cannot be copied! The index range does not match!" );
221 TYP*
column(
long i ) {
return this->m_buffer + i * m_rows; }
223 const TYP*
column(
long i )
const {
return this->m_buffer + i * m_rows; }
238 mutable TYP* m_ptr =
nullptr;
248 operator const void*()
const {
return m_ptr; }
268 operator const TYP()
const {
return this->m_ptr->get(); }
272 const TYP
operator*()
const {
return this->m_ptr->get(); }
281 this->m_ptr->set( data );
288 this->m_ptr->set( data->get() );
293 this->m_ptr->set( this->m_ptr->get() + data );
298 this->m_ptr->set( this->m_ptr->get() - data );
303 this->m_ptr->set( this->m_ptr->get() * data );
308 this->m_ptr->set( this->m_ptr->get() / data );
324 operator bool()
const {
return this->m_ptr->get(); }
328 this->m_ptr->set( data );
335 this->m_ptr->set( data->get() );
352 *( this->m_ptr ) = *( copy.operator->() );
359 return this->m_ptr->data( i );
365 return this->m_ptr->data( i );
368 TYP*
begin() {
return this->m_ptr->begin(); }
369 TYP*
end() {
return this->m_ptr->end(); }
384 *( this->m_ptr ) = *( copy.operator->() );
391 return this->m_ptr->column( i );
397 return this->m_ptr->column( i );
412 template <
class TYPE>
416 result =
dynamic_cast<_Item<TYPE>*
>( i_find( name ) );
423 template <
class TYPE>
445 template <
class TYPE>
449 if ( clID() == CLID_ColumnWiseTuple ) {
458 template <
class TYPE>
462 if ( clID() == CLID_ColumnWiseTuple ) {
471 template <
class TYPE>
474 if ( !i_find( name ) ) {
482 template <
class TYPE>
486 if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
492 template <
class TYPE>
496 if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
502 template <
class TYPE>
505 if ( !i_find( name ) && clID() == CLID_ColumnWiseTuple ) {
513 template <
class TYPE>
516 return i_item( name, result.
m_ptr );
519 template <
class TYPE>
522 return i_item( name, result.
m_ptr );
525 template <
class TYPE>
528 return i_item( name, result.
m_ptr );
531 template <
class TYPE>
534 return i_item( name, result.
m_ptr );
537 template <
class TYPE>
540 return i_item( name, result.
m_ptr );
544 template <
class TYPE>
547 return i_item( name, result.
m_ptr );
563 template <
class TYPE>
567 return i_addItem( name, 1,
"", _R::min(), _R::max(), itm.
m_ptr );
578 template <
class TYPE>
581 return i_addObject( name, itm.
m_ptr,
typeid( TYPE ) );
595 return i_addItem( name, 1,
"", _R::min(), _R::max(), itm.
m_ptr );
615 template <
class TYPE,
class RANGE>
618 return i_addItem( name, 1,
"", TYPE( low ), TYPE( high ), itm.
m_ptr );
634 template <
class TYPE>
659 template <
class TYPE,
class RANGE>
662 return i_addItem( name, dim,
"", TYPE( low ), TYPE( high ), array.
m_ptr );
695 template <
class TYPE,
class INDEX,
class RANGE>
699 return i_addItem( name, index->
range().distance(), index->name(), TYPE( low ), TYPE( high ), array.
m_ptr );
727 template <
class TYPE,
class INDEX,
class RANGE>
731 return i_addItem( name, index->
range().distance(), index->name(), TYPE( low ), TYPE( high ), array.
m_ptr );
758 template <
class TYPE,
class INDEX>
784 template <
class TYPE,
class INDEX>
808 template <
class TYPE>
836 template <
class TYPE,
class RANGE>
840 return i_addItem( name, cols, rows,
"", TYPE( low ), TYPE( high ), result.
m_ptr );
868 template <
class TYPE,
class INDEX>
895 template <
class TYPE,
class INDEX>
934 template <
class TYPE,
class INDEX,
class RANGE>
938 return i_addItem( name, index->
range().distance(), rows, index->name(), TYPE( low ), TYPE( high ), matrix.
m_ptr );
968 template <
class TYPE,
class INDEX,
class RANGE>
970 const RANGE low,
const RANGE high )
972 return i_addItem( name, index->
range().distance(), rows, index->name(), TYPE( low ), TYPE( high ), matrix.
m_ptr );
982 const CLID&
clID()
const override {
return classID(); }
997 bool m_isOpen =
false;
1003 : m_name(
std::move( name ) ), m_logName(
std::move( logName ) ), m_type( type )
1010 const CLID&
clID()
const override {
return classID(); }
1014 long type()
const {
return m_type; }
1037 virtual ~
Array() =
default;
1038 virtual void dummy() = 0;
1046 virtual ~
Matrix() =
default;
1047 virtual void dummy() = 0;
1050 #ifndef ALLOW_ALL_TYPES 1092 return s << T( obj );
1101 #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.
constexpr static const auto FAILURE
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.
std::vector< Row > Matrix
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.
constexpr static const auto SUCCESS
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)
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)
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.