Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v38r1p1 (ae26267b)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
Tuples::TupleObj Class Referenceabstract

A simple wrapper class over standard Gaudi NTuple::Tuple facility. More...

#include <GaudiAlg/TupleObj.h>

Inheritance diagram for Tuples::TupleObj:
Collaboration diagram for Tuples::TupleObj:

Classes

class  ColumnStorage
 

Public Types

using Bool = NTuple::Item< bool >
 basics type for various items More...
 
using Char = NTuple::Item< char >
 
using UChar = NTuple::Item< unsigned char >
 
using Short = NTuple::Item< short >
 
using UShort = NTuple::Item< unsigned short >
 
using Int = NTuple::Item< int >
 
using UInt = NTuple::Item< unsigned int >
 
using LongLong = NTuple::Item< long long >
 
using ULongLong = NTuple::Item< unsigned long long >
 
using Float = NTuple::Item< float >
 
using Double = NTuple::Item< double >
 
using Address = NTuple::Item< IOpaqueAddress * >
 
using FArray = NTuple::Array< float >
 
using FMatrix = NTuple::Matrix< float >
 
typedef unsigned short MIndex
 
typedef std::map< std::string, std::string, std::less<> > ItemMap
 

Public Member Functions

virtual ~TupleObj ()
 
StatusCode column (std::string_view name, float value)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, double value)
 Set the value for the selected tuple column If the column does not exist, it will be automatically created and appended to the tuple. More...
 
StatusCode column (std::string_view name, short value)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, short value, short minv, short maxv)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, unsigned short value)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, unsigned short value, unsigned short minv, unsigned short maxv)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, char value)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, char value, char minv, char maxv)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, unsigned char value)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, unsigned char value, unsigned char minv, unsigned char maxv)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, int value)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, int value, int minv, int maxv)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, unsigned int value)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, unsigned int value, unsigned int minv, unsigned int maxv)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, long value)
 Set the value for the selected tuple column. More...
 
StatusCode column (std::string_view name, long value, long minv, long maxv)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, unsigned long value)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, unsigned long value, unsigned long minv, unsigned long maxv)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, long long value)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, long long value, long long minv, long long maxv)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, unsigned long long value)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, unsigned long long value, unsigned long long minv, unsigned long long maxv)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, signed char value)
 Set the value for the selected tuple column. More...
 
StatusCode column (std::string_view name, bool value)
 Set the value for selected tuple column. More...
 
StatusCode column (std::string_view name, IOpaqueAddress *address)
 Put IOpaqueAddress in POOL-based NTuple. More...
 
StatusCode column (IOpaqueAddress *address)
 Put IOpaqueAddress in NTuple. More...
 
template<typename Value , typename... Args>
StatusCode columns (Value &&value, Args &&... args)
 Set the values for several columns simultaneously, for the same object Non-existing columns will be automatically created and appended to the ntuple. More...
 
template<typename Arg , typename... Args>
StatusCode fill (std::string_view fmt, Arg arg, Args... args)
 Set the values for several columns simultaneously. More...
 
template<typename ITERATOR1 , typename ITERATOR2 >
StatusCode farray (std::string_view name, ITERATOR1 &&first, ITERATOR2 &&last, std::string_view length, size_t maxv)
 Add an indexed array (of type float) to N-tuple. More...
 
template<class DATA >
StatusCode farray (std::string_view name, const DATA &data, std::string_view length, const size_t maxv)
 Add an indexed array (of type float) to N-tuple. More...
 
template<class FUNCTION , class ITERATOR >
StatusCode farray (std::string_view name, const FUNCTION &function, ITERATOR first, ITERATOR last, std::string_view length, size_t maxv)
 Put an indexed array into LoKi-style N-Tuple. More...
 
template<typename FunIterator , typename DataIterator >
StatusCode farray_impl (FunIterator first_item, FunIterator last_item, DataIterator first, DataIterator last, std::string_view length, size_t maxv)
 Put arbitrary number of functions from one data array into LoKi-style N-Tuple simultaneously (effective!) More...
 
template<typename DataIterator , template< typename, typename... > class Container = std::initializer_list, typename NamedFunction = std::pair<std::string_view, std::function<float( detail::const_ref_t<DataIterator> )>, typename = std::enable_if_t<!std::is_convertible_v<Container<NamedFunction>, std::string_view>>>
StatusCode farray (const Container< NamedFunction > &funs, DataIterator first, DataIterator last, std::string_view length, size_t maxv)
 
template<typename NamedFunctions , typename DataIterator , typename = std::enable_if_t<!std::is_convertible_v<NamedFunctions, std::string_view>>>
StatusCode farray (const NamedFunctions &funs, DataIterator first, DataIterator last, std::string_view length, size_t maxv)
 
template<class FUNC1 , class FUNC2 , class Iterator >
StatusCode farray (std::string_view name1, const FUNC1 &func1, std::string_view name2, const FUNC2 &func2, Iterator &&first, Iterator &&last, std::string_view length, size_t maxv)
 Put two functions from one data array into LoKi-style N-Tuple simultaneously (effective!) More...
 
template<class FUNC1 , class FUNC2 , class FUNC3 , class Iterator >
StatusCode farray (std::string_view name1, const FUNC1 &func1, std::string_view name2, const FUNC2 &func2, std::string_view name3, const FUNC3 &func3, Iterator &&first, Iterator &&last, std::string_view length, size_t maxv)
 Put three functions from one data array into LoKi-style N-Tuple simultaneously (effective!) More...
 
template<class FUNC1 , class FUNC2 , class FUNC3 , class FUNC4 , class Iterator >
StatusCode farray (std::string_view name1, const FUNC1 &func1, std::string_view name2, const FUNC2 &func2, std::string_view name3, const FUNC3 &func3, std::string_view name4, const FUNC4 &func4, Iterator &&first, Iterator &&last, std::string_view length, size_t maxv)
 Put four functions from one data array into LoKi-style N-Tuple simultaneously (effective!) More...
 
template<class MATRIX >
StatusCode fmatrix (std::string_view name, const MATRIX &data, size_t rows, const MIndex &cols, std::string_view length, size_t maxv)
 Fill N-Tuple with data from variable-size matrix. More...
 
template<class DATA >
StatusCode fmatrix (std::string_view name, DATA first, DATA last, const MIndex &cols, std::string_view length, size_t maxv)
 Fill N-Tuple with data from variable-size matrix. More...
 
template<class FUN , class DATA >
StatusCode fmatrix (std::string_view name, FUN funF, FUN funL, DATA first, DATA last, std::string_view length, size_t maxv)
 fill N-Tuple with matrix of "direct-product" of "data-vector" [first,last) and "function-vector" [funF, funL) More...
 
template<class DATA >
StatusCode array (std::string_view name, DATA first, DATA last)
 fill N-Tuple with fixed-size array More...
 
template<class ARRAY >
StatusCode array (std::string_view name, const ARRAY &data, const MIndex &length)
 fill N-Tuple with fixed-size array More...
 
template<class ARRAY >
StatusCode array (std::string_view name, const ARRAY &data)
 fill N-Tuple with fixed-size array More...
 
template<class MATRIX >
StatusCode matrix (std::string_view name, const MATRIX &data, const MIndex &rows, const MIndex &cols)
 fill N-Tuple with fixed-size matrix More...
 
template<class TYPE >
StatusCode column (std::string_view name, const ROOT::Math::LorentzVector< TYPE > &v)
 Useful shortcut to put LorentzVector directly into N-Tuple: More...
 
template<class TYPE , class TAG >
StatusCode column (std::string_view name, const ROOT::Math::DisplacementVector3D< TYPE, TAG > &v)
 Useful shortcut to put 3D-Vector directly into N-Tuple: More...
 
template<class TYPE , class TAG >
StatusCode column (std::string_view name, const ROOT::Math::PositionVector3D< TYPE, TAG > &v)
 Useful shortcut to put 3D-Vector directly into N-Tuple: More...
 
template<class TYPE , unsigned int D1, unsigned int D2, class REP >
StatusCode matrix (std::string_view name, const ROOT::Math::SMatrix< TYPE, D1, D2, REP > &mtrx)
 shortcut to put Smatrix into N-tuple: More...
 
template<class KEY , class VALUE >
StatusCode fmatrix (std::string_view name, const GaudiUtils::VectorMap< KEY, VALUE > &info, std::string_view length, const size_t maxv=100)
 shortcut to put "ExtraInfo" fields of major into N-Tuple More...
 
template<class TYPE >
StatusCode put (std::string_view name, const TYPE *obj)
 The function allows to add almost arbitrary object into N-tuple. More...
 
StatusCode write ()
 write a record to NTuple More...
 
const std::stringname () const
 get the name More...
 
const NTuple::Tupletuple () const
 provide the access to underlying Gaudi N-tuple More...
 
NTuple::Tupletuple ()
 provide the access to underlying Gaudi N-tuple More...
 
const CLIDclid () const
 accessor to the N-Tuple CLID More...
 
Tuples::Type type () const
 accessor to the N-Tuple type More...
 
bool columnWise () const
 column wise NTuple ? More...
 
bool rowWise () const
 row wise NTuple ? More...
 
bool evtColType () const
 Event collection ? More...
 
bool valid () const
 valid pointer to tuple ? More...
 
bool invalid () const
 invalid pointer to tuple ? More...
 
bool addItem (std::string name, std::string type)
 add the item name into the list of known items More...
 
bool goodItem (std::string_view name) const
 check the uniqueness of the name More...
 
const ItemMapitems () const
 get the full list of booked items More...
 
virtual StatusCode Error (const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const =0
 
virtual StatusCode Warning (const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const =0
 

Protected Member Functions

 TupleObj (std::string name, NTuple::Tuple *tuple, const CLID &clid=CLID_ColumnWiseTuple, const Tuples::Type type=Tuples::NTUPLE)
 Standard constructor. More...
 

Private Member Functions

Intints (std::string_view name, int minv, int maxv)
 get the column More...
 
FArrayfArray (std::string_view name, Int *item)
 get the column More...
 
FArrayfArray (std::string_view name, const MIndex &rows)
 get the column More...
 
Addressaddresses (std::string_view name)
 get the column More...
 
FMatrixfMatrix (std::string_view name, Int *item, const MIndex &cols)
 get the column More...
 
FMatrixfMatrix (std::string_view name, const MIndex &rows, const MIndex &cols)
 get the column More...
 
 TupleObj (const TupleObj &)=delete
 delete the copy constructor and assignment More...
 
TupleObjoperator= (const TupleObj &)=delete
 

Private Attributes

std::string m_name
 name More...
 
NTuple::Tuplem_tuple
 tuple itself More...
 
CLID m_clid
 tuple CLID More...
 
Tuples::Type m_type
 tuple 'type' More...
 
size_t m_refCount = 0
 reference counter More...
 
ColumnStorage< Boolm_bools
 the actual storage of all 'bool' columns More...
 
ColumnStorage< Charm_chars
 the actual storage of all 'Int' columns More...
 
ColumnStorage< UCharm_uchars
 the actual storage of all 'unsigned int' columns More...
 
ColumnStorage< Shortm_shorts
 the actual storage of all 'Int' columns More...
 
ColumnStorage< UShortm_ushorts
 the actual storage of all 'unsigned int' columns More...
 
ColumnStorage< Intm_ints
 the actual storage of all 'Int' columns More...
 
ColumnStorage< UIntm_uints
 the actual storage of all 'unsigned int' columns More...
 
ColumnStorage< LongLongm_longlongs
 the actual storage of all 'long long' columns More...
 
ColumnStorage< ULongLongm_ulonglongs
 the actual storage of all 'unsigned long long' columns More...
 
ColumnStorage< Floatm_floats
 the actual storage of all 'Float' columns More...
 
ColumnStorage< Doublem_doubles
 the actual storage of all 'Double' columns More...
 
ColumnStorage< Addressm_addresses
 the actual storage of all 'Address' columns More...
 
ColumnStorage< FArraym_farrays
 the actual storage of all 'FArray' columns More...
 
ColumnStorage< FArraym_arraysf
 the actual storage of all 'FArray' columns (fixed) More...
 
ColumnStorage< FMatrixm_fmatrices
 the actual storage of all 'FArray' columns More...
 
ColumnStorage< FMatrixm_matricesf
 the actual storage of all 'FMatrix' columns (fixed) More...
 
ItemMap m_items
 all booked types: More...
 

Detailed Description

A simple wrapper class over standard Gaudi NTuple::Tuple facility.

The design and implementation are imported from LoKi package

One should not use lass TupleObj directly. The special handler Tuples::Tuple should be used instead, which is simultaneously 'proxy' an d'smart pointer' for real (and heavy!) TupleObj class.

The main advantages of local ntuples with respect to 'standard' Gaudi NTuples ( NTuple::Tuple ) is their "locality". For 'standard' ntuples one need

  1. Define all ntuple columns/items as data members of the algorithm
  2. Book the NTuple::Tuple object using INTupleSvc
  3. Add all defined columns/items to the booked ntuple
  4. Fill ntuple records

Usually the first step is done in the header file (separate file!) of the algorithm, the second and the third steps are done in initialize() method of the algorithm and the fourth step is done somewhere in execute() method of the same algorithm. Such approach requires to keep track of the tuple structure through different method and event through different files. And even minor modification of the structure of the ntuple will require the modification of at least 2 methods and 2 files.

The Tuples::Tuple wrapper over standard Gaudi NTuple::Tuple class solves all above listed problems with "non-local" nature of Gaudi NTuple::Tuple objects.

Tuples::Tuple object is booked and used 'locally'. One does not need to pre-book the ntuple or its columns/items somewhere in different compilation units or other methods different from the actual point of using the ntuple.

The simplest example of usage Tuples::Tuple object:

Tuple tuple = nTuple( "some more or less unique tuple title ");
for( Loop D0 = loop( "K- pi+", "D0" ) , D0 , ++D0 )
{
tuple -> column ( "mass" , M ( D0 ) / GeV ) ;
tuple -> column ( "pt" , PT ( D0 ) / GeV ) ;
tuple -> column ( "p" , P ( D0 ) / GeV ) ;
tuple -> write () ;
}

One could fill some Tuple variables in one go

Tuple tuple = nTuple( "some more or less unique tuple title ");
for( Loop D0 = loop( "K- pi+", "D0" ) , D0 , ++D0 )
{
tuple -> column ( "mass" , M ( D0 ) / GeV ) ;
tuple -> fill ( "pt , p " , PT ( D0 ) / GeV , P(D0) / GeV ) ;
tuple -> write () ;
}

Even ALL variables could be filled in one go:

Tuple tuple = nTuple( "some more or less unique tuple title ");
for( Loop D0 = loop( "K- pi+", "D0" ) , D0 , ++D0 )
{
tuple -> fill ( "mass pt , p ", M(D0)/GeV,PT(D0)/GeV,P(D0)/GeV ) ;
tuple -> write () ;
}

The 'array-like' columns are also supported ( see methods 'farray')

All these techniques could be easily combined in arbitrary ways

class TupleObj is an abstract class with 3 pure abstract functions Error and Warning , which need to be reimplemented in any 'concrete class. Helper classes TupleObjImp, ErrorHandler and functions createTupleObj and make_handler allows to create concrete objects 'on-flight'

Attention
long long and unsigned long long types are not supported. One needs to convert the data into some other representation (e.g. as 2 separate fields, or perform the explicitly cast to long)
Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2004-01-23

Definition at line 211 of file TupleObj.h.

Member Typedef Documentation

◆ Address

Definition at line 226 of file TupleObj.h.

◆ Bool

basics type for various items

Definition at line 215 of file TupleObj.h.

◆ Char

Definition at line 216 of file TupleObj.h.

◆ Double

Definition at line 225 of file TupleObj.h.

◆ FArray

Definition at line 227 of file TupleObj.h.

◆ Float

Definition at line 224 of file TupleObj.h.

◆ FMatrix

Definition at line 228 of file TupleObj.h.

◆ Int

Definition at line 220 of file TupleObj.h.

◆ ItemMap

◆ LongLong

Definition at line 222 of file TupleObj.h.

◆ MIndex

typedef unsigned short Tuples::TupleObj::MIndex

Definition at line 231 of file TupleObj.h.

◆ Short

Definition at line 218 of file TupleObj.h.

◆ UChar

using Tuples::TupleObj::UChar = NTuple::Item<unsigned char>

Definition at line 217 of file TupleObj.h.

◆ UInt

using Tuples::TupleObj::UInt = NTuple::Item<unsigned int>

Definition at line 221 of file TupleObj.h.

◆ ULongLong

using Tuples::TupleObj::ULongLong = NTuple::Item<unsigned long long>

Definition at line 223 of file TupleObj.h.

◆ UShort

using Tuples::TupleObj::UShort = NTuple::Item<unsigned short>

Definition at line 219 of file TupleObj.h.

Constructor & Destructor Documentation

◆ TupleObj() [1/2]

Tuples::TupleObj::TupleObj ( std::string  name,
NTuple::Tuple tuple,
const CLID clid = CLID_ColumnWiseTuple,
const Tuples::Type  type = Tuples::NTUPLE 
)
protected

Standard constructor.

See also
NTuple:Tuple
Parameters
namename of the object
tuplepointer to standard Gaudi NTuple::Tuple object
clidCLID_ColumnWiseTuple or CLID_RowWiseTuple
typethe type of the tuple

Definition at line 229 of file TupleObj.cpp.

231  : m_name( std::move( name ) ), m_tuple( tuple ), m_clid( clid ), m_type( type ) {
232  // make counts
233  Tuples::Local::s_InstanceCounter.increment( m_name );
234 }

◆ ~TupleObj()

Tuples::TupleObj::~TupleObj ( )
virtual

Definition at line 238 of file TupleObj.cpp.

238  {
239  // make counts
240  Tuples::Local::s_InstanceCounter.decrement( m_name );
241 }

◆ TupleObj() [2/2]

Tuples::TupleObj::TupleObj ( const TupleObj )
privatedelete

delete the copy constructor and assignment

Member Function Documentation

◆ addItem()

bool Tuples::TupleObj::addItem ( std::string  name,
std::string  type 
)
inline

add the item name into the list of known items

Parameters
namethe name of the item
typethe type of the item
Returns
true if the name is indeed added

Definition at line 1897 of file TupleObj.h.

1897  {
1898  return m_items.emplace( std::move( name ), std::move( type ) ).second;
1899  }

◆ addresses()

Address* Tuples::TupleObj::addresses ( std::string_view  name)
private

get the column

◆ array() [1/3]

template<class ARRAY >
StatusCode Tuples::TupleObj::array ( std::string_view  name,
const ARRAY &  data 
)
inline

fill N-Tuple with fixed-size array

"ARRAY" is any sequence, which supports ARRAY::begin() and ARRAY::end() protocol, e.g.

  • std::vector<TYPE>
  • ROOT::Math::SVector<double,15>

The content of array should be implicitly convertible to "float"

typedef std::vector<double> Seq ;
Seq data( 10 ) ;
for ( int i = 0 ; i < 10 ; ++i )
{
data[i] = ... ;
}
tuple -> array( "data" , data ) ;
Parameters
nameN-Tupel entry name
datadata sequence
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@l.nosp@m.app..nosp@m.in2p3.nosp@m..fr
Date
2005-05-01

Definition at line 1642 of file TupleObj.h.

1642  {
1643  using std::begin;
1644  using std::end;
1645  return array( name, begin( data ), end( data ) );
1646  }

◆ array() [2/3]

template<class ARRAY >
StatusCode Tuples::TupleObj::array ( std::string_view  name,
const ARRAY &  data,
const MIndex length 
)
inline

fill N-Tuple with fixed-size array

"ARRAY" must support indexing operations: e.g it coudl be of type:

  • std::vector<TYPE>
  • CLHEP::HepVector, ...
  • "TYPE"[n]

The content of array should be implicitly convertible to "float"

CLHEP::HepVector vct1(10) ;
...
tuple -> array ( "vct1" , vct1 , 10 ) ;
double vct2[40];
...
tuple -> array ( "vct2" , vct2 , 40 ) ;
long vct3[4];
...
tuple -> array ( "vct3" , vct4 , 4 ) ;
...
tuple -> array ( "vct4" , vct4 , 15 ) ;
Parameters
nameN-Tuple entry name
datadata sequence
lengthdata length (fixed!)
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@l.nosp@m.app..nosp@m.in2p3.nosp@m..fr
Date
2005-05-01

Definition at line 1602 of file TupleObj.h.

1602  {
1603  using std::begin; // allow data to be eg. CLHEP::HepVector (which does not define HepVector::begin()!,
1604  // in which case ADL prefers CLHEP::begin (yah! at least they (now) use a namespace)
1605  // so one just to insure double* CLHEP::begin(CLHEP::HepVector& v) { return &v[0]; }
1606  // is visible when this function gets instantiated for CLHEP::HepVector...
1607  auto first = begin( data );
1608  return array( name, first, std::next( first, length ) );
1609  }

◆ array() [3/3]

template<class DATA >
StatusCode Tuples::TupleObj::array ( std::string_view  name,
DATA  first,
DATA  last 
)
inline

fill N-Tuple with fixed-size array

SEQUENCE data( 10 ) ;
...
tuple -> array("data" ,
data.begin () ,
data.end () ) ;

Sequence may be of any objects, implicitly convertible into "float"

Parameters
nameN-Tuple entry name
firstbegin-iterator for data sequence
lastend-iterator for data sequence
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@l.nosp@m.app..nosp@m.in2p3.nosp@m..fr
Date
2005-05-01

fill the array

Definition at line 1544 of file TupleObj.h.

1546  {
1547  if ( invalid() ) return ErrorCodes::InvalidTuple;
1548  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1549 
1550  // get the length (fixed!)
1551  auto length = std::distance( first, last );
1552 
1553  // get the array itself
1554  FArray* var = fArray( name, length );
1555  if ( !var ) return ErrorCodes::InvalidColumn;
1556 
1558  std::copy( first, last, std::begin( *var ) );
1559 
1560  return StatusCode::SUCCESS;
1561  }

◆ clid()

const CLID& Tuples::TupleObj::clid ( ) const
inline

accessor to the N-Tuple CLID

Definition at line 1870 of file TupleObj.h.

1870 { return m_clid; }

◆ column() [1/29]

StatusCode Tuples::TupleObj::column ( IOpaqueAddress address)

Put IOpaqueAddress in NTuple.

If the column does not exist, it will be automatically created and appended to the tuple. The column name is set to be "Address"

IOpaqueAddress* address = ... ;
tuple->column ( address );
Warning
It has sense only for Event tag collection N-Tuples
Parameters
addressIOpaqueAddress
Returns
status code

Definition at line 264 of file TupleObj.cpp.

264 { return column( "Address", address ); }

◆ column() [2/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
bool  value 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically create and appended to the tuple

tuple->column( "empty" , v.empty() );
Parameters
namethe name of the column
valuethe value of the variable
Returns
status code

Definition at line 377 of file TupleObj.cpp.

377  {
378  return column_( this, m_bools, name, value );
379 }

◆ column() [3/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
char  value 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

char number = ... ;
tuple -> column ( "num" , number );
Parameters
namethe name of the column
valuethe value of the variable
Returns
status code

Definition at line 275 of file TupleObj.cpp.

275  {
276  return column_( this, m_chars, name, value );
277 }

◆ column() [4/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
char  value,
char  minv,
char  maxv 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

char number = ... ;
tuple->column( "num", number );
Parameters
namename of the column
valuevalue of the variable
minvminimum value of the variable
maxvmaximum value of the variable
Returns
status code

Definition at line 279 of file TupleObj.cpp.

279  {
280  return column_( this, m_chars, name, value, minv, maxv );
281 }

◆ column() [5/29]

template<class TYPE , class TAG >
StatusCode Tuples::TupleObj::column ( std::string_view  name,
const ROOT::Math::DisplacementVector3D< TYPE, TAG > &  v 
)
inline

Useful shortcut to put 3D-Vector directly into N-Tuple:

const LHCb::Vertex* V = ...
Tuple tuple = nTuple("My N-Tuple") ;
// put vertex position into N-tuple:
tuple -> column ("B" , B->position() ) ;
Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2006-11-26

Definition at line 1757 of file TupleObj.h.

◆ column() [6/29]

template<class TYPE >
StatusCode Tuples::TupleObj::column ( std::string_view  name,
const ROOT::Math::LorentzVector< TYPE > &  v 
)
inline

Useful shortcut to put LorentzVector directly into N-Tuple:

const LHCb::Particle* B = ...
Tuple tuple = nTuple("My N-Tuple") ;
// put 4-vector of B-candidate into N-tuple:
tuple -> column ("B" , B->momentum() ) ;
Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2006-11-26

Definition at line 1733 of file TupleObj.h.

1733  {
1734  return columns( v, std::pair{ fmt::format( "{}E", name ), &ROOT::Math::LorentzVector<TYPE>::E },
1735  std::pair{ fmt::format( "{}X", name ), &ROOT::Math::LorentzVector<TYPE>::Px },
1736  std::pair{ fmt::format( "{}Y", name ), &ROOT::Math::LorentzVector<TYPE>::Py },
1737  std::pair{ fmt::format( "{}Z", name ), &ROOT::Math::LorentzVector<TYPE>::Pz } );
1738  }

◆ column() [7/29]

template<class TYPE , class TAG >
StatusCode Tuples::TupleObj::column ( std::string_view  name,
const ROOT::Math::PositionVector3D< TYPE, TAG > &  v 
)
inline

Useful shortcut to put 3D-Vector directly into N-Tuple:

const LHCb::Vertex* V = ...
Tuple tuple = nTuple("My N-Tuple") ;
// put vertex position into N-tuple:
tuple -> column ("B" , B->position() ) ;
Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2006-11-26

Definition at line 1780 of file TupleObj.h.

◆ column() [8/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
double  value 
)

Set the value for the selected tuple column If the column does not exist, it will be automatically created and appended to the tuple.

//
const double mass = ... ;
tuple->column( "m", mass );
//
Warning
the value is truncated to float
Parameters
namethe name of the column
valuethe value of the variable
Returns
status code

Definition at line 271 of file TupleObj.cpp.

271  {
272  return column_( this, m_doubles, name, value );
273 }

◆ column() [9/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
float  value 
)

Set the value for selected tuple column.

If column does not exist, it will be automatically created and appended to the tuple

//
const float mass = ... ;
tuple->column( "m", mass );
//
Parameters
namethe name of the column
valuethe value of the variable
Returns
status code

Definition at line 267 of file TupleObj.cpp.

267  {
268  return column_( this, m_floats, name, value );
269 }

◆ column() [10/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
int  value 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

int number = ... ;
tuple->column("num", number );
Parameters
namename of the column
valuevalue of the variable
Returns
status code

Definition at line 309 of file TupleObj.cpp.

309 { return column_( this, m_ints, name, value ); }

◆ column() [11/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
int  value,
int  minv,
int  maxv 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

int number = ... ;
tuple->column( "num", number );
Parameters
namename of the column
valuevalue of the variable
minvminimum value of the variable
maxvmaximum value of the variable
Returns
status code

Definition at line 311 of file TupleObj.cpp.

311  {
312  return column_( this, m_ints, name, value, minv, maxv );
313 }

◆ column() [12/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
IOpaqueAddress address 
)

Put IOpaqueAddress in POOL-based NTuple.

If the column does not exist, it will be automatically created and appended to the tuple.

IOpaqueAddress* address = ... ;
tuple->column( "Address", address );
Warning
It has sense only for Event tag collection N-Tuples
Parameters
namename of the column ("Address" is a recommended convention!)
addressIOpaqueAddress
Returns
status code

Definition at line 254 of file TupleObj.cpp.

254  {
255  if ( !evtColType() ) return ErrorCodes::InvalidOperation;
256  if ( !address )
257  return Error( fmt::format( "column('{}') IOpaqueAddress* is NULL!", name ), ErrorCodes::InvalidObject );
258  return column_( this, m_addresses, name, address );
259 }

◆ column() [13/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
long long  value 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

long long number = ... ;
tuple->column( "num", number );
Parameters
namename of the column
valuevalue of the variable
Returns
status code

Definition at line 360 of file TupleObj.cpp.

360  {
361  return column_( this, m_longlongs, name, value );
362 }

◆ column() [14/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
long long  value,
long long  minv,
long long  maxv 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

long long number = ... ;
tuple->column( "num", number );
Parameters
namename of the column
valuevalue of the variable
minvminimum value of the variable
maxvmaximum value of the variable
Returns
status code

Definition at line 364 of file TupleObj.cpp.

364  {
365  return column_( this, m_longlongs, name, value, minv, maxv );
366 }

◆ column() [15/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
long  value 
)

Set the value for the selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

long number = ... ;
tuple -> column ( "num", number );
Warning
the value could be truncated to int
Parameters
namethe name of the column
valuethe value of the variable
Returns
status code

Definition at line 327 of file TupleObj.cpp.

327  {
328  Warning( fmt::format( "'long' has different sizes on 32/64 bit systems. Casting '{}' to 'long long'", name ),
330  .ignore();
331  return column( name, static_cast<long long>( value ) );
332 }

◆ column() [16/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
long  value,
long  minv,
long  maxv 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

long number = ... ;
tuple->column("num", number );
Parameters
namename of the column
valuevalue of the variable
minvminimum value of the variable
maxvmaximum value of the variable
Returns
status code

Definition at line 334 of file TupleObj.cpp.

334  {
335  Warning( fmt::format( "'long' has different sizes on 32/64 bit systems. Casting '{}' to 'long long'", name ),
337  .ignore();
338  return column( name, static_cast<long long>( value ), static_cast<long long>( minv ),
339  static_cast<long long>( maxv ) );
340 }

◆ column() [17/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
short  value 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

short number = ... ;
tuple -> column ( "num" , number );
Parameters
namethe name of the column
valuethe value of the variable
Returns
status code

Definition at line 292 of file TupleObj.cpp.

292  {
293  return column_( this, m_shorts, name, value );
294 }

◆ column() [18/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
short  value,
short  minv,
short  maxv 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

short number = ... ;
tuple->column( "num", number );
Parameters
namename of the column
valuevalue of the variable
minvminimum value of the variable
maxvmaximum value of the variable
Returns
status code

Definition at line 296 of file TupleObj.cpp.

296  {
297  return column_( this, m_shorts, name, value, minv, maxv );
298 }

◆ column() [19/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
signed char  value 
)
inline

Set the value for the selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

signed char number = ... ;
tuple->column("num", number );
Parameters
namethe name of the column
valuethe value of tve variable
Returns
status code

Definition at line 689 of file TupleObj.h.

◆ column() [20/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
unsigned char  value 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

unsigned char number = ... ;
tuple -> column ( "num" , number );
Parameters
namethe name of the column
valuethe value of the variable
Returns
status code

Definition at line 283 of file TupleObj.cpp.

283  {
284  return column_( this, m_uchars, name, value );
285 }

◆ column() [21/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
unsigned char  value,
unsigned char  minv,
unsigned char  maxv 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

unsigned char number = ... ;
tuple->column( "num", number );
Parameters
namename of the column
valuevalue of the variable
minvminimum value of the variable
maxvmaximum value of the variable
Returns
status code

Definition at line 287 of file TupleObj.cpp.

288  {
289  return column_( this, m_uchars, name, value, minv, maxv );
290 }

◆ column() [22/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
unsigned int  value 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

unsigned int number = ... ;
tuple->column("num", number );
Parameters
namename of the column
valuevalue of the variable
Returns
status code

Definition at line 319 of file TupleObj.cpp.

319  {
320  return column_( this, m_uints, name, value );
321 }

◆ column() [23/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
unsigned int  value,
unsigned int  minv,
unsigned int  maxv 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

unsigned int number = ... ;
tuple->column("num", number );
Parameters
namename of the column
valuevalue of the variable
minvminimum value of the variable
maxvmaximum value of the variable
Returns
status code

Definition at line 323 of file TupleObj.cpp.

323  {
324  return column_( this, m_uints, name, value, minv, maxv );
325 }

◆ column() [24/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
unsigned long long  value 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

unsigned long long number = ... ;
tuple->column( "num", number );
Parameters
namename of the column
valuevalue of the variable
Returns
status code

Definition at line 368 of file TupleObj.cpp.

368  {
369  return column_( this, m_ulonglongs, name, value );
370 }

◆ column() [25/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
unsigned long long  value,
unsigned long long  minv,
unsigned long long  maxv 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

unsigned long long number = ... ;
tuple->column( "num", number );
Parameters
namename of the column
valuevalue of the variable
minvminimum value of the variable
maxvmaximum value of the variable
Returns
status code

Definition at line 372 of file TupleObj.cpp.

373  {
374  return column_( this, m_ulonglongs, name, value, minv, maxv );
375 }

◆ column() [26/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
unsigned long  value 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

unsigned long number = ... ;
tuple -> column ( "num" , number );
Warning
the value could be truncated to int
Parameters
namethe name of the column
valuethe value of the variable
Returns
status code

Definition at line 342 of file TupleObj.cpp.

342  {
344  "'unsigned long' has different sizes on 32/64 bit systems. Casting '{}' to 'unsigned long long'", name ),
346  .ignore();
347  return column( name, static_cast<unsigned long long>( value ) );
348 }

◆ column() [27/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
unsigned long  value,
unsigned long  minv,
unsigned long  maxv 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

unsigned long number = ... ;
tuple->column( "num", number );
Parameters
namename of the column
valuevalue of the variable
minvminimum value of the variable
maxvmaximum value of the variable
Returns
status code

Definition at line 350 of file TupleObj.cpp.

351  {
353  "'unsigned long' has different sizes on 32/64 bit systems. Casting '{}' to 'unsigned long long'", name ),
355  .ignore();
356  return column( name, static_cast<unsigned long long>( value ), static_cast<unsigned long long>( minv ),
357  static_cast<unsigned long long>( maxv ) );
358 }

◆ column() [28/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
unsigned short  value 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

unsigned short number = ... ;
tuple -> column ( "num" , number );
Parameters
namethe name of the column
valuethe value of the variable
Returns
status code

Definition at line 300 of file TupleObj.cpp.

300  {
301  return column_( this, m_ushorts, name, value );
302 }

◆ column() [29/29]

StatusCode Tuples::TupleObj::column ( std::string_view  name,
unsigned short  value,
unsigned short  minv,
unsigned short  maxv 
)

Set the value for selected tuple column.

If the column does not exist yet, it will be automatically created and appended to the tuple

unsigned short number = ... ;
tuple->column( "num", number );
Parameters
namename of the column
valuevalue of the variable
minvminimum value of the variable
maxvmaximum value of the variable
Returns
status code

Definition at line 304 of file TupleObj.cpp.

305  {
306  return column_( this, m_ushorts, name, value, minv, maxv );
307 }

◆ columns()

template<typename Value , typename... Args>
StatusCode Tuples::TupleObj::columns ( Value &&  value,
Args &&...  args 
)
inline

Set the values for several columns simultaneously, for the same object Non-existing columns will be automatically created and appended to the ntuple.

tuple->columns( p, std::pair{ "X", &Gaudi::XYZPoint::X},
std::pair{ "Y", &Gaudi::XYZPoint::Y},
std::pair{ "Z", &Gaudi::XYZPoint::Z} );
Warning
the type of column is set (implicitly) by the type returned by the 'callable' for that column, i.e. in the above the return type of eg. Gaudi::XYZPoint::X()
Author
Gerhard Raven

Definition at line 773 of file TupleObj.h.

773  {
774  if ( sizeof...( Args ) == 0 ) return StatusCode::SUCCESS;
776  this->column( std::get<0>( args ), std::invoke( std::get<1>( args ), value ) )... };
777  return std::accumulate( std::next( begin( scs ) ), end( scs ), *begin( scs ),
778  []( StatusCode sc, const StatusCode& i ) {
779  i.ignore(); // make sure there are no unchecked StatusCodes...
780  return sc.isFailure() ? sc : i; // latch to the first non-success case
781  } );
782  }

◆ columnWise()

bool Tuples::TupleObj::columnWise ( ) const
inline

column wise NTuple ?

Definition at line 1876 of file TupleObj.h.

1876 { return CLID_ColumnWiseTuple == clid(); }

◆ Error()

virtual StatusCode Tuples::TupleObj::Error ( const std::string msg,
const StatusCode  sc = StatusCode::FAILURE 
) const
pure virtual

◆ evtColType()

bool Tuples::TupleObj::evtColType ( ) const
inline

Event collection ?

Definition at line 1882 of file TupleObj.h.

1882 { return Tuples::EVTCOL == type(); }

◆ farray() [1/8]

template<typename DataIterator , template< typename, typename... > class Container = std::initializer_list, typename NamedFunction = std::pair<std::string_view, std::function<float( detail::const_ref_t<DataIterator> )>, typename = std::enable_if_t<!std::is_convertible_v<Container<NamedFunction>, std::string_view>>>
StatusCode Tuples::TupleObj::farray ( const Container< NamedFunction > &  funs,
DataIterator  first,
DataIterator  last,
std::string_view  length,
size_t  maxv 
)
inline

Definition at line 1104 of file TupleObj.h.

1105  {
1106  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1107  std::forward<DataIterator>( last ), length, maxv );
1108  }

◆ farray() [2/8]

template<typename NamedFunctions , typename DataIterator , typename = std::enable_if_t<!std::is_convertible_v<NamedFunctions, std::string_view>>>
StatusCode Tuples::TupleObj::farray ( const NamedFunctions &  funs,
DataIterator  first,
DataIterator  last,
std::string_view  length,
size_t  maxv 
)
inline

Definition at line 1112 of file TupleObj.h.

1113  {
1114  return farray_impl( funs.begin(), funs.end(), std::forward<DataIterator>( first ),
1115  std::forward<DataIterator>( last ), length, maxv );
1116  }

◆ farray() [3/8]

template<class DATA >
StatusCode Tuples::TupleObj::farray ( std::string_view  name,
const DATA &  data,
std::string_view  length,
const size_t  maxv 
)
inline

Add an indexed array (of type float) to N-tuple.

it is just a small adaptor for the previous method

std::vector<double> values = ... ;
tuple->farray( "Values" , // item name
values , // sequence
"Length" , // name of "length" item
10000 ) ;

The name of "length" item can be reused for several arrays. The last assignment "wins"

std::vector<double> val1 = ... ;
std::vector<double> val2 = ... ;
tuple->farray( "Val1" , // item name
val1 , // begin of sequence
"Length" , // name of "length" item
10000 ) ; // maximal length
tuple->farray( "Val2" , // item name
val2 , // begin of sequence
"Length" , // name of "length" item
10000 ) ; // maximal length

Any sequence which provides begin() and end() methods can be used.

Parameters
namename of N-tuple item
datadata sequence
lengthname of "length" item
maxvmaximal length of array

Definition at line 935 of file TupleObj.h.

935  {
936  return farray( name, std::begin( data ), std::end( data ), length, maxv );
937  }

◆ farray() [4/8]

template<class FUNCTION , class ITERATOR >
StatusCode Tuples::TupleObj::farray ( std::string_view  name,
const FUNCTION &  function,
ITERATOR  first,
ITERATOR  last,
std::string_view  length,
size_t  maxv 
)
inline

Put an indexed array into LoKi-style N-Tuple.

std::vector<double> data = ... ;
Tuple tuple = ntuple( "My Ntuple" );
tuple->farray( "data" , // data item name
sqrt , // "function" to be applied
data.begin () , // begin of data sequence
data.end () , // end of data sequence
"length" , // name of "length" tuple item
10000 ) ; // maximal array length

Since the method is templated, one can use arbitrary combinations of "sequences" and "functions", e.g. one can directly manipulate with complex objects. The only one thing is required - the result of FUNCTION(*DATA) formal operation MUST be convertible to type float

// some container of particles.
ParticleVector particles = ... ;
Tuple tuple = ntuple( "My Ntuple" );
// put the transverse momentum of all particles into N-Tuple
tuple->farray( "pt" , // data item name
PT , // function object
particles.begin () , // begin of data sequence
particles.end () , // end of data sequence
"num" , // name of "length" tuple item
10000 ) ; // maximal array length
// create the appropriate function object
Fun fun = Q / P ;
// put Q/P of all particles into N-Tuple
tuple->farray( "qp" , // data item name
fun , // function object
particles.begin () , // begin of data sequence
particles.end () , // end of data sequence
"num" , // name of "length" tuple item
10000 ) ; // maximal array length
Parameters
nametuple item name
functionfunction to be applied
firstbegin of data sequence
lastend of data sequence
lengthname of "length" tuple name
maxvmaximal length of the array
Returns
status code

Definition at line 1002 of file TupleObj.h.

1003  {
1004  if ( invalid() ) return ErrorCodes::InvalidTuple;
1005  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1006 
1007  // adjust the length
1008  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1009  Warning( fmt::format( "farray('{}'): array is overflow, skip extra entries", name ) )
1010  .ignore( /* AUTOMATICALLY ADDED FOR gaudi/Gaudi!763 */ );
1011  last = std::next( first, maxv );
1012  }
1013 
1014  // get the length item
1015  Int* len = ints( length, 0, maxv );
1016  if ( !len ) return ErrorCodes::InvalidColumn;
1017 
1018  // adjust the length
1019  *len = std::distance( first, last );
1020 
1021  // get the array itself
1022  FArray* var = fArray( name, len );
1023  if ( !var ) return ErrorCodes::InvalidColumn;
1024 
1025  // fill the array
1026  std::transform( first, last, std::begin( *var ),
1027  [&]( auto&& i ) { return std::invoke( function, std::forward<decltype( i )>( i ) ); } );
1028 
1029  return StatusCode::SUCCESS;
1030  }

◆ fArray() [1/2]

Tuples::TupleObj::FArray * Tuples::TupleObj::fArray ( std::string_view  name,
const MIndex rows 
)
private

get the column

Definition at line 394 of file TupleObj.cpp.

394  {
395  // existing array ?
396  auto found = m_arraysf.find( name );
397  if ( m_arraysf.end() != found ) return &*found;
398  return create_( this, m_arraysf, name, [&]( std::string_view n, FArray& i ) {
399  return this->tuple()->addItem( std::string{ n }, rows, i );
400  } );
401 }

◆ fArray() [2/2]

Tuples::TupleObj::FArray * Tuples::TupleObj::fArray ( std::string_view  name,
Int item 
)
private

get the column

Definition at line 383 of file TupleObj.cpp.

383  {
384  // existing array ?
385  auto found = m_farrays.find( name );
386  if ( m_farrays.end() != found ) return &*found;
387  return create_( this, m_farrays, name, [&]( std::string_view n, FArray& i ) {
388  return this->tuple()->addIndexedItem( std::string{ n }, *length, i );
389  } );
390 }

◆ farray() [5/8]

template<typename ITERATOR1 , typename ITERATOR2 >
StatusCode Tuples::TupleObj::farray ( std::string_view  name,
ITERATOR1 &&  first,
ITERATOR2 &&  last,
std::string_view  length,
size_t  maxv 
)
inline

Add an indexed array (of type float) to N-tuple.

The method is not VERY efficient since it copies the data.

std::vector<double> values = ... ;
tuple->farray( "Values" , // item name
values.begin () , // begin of sequence
values.end () , // end of sequence
"Length" , // name of "length" item
10000 ) ;

The name of "length" item can be reused for several arrays. The last assignement "wins"

std::vector<double> val1 = ... ;
std::vector<double> val2 = ... ;
tuple->farray( "Val1" , // item name
val1.begin () , // begin of sequence
val1.end () , // end of sequence
"Length" , // name of "length" item
10000 ) ; // maximal length
tuple->farray( "Val2" , // item name
val2.begin () , // begin of sequence
val2.end () , // end of sequence
"Length" , // name of "length" item
10000 ) ; // maximal length

Any sequence [first:last[ of objects which can be converted to type float can be used as input data, e.g. std::vector<double>, std::vector<float>, plain C-array, or whatever else

Parameters
namename of N-tuple item
firstbegin of data sequence
lastend of data sequence
lengthname of "length" item
maxvmaximal length of array

Definition at line 886 of file TupleObj.h.

887  {
888  return farray( name, detail::to_float, std::forward<ITERATOR1>( first ), std::forward<ITERATOR2>( last ), length,
889  maxv );
890  }

◆ farray() [6/8]

template<class FUNC1 , class FUNC2 , class Iterator >
StatusCode Tuples::TupleObj::farray ( std::string_view  name1,
const FUNC1 &  func1,
std::string_view  name2,
const FUNC2 &  func2,
Iterator &&  first,
Iterator &&  last,
std::string_view  length,
size_t  maxv 
)
inline

Put two functions from one data array into LoKi-style N-Tuple simultaneously (effective!)

std::vector<double> data = ... ;
Tuple tuple = ntuple( "My Ntuple" );
tuple->farray( "square_root" , // the first data item name
sqrt , // "func1" to be used
"sinus" , // the second data item name
sin , // "func2" to be used
data.begin () , // begin of data sequence
data.end () , // end of data sequence
"length" , // name of "length" tuple item
10000 ) ; // maximal array length
Parameters
name1the first tuple item name
func1the first function to be applied
name2the second tuple item name
func2the second function to be applied
firstbegin of data sequence
lastend of data sequence
lengthname of "length" tuple name
maxvmaximal length of the array
Returns
status code

Definition at line 1150 of file TupleObj.h.

1151  {
1152  return farray( { { name1, std::cref( func1 ) }, { name2, std::cref( func2 ) } }, std::forward<Iterator>( first ),
1153  std::forward<Iterator>( last ), length, maxv );
1154  }

◆ farray() [7/8]

template<class FUNC1 , class FUNC2 , class FUNC3 , class Iterator >
StatusCode Tuples::TupleObj::farray ( std::string_view  name1,
const FUNC1 &  func1,
std::string_view  name2,
const FUNC2 &  func2,
std::string_view  name3,
const FUNC3 &  func3,
Iterator &&  first,
Iterator &&  last,
std::string_view  length,
size_t  maxv 
)
inline

Put three functions from one data array into LoKi-style N-Tuple simultaneously (effective!)

std::vector<double> data = ... ;
Tuple tuple = ntuple( "My Ntuple" );
tuple->farray( "square_root" , // the first data item name
sqrt , // "func1" to be used
"sinus" , // the second data item name
sin , // "func2" to be used
"tan" , // the third data item name
tan , // "func3" to be used
data.begin () , // begin of data sequence
data.end () , // end of data sequence
"length" , // name of "length" tuple item
10000 ) ; // maximal array length
Parameters
name1the first tuple item name
func1the first function to be applied
name2the second tuple item name
func2the second function to be applied
name3the third tuple item name
func3the third function to be applied
firstbegin of data sequence
lastend of data sequence
lengthname of "length" tuple name
maxvmaximal length of the array
Returns
status code

Definition at line 1193 of file TupleObj.h.

1195  {
1196  return farray( { { name1, std::cref( func1 ) }, { name2, std::cref( func2 ) }, { name3, std::cref( func3 ) } },
1197  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1198  }

◆ farray() [8/8]

template<class FUNC1 , class FUNC2 , class FUNC3 , class FUNC4 , class Iterator >
StatusCode Tuples::TupleObj::farray ( std::string_view  name1,
const FUNC1 &  func1,
std::string_view  name2,
const FUNC2 &  func2,
std::string_view  name3,
const FUNC3 &  func3,
std::string_view  name4,
const FUNC4 &  func4,
Iterator &&  first,
Iterator &&  last,
std::string_view  length,
size_t  maxv 
)
inline

Put four functions from one data array into LoKi-style N-Tuple simultaneously (effective!)

std::vector<double> data = ... ;
Tuple tuple = ntuple( "My Ntuple" );
tuple->farray( "square_root" , // the first data item name
sqrt , // "func1" to be used
"sinus" , // the second data item name
sin , // "func2" to be used
"tan" , // the third data item name
tan , // "func3" to be used
"tanh" , //
tanh , //
data.begin () , // begin of data sequence
data.end () , // end of data sequence
"length" , // name of "length" tuple item
10000 ) ; // maximal array length
Parameters
name1the first tuple item name
func1the first function to be applied
name2the second tuple item name
func2the second function to be applied
name3the third tuple item name
func3the third function to be applied
name4the fourth tuple item name
func4the fourth function to be applied
firstbegin of data sequence
lastend of data sequence
lengthname of "length" tuple name
maxvmaximal length of the array
Returns
status code

Definition at line 1240 of file TupleObj.h.

1242  {
1243  return farray( { { name1, std::cref( func1 ) },
1244  { name2, std::cref( func2 ) },
1245  { name3, std::cref( func3 ) },
1246  { name4, std::cref( func4 ) } },
1247  std::forward<Iterator>( first ), std::forward<Iterator>( last ), length, maxv );
1248  }

◆ farray_impl()

template<typename FunIterator , typename DataIterator >
StatusCode Tuples::TupleObj::farray_impl ( FunIterator  first_item,
FunIterator  last_item,
DataIterator  first,
DataIterator  last,
std::string_view  length,
size_t  maxv 
)
inline

Put arbitrary number of functions from one data array into LoKi-style N-Tuple simultaneously (effective!)

std::vector<double> data = ... ;
Tuple tuple = ntuple( "My Ntuple" );
tuple->farray( { { "sqrt", sqrt }, // name of 1st column, and function to use for it
{ "sinus", sin } }, // name of the 2nd column, and corresponding function
data.begin () , // begin of data sequence
data.end () , // end of data sequence
"length" , // name of "length" tuple item
10000 ) ; // maximal array length
Parameters
itemsvector of pairs { name, callable }
firstbegin of data sequence
lastend of data sequence
lengthname of "length" tuple name
maxvmaximal length of the array
Returns
status code

Definition at line 1060 of file TupleObj.h.

1061  {
1062  if ( invalid() ) return ErrorCodes::InvalidTuple;
1063  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1064 
1065  // adjust the length
1066  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1068  std::ostringstream os;
1069  ostream_joiner( os, first_item, last_item, ",",
1070  []( std::ostream& os, const auto& i ) -> decltype( auto ) { return os << i.first; } );
1071  Warning( "farray('" + os.str() + "'): array overflow, skipping extra entries" ).ignore();
1072  last = std::next( first, maxv );
1073  }
1074 
1075  // get the length item
1076  Int* len = ints( length, 0, maxv );
1077  if ( !len ) return ErrorCodes::InvalidColumn;
1078 
1079  // adjust the length
1080  *len = std::distance( first, last );
1081 
1082  // get the arrays themselves
1083  std::vector<FArray*> vars;
1084  vars.reserve( std::distance( first_item, last_item ) );
1085  std::transform( first_item, last_item, std::back_inserter( vars ),
1086  [&]( const auto& item ) { return this->fArray( item.first, len ); } );
1087  if ( std::any_of( vars.begin(), vars.end(), []( const FArray* f ) { return !f; } ) ) {
1089  }
1090 
1091  // fill the array
1092  for ( size_t index = 0; first != last; ++first, ++index ) {
1093  auto item = first_item;
1094  for ( auto& var : vars ) { ( *var )[index] = std::invoke( ( item++ )->second, *first ); }
1095  }
1096 
1097  return StatusCode::SUCCESS;
1098  }

◆ fill()

template<typename Arg , typename... Args>
StatusCode Tuples::TupleObj::fill ( std::string_view  fmt,
Arg  arg,
Args...  args 
)
inline

Set the values for several columns simultaneously.

Number of columns is arbitrary, but it should match the number of blank, or comma, or semi-column separated tags in format string. Non-existing columns will be automatically created and appended to the ntuple.

double r1 , r2 , r3 , r4 , mass , length ;
tuple->fill( "var1 var2, radius rad4 mass len" ,
r1, r2, r3, r4, mass, length);
Parameters
formatblank-separated list of variables, followed by variable number of arguments.
Author
Vanya Belyaev Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru
Date
2002-10-30

Definition at line 807 of file TupleObj.h.

807  {
808  constexpr auto separators = " ,;";
809  // split into token, and remainder
810  auto token = fmt.substr( 0, fmt.find_first_of( separators ) );
811  fmt.remove_prefix( std::min( token.size() + 1, fmt.size() ) );
812 
813  if ( !token.empty() ) {
814  // check the underlying tuple
815  if ( invalid() ) return ErrorCodes::InvalidTuple;
816  return column( token, arg ).andThen( [&] {
817  if constexpr ( sizeof...( Args ) != 0 ) { return fill( fmt, args... ); }
818  // no more args to deal with -- so check that there is nothing usefull left in fmt, and if so, call it a
819  // success...
820  if ( fmt.find_first_not_of( separators ) != std::string_view::npos )
821  throw std::runtime_error{ "TupleObj::fill: bad format -- too few arguments for specified format" };
823  } );
824  } else if ( !fmt.empty() ) {
825  // got a separator at the front of fmt -- try again now that it is removed from fmt...
826  return fill( fmt, arg, args... );
827  } else {
828  // empty token, and nothing left in fmt -- but we still where called with (at least) one argument...
829  throw std::runtime_error{ "TupleObj::fill: bad format -- too many arguments for specified format" };
830  return StatusCode::SUCCESS;
831  }
832  }

◆ fmatrix() [1/4]

template<class KEY , class VALUE >
StatusCode Tuples::TupleObj::fmatrix ( std::string_view  name,
const GaudiUtils::VectorMap< KEY, VALUE > &  info,
std::string_view  length,
const size_t  maxv = 100 
)
inline

shortcut to put "ExtraInfo" fields of major into N-Tuple

const LHCb::Particle* B = ...
Tuple tuple = nTuple("My N-Tuple") ;
// put the vector into N-Tuple:
tuple -> fmatrix ( "Info" , B->extraInfo() , "nInfo" , 100 ) ;
Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2006-11-26

Definition at line 1829 of file TupleObj.h.

1830  {
1831  using Info = std::pair<KEY, VALUE>;
1832  static const std::array<float ( * )( const Info& ), 2> fns = {
1833  { []( const Info& i ) -> float { return i.first; }, []( const Info& i ) -> float { return i.second; } } };
1834  return fmatrix( name, begin( fns ), end( fns ), begin( info ), end( info ), length, maxv );
1835  }

◆ fmatrix() [2/4]

template<class MATRIX >
StatusCode Tuples::TupleObj::fmatrix ( std::string_view  name,
const MATRIX &  data,
size_t  rows,
const MIndex cols,
std::string_view  length,
size_t  maxv 
)
inline

Fill N-Tuple with data from variable-size matrix.

"Matrix" could be of any type, which supports data[iRow][iCol] indexing, e.g.

  • std::vector<std::vector<TYPE> >
  • CLHEP::HepMatrix, etc...
typedef std::vector<Row> Mtrx ;
// number of columns (fixed!)
const size_t numCols = 5 ;
// maximal number of rows
const size_t maxRows = 300 ;
// number of rows (variable)
size_t numRows = .... ;
...
tuple -> fMatrix ( "mtrx" , // "column" name
mtrx , // matrix
numRows , // number of rows (variable!)
numCols , // number of columns (fixed)
"Length" , // name for "length" column
maxRows ) ; // maximal number of columns
CLHEP::HepMatrix mtrx = ... ;
...
tuple -> fMatrix ( "mtrx" , // "column" name
mtrx , // matrix
mtrx.num_row() , // number of rows (variable!)
mtrx.num_col() , // number of columns (fixed)
"Length" , // name for "length" column
maxRows ) ; // maximal number of columns
Parameters
nameentry name in N-Tuple
datamatrix itself
rowsnumber of rows of matrix (variable)
colsnumber of columns of matrix (fixed)
lengthentry name in NTuple for number of matrix column
maxvmaximal number of rows in matrix
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@l.nosp@m.app..nosp@m.in2p3.nosp@m..fr
Date
2005-05-01

fill the matrix

Definition at line 1303 of file TupleObj.h.

1304  {
1305  if ( invalid() ) return ErrorCodes::InvalidTuple;
1306  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1307 
1308  // adjust the length
1309  if ( rows >= maxv ) {
1310  Warning( fmt::format( "fmatrix('{}'): matrix is overflow, skip extra items", name ) ).ignore();
1311  rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0;
1312  }
1313 
1314  // get the length item
1315  Int* len = ints( length, 0, maxv );
1316  if ( !len ) return ErrorCodes::InvalidColumn;
1317 
1318  // adjust the length item
1319  *len = rows;
1320 
1321  // get the array itself
1322  FMatrix* var = fMatrix( name, len, cols );
1323  if ( !var ) return ErrorCodes::InvalidColumn;
1324 
1326  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1327  for ( MIndex iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1328  }
1329 
1330  return StatusCode::SUCCESS;
1331  }

◆ fMatrix() [1/2]

Tuples::TupleObj::FMatrix * Tuples::TupleObj::fMatrix ( std::string_view  name,
const MIndex rows,
const MIndex cols 
)
private

get the column

Definition at line 417 of file TupleObj.cpp.

418  {
419  // existing array ?
420  auto found = m_matricesf.find( name );
421  if ( m_matricesf.end() != found ) return &*found;
422  return create_( this, m_matricesf, name, [&]( std::string_view n, FMatrix& i ) {
423  return this->tuple()->addItem( std::string{ n }, rows, cols, i );
424  } );
425 }

◆ fmatrix() [3/4]

template<class DATA >
StatusCode Tuples::TupleObj::fmatrix ( std::string_view  name,
DATA  first,
DATA  last,
const MIndex cols,
std::string_view  length,
size_t  maxv 
)
inline

Fill N-Tuple with data from variable-size matrix.

"Matrix" could be of any type, which supports iteration from the first column to the last column and for each iterating column supports the indexing: (*first)[iCol]

typedef std::vector<Row> Mtrx ;
// number of rows (fixed!)
const size_t numRows = 5 ;
// maximal number of columns
const size_t maxCols = 300 ;
// number of columns (variable)
size_t numCols = .... ;
...
tuple -> fMatrix ( "mtrx" , // entry name
mtrx.begin() , // first row of matrix
mtrx.end () , // last row of matrix
numCols , // number of columns (fixed!)
"Length" , // name for "length" column
maxRows ) ; // maximal number of rows
Parameters
nameentry name in N-Tuple
firstiterator for the first row of matrix
lastiterator for the last row of matrix
colsnumber of columns for matrix (fixed!)
lengthentry name in NTuple for number of matrix column
maxvmaximal number of rows in matrix
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@l.nosp@m.app..nosp@m.in2p3.nosp@m..fr
Date
2005-05-01

fill the matrix

Definition at line 1370 of file TupleObj.h.

1371  {
1372  if ( invalid() ) return ErrorCodes::InvalidTuple;
1373  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1374 
1375  // adjust the length
1376  if ( first + maxv < last ) {
1377  Warning( fmt::format( "fmatrix('{}'): matrix is overflow, skip extra items", name ) ).ignore();
1378  last = first + maxv;
1379  }
1380 
1381  // get the length item
1382  Int* len = ints( length, 0, maxv );
1383  if ( !len ) return ErrorCodes::InvalidColumn;
1384 
1385  // adjust the length item
1386  *len = last - first;
1387 
1388  // get the array itself
1389  FMatrix* var = fMatrix( name, len, cols );
1390  if ( !var ) return ErrorCodes::InvalidColumn;
1391 
1393  size_t iRow = 0;
1394  for ( ; first != last; ++first ) {
1395  //
1396  for ( MIndex iCol = 0; iCol < cols; ++iCol ) { ( *var )[iRow][iCol] = ( *first )[iCol]; }
1397  //
1398  ++iRow;
1399  }
1400 
1401  return StatusCode::SUCCESS;
1402  }

◆ fmatrix() [4/4]

template<class FUN , class DATA >
StatusCode Tuples::TupleObj::fmatrix ( std::string_view  name,
FUN  funF,
FUN  funL,
DATA  first,
DATA  last,
std::string_view  length,
size_t  maxv 
)
inline

fill N-Tuple with matrix of "direct-product" of "data-vector" [first,last) and "function-vector" [funF, funL)

The elements of effective matrix are:

mtrx[iCol][iRow] = (*(funF+iRow))( *(first+iCol) )

Attention
The length of data-vector is variable, while the length of "function" vector is fixed!
Array array = ... ;
typedef double (*fun)( double ) ;
typedef std::vector<fun> Funs ;
Funs funs ;
funs.push_back( sin ) ;
funs.push_back( cos ) ;
funs.push_back( tan ) ;
funs.push_back( sinh ) ;
funs.push_back( cosh ) ;
funs.push_back( tanh ) ;
tuple->fmatrix ( "mtrx" , // N-Tuple entry name
funs.begin () , // begin of "function-vector"
funs.end () , // end of "function-vector"
array.begin () , // begin of "data-vector"
array.end () , // end of "data-vector"
"Length" ,
100 ) ;

This method is very convenient e.g. for using within LoKi:

typedef std::vector<Fun> VctFun ;
// sequence of Particles
Range particles = .... ;
// vector of functions:
VctFun funs ;
funs.push_back( E / GeV ) ;
funs.push_back( PX / GeV ) ;
funs.push_back( PY / GeV ) ;
funs.push_back( PZ / GeV ) ;
funs.push_back( PT / GeV ) ;
funs.push_back( M / GeV ) ;
funs.push_back( ID ) ;
// fill N-Tuple with information about each particle
tuple -> fmatrix ( "vars" ,
funs.begin () ,
funs.end () ,
particles.begin () ,
particles.end () ,
"nParts" ,
200 ) ;
Parameters
nameentry name in N-Tuple
funF"begin"-iterator for vector of functions
funL"end"-iterator for vector of functions
first"begin"-iterator for vector of data
last"end"-iterator for vector of data
lengthentry name in NTuple for number of matrix column
maxvmaximal number of rows in matrix
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@l.nosp@m.app..nosp@m.in2p3.nosp@m..fr
Date
2005-05-01

fill the matrix

Definition at line 1483 of file TupleObj.h.

1484  {
1485  if ( invalid() ) return ErrorCodes::InvalidTuple;
1486  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1487 
1488  // adjust the length
1489  if ( std::distance( first, last ) > static_cast<std::ptrdiff_t>( maxv ) ) {
1490  Warning( fmt::format( "fmatrix('{}'): matrix is overflow, skip extra items", name ) ).ignore();
1491  last = std::next( first, maxv );
1492  }
1493 
1494  // get the length item
1495  Int* len = ints( length, 0, maxv );
1496 
1497  if ( !len ) return ErrorCodes::InvalidColumn;
1498 
1499  // adjust the length item
1500  *len = std::distance( first, last );
1501 
1502  // get the array itself
1503  auto cols = std::distance( funF, funL );
1504  FMatrix* var = fMatrix( name, len, cols );
1505  if ( !var ) return ErrorCodes::InvalidColumn;
1506 
1508  size_t iRow = 0;
1509  for ( ; first != last; ++first ) {
1510  //
1511  for ( FUN fun = funF; fun < funL; ++fun ) { ( *var )[iRow][fun - funF] = std::invoke( *fun, *first ); }
1512  //
1513  ++iRow;
1514  }
1515 
1516  return StatusCode::SUCCESS;
1517  }

◆ fMatrix() [2/2]

Tuples::TupleObj::FMatrix * Tuples::TupleObj::fMatrix ( std::string_view  name,
Int item,
const MIndex cols 
)
private

get the column

Definition at line 405 of file TupleObj.cpp.

406  {
407  // existing array ?
408  auto found = m_fmatrices.find( name );
409  if ( m_fmatrices.end() != found ) return &*found;
410  return create_( this, m_fmatrices, name, [&]( std::string_view n, FMatrix& i ) {
411  return this->tuple()->addIndexedItem( std::string{ n }, *length, cols, i );
412  } );
413 }

◆ goodItem()

bool Tuples::TupleObj::goodItem ( std::string_view  name) const
inline

check the uniqueness of the name

Parameters
namethe name of the item
Returns
true if the name is indeed unique

Definition at line 1905 of file TupleObj.h.

1905 { return m_items.end() == m_items.find( name ); }

◆ ints()

Tuples::TupleObj::Int * Tuples::TupleObj::ints ( std::string_view  name,
int  minv,
int  maxv 
)
private

get the column

Definition at line 315 of file TupleObj.cpp.

315  {
316  return find_or_create( this, name, m_ints, minv, maxv );
317 }

◆ invalid()

bool Tuples::TupleObj::invalid ( ) const
inline

invalid pointer to tuple ?

Definition at line 1888 of file TupleObj.h.

1888 { return !valid(); }

◆ items()

const ItemMap& Tuples::TupleObj::items ( ) const
inline

get the full list of booked items

Definition at line 1908 of file TupleObj.h.

1908 { return m_items; }

◆ matrix() [1/2]

template<class MATRIX >
StatusCode Tuples::TupleObj::matrix ( std::string_view  name,
const MATRIX &  data,
const MIndex rows,
const MIndex cols 
)
inline

fill N-Tuple with fixed-size matrix

"MATRIX" must support indexing operations: data[iRow][iCol]

e.g it could be of type:

  • std::vector<std::vector<TYPE> >
  • CLHEP::HepMatrix , CLHEP::GenMatrix, etc ...
  • "TYPE"[n][m]

The content of MATRIX should be implicitly convertible to "float"

CLHEP::HepMatrix mtrx1(3,20) ;
...
tuple -> matrix ( "m1" ,
mtrx1 ,
mtrx1.num_row() ,
mtrx1.num_col() ) ;
typedef std:vector<Row> Mtrx ;
Mtrx mtrx2( 3 , Row(10) ) ;
...
tuple -> matrix ( "m2" ,
mtrx2 ,
3 ,
10 ) ;
float mtrx3[3][10] ;
...
tuple -> matrix ( "m3" ,
mtrx3 ,
3 ,
10 ) ;
Parameters
nameN-Tuple entry name
datadata source (matrix)
colsnumber of columns
rowsnumber of rows
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@l.nosp@m.app..nosp@m.in2p3.nosp@m..fr
Date
2005-05-01

fill the matrix

Definition at line 1699 of file TupleObj.h.

1699  {
1700  if ( invalid() ) return ErrorCodes::InvalidTuple;
1701  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1702 
1703  // get the matrix itself
1704  FMatrix* var = fMatrix( name, rows, cols );
1705  if ( !var ) return ErrorCodes::InvalidColumn;
1706 
1708  for ( size_t iCol = 0; iCol < cols; ++iCol ) {
1709  for ( size_t iRow = 0; iRow < rows; ++iRow ) { ( *var )[iRow][iCol] = data[iRow][iCol]; }
1710  };
1711  return StatusCode::SUCCESS;
1712  }

◆ matrix() [2/2]

template<class TYPE , unsigned int D1, unsigned int D2, class REP >
StatusCode Tuples::TupleObj::matrix ( std::string_view  name,
const ROOT::Math::SMatrix< TYPE, D1, D2, REP > &  mtrx 
)
inline

shortcut to put Smatrix into N-tuple:

Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2006-11-26

fill the matrix

Definition at line 1795 of file TupleObj.h.

1795  {
1796  if ( invalid() ) return ErrorCodes::InvalidTuple;
1797  if ( rowWise() ) return ErrorCodes::InvalidOperation;
1798 
1799  // get the matrix itself
1800  FMatrix* var = fMatrix( name, (MIndex)D1, (MIndex)D2 );
1801  if ( !var ) return ErrorCodes::InvalidColumn;
1802 
1804  for ( size_t iCol = 0; iCol < D2; ++iCol ) {
1805  for ( size_t iRow = 0; iRow < D1; ++iRow ) { ( *var )[iRow][iCol] = mtrx( iRow, iCol ); }
1806  };
1807 
1808  return StatusCode::SUCCESS;
1809  }

◆ name()

const std::string& Tuples::TupleObj::name ( ) const
inline

get the name

Definition at line 1857 of file TupleObj.h.

1857 { return m_name; }

◆ operator=()

TupleObj& Tuples::TupleObj::operator= ( const TupleObj )
privatedelete

◆ put()

template<class TYPE >
StatusCode Tuples::TupleObj::put ( std::string_view  name,
const TYPE *  obj 
)

The function allows to add almost arbitrary object into N-tuple.

Attention
it requires POOL persistency
Parameters
namecolumn name
objpointer to the object
Author
Vanya BELYAEV ibely.nosp@m.aev@.nosp@m.physi.nosp@m.cs.s.nosp@m.yr.ed.nosp@m.u
Date
2007-04-08

Definition at line 117 of file TuplePut.h.

117  {
118  if ( invalid() ) { return ErrorCodes::InvalidTuple; } // RETURN
119  if ( !evtColType() ) { return ErrorCodes::InvalidOperation; } // RETURN
120 
121  // static block: The type description & the flag
122  static bool s_fail = false; // STATIC
123  static TClass* s_type = nullptr; // STATIC
124  // check the status
125  if ( s_fail ) {
127  } // RETURN
128  else if ( !s_type ) {
129  s_type = TClass::GetClass( typeid( TYPE ) );
130  if ( !s_type ) {
131  s_fail = true;
132  return Error( fmt::format( " put('{}',{}) :Invalid ROOT Type", name, System::typeinfoName( typeid( TYPE ) ) ),
133  ErrorCodes::InvalidItem ); // RETURN
134  }
135  }
136  // the local storage of items
137  static Tuples::ItemStore<TYPE*> s_map;
138  // get the variable by name:
139  auto item = s_map.getItem( name, this );
140  if ( !item ) { return Error( fmt::format( " put('{}'): invalid item detected", name ), ErrorCodes::InvalidItem ); }
141  // assign the item!
142  *item = const_cast<TYPE*>( obj ); // THATS ALL!!
143  //
144  return StatusCode::SUCCESS; // RETURN
145 }

◆ rowWise()

bool Tuples::TupleObj::rowWise ( ) const
inline

row wise NTuple ?

Definition at line 1879 of file TupleObj.h.

1879 { return CLID_RowWiseTuple == clid(); }

◆ tuple() [1/2]

NTuple::Tuple* Tuples::TupleObj::tuple ( )
inline

provide the access to underlying Gaudi N-tuple

Returns
pointer to Gaudi N-tuple object

Definition at line 1867 of file TupleObj.h.

1867 { return m_tuple; }

◆ tuple() [2/2]

const NTuple::Tuple* Tuples::TupleObj::tuple ( ) const
inline

provide the access to underlying Gaudi N-tuple

Returns
pointer to Gaudi N-tuple object

Definition at line 1862 of file TupleObj.h.

1862 { return m_tuple; }

◆ type()

Tuples::Type Tuples::TupleObj::type ( ) const
inline

accessor to the N-Tuple type

Definition at line 1873 of file TupleObj.h.

1873 { return m_type; }

◆ valid()

bool Tuples::TupleObj::valid ( ) const
inline

valid pointer to tuple ?

Definition at line 1885 of file TupleObj.h.

1885 { return 0 != tuple(); }

◆ Warning()

virtual StatusCode Tuples::TupleObj::Warning ( const std::string msg,
const StatusCode  sc = StatusCode::FAILURE 
) const
pure virtual

◆ write()

StatusCode Tuples::TupleObj::write ( )

write a record to NTuple

Returns
status code

Definition at line 245 of file TupleObj.cpp.

245  {
246  if ( invalid() ) return ErrorCodes::InvalidTuple;
247  return tuple()->write();
248 }

Member Data Documentation

◆ m_addresses

ColumnStorage<Address> Tuples::TupleObj::m_addresses
mutableprivate

the actual storage of all 'Address' columns

Definition at line 2016 of file TupleObj.h.

◆ m_arraysf

ColumnStorage<FArray> Tuples::TupleObj::m_arraysf
mutableprivate

the actual storage of all 'FArray' columns (fixed)

Definition at line 2022 of file TupleObj.h.

◆ m_bools

ColumnStorage<Bool> Tuples::TupleObj::m_bools
mutableprivate

the actual storage of all 'bool' columns

Definition at line 1983 of file TupleObj.h.

◆ m_chars

ColumnStorage<Char> Tuples::TupleObj::m_chars
mutableprivate

the actual storage of all 'Int' columns

Definition at line 1986 of file TupleObj.h.

◆ m_clid

CLID Tuples::TupleObj::m_clid
private

tuple CLID

Definition at line 1949 of file TupleObj.h.

◆ m_doubles

ColumnStorage<Double> Tuples::TupleObj::m_doubles
mutableprivate

the actual storage of all 'Double' columns

Definition at line 2013 of file TupleObj.h.

◆ m_farrays

ColumnStorage<FArray> Tuples::TupleObj::m_farrays
mutableprivate

the actual storage of all 'FArray' columns

Definition at line 2019 of file TupleObj.h.

◆ m_floats

ColumnStorage<Float> Tuples::TupleObj::m_floats
mutableprivate

the actual storage of all 'Float' columns

Definition at line 2010 of file TupleObj.h.

◆ m_fmatrices

ColumnStorage<FMatrix> Tuples::TupleObj::m_fmatrices
mutableprivate

the actual storage of all 'FArray' columns

Definition at line 2025 of file TupleObj.h.

◆ m_ints

ColumnStorage<Int> Tuples::TupleObj::m_ints
mutableprivate

the actual storage of all 'Int' columns

Definition at line 1998 of file TupleObj.h.

◆ m_items

ItemMap Tuples::TupleObj::m_items
private

all booked types:

Definition at line 2031 of file TupleObj.h.

◆ m_longlongs

ColumnStorage<LongLong> Tuples::TupleObj::m_longlongs
mutableprivate

the actual storage of all 'long long' columns

Definition at line 2004 of file TupleObj.h.

◆ m_matricesf

ColumnStorage<FMatrix> Tuples::TupleObj::m_matricesf
mutableprivate

the actual storage of all 'FMatrix' columns (fixed)

Definition at line 2028 of file TupleObj.h.

◆ m_name

std::string Tuples::TupleObj::m_name
private

name

Definition at line 1943 of file TupleObj.h.

◆ m_refCount

size_t Tuples::TupleObj::m_refCount = 0
private

reference counter

Definition at line 1955 of file TupleObj.h.

◆ m_shorts

ColumnStorage<Short> Tuples::TupleObj::m_shorts
mutableprivate

the actual storage of all 'Int' columns

Definition at line 1992 of file TupleObj.h.

◆ m_tuple

NTuple::Tuple* Tuples::TupleObj::m_tuple
private

tuple itself

Definition at line 1946 of file TupleObj.h.

◆ m_type

Tuples::Type Tuples::TupleObj::m_type
private

tuple 'type'

Definition at line 1952 of file TupleObj.h.

◆ m_uchars

ColumnStorage<UChar> Tuples::TupleObj::m_uchars
mutableprivate

the actual storage of all 'unsigned int' columns

Definition at line 1989 of file TupleObj.h.

◆ m_uints

ColumnStorage<UInt> Tuples::TupleObj::m_uints
mutableprivate

the actual storage of all 'unsigned int' columns

Definition at line 2001 of file TupleObj.h.

◆ m_ulonglongs

ColumnStorage<ULongLong> Tuples::TupleObj::m_ulonglongs
mutableprivate

the actual storage of all 'unsigned long long' columns

Definition at line 2007 of file TupleObj.h.

◆ m_ushorts

ColumnStorage<UShort> Tuples::TupleObj::m_ushorts
mutableprivate

the actual storage of all 'unsigned int' columns

Definition at line 1995 of file TupleObj.h.


The documentation for this class was generated from the following files:
GaudiAlg.TupleUtils.nTuple
def nTuple(dirpath, ID, ID2=None, topdir=None, LUN="FILE1")
Definition: TupleUtils.py:84
NTuple::Tuple::addIndexedItem
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.
Definition: NTuple.h:672
Tuples::TupleObj::m_type
Tuples::Type m_type
tuple 'type'
Definition: TupleObj.h:1952
Gaudi::Accumulators::sqrt
auto sqrt(std::chrono::duration< Rep, Period > d)
sqrt for std::chrono::duration
Definition: Counters.h:34
Containers::Array
KeyedObjectManager< array > Array
Forward declaration of specialized redirection array object manager.
Definition: KeyedObjectManager.h:111
std::string
STL class.
Tuples::TupleObj::type
Tuples::Type type() const
accessor to the N-Tuple type
Definition: TupleObj.h:1873
Tuples::TupleObj::columns
StatusCode columns(Value &&value, Args &&... args)
Set the values for several columns simultaneously, for the same object Non-existing columns will be a...
Definition: TupleObj.h:773
Tuples::TupleObj::m_shorts
ColumnStorage< Short > m_shorts
the actual storage of all 'Int' columns
Definition: TupleObj.h:1992
Tuples::ErrorCodes::InvalidColumn
@ InvalidColumn
Tuples::TupleObj::column
StatusCode column(std::string_view name, float value)
Set the value for selected tuple column.
Definition: TupleObj.cpp:267
StatusCode::andThen
StatusCode andThen(F &&f, ARGS &&... args) const
Chain code blocks making the execution conditional a success result.
Definition: StatusCode.h:163
std::move
T move(T... args)
Tuples::TupleObj::m_fmatrices
ColumnStorage< FMatrix > m_fmatrices
the actual storage of all 'FArray' columns
Definition: TupleObj.h:2025
ROOT::Math::PositionVector3D
Definition: IMagneticFieldSvc.h:25
Tuples::TupleObj::tuple
const NTuple::Tuple * tuple() const
provide the access to underlying Gaudi N-tuple
Definition: TupleObj.h:1862
Tuples::TupleObj::matrix
StatusCode matrix(std::string_view name, const MATRIX &data, const MIndex &rows, const MIndex &cols)
fill N-Tuple with fixed-size matrix
Definition: TupleObj.h:1699
Tuples::EVTCOL
@ EVTCOL
Definition: TupleObj.h:93
std::pair
std::vector::reserve
T reserve(T... args)
Tuples::TupleObj::Error
virtual StatusCode Error(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const =0
Tuples::TupleObj::m_arraysf
ColumnStorage< FArray > m_arraysf
the actual storage of all 'FArray' columns (fixed)
Definition: TupleObj.h:2022
IOpaqueAddress
Definition: IOpaqueAddress.h:33
std::vector< double >
std::map::find
T find(T... args)
Gaudi::Units::GeV
constexpr double GeV
Definition: SystemOfUnits.h:179
std::back_inserter
T back_inserter(T... args)
GaudiAlg.Algs.Tuple
Tuple
Definition: Algs.py:1173
Tuples::TupleObj::evtColType
bool evtColType() const
Event collection ?
Definition: TupleObj.h:1882
std::map::emplace
T emplace(T... args)
std::distance
T distance(T... args)
Tuples::TupleObj::fill
StatusCode fill(std::string_view fmt, Arg arg, Args... args)
Set the values for several columns simultaneously.
Definition: TupleObj.h:807
Tuples::TupleObj::farray_impl
StatusCode farray_impl(FunIterator first_item, FunIterator last_item, DataIterator first, DataIterator last, std::string_view length, size_t maxv)
Put arbitrary number of functions from one data array into LoKi-style N-Tuple simultaneously (effecti...
Definition: TupleObj.h:1060
Gaudi::Units::second
constexpr double second
Definition: SystemOfUnits.h:139
Tuples::TupleObj::array
StatusCode array(std::string_view name, DATA first, DATA last)
fill N-Tuple with fixed-size array
Definition: TupleObj.h:1544
std::any_of
T any_of(T... args)
System::typeinfoName
GAUDI_API const std::string typeinfoName(const std::type_info &)
Get platform independent information about the class type.
Definition: System.cpp:313
Tuples::Local::Counter::increment
long increment(std::string_view object)
Definition: TupleObj.cpp:189
Tuples::TupleObj::m_clid
CLID m_clid
tuple CLID
Definition: TupleObj.h:1949
Tuples::TupleObj::m_floats
ColumnStorage< Float > m_floats
the actual storage of all 'Float' columns
Definition: TupleObj.h:2010
Tuples::TupleObj::m_bools
ColumnStorage< Bool > m_bools
the actual storage of all 'bool' columns
Definition: TupleObj.h:1983
std::vector::push_back
T push_back(T... args)
Tuples::ItemStore::getItem
NTuple::Item< VALUE > * getItem(std::string_view key, Tuples::TupleObj *tuple)
the only one method:
Definition: TuplePut.h:44
Tuples::TupleObj::m_matricesf
ColumnStorage< FMatrix > m_matricesf
the actual storage of all 'FMatrix' columns (fixed)
Definition: TupleObj.h:2028
StatusCode
Definition: StatusCode.h:65
Tuples::TupleObj::m_items
ItemMap m_items
all booked types:
Definition: TupleObj.h:2031
std::ostream
STL class.
std::forward
T forward(T... args)
CLHEP::begin
double * begin(CLHEP::HepVector &v)
Definition: TupleAlg.cpp:45
INTuple::write
virtual StatusCode write()=0
Write record of the NTuple (Shortcut of writeRecord)
Tuples::TupleObj::FMatrix
NTuple::Matrix< float > FMatrix
Definition: TupleObj.h:228
Tuples::TupleObj::valid
bool valid() const
valid pointer to tuple ?
Definition: TupleObj.h:1885
Tuples::TupleObj::fmatrix
StatusCode fmatrix(std::string_view name, const MATRIX &data, size_t rows, const MIndex &cols, std::string_view length, size_t maxv)
Fill N-Tuple with data from variable-size matrix.
Definition: TupleObj.h:1303
std::array
STL class.
Tuples::ErrorCodes::InvalidObject
@ InvalidObject
std::copy
T copy(T... args)
std::runtime_error
STL class.
std::accumulate
T accumulate(T... args)
format
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
NTuple::Tuple::addItem
StatusCode addItem(const std::string &name, Item< TYPE > &itm)
Add a scalar data item a N tuple.
Definition: NTuple.h:515
Tuples::TupleObj::m_addresses
ColumnStorage< Address > m_addresses
the actual storage of all 'Address' columns
Definition: TupleObj.h:2016
std::transform
T transform(T... args)
Tuples::detail::to_float
constexpr to_< float > to_float
Definition: TupleObj.h:80
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:234
Tuples::TupleObj::m_longlongs
ColumnStorage< LongLong > m_longlongs
the actual storage of all 'long long' columns
Definition: TupleObj.h:2004
Tuples::TupleObj::m_ushorts
ColumnStorage< UShort > m_ushorts
the actual storage of all 'unsigned int' columns
Definition: TupleObj.h:1995
Tuples::TupleObj::m_name
std::string m_name
name
Definition: TupleObj.h:1943
StatusCode::ignore
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
Definition: StatusCode.h:139
std::min
T min(T... args)
std::sin
T sin(T... args)
std::ostringstream
STL class.
StatusCode::isFailure
bool isFailure() const
Definition: StatusCode.h:129
Tuples::TupleObj::ints
Int * ints(std::string_view name, int minv, int maxv)
get the column
Definition: TupleObj.cpp:315
Tuples::TupleObj::m_farrays
ColumnStorage< FArray > m_farrays
the actual storage of all 'FArray' columns
Definition: TupleObj.h:2019
Tuples::TupleObj::clid
const CLID & clid() const
accessor to the N-Tuple CLID
Definition: TupleObj.h:1870
Tuples::TupleObj::m_doubles
ColumnStorage< Double > m_doubles
the actual storage of all 'Double' columns
Definition: TupleObj.h:2013
GaudiAlg.TupleUtils.ntuple
def ntuple
Definition: TupleUtils.py:160
Tuples::TupleObj::Warning
virtual StatusCode Warning(const std::string &msg, const StatusCode sc=StatusCode::FAILURE) const =0
Tuples::TupleObj::m_ints
ColumnStorage< Int > m_ints
the actual storage of all 'Int' columns
Definition: TupleObj.h:1998
Tuples::TupleObj::m_ulonglongs
ColumnStorage< ULongLong > m_ulonglongs
the actual storage of all 'unsigned long long' columns
Definition: TupleObj.h:2007
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
Tuples::TupleObj::invalid
bool invalid() const
invalid pointer to tuple ?
Definition: TupleObj.h:1888
gaudirun.args
args
Definition: gaudirun.py:336
Tuples::ErrorCodes::InvalidTuple
@ InvalidTuple
std::begin
T begin(T... args)
Tuples::TupleObj::FArray
NTuple::Array< float > FArray
Definition: TupleObj.h:227
Tuples::TupleObj::MIndex
unsigned short MIndex
Definition: TupleObj.h:231
Tuples::Local::Counter::decrement
long decrement(std::string_view object)
Definition: TupleObj.cpp:191
fmt
Definition: MessageSvcSink.cpp:26
GaudiAlg.Algs.std
std
Definition: Algs.py:82
std::ptrdiff_t
ROOT::Math::DisplacementVector3D
Definition: IMagneticFieldSvc.h:28
Tuples::TupleObj::m_uchars
ColumnStorage< UChar > m_uchars
the actual storage of all 'unsigned int' columns
Definition: TupleObj.h:1989
Tuples::TupleObj::write
StatusCode write()
write a record to NTuple
Definition: TupleObj.cpp:245
Tuples::TupleObj::m_tuple
NTuple::Tuple * m_tuple
tuple itself
Definition: TupleObj.h:1946
Properties.v
v
Definition: Properties.py:122
Tuples::TupleObj::farray
StatusCode farray(std::string_view name, ITERATOR1 &&first, ITERATOR2 &&last, std::string_view length, size_t maxv)
Add an indexed array (of type float) to N-tuple.
Definition: TupleObj.h:886
Tuples::TupleObj::m_uints
ColumnStorage< UInt > m_uints
the actual storage of all 'unsigned int' columns
Definition: TupleObj.h:2001
Tuples::TupleObj::rowWise
bool rowWise() const
row wise NTuple ?
Definition: TupleObj.h:1879
std::end
T end(T... args)
IOTest.end
end
Definition: IOTest.py:123
Tuples::TupleObj::Int
NTuple::Item< int > Int
Definition: TupleObj.h:220
Tuples::ErrorCodes::InvalidItem
@ InvalidItem
Tuples::TupleObj::fMatrix
FMatrix * fMatrix(std::string_view name, Int *item, const MIndex &cols)
get the column
Definition: TupleObj.cpp:405
Tuples::ErrorCodes::InvalidOperation
@ InvalidOperation
Tuples::TupleObj::fArray
FArray * fArray(std::string_view name, Int *item)
get the column
Definition: TupleObj.cpp:383
std::numeric_limits
Tuples::ItemStore
Definition: TuplePut.h:35
GaudiPython::Row
Vector Row
Definition: Vector.h:29
Tuples::TupleObj::m_chars
ColumnStorage< Char > m_chars
the actual storage of all 'Int' columns
Definition: TupleObj.h:1986
std::cref
T cref(T... args)
Tuples::TupleObj::name
const std::string & name() const
get the name
Definition: TupleObj.h:1857
Gaudi::ParticleProperties::index
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...
Definition: IParticlePropertySvc.cpp:39
GaudiUtils::details::ostream_joiner
Stream & ostream_joiner(Stream &os, Iterator first, Iterator last, Separator sep, OutputElement output=OutputElement{})
Definition: SerializeSTL.h:73
std::next
T next(T... args)
std::initializer_list
Gaudi::XYZPoint
ROOT::Math::XYZPoint XYZPoint
3D cartesian point (double)
Definition: Point3DTypes.h:39