11 #ifndef GAUDIKERNEL_NTUPLE_H 12 #define GAUDIKERNEL_NTUPLE_H 33 class NTupleDirectory;
84 virtual ~Range() =
default;
105 virtual ~Range() =
default;
107 bool lower()
const {
return false; }
113 static bool min() {
return false; }
115 static bool max() {
return true; }
133 TYP* m_buffer =
nullptr;
139 virtual void setDefault(
const TYP d ) = 0;
155 *this->m_buffer = copy.get();
159 void set(
const TYP& item ) { *this->m_buffer = item; }
161 virtual TYP
get()
const {
return *this->m_buffer; }
167 class GAUDI_API _Array :
virtual public _Data<TYP> {
171 long len, TYP
min, TYP
max, TYP def );
175 long len = this->length();
176 if ( len == copy.length() ) {
177 const T* source = (
const T*)copy.buffer();
181 throw std::out_of_range(
"N-tuple matrix cannot be copied! The index range does not match!" );
185 const TYP&
data(
long i )
const {
return this->m_buffer[i]; }
187 TYP&
data(
long i ) {
return this->m_buffer[i]; }
189 TYP*
begin() {
return this->m_buffer; }
190 TYP*
end() {
return this->m_buffer + this->length(); }
196 class GAUDI_API _Matrix :
virtual public _Data<TYP> {
204 long ncol,
long nrow, TYP
min, TYP
max, TYP def );
208 long len = this->length();
209 if ( len == copy.length() ) {
210 const T* source = (
const T*)copy.buffer();
214 throw std::out_of_range(
"N-tuple matrix cannot be copied! The index range does not match!" );
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; }
244 operator const void*()
const {
return m_ptr; }
256 class Item :
virtual public _Accessor<_Item<TYP>> {
263 operator const TYP()
const {
return this->
m_ptr->get(); }
275 this->
m_ptr->set( data );
281 this->
m_ptr->set( data->get() );
285 this->
m_ptr->set( this->
m_ptr->get() + data );
289 this->
m_ptr->set( this->
m_ptr->get() - data );
293 this->
m_ptr->set( this->
m_ptr->get() * data );
297 this->
m_ptr->set( this->
m_ptr->get() / data );
312 operator bool()
const {
return this->
m_ptr->get(); }
315 this->
m_ptr->set( data );
321 this->
m_ptr->set( data->get() );
329 class Array :
virtual public _Accessor<_Array<TYP>> {
336 *( this->
m_ptr ) = *( copy.operator->() );
342 return this->
m_ptr->data( i );
347 return this->
m_ptr->data( i );
357 class Matrix :
virtual public _Accessor<_Matrix<TYP>> {
364 *( this->
m_ptr ) = *( copy.operator->() );
370 return this->
m_ptr->column( i );
375 return this->
m_ptr->column( i );
389 template <
class TYPE>
393 }
catch ( ... ) { result =
nullptr; }
397 template <
class TYPE>
402 }
catch ( ... ) { result =
nullptr; }
409 }
catch ( ... ) { result =
nullptr; }
413 template <
class TYPE>
417 }
catch ( ... ) { result =
nullptr; }
421 template <
class TYPE>
425 }
catch ( ... ) { result =
nullptr; }
429 template <
class TYPE>
440 template <
class TYPE>
449 template <
class TYPE>
458 template <
class TYPE>
468 template <
class TYPE>
473 template <
class TYPE>
478 template <
class TYPE>
483 template <
class TYPE>
488 template <
class TYPE>
494 template <
class TYPE>
512 template <
class TYPE>
526 template <
class TYPE>
561 template <
class TYPE,
class RANGE>
563 return i_addItem(
name, 1,
"", TYPE( low ), TYPE( high ), itm.m_ptr );
579 template <
class TYPE>
603 template <
class TYPE,
class RANGE>
638 template <
class TYPE,
class INDEX,
class RANGE>
641 return i_addItem(
name, index->range().distance(), index->name(), TYPE( low ), TYPE( high ),
array.m_ptr );
669 template <
class TYPE,
class INDEX,
class RANGE>
672 return i_addItem(
name, index->range().distance(), index->name(), TYPE( low ), TYPE( high ),
array.m_ptr );
699 template <
class TYPE,
class INDEX>
724 template <
class TYPE,
class INDEX>
747 template <
class TYPE>
774 template <
class TYPE,
class RANGE>
777 return i_addItem(
name, cols, rows,
"", TYPE( low ), TYPE( high ), result.m_ptr );
805 template <
class TYPE,
class INDEX>
831 template <
class TYPE,
class INDEX>
869 template <
class TYPE,
class INDEX,
class RANGE>
872 return i_addItem(
name, index->range().distance(), rows, index->name(), TYPE( low ), TYPE( high ), matrix.m_ptr );
902 template <
class TYPE,
class INDEX,
class RANGE>
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 );
966 virtual ~
Array() =
default;
967 virtual void dummy() = 0;
974 virtual ~
Matrix() =
default;
975 virtual void dummy() = 0;
978 #ifndef ALLOW_ALL_TYPES 1019 return s << T( obj );
1028 #endif // GAUDIKERNEL_NTUPLE_H Item< TYP > & operator *=(const TYP data)
const TYP * column(long i) const
Access to data by reference (CONST)
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 TYP & data(long i) const
Access to data by reference (CONST)
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.
const TYP * operator->() const
Dereference operator (CONST)
std::ostream & operator<<(std::ostream &s, const Item< T > &obj)
TYP m_lower
Lower boundary of range.
bool lower() const
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.
StatusCode i_item(const std::string &name, _Matrix< TYPE > *&result) const
Locate a _Matrix of data to the N tuple type safe.
bool operator!() const
Check if column is present.
_Accessor()=default
Standard Constructor.
Matrix()=default
Standard Constructor.
bool distance() const
Distance between lower and upper range.
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.
StatusCode item(const std::string &name, const Array< TYPE > &result) const
Locate a Array of data to the N tuple type safe (CONST)
Class acting as a smart pointer holding a N tuple _Item.
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)
virtual StatusCode add(INTupleItem *item)=0
Add an item row to the N tuple.
_Array< TYP > & operator=(const _Array< T > ©)
Assignment operator.
static TYP min()
Minimal number of data.
constexpr static const auto SUCCESS
TYP * operator->()
Dereference operator.
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.
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 item(const std::string &name, const Item< TYPE > &result) const
Locate a scalar Item of data to the N tuple type safe (CONST)
const std::string & name() const
Retrun physical file name.
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 TYP * operator[](const T i) const
Array operator.
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
void set(const TYP &item)
Access to data by reference.
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, _Item< TYPE * > *&result) const
Locate a _Column of data to the N tuple type unsafe for objects.
Item< TYP > & operator-=(const TYP data)
NTuple interface class definition.
TYP distance() const
Distance between lower and upper range.
const CLID & clID() const override
class ID of the object
static const CLID & classID()
class ID of the object
Class acting as a smart pointer holding a N tuple entry.
StatusCode i_item(const std::string &name, _Array< TYPE > *&result) const
Locate a _Array of data to the N tuple type safe.
const Range< TYP > & range() const
Access the range.
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.
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.
Abstract class describing basic data in an Ntuple.
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.
StatusCode i_item(const std::string &name, _Item< IOpaqueAddress * > *&result) const
Locate a _Column of data to the N tuple type safe.
virtual TYP get() const
Access to data by reference (CONST)
const std::string & logicalName() const
Abstract base class which allows the user to interact with the actual N tuple implementation.
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
void setType(const long typ)
Set access type.
bool m_isOpen
Flag to indicate wether the file was opened already.
std::vector< Row > Matrix
TYP * m_ptr
Pointer to instance.
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)
virtual const CLID & clID() const
Retrieve reference to class definition structure.
StatusCode addItem(const std::string &name, Item< TYPE * > &itm)
Add an simple object item to an N tuple.
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 CLID & clID() const override
class ID of the object
TYP * operator[](const T i)
Array operator.
virtual INTupleItem * i_find(const std::string &name) const =0
Internally used by abstract classes.
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
const TYP & operator[](const T i) const
Array operator.
TYP lower() const
Lower boundary of range.
Small class representing an N tuple directory in the transient store.
bool isOpen() const
Access "open" flag.
TYP operator *()
Dereference operator for pointers.
Array & operator=(const Array< T > ©)
Assignment operator.
decltype(auto) range(Args &&... args)
Zips multiple containers together to form a single range.
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.
StatusCode i_item(const std::string &name, _Item< TYPE > *&result) const
Locate a _Column of data to the N tuple type safe.
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.
Class acting as a smart pointer holding a N tuple _Item.
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.
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 > &)
StatusCode item(const std::string &name, Matrix< TYPE > &result)
Locate a Matrix 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)
TYP upper() const
Upper boundary of range.
long type() const
Return access type.
Range & operator=(const Range< TYP > ©)
Adjust ranges.
Small class representing an N tuple file in the transient store.
virtual ~_Accessor()=default
Standard Destructor.
Range(TYP low, TYP upper)
Standard constructor.
bool upper() const
Upper boundary of range.
Abstract class describing a column-array in a N tuple.