Go to the documentation of this file.
11 #ifndef GAUDIKERNEL_NTUPLE_H
12 #define GAUDIKERNEL_NTUPLE_H
33 class NTupleDirectory;
107 bool lower()
const {
return false; }
113 static bool min() {
return false; }
115 static bool max() {
return true; }
133 TYP* m_buffer =
nullptr;
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; }
247 operator const void*()
const {
return m_ptr; }
259 class Item :
virtual public _Accessor<_Item<TYP>> {
266 operator const TYP()
const {
return this->m_ptr->get(); }
270 const TYP
operator*()
const {
return this->m_ptr->get(); }
278 this->m_ptr->set( data );
284 this->m_ptr->set( data->get() );
288 this->m_ptr->set( this->m_ptr->get() + data );
292 this->m_ptr->set( this->m_ptr->get() - data );
296 this->m_ptr->set( this->m_ptr->get() * data );
300 this->m_ptr->set( this->m_ptr->get() / data );
315 operator bool()
const {
return this->m_ptr->get(); }
318 this->m_ptr->set( data );
324 this->m_ptr->set( data->get() );
332 class Array :
virtual public _Accessor<_Array<TYP>> {
339 *( this->m_ptr ) = *( copy.operator->() );
345 return this->m_ptr->data( i );
350 return this->m_ptr->data( i );
353 TYP*
begin() {
return this->m_ptr->begin(); }
354 TYP*
end() {
return this->m_ptr->end(); }
360 class Matrix :
virtual public _Accessor<_Matrix<TYP>> {
367 *( this->m_ptr ) = *( copy.operator->() );
373 return this->m_ptr->column( i );
378 return this->m_ptr->column( i );
392 template <
class TYPE>
396 }
catch ( ... ) { result =
nullptr; }
400 template <
class TYPE>
405 }
catch ( ... ) { result =
nullptr; }
412 }
catch ( ... ) { result =
nullptr; }
416 template <
class TYPE>
420 }
catch ( ... ) { result =
nullptr; }
424 template <
class TYPE>
428 }
catch ( ... ) { result =
nullptr; }
432 template <
class TYPE>
443 template <
class TYPE>
452 template <
class TYPE>
461 template <
class TYPE>
471 template <
class TYPE>
476 template <
class TYPE>
481 template <
class TYPE>
486 template <
class TYPE>
491 template <
class TYPE>
497 template <
class TYPE>
515 template <
class TYPE>
518 return i_addItem(
name, 1,
"", _R::min(), _R::max(), itm.m_ptr );
529 template <
class TYPE>
544 return i_addItem(
name, 1,
"", _R::min(), _R::max(), itm.m_ptr );
564 template <
class TYPE,
class RANGE>
566 return i_addItem(
name, 1,
"", TYPE( low ), TYPE( high ), itm.m_ptr );
582 template <
class TYPE>
606 template <
class TYPE,
class RANGE>
641 template <
class TYPE,
class INDEX,
class RANGE>
672 template <
class TYPE,
class INDEX,
class RANGE>
702 template <
class TYPE,
class INDEX>
727 template <
class TYPE,
class INDEX>
750 template <
class TYPE>
777 template <
class TYPE,
class RANGE>
780 return i_addItem(
name, cols, rows,
"", TYPE( low ), TYPE( high ), result.m_ptr );
808 template <
class TYPE,
class INDEX>
834 template <
class TYPE,
class INDEX>
872 template <
class TYPE,
class INDEX,
class RANGE>
875 return i_addItem(
name,
index->range().distance(), rows,
index->name(), TYPE( low ), TYPE( high ), matrix.m_ptr );
905 template <
class TYPE,
class INDEX,
class RANGE>
907 const RANGE low,
const RANGE high ) {
908 return i_addItem(
name,
index->range().distance(), rows,
index->name(), TYPE( low ), TYPE( high ), matrix.m_ptr );
981 #ifndef ALLOW_ALL_TYPES
1022 return s << T( obj );
1031 #endif // GAUDIKERNEL_NTUPLE_H
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.
virtual const ItemRange & range() const =0
Access the range if specified.
_Array< TYP > & operator=(const _Array< T > ©)
Assignment operator.
Range(const bool, const bool)
Standard constructor.
Item & operator=(const bool data)
Assignment operator.
const Range< TYP > & range() const
Access the range.
KeyedObjectManager< array > Array
Forward declaration of specialized redirection array object manager.
const std::string & name() const
Retreive DataObject name. It is the name when registered in the store.
Small class representing an N tuple file in the transient store.
Item()=default
Standard Constructor.
TYP & operator[](const T i)
Array operator.
StatusCode i_item(const std::string &name, _Item< IOpaqueAddress * > *&result) const
Locate a _Column of data to the N tuple type safe.
TYP * m_ptr
Pointer to instance.
bool lower() const
Lower boundary of range.
virtual INTupleItem * i_find(const std::string &name) const =0
Internally used by abstract classes.
void setLogicalName(std::string l)
Small class representing an N tuple directory in the transient store.
StatusCode i_addObject(const std::string &name, _Item< TYPE * > *&result, const std::type_info &)
StatusCode i_item(const std::string &name, _Array< TYPE > *&result) const
Locate a _Array of data to the N tuple type safe.
File(long type, std::string name, std::string logName)
Standard constructor.
virtual ~Range()=default
Destructor.
_Accessor()=default
Standard Constructor.
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.
const CLID & clID() const override
class ID of the object
std::ostream & operator<<(std::ostream &s, const Item< T > &obj)
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()=default
Standard Constructor.
StatusCode addItem(const std::string &name, Item< IOpaqueAddress * > &itm)
Add an address object item to an N tuple: specialized call.
Class acting as a smart pointer holding a N tuple entry.
const TYP * operator[](const T i) const
Array operator.
TYP * operator[](const T i)
Array operator.
Abstract class describing a column in a N tuple.
const TYP & data(long i) const
Access to data by reference (CONST)
virtual TYP get() const
Access to data by reference (CONST)
Array & operator=(const Array< T > ©)
Assignment operator.
const TYP * column(long i) const
Access to data by reference (CONST)
std::string m_name
Physical file name.
static const CLID & classID()
class ID of the object
SmartDataPtr< NTuple::Directory > NTupleDirPtr
bool m_isOpen
Flag to indicate wether the file was opened already.
StatusCode i_item(const std::string &name, _Item< TYPE * > *&result) const
Locate a _Column of data to the N tuple type unsafe for objects.
TYP lower() const
Lower boundary of range.
Matrix & operator=(const Matrix< T > ©)
Assignment operator.
StatusCode item(const std::string &name, Item< TYPE > &result)
Locate a scalar Item of data to the N tuple type safe.
StatusCode item(const std::string &name, Matrix< TYPE > &result)
Locate a Matrix of data to the N tuple type safe.
TYP & data(long i)
Access to data by reference (CONST)
bool distance() const
Distance between lower and upper range.
const std::string & logicalName() const
Item< TYP > & operator-=(const TYP data)
_Accessor(const _Accessor &)=default
Default copy constructor.
Abstract class describing basic data in an Ntuple.
_Matrix< TYP > & operator=(const _Matrix< T > ©)
Assignment operator.
SmartDataPtr< NTuple::Tuple > NTuplePtr
static const CLID & classID()
class ID of the object
long m_rows
Number of rows per column.
const TYP & operator[](const T i) const
Array operator.
void setType(const long typ)
Set access type.
long type() const
Return access type.
Item & operator=(const Item< T > &data)
Assignment operator.
Item< TYP > & operator*=(const TYP data)
Item< TYP > & operator/=(const TYP data)
virtual void setDefault(const TYP d)=0
Set default value.
void set(const TYP &item)
Access to data by reference.
static bool max()
Maximal number of data.
Range(const Range< bool > &)
Copy constructor.
TYP * operator->()
Dereference operator.
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 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, const std::string &, TYPE low, TYPE high, _Item< TYPE > *&result)
Add a _Item of data to the N tuple.
const TYP * operator->() const
Dereference operator (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.
StatusCode i_item(const std::string &name, _Item< TYPE > *&result) const
Locate a _Column of data to the N tuple type safe.
unsigned int CLID
Class ID definition.
TYP distance() const
Distance between lower and upper range.
virtual StatusCode add(INTupleItem *item)=0
Add an item row to the N tuple.
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.
SmartDataPtr< NTuple::File > NTupleFilePtr
StatusCode addItem(const std::string &name, Item< TYPE > &itm)
Add a scalar data item a N tuple.
Range(const Range< TYP > ©)
Copy constructor.
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.
TYP upper() const
Upper boundary of range.
Range & operator=(const Range< TYP > ©)
Adjust ranges.
virtual ~Range()=default
Destructor.
static TYP max()
Maximal number of data.
Abstract class describing a column-array in a N tuple.
StatusCode item(const std::string &name, const Item< TYPE > &result) const
Locate a scalar Item of data to the N tuple type safe (CONST)
Class acting as a smart pointer holding a N tuple _Item.
const TYP operator*() const
Dereference operator for pointers(CONST)
constexpr static const auto SUCCESS
Abstract class describing a matrix column in a N tuple.
StatusCode addItem(const std::string &name, Item< INDEX > &index, Array< TYPE > &array)
Add an indexed Array of data to a column wise N tuple.
virtual ~_Accessor()=default
Standard Destructor.
struct GAUDI_API array
Parametrisation class for redirection array - like implementation.
void setName(std::string nam)
Set access type.
A small class used to access easily (and efficiently) data items residing in data stores.
Abstract base class which allows the user to interact with the actual N tuple implementation.
static bool min()
Minimal number of data.
const std::string & name() const
Retrun physical file name.
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.
Item & operator=(const Item< T > &data)
Assignment operator.
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.
virtual ~Matrix()=default
_Accessor< TYP > & operator=(const _Accessor< TYP > &)=delete
Needs to be implemented in derived classes.
StatusCode item(const std::string &name, const Array< TYPE > &result) const
Locate a Array of data to the N tuple type safe (CONST)
std::vector< Row > Matrix
void setOpen(bool flag)
Set "open" flag.
bool isOpen() const
Access "open" flag.
Item< TYP > & operator+=(const TYP data)
_Item< TYP > & operator=(const _Item< T > ©)
Assignment operator.
Matrix()=default
Standard Constructor.
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.
bool operator!() const
Check if column is present.
Specialization acting as a smart pointer holding a N tuple _Item.
constexpr static const auto FAILURE
StatusCode item(const std::string &name, const Matrix< TYPE > &result) const
Locate a Matrix of data to the N tuple type safe (CONST)
StatusCode addItem(const std::string &name, long dim, Array< TYPE > &array)
Add an fixed-size Array of data to a column wise N tuple.
Range(TYP low, TYP upper)
Standard constructor.
TYP m_upper
Upper boundary of range.
TYP m_lower
Lower boundary of range.
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.
Item & operator=(const TYP data)
Assignment operator.
const CLID & clID() const override
class ID of the object
Class acting as a smart pointer holding a N tuple _Item.
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.
TYP * column(long i)
Access to data by reference.
Range< TYP > ItemRange
Set type definition to make life more easy easy.
virtual const CLID & clID() const
Retrieve reference to class definition structure.
Array()=default
Standard Constructor.
static TYP min()
Minimal number of data.
TYP operator*()
Dereference operator for pointers.
bool upper() const
Upper boundary of range.
size_t index(const Gaudi::ParticleProperty *property, const Gaudi::Interfaces::IParticlePropertySvc *service)
helper utility for mapping of Gaudi::ParticleProperty object into non-negative integral sequential id...
StatusCode item(const std::string &name, Array< TYPE > &result)
Locate a Array of data to the N tuple type safe.
Class acting as a smart pointer holding a N tuple _Item.
StatusCode i_item(const std::string &name, _Matrix< TYPE > *&result) const
Locate a _Matrix of data to the N tuple type safe.
std::string m_logName
Logical file name.
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.