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;
129 ~
_Item()
override =
default;
140 *this->m_buffer = copy.
get();
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> {
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; }
222 template <
class TYP>
class _Accessor {
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(); }
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->());
340 ~Array()
override =
default;
345 template <
class TYP>
class Matrix :
virtual public _Accessor< _Matrix<TYP> > {
352 *(this->
m_ptr) = *(copy.operator->());
411 if (
clID() == CLID_ColumnWiseTuple ) {
424 if (
clID() == CLID_ColumnWiseTuple ) {
434 template <
class TYPE>
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);
609 return i_addItem( name, 1,
"", TYPE(low), TYPE(high), itm.m_ptr);
702 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode
710 index->range().distance(),
742 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode
750 index->range().distance(),
787 index->range().distance(),
819 index->range().distance(),
929 index->range().distance(),
964 col_index->range().distance(),
1004 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode
1013 index->range().distance(),
1048 template <
class TYPE,
class INDEX,
class RANGE>
StatusCode
1057 index->range().distance(),
1078 return CLID_NTupleDirectory;
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.
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.
KeyedObjectManager< array > Array
Forward declaration of specialized redirection array object manager.
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.
_Accessor()=default
Standard Constructor.
Matrix()=default
Standard Constructor.
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.
const CLID & clID() const override
class ID of the object
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
virtual StatusCode add(INTupleItem *item)=0
Add an item row to the N tuple.
_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.
~Directory() override=default
Standard destructor.
SmartDataPtr< NTuple::Tuple > NTuplePtr
~Array() override=default
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
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, _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.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
const CLID & clID() const override
class ID of the object
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range form arbitrary container
Class acting as a smart pointer holding a N tuple entry.
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.
~File() override=default
Standard 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.
~Matrix() override=default
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.
bool operator!() const
Check if column is present.
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 distance() const
Distance between lower and upper range.
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.
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.
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
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.
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()=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.
StatusCode i_item(const std::string &name, _Item< IOpaqueAddress * > *&result) const
Locate a _Column of data to the N tuple type safe.
Array()=default
Standard Constructor.
~Tuple() override=default
Standard destructor.
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.
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
virtual ~_Accessor()=default
Standard Destructor.
virtual long length() const =0
Access the buffer length.
virtual const void * buffer() const =0
Access data buffer (CONST)
Range(TYP low, TYP upper)
Standard constructor.
Abstract class describing a column-array in a N tuple.