Gaudi Framework, version v23r5

Home   Generated: Wed Nov 28 2012
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
Tuples::TupleObj Class Referenceabstract

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

#include <GaudiAlg/TupleObj.h>

Inheritance diagram for Tuples::TupleObj:
Inheritance graph
[legend]
Collaboration diagram for Tuples::TupleObj:
Collaboration graph
[legend]

Public Types

typedef NTuple::Item< bool > Bool
 basic type for int items
 
typedef NTuple::Item< char > Char
 basic type for int items
 
typedef NTuple::Item< unsigned
char > 
UChar
 basic type for unsigned int items
 
typedef NTuple::Item< short > Short
 basic type for int items
 
typedef NTuple::Item< unsigned
short > 
UShort
 basic type for unsigned int items
 
typedef NTuple::Item< intInt
 basic type for int items
 
typedef NTuple::Item< unsigned
int
UInt
 basic type for unsigned int items
 
typedef NTuple::Item< long long > LongLong
 basic type for unsigned long long items
 
typedef NTuple::Item< unsigned
long long > 
ULongLong
 basic type for unsigned long long items
 
typedef NTuple::Item< float > Float
 basic type for float items
 
typedef NTuple::Item< double > Double
 basic type for double items
 
typedef NTuple::Item
< IOpaqueAddress * > 
Address
 basic type for address items
 
typedef NTuple::Array< float > FArray
 basic type for array of floats
 
typedef NTuple::Matrix< float > FMatrix
 basic type for matrix of floats
 
typedef unsigned short MIndex
 
typedef std::map< std::string,
std::string
ItemMap
 

Public Member Functions

StatusCode column (const std::string &name, const float value)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const 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.
 
StatusCode column (const std::string &name, const short value)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const short value, const short minv, const short maxv)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const unsigned short value)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const unsigned short value, const unsigned short minv, const unsigned short maxv)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const char value)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const char value, const char minv, const char maxv)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const unsigned char value)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const unsigned char value, const unsigned char minv, const unsigned char maxv)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const int value)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const int value, const int minv, const int maxv)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const unsigned int value)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const unsigned int value, const unsigned int minv, const unsigned int maxv)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const long value)
 Set the value for the selected tuple column.
 
StatusCode column (const std::string &name, const long value, const long minv, const long maxv)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const unsigned long value)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const unsigned long value, const unsigned long minv, const unsigned long maxv)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const long long value)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const long long value, const long long minv, const long long maxv)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const unsigned long long value)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const unsigned long long value, const unsigned long long minv, const unsigned long long maxv)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, const signed char value)
 Set the value for the selected tuple column.
 
StatusCode column (const std::string &name, const bool value)
 Set the value for selected tuple column.
 
StatusCode column (const std::string &name, IOpaqueAddress *address)
 Put IOpaqueAddress in POOL-based NTuple.
 
StatusCode column (IOpaqueAddress *address)
 Put IOpaqueAddress in NTuple.
 
StatusCode fill (const char *format...)
 Set the values for several columns simultaneously.
 
template<class DATA >
StatusCode farray (const std::string &name, DATA first, DATA last, const std::string &length, const size_t maxv)
 Add an indexed array (of type float) to N-tuple.
 
template<class DATA >
StatusCode farray (const std::string &name, const DATA &data, const std::string &length, const size_t maxv)
 Add an indexed array (of type float) to N-tuple.
 
template<class FUNCTION , class DATA >
StatusCode farray (const std::string &name, const FUNCTION &function, DATA first, DATA last, const std::string &length, const size_t maxv)
 Put an indexed array into LoKi-style N-Tuple.
 
template<class FUNC1 , class FUNC2 , class DATA >
StatusCode farray (const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, DATA first, DATA last, const std::string &length, const size_t maxv)
 Put two functions from one data array into LoKi-style N-Tuple simultaneously (effective!)
 
template<class FUNC1 , class FUNC2 , class FUNC3 , class DATA >
StatusCode farray (const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, const std::string &name3, const FUNC3 &func3, DATA first, DATA last, const std::string &length, const size_t maxv)
 Put three functions from one data array into LoKi-style N-Tuple simultaneously (effective!)
 
template<class FUNC1 , class FUNC2 , class FUNC3 , class FUNC4 , class DATA >
StatusCode farray (const std::string &name1, const FUNC1 &func1, const std::string &name2, const FUNC2 &func2, const std::string &name3, const FUNC3 &func3, const std::string &name4, const FUNC4 &func4, DATA first, DATA last, const std::string &length, const size_t maxv)
 Put four functions from one data array into LoKi-style N-Tuple simultaneously (effective!)
 
template<class MATRIX >
StatusCode fmatrix (const std::string &name, const MATRIX &data, size_t rows, const MIndex &cols, const std::string &length, const size_t maxv)
 Fill N-Tuple with data from variable-size matrix.
 
template<class DATA >
StatusCode fmatrix (const std::string &name, DATA first, DATA last, const MIndex &cols, const std::string &length, const size_t maxv)
 Fill N-Tuple with data from variable-size matrix.
 
template<class FUN , class DATA >
StatusCode fmatrix (const std::string &name, FUN funF, FUN funL, DATA first, DATA last, const std::string &length, const size_t maxv)
 fill N-Tuple with matrix of "direct-product" of "data-vector" [first,last) and "function-vector" [funF, funL)
 
template<class DATA >
StatusCode array (const std::string &name, DATA first, DATA last)
 fill N-Tuple with fixed-size array
 
template<class ARRAY >
StatusCode array (const std::string &name, const ARRAY &data, const MIndex &length)
 fill N-Tuple with fixed-size array
 
template<class ARRAY >
StatusCode array (const std::string &name, const ARRAY &data)
 fill N-Tuple with fixed-size array
 
template<class MATRIX >
StatusCode matrix (const std::string &name, const MATRIX &data, const MIndex &rows, const MIndex &cols)
 fill N-Tuple with fixed-size matrix
 
template<class TYPE >
StatusCode column (const std::string &name, const ROOT::Math::LorentzVector< TYPE > &v)
 Useful shortcut to put LorentzVector directly into N-Tuple:
 
template<class TYPE , class TAG >
StatusCode column (const std::string &name, const ROOT::Math::DisplacementVector3D< TYPE, TAG > &v)
 Useful shortcut to put 3D-Vector directly into N-Tuple:
 
template<class TYPE , class TAG >
StatusCode column (const std::string &name, const ROOT::Math::PositionVector3D< TYPE, TAG > &v)
 Useful shortcut to put 3D-Vector directly into N-Tuple:
 
template<class TYPE , unsigned int DIM>
StatusCode array (const std::string &name, const ROOT::Math::SVector< TYPE, DIM > &vect)
 shortcut to put SVector into N-tuple:
 
template<class TYPE , unsigned int D1, unsigned int D2, class REP >
StatusCode matrix (const std::string &name, const ROOT::Math::SMatrix< TYPE, D1, D2, REP > &mtrx)
 shortcut to put Smatrix into N-tuple:
 
template<class KEY , class VALUE >
StatusCode fmatrix (const std::string &name, const GaudiUtils::VectorMap< KEY, VALUE > &info, const std::string &length, const size_t maxv=100)
 shortcut to put "ExtraInfo" fields of major into N-Tuple
 
template<class TYPE >
StatusCode put (const std::string &name, const TYPE *obj)
 The function allows to add almost arbitrary object into N-tuple.
 
StatusCode write ()
 write a record to NTuple
 
const std::stringname () const
 get the name
 
NTuple::Tupletuple () const
 provide the access to underlying Gaudi N-tuple
 
unsigned long refCount () const
 return the reference counter
 
unsigned long addRef ()
 add the reference to TupleObj
 
void release ()
 release the reference to TupleObj if reference counter becomes zero, object will be automatically deleted
 
const CLIDclid () const
 accessor to the N-Tuple CLID
 
Tuples::Type type () const
 accessor to the N-Tuple type
 
bool columnWise () const
 column wise NTuple ?
 
bool rowWise () const
 row wise NTuple ?
 
bool evtColType () const
 Event collection ?
 
bool valid () const
 valid pointer to tuple ?
 
bool invalid () const
 invalid pointer to tuple ?
 
bool addItem (const std::string &name, const std::string &type)
 add the item name into the list of known items
 
bool goodItem (const std::string &name) const
 check the uniqueness of the name
 
const ItemMapitems () const
 get the full list of booked items
 
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 (const std::string &name, NTuple::Tuple *tuple, const CLID &clid=CLID_ColumnWiseTuple, const Tuples::Type type=Tuples::NTUPLE)
 Standard constructor.
 
virtual ~TupleObj ()
 destructor is protected
 

Private Types

typedef GaudiUtils::HashMap
< std::string, Bool * > 
Bools
 the actual storage type for short columns
 
typedef GaudiUtils::HashMap
< std::string, Char * > 
Chars
 the actual storage type for short columns
 
typedef GaudiUtils::HashMap
< std::string, UChar * > 
UChars
 the actual storage type for unsigned short columns
 
typedef GaudiUtils::HashMap
< std::string, Short * > 
Shorts
 the actual storage type for short columns
 
typedef GaudiUtils::HashMap
< std::string, UShort * > 
UShorts
 the actual storage type for unsigned short columns
 
typedef GaudiUtils::HashMap
< std::string, Int * > 
Ints
 the actual storage type for integer columns
 
typedef GaudiUtils::HashMap
< std::string, UInt * > 
UInts
 the actual storage type for unsigned integer columns
 
typedef GaudiUtils::HashMap
< std::string, LongLong * > 
LongLongs
 the actual storage type for longlong columns
 
typedef GaudiUtils::HashMap
< std::string, ULongLong * > 
ULongLongs
 the actual storage type for ulonglong columns
 
typedef GaudiUtils::HashMap
< std::string, Float * > 
Floats
 the actual storage type for float columns
 
typedef GaudiUtils::HashMap
< std::string, Double * > 
Doubles
 the actual storage type for float columns
 
typedef GaudiUtils::HashMap
< std::string, Address * > 
Addresses
 the actual storage type for address columns
 
typedef GaudiUtils::HashMap
< std::string, FArray * > 
FArrays
 the actual storage type for array columns
 
typedef GaudiUtils::HashMap
< std::string, FMatrix * > 
FMatrices
 the actual storage type for matrix columns
 

Private Member Functions

Boolbools (const std::string &name)
 get the column
 
Floatfloats (const std::string &name)
 get the column
 
Doubledoubles (const std::string &name)
 get the column
 
Charchars (const std::string &name)
 get the column
 
Charchars (const std::string &name, const char minv, const char maxv)
 get the column
 
UCharuchars (const std::string &name)
 get the column
 
UCharuchars (const std::string &name, const unsigned char minv, const unsigned char maxv)
 get the column
 
Shortshorts (const std::string &name)
 get the column
 
Shortshorts (const std::string &name, const short minv, const short maxv)
 get the column
 
UShortushorts (const std::string &name)
 get the column
 
UShortushorts (const std::string &name, const unsigned short minv, const unsigned short maxv)
 get the column
 
Intints (const std::string &name)
 get the column
 
Intints (const std::string &name, const int minv, const int maxv)
 get the column
 
UIntuints (const std::string &name)
 get the column
 
UIntuints (const std::string &name, const unsigned int minv, const unsigned int maxv)
 get the column
 
LongLonglonglongs (const std::string &name)
 get the column
 
LongLonglonglongs (const std::string &name, const long long minv, const long long maxv)
 get the column
 
ULongLongulonglongs (const std::string &name)
 get the column
 
ULongLongulonglongs (const std::string &name, const unsigned long long minv, const unsigned long long maxv)
 get the column
 
FArrayfArray (const std::string &name, Int *item)
 get the column
 
FArrayfArray (const std::string &name, const MIndex &rows)
 get the column
 
Addressaddresses (const std::string &name)
 get the column
 
FMatrixfMatrix (const std::string &name, Int *item, const MIndex &cols)
 get the column
 
FMatrixfMatrix (const std::string &name, const MIndex &rows, const MIndex &cols)
 get the column
 
 TupleObj ()
 the default constructor is disabled
 
 TupleObj (const TupleObj &)
 copy constructor is disabled
 
TupleObjoperator= (const TupleObj &)
 assignment is disabled
 

Private Attributes

std::string m_name
 name
 
NTuple::Tuplem_tuple
 tuple itself
 
CLID m_clid
 tuple CLID
 
Tuples::Type m_type
 tuple 'type'
 
size_t m_refCount
 reference counter
 
Bools m_bools
 the actual storage of all 'bool' columns
 
Chars m_chars
 the actual storage of all 'Int' columns
 
UChars m_uchars
 the actual storage of all 'unsigned int' columns
 
Shorts m_shorts
 the actual storage of all 'Int' columns
 
UShorts m_ushorts
 the actual storage of all 'unsigned int' columns
 
Ints m_ints
 the actual storage of all 'Int' columns
 
UInts m_uints
 the actual storage of all 'unsigned int' columns
 
LongLongs m_longlongs
 the actual storage of all 'longlong' columns
 
ULongLongs m_ulonglongs
 the actual storage of all 'ulonglong' columns
 
Floats m_floats
 the actual storage of all 'Float' columns
 
Doubles m_doubles
 the actual storage of all 'Double' columns
 
Addresses m_addresses
 the actual storage of all 'Address' columns
 
FArrays m_farrays
 the actual storage of all 'FArray' columns
 
FArrays m_arraysf
 the actual storage of all 'FArray' columns (fixed)
 
FMatrices m_fmatrices
 the actual storage of all 'FArray' columns
 
FMatrices m_matricesf
 the actual storage of all 'FMatrix' columns (fixed)
 
ItemMap m_items
 all booked types:
 

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 180 of file TupleObj.h.

Member Typedef Documentation

basic type for address items

Definition at line 218 of file TupleObj.h.

the actual storage type for address columns

Definition at line 2301 of file TupleObj.h.

basic type for int items

Definition at line 185 of file TupleObj.h.

the actual storage type for short columns

Definition at line 2268 of file TupleObj.h.

basic type for int items

Definition at line 188 of file TupleObj.h.

the actual storage type for short columns

Definition at line 2271 of file TupleObj.h.

basic type for double items

Definition at line 215 of file TupleObj.h.

the actual storage type for float columns

Definition at line 2298 of file TupleObj.h.

basic type for array of floats

Definition at line 221 of file TupleObj.h.

the actual storage type for array columns

Definition at line 2304 of file TupleObj.h.

basic type for float items

Definition at line 212 of file TupleObj.h.

the actual storage type for float columns

Definition at line 2295 of file TupleObj.h.

the actual storage type for matrix columns

Definition at line 2307 of file TupleObj.h.

basic type for matrix of floats

Definition at line 224 of file TupleObj.h.

basic type for int items

Definition at line 200 of file TupleObj.h.

the actual storage type for integer columns

Definition at line 2283 of file TupleObj.h.

Definition at line 230 of file TupleObj.h.

basic type for unsigned long long items

Definition at line 206 of file TupleObj.h.

the actual storage type for longlong columns

Definition at line 2289 of file TupleObj.h.

typedef unsigned short Tuples::TupleObj::MIndex

Definition at line 227 of file TupleObj.h.

basic type for int items

Definition at line 194 of file TupleObj.h.

the actual storage type for short columns

Definition at line 2277 of file TupleObj.h.

typedef NTuple::Item<unsigned char> Tuples::TupleObj::UChar

basic type for unsigned int items

Definition at line 191 of file TupleObj.h.

the actual storage type for unsigned short columns

Definition at line 2274 of file TupleObj.h.

basic type for unsigned int items

Definition at line 203 of file TupleObj.h.

the actual storage type for unsigned integer columns

Definition at line 2286 of file TupleObj.h.

typedef NTuple::Item<unsigned long long> Tuples::TupleObj::ULongLong

basic type for unsigned long long items

Definition at line 209 of file TupleObj.h.

the actual storage type for ulonglong columns

Definition at line 2292 of file TupleObj.h.

typedef NTuple::Item<unsigned short> Tuples::TupleObj::UShort

basic type for unsigned int items

Definition at line 197 of file TupleObj.h.

the actual storage type for unsigned short columns

Definition at line 2280 of file TupleObj.h.

Constructor & Destructor Documentation

Tuples::TupleObj::TupleObj ( const 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 84 of file TupleObj.cpp.

: m_name ( name )
, m_tuple ( tuple )
, m_clid ( clid )
, m_type ( type )
// for error handling
, m_refCount ( 0 )
// columns
, m_bools ()
, m_chars ()
, m_uchars ()
, m_shorts ()
, m_ushorts ()
, m_ints ()
, m_uints ()
, m_floats ()
, m_doubles ()
, m_farrays ()
, m_arraysf ()
//
, m_items ()
{
// make counts
}
Tuples::TupleObj::~TupleObj ( )
protectedvirtual

destructor is protected

Definition at line 121 of file TupleObj.cpp.

{
{// delete 'bool' columns
m_bools.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'char' columns
m_chars.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'unsigned char' columns
m_uchars.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'short' columns
m_shorts.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'unsigned short' columns
m_ushorts.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'int' columns
for( Ints::iterator it = m_ints.begin() ;
m_ints.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'unsigned int' columns
m_uints.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'longlong' columns
m_longlongs.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'ulonglong' columns
m_ulonglongs.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'float' columns
m_floats.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'double' columns
m_doubles.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'fArray' columns
m_farrays.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{// delete 'fArray' columns
m_arraysf.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{ // destroy and clean all "addresses"
m_addresses.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{ // destroy and clean all "matrices"
m_fmatrices.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
{ // destroy and clean all "matrices" (fixed)
m_matricesf.end() != it ; ++it )
{ if( 0 != it->second ) { delete it->second ; } }
}
// make counts
}
Tuples::TupleObj::TupleObj ( )
private

the default constructor is disabled

Tuples::TupleObj::TupleObj ( const TupleObj )
private

copy constructor is disabled

Member Function Documentation

bool Tuples::TupleObj::addItem ( const std::string name,
const 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 2134 of file TupleObj.h.

{ return m_items.insert ( std::make_pair ( name , type ) ).second ; }
unsigned long Tuples::TupleObj::addRef ( )
inline

add the reference to TupleObj

Returns
current reference counter

Definition at line 2098 of file TupleObj.h.

{ return ++m_refCount ; }
Tuples::TupleObj::Address * Tuples::TupleObj::addresses ( const std::string name)
private

get the column

Definition at line 887 of file TupleObj.cpp.

{
if( m_addresses.end() != found ) { return found->second ; }
Address* item = new Address() ;
const StatusCode sc = tuple()->addItem( name , *item );
if( sc.isFailure() )
{ Error ( "addresses ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "IOpaqueAddress*" ) )
{ Error ( "addresses ('" + name + "'): item is not unique" ) ; }
return item ;
}
template<class DATA >
StatusCode Tuples::TupleObj::array ( const std::string 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 1659 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// get the length (fixed!)
const size_t length = last - first ;
// get the array itself
FArray* var = fArray ( name , length ) ;
if ( 0 == var ) { return InvalidColumn ; }
size_t iCol = 0 ;
for ( ; first != last ; ++first )
{ (*var)[ iCol ] = (float)(*first) ; ++iCol ; }
}
template<class ARRAY >
StatusCode Tuples::TupleObj::array ( const std::string 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

fill the array

Definition at line 1721 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// get the array itself
FArray* var = fArray ( name , length ) ;
if ( 0 == var ) { return InvalidColumn ; }
for ( size_t index = 0 ; index < length ; ++index )
{ (*var)[ index ] = (float) data[index] ; }
}
template<class ARRAY >
StatusCode Tuples::TupleObj::array ( const std::string 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>

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 1769 of file TupleObj.h.

{ return array ( name , data.begin() , data.end() ) ; }
template<class TYPE , unsigned int DIM>
StatusCode Tuples::TupleObj::array ( const std::string name,
const ROOT::Math::SVector< TYPE, DIM > &  vect 
)
inline

shortcut to put SVector into N-tuple:

ROOT::Math::SVector<double,15> vct = ... ;
Tuple tuple = nTuple("My N-Tuple") ;
// put the vector into N-Tuple:
tuple -> array ( "v" , vct ) ;
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 1963 of file TupleObj.h.

{
return this->array( name , vect.begin() , vect.end() ) ;
}
Tuples::TupleObj::Bool * Tuples::TupleObj::bools ( const std::string name)
private

get the column

Definition at line 616 of file TupleObj.cpp.

{
if( m_bools.end() != found ) { return found->second ; }
Bool* item = new Bool() ;
m_bools[ name ] = item ;
StatusCode sc = tuple()->addItem( name , *item );
if( sc.isFailure() )
{ Error ( "bools ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "bools ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::Char * Tuples::TupleObj::chars ( const std::string name)
private

get the column

Definition at line 631 of file TupleObj.cpp.

{
if( m_chars.end() != found ) { return found->second ; }
Char* item = new Char() ;
m_chars[ name ] = item ;
StatusCode sc = tuple()->addItem( name , *item );
if( sc.isFailure() )
{ Error ( "chars ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "chars ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::Char * Tuples::TupleObj::chars ( const std::string name,
const char  minv,
const char  maxv 
)
private

get the column

Definition at line 646 of file TupleObj.cpp.

{
if( m_chars.end() != found ) { return found->second ; }
Char* item = new Char() ;
m_chars[ name ] = item ;
const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
if( sc.isFailure() )
{ Error ( "chars ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "chars ('" + name + "'): item is not unique" ) ; }
return item ;
}
const CLID& Tuples::TupleObj::clid ( ) const
inline

accessor to the N-Tuple CLID

Definition at line 2107 of file TupleObj.h.

{ return m_clid ; }
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 337 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
Float* item = floats ( name ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 347 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
Double * item = doubles ( name ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 401 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const short  value,
const short  minv,
const 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 411 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
Short* item = shorts ( name , minv , maxv ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 423 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const unsigned short  value,
const unsigned short  minv,
const 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 433 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
UShort* item = ushorts ( name , minv , maxv ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 357 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
Char* item = chars( name ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const char  value,
const char  minv,
const 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 367 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
Char* item = chars ( name , minv , maxv ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 379 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const unsigned char  value,
const unsigned char  minv,
const 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 389 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
UChar* item = uchars ( name , minv , maxv ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 445 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
Int* item = ints( name ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const int  value,
const int  minv,
const 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 455 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
Int* item = ints ( name , minv , maxv ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 467 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
UInt* item = uints( name ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const unsigned int  value,
const unsigned int  minv,
const 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 477 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
UInt* item = uints ( name , minv , maxv ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 489 of file TupleObj.cpp.

{
Warning( "'long' has different sizes on 32/64 bit systems. Casting '" +
name + "' to 'long long'", StatusCode::SUCCESS ).ignore();
return column( name, (long long)value );
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const long  value,
const long  minv,
const 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 497 of file TupleObj.cpp.

{
Warning( "'long' has different sizes on 32/64 bit systems. Casting '" +
name + "' to 'long long'", StatusCode::SUCCESS ).ignore();
return column( name,
(long long)value,
(long long)minv,
(long long)maxv );
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 510 of file TupleObj.cpp.

{
Warning( "'unsigned long' has different sizes on 32/64 bit systems. Casting '" +
name + "' to 'unsigned long long'", StatusCode::SUCCESS ).ignore();
return column( name, (unsigned long long)value );
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const unsigned long  value,
const unsigned long  minv,
const 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 518 of file TupleObj.cpp.

{
Warning( "'unsigned long' has different sizes on 32/64 bit systems. Casting '" +
name + "' to 'unsigned long long'", StatusCode::SUCCESS ).ignore();
return column( name,
(unsigned long long)value,
(unsigned long long)minv,
(unsigned long long)maxv );
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 531 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const long long  value,
const long long  minv,
const 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 541 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
LongLong* item = longlongs ( name , minv , maxv ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 553 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const unsigned long long  value,
const unsigned long long  minv,
const 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 563 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
ULongLong* item = ulonglongs ( name , minv , maxv ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 732 of file TupleObj.h.

StatusCode Tuples::TupleObj::column ( const std::string name,
const 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 575 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
Bool* item = bools( name ) ;
if ( !item ) { return InvalidColumn ; }
*item = value ;
}
StatusCode Tuples::TupleObj::column ( const std::string 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 313 of file TupleObj.cpp.

{
if ( invalid () ) { return InvalidTuple ; }
if ( !evtColType () ) { return InvalidOperation ; }
if ( 0 == address )
{ return Error ( "column('" + name +
"') IOpaqueAddress* is NULL!" , InvalidObject ) ; }
if ( 0 == item ) { return InvalidItem ; }
*item = address ;
}
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 331 of file TupleObj.cpp.

{
return column ( "Address" , address ) ;
}
template<class TYPE >
StatusCode Tuples::TupleObj::column ( const std::string 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 1865 of file TupleObj.h.

{
if ( invalid() ) { return InvalidTuple ; }
// fill all separate columns:
StatusCode sc1 = this -> column ( name + "E" , v.E () ) ;
StatusCode sc2 = this -> column ( name + "X" , v.Px () ) ;
StatusCode sc3 = this -> column ( name + "Y" , v.Py () ) ;
StatusCode sc4 = this -> column ( name + "Z" , v.Pz () ) ;
return
sc1.isFailure () ? sc1 :
sc2.isFailure () ? sc2 :
sc3.isFailure () ? sc3 :
sc4.isFailure () ? sc4 : StatusCode(StatusCode::SUCCESS) ;
}
template<class TYPE , class TAG >
StatusCode Tuples::TupleObj::column ( const std::string 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

fill separate columns

Definition at line 1899 of file TupleObj.h.

{
if ( invalid() ) { return InvalidTuple ; }
StatusCode sc1 = this -> column ( name + "X" , v.X () ) ;
StatusCode sc2 = this -> column ( name + "Y" , v.Y () ) ;
StatusCode sc3 = this -> column ( name + "Z" , v.Z () ) ;
return
sc1.isFailure () ? sc1 :
sc2.isFailure () ? sc2 :
sc3.isFailure () ? sc3 : StatusCode(StatusCode::SUCCESS) ;
}
template<class TYPE , class TAG >
StatusCode Tuples::TupleObj::column ( const std::string 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

fill separate columns

Definition at line 1931 of file TupleObj.h.

{
if ( invalid() ) { return InvalidTuple ; }
StatusCode sc1 = this -> column ( name + "X" , v.X () ) ;
StatusCode sc2 = this -> column ( name + "Y" , v.Y () ) ;
StatusCode sc3 = this -> column ( name + "Z" , v.Z () ) ;
return
sc1.isFailure () ? sc1 :
sc2.isFailure () ? sc2 :
sc3.isFailure () ? sc3 : StatusCode(StatusCode::SUCCESS) ;
}
bool Tuples::TupleObj::columnWise ( ) const
inline

column wise NTuple ?

Definition at line 2113 of file TupleObj.h.

{ return CLID_ColumnWiseTuple == clid() ; }
Tuples::TupleObj::Double * Tuples::TupleObj::doubles ( const std::string name)
private

get the column

Definition at line 601 of file TupleObj.cpp.

{
if ( m_doubles.end() != found ) { return found->second ; }
Double* item = new Double() ;
const StatusCode sc = tuple()->addItem( name , *item );
if ( sc.isFailure() )
{ Error ( "doubles ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "D" ) )
{ Error ( "doubles ('" + name + "'): item is not unique" ) ; }
return item ;
}
virtual StatusCode Tuples::TupleObj::Error ( const std::string msg,
const StatusCode  sc = StatusCode::FAILURE 
) const
pure virtual
bool Tuples::TupleObj::evtColType ( ) const
inline

Event collection ?

Definition at line 2119 of file TupleObj.h.

{ return Tuples::EVTCOL == type() ; }
template<class DATA >
StatusCode Tuples::TupleObj::farray ( const std::string name,
DATA  first,
DATA  last,
const std::string length,
const 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

fill the array

Definition at line 880 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// adjust the length
if( first + maxv < last )
{
Warning( "farray('"+name+"'): array is overflow, skip extra items") ;
last = first + maxv ;
}
// get the length item
Int* len = ints( length , 0 , maxv ) ;
if( 0 == len ) { return InvalidColumn; }
// adjust the length item
*len = last - first ;
// get the array itself
FArray* var = fArray ( name , len ) ;
if( 0 == var ) { return InvalidColumn ; }
size_t index = 0 ;
for( ; first != last ; ++first )
{ (*var)[ index ] = (float)(*first) ; ++index ; }
}
template<class DATA >
StatusCode Tuples::TupleObj::farray ( const std::string name,
const DATA &  data,
const std::string 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 958 of file TupleObj.h.

{ return farray ( name , data.begin() , data.end() , length , maxv ) ; }
template<class FUNCTION , class DATA >
StatusCode Tuples::TupleObj::farray ( const std::string name,
const FUNCTION &  function,
DATA  first,
DATA  last,
const std::string length,
const 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 1027 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// adjust the length
if( first + maxv < last )
{
Warning("farray('"
+ name + "'): array is overflow, skip extra entries") ;
last = first + maxv ;
}
// get the length item
Int* len = ints( length , 0 , maxv ) ;
if( 0 == len ) { return InvalidColumn ; }
// adjust the length
*len = last - first ;
// get the array itself
FArray* var = fArray ( name , len ) ;
if( 0 == var ) { return InvalidColumn ; }
// fill the array
size_t index = 0 ;
for( ; first != last ; ++first )
{ (*var)[ index ] = function( *first ) ; ++index ; }
}
template<class FUNC1 , class FUNC2 , class DATA >
StatusCode Tuples::TupleObj::farray ( const std::string name1,
const FUNC1 &  func1,
const std::string name2,
const FUNC2 &  func2,
DATA  first,
DATA  last,
const std::string length,
const 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( "sqr" , // 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 1096 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// adjust the lenfth
if( first + maxv < last )
{
Warning("farray('"
+ name1 + ","
+ name2 + "'): array is overflow, skip extra entries").ignore() ;
Warning("farray('"+name1+"'): array is overflow, skip extra items").ignore() ;
last = first + maxv ;
}
// get the length item
Int* len = ints ( length , 0 , maxv ) ;
if ( 0 == len ) { return InvalidColumn ; }
// adjust the length
*len = last - first ;
// get the array itself
FArray* var1 = fArray ( name1 , len ) ;
if ( 0 == var1 ) { return InvalidColumn ; }
// get the array itself
FArray* var2 = fArray ( name2 , len ) ;
if ( 0 == var2 ) { return InvalidColumn ; }
// fill the array
size_t index = 0 ;
for( ; first != last ; ++first )
{
( *var1 ) [ index ] = func1 ( *first ) ;
( *var2 ) [ index ] = func2 ( *first ) ;
++index ;
}
}
template<class FUNC1 , class FUNC2 , class FUNC3 , class DATA >
StatusCode Tuples::TupleObj::farray ( const std::string name1,
const FUNC1 &  func1,
const std::string name2,
const FUNC2 &  func2,
const std::string name3,
const FUNC3 &  func3,
DATA  first,
DATA  last,
const std::string length,
const 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( "sqr" , // 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 1182 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// adjust the length
if( first + maxv < last )
{
Warning("farray('"
+ name1 + ","
+ name2 + ","
+ name3 + "'): array is overflow, skip extra entries").ignore() ;
last = first + maxv ;
}
// get the length item
Int* len = ints ( length , 0 , maxv ) ;
if( 0 == len ) { return InvalidColumn ; }
// adjust the length
*len = last - first ;
// get the array itself
FArray* var1 = fArray ( name1 , len ) ;
if( 0 == var1 ) { return InvalidColumn ; }
// get the array itself
FArray* var2 = fArray ( name2 , len ) ;
if( 0 == var2 ) { return InvalidColumn ; }
// get the array itself
FArray* var3 = fArray ( name3 , len ) ;
if( 0 == var3 ) { return InvalidColumn ; }
// fill the array
size_t index = 0 ;
for( ; first != last ; ++first )
{
( *var1 ) [ index ] = (float)func1 ( *first ) ;
( *var2 ) [ index ] = (float)func2 ( *first ) ;
( *var3 ) [ index ] = (float)func3 ( *first ) ;
++index ;
}
}
template<class FUNC1 , class FUNC2 , class FUNC3 , class FUNC4 , class DATA >
StatusCode Tuples::TupleObj::farray ( const std::string name1,
const FUNC1 &  func1,
const std::string name2,
const FUNC2 &  func2,
const std::string name3,
const FUNC3 &  func3,
const std::string name4,
const FUNC4 &  func4,
DATA  first,
DATA  last,
const std::string length,
const 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( "sqr" , // 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 1277 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// adjust the length
if( first + maxv < last )
{
Warning("farray('"
+ name1 + ","
+ name2 + ","
+ name3 + ","
+ name4 + "'): array is overflow, skip extra entries").ignore() ;
last = first + maxv ;
}
// get the length item
Int* len = ints ( length , 0 , maxv ) ;
if( 0 == len ) { return InvalidColumn ; }
// adjust the length
*len = last - first ;
// get the array itself
FArray* var1 = fArray ( name1 , len ) ;
if( 0 == var1 ) { return InvalidColumn ; }
// get the array itself
FArray* var2 = fArray ( name2 , len ) ;
if( 0 == var2 ) { return InvalidColumn ; }
// get the array itself
FArray* var3 = fArray ( name3 , len ) ;
if( 0 == var3 ) { return InvalidColumn ; }
// get the array itself
FArray* var4 = fArray ( name4 , len ) ;
if( 0 == var4 ) { return InvalidColumn ; }
// fill the array
size_t index = 0 ;
for( ; first != last ; ++first )
{
( *var1 ) [ index ] = static_cast<float> ( func1 ( *first ) );
( *var2 ) [ index ] = static_cast<float> ( func2 ( *first ) );
( *var3 ) [ index ] = static_cast<float> ( func3 ( *first ) );
( *var4 ) [ index ] = static_cast<float> ( func4 ( *first ) );
++index ;
}
}
Tuples::TupleObj::FArray * Tuples::TupleObj::fArray ( const std::string name,
Int item 
)
private

get the column

Definition at line 904 of file TupleObj.cpp.

{
// existing array ?
if( m_farrays.end() != found ) { return found->second ; }
// create new array
FArray* array = new FArray () ;
const StatusCode sc = tuple() -> addIndexedItem( name , *length , *array) ;
if( sc.isFailure() )
{ Error ( "farray ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "FArray" ) )
{ Error ( "farray ('" + name + "'): item is not unique" ) ; }
return array ;
}
Tuples::TupleObj::FArray * Tuples::TupleObj::fArray ( const std::string name,
const MIndex rows 
)
private

get the column

Definition at line 924 of file TupleObj.cpp.

{
// existing array ?
if( m_arraysf.end() != found ) { return found->second ; }
// create new array
FArray* array = new FArray () ;
const StatusCode sc = tuple() -> addItem ( name , rows , *array) ;
if( sc.isFailure() )
{ Error ( "array ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "FArray" ) )
{ Error ( "array ('" + name + "'): item is not unique" ) ; }
return array ;
}
StatusCode Tuples::TupleObj::fill ( const char *  format...)

Set the values for several columns simultaneously.

Number of columns is arbitrary, but it should not be less than number of blank or comma 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);
Warning
ALL columns are assumed to be of type double
Parameters
formatblank-separated list of variables, followed by variable number of arguments.
Attention
All variables are assumed to be double numbers
Author
Vanya Belyaev Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru
Date
2002-10-30

decode arguments

Definition at line 282 of file TupleObj.cpp.

{
// check the underlying tuple
if ( invalid() ) { return InvalidTuple ; }
// decode format string into tokens
Tokens tokens ;
tokenize( format , tokens , " ,;" );
if ( tokens.empty() ) { return StatusCode::SUCCESS ; }
va_list valist ;
va_start( valist , format ) ;
// loop over all tokens
for( Tokens::const_iterator token = tokens.begin() ;
tokens.end() != token && status.isSuccess() ; ++token )
{
const double val = va_arg( valist , double );
status = column( *token , val );
if( status.isFailure() )
{ Error ( "fill(): Can not add column '" + *token + "' " ) ; }
}
// mandatory !!!
va_end( valist );
//
return status ;
}
Tuples::TupleObj::Float * Tuples::TupleObj::floats ( const std::string name)
private

get the column

Definition at line 586 of file TupleObj.cpp.

{
if ( m_floats.end() != found ) { return found->second ; }
Float* item = new Float() ;
const StatusCode sc = tuple()->addItem( name , *item );
if ( sc.isFailure() )
{ Error ( "floats ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "F" ) )
{ Error ( "floats ('" + name + "'): item is not unique" ) ; }
return item ;
}
template<class MATRIX >
StatusCode Tuples::TupleObj::fmatrix ( const std::string name,
const MATRIX &  data,
size_t  rows,
const MIndex cols,
const std::string length,
const 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 1394 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// adjust the length
if ( rows >= maxv )
{
Warning ( "fmatrix('"+name+"'): matrix is overflow, skip extra items").ignore() ;
rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0 ;
}
// get the length item
Int* len = ints( length , 0 , maxv ) ;
if ( 0 == len ) { return InvalidColumn; }
// adjust the length item
*len = rows ;
// get the array itself
FMatrix* var = fMatrix ( name , len , cols ) ;
if ( 0 == var ) { return InvalidColumn ; }
for ( size_t iCol = 0 ; iCol < cols ; ++iCol )
{
for ( MIndex iRow = 0 ; iRow < rows ; ++iRow )
{ (*var)[ iRow ] [ iCol ] = (float)(data[ iRow ][ iCol ]) ; }
}
}
template<class DATA >
StatusCode Tuples::TupleObj::fmatrix ( const std::string name,
DATA  first,
DATA  last,
const MIndex cols,
const std::string length,
const 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 1469 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// adjust the length
if ( first + maxv < last )
{
Warning("fmatrix('"+name+"'): matrix is overflow, skip extra items").ignore() ;
last = first + maxv ;
}
// get the length item
Int* len = ints( length , 0 , maxv ) ;
if ( 0 == len ) { return InvalidColumn; }
// adjust the length item
*len = last - first ;
// get the array itself
FMatrix* var = fMatrix ( name , len , cols ) ;
if ( 0 == var ) { return InvalidColumn ; }
size_t iRow = 0 ;
for ( ; first != last ; ++first )
{
//
for ( MIndex iCol = 0 ; iCol < cols ; ++iCol )
{ (*var)[ iRow ] [ iCol ] = (float)((*first)[ iCol ]) ; }
//
++iRow ;
}
}
template<class FUN , class DATA >
StatusCode Tuples::TupleObj::fmatrix ( const std::string name,
FUN  funF,
FUN  funL,
DATA  first,
DATA  last,
const std::string length,
const 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 1590 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// adjust the length
if ( first + maxv < last )
{
Warning("fmatrix('"+name+"'): matrix is overflow, skip extra items").ignore() ;
last = first + maxv ;
}
// get the length item
Int* len = ints( length , 0 , maxv ) ;
if ( 0 == len ) { return InvalidColumn; }
// adjust the length item
*len = last - first ;
// get the array itself
const size_t cols = funL - funF ;
FMatrix* var = fMatrix ( name , len , cols ) ;
if ( 0 == var ) { return InvalidColumn ; }
size_t iRow = 0 ;
for ( ; first != last ; ++first )
{
//
for ( FUN fun = funF ; fun < funL ; ++fun )
{ (*var)[ iRow ] [ fun - funF ] = (float)((*fun) ( *first )) ; }
//
++iRow;
}
}
template<class KEY , class VALUE >
StatusCode Tuples::TupleObj::fmatrix ( const std::string name,
const GaudiUtils::VectorMap< KEY, VALUE > &  info,
const std::string 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

fill the matrix

Definition at line 2018 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// adjust the length
if ( maxv < info.size() )
{
Warning("fmatrix('"+name+"'): matrix is overflow, skip extra items") ;
end = begin + maxv ;
} ;
// get the length item
Int* len = ints( length , 0 , maxv ) ;
if ( 0 == len ) { return InvalidColumn; }
// adjust the length item
*len = end - begin ;
// get the array itself
FMatrix* var = fMatrix ( name , len , 2 ) ;
if ( 0 == var ) { return InvalidColumn ; }
size_t iRow = 0 ;
for ( ; begin != end ; ++begin)
{
//
(*var)[iRow][0] = (float) begin->first ;
(*var)[iRow][1] = (float) begin->second ;
//
++iRow ;
} ;
}
Tuples::TupleObj::FMatrix * Tuples::TupleObj::fMatrix ( const std::string name,
Int item,
const MIndex cols 
)
private

get the column

Definition at line 945 of file TupleObj.cpp.

{
// existing array ?
if( m_fmatrices.end() != found ) { return found->second ; }
// create new array
FMatrix* matrix = new FMatrix () ;
const StatusCode sc =
tuple() -> addIndexedItem( name , *length , cols , *matrix ) ;
if( sc.isFailure() )
{ Error ( "fmatrix ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "FMatrix" ) )
{ Error ( "fmatrix ('" + name + "'): item is not unique" ) ; }
return matrix ;
}
Tuples::TupleObj::FMatrix * Tuples::TupleObj::fMatrix ( const std::string name,
const MIndex rows,
const MIndex cols 
)
private

get the column

Definition at line 968 of file TupleObj.cpp.

{
// existing array ?
if( m_matricesf.end() != found ) { return found->second ; }
// create new array
FMatrix* matrix = new FMatrix () ;
const StatusCode sc =
tuple() -> addItem( name , rows , cols , *matrix ) ;
if( sc.isFailure() )
{ Error ( "matrix ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "FMatrix" ) )
{ Error ( "matrix ('" + name + "'): item is not unique" ) ; }
return matrix ;
}
bool Tuples::TupleObj::goodItem ( const std::string 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 2142 of file TupleObj.h.

{ return m_items.end() == m_items.find ( name ) ; }
Tuples::TupleObj::Int * Tuples::TupleObj::ints ( const std::string name)
private

get the column

Definition at line 759 of file TupleObj.cpp.

{
if( m_ints.end() != found ) { return found->second ; }
Int* item = new Int() ;
m_ints[ name ] = item ;
StatusCode sc = tuple()->addItem( name , *item );
if( sc.isFailure() )
{ Error ( "ints ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "ints ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::Int * Tuples::TupleObj::ints ( const std::string name,
const int  minv,
const int  maxv 
)
private

get the column

Definition at line 774 of file TupleObj.cpp.

{
if( m_ints.end() != found ) { return found->second ; }
Int* item = new Int() ;
m_ints[ name ] = item ;
const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
if( sc.isFailure() )
{ Error ( "ints ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "ints ('" + name + "'): item is not unique" ) ; }
return item ;
}
bool Tuples::TupleObj::invalid ( ) const
inline

invalid pointer to tuple ?

Definition at line 2125 of file TupleObj.h.

{ return ! valid() ; }
const ItemMap& Tuples::TupleObj::items ( ) const
inline

get the full list of booked items

Definition at line 2146 of file TupleObj.h.

{ return m_items ; }
Tuples::TupleObj::LongLong * Tuples::TupleObj::longlongs ( const std::string name)
private

get the column

Definition at line 823 of file TupleObj.cpp.

{
if( m_longlongs.end() != found ) { return found->second ; }
LongLong* item = new LongLong() ;
StatusCode sc = tuple()->addItem( name , *item );
if( sc.isFailure() )
{ Error ( "ints ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "ULL" ) )
{ Error ( "ints ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::LongLong * Tuples::TupleObj::longlongs ( const std::string name,
const long long  minv,
const long long  maxv 
)
private

get the column

Definition at line 838 of file TupleObj.cpp.

{
if( m_longlongs.end() != found ) { return found->second ; }
LongLong* item = new LongLong() ;
const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
if( sc.isFailure() )
{ Error ( "longlongs ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "ULL" ) )
{ Error ( "longlongs ('" + name + "'): item is not unique" ) ; }
return item ;
}
template<class MATRIX >
StatusCode Tuples::TupleObj::matrix ( const std::string 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 1824 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// get the matrix itself
FMatrix* var = fMatrix ( name , rows , cols ) ;
if ( 0 == var ) { return InvalidColumn ; }
for ( size_t iCol = 0 ; iCol < cols ; ++iCol )
{
for ( size_t iRow = 0 ; iRow < rows ; ++iRow )
{ (*var)[iRow][iCol] = (float)(data[iRow][iCol]) ; }
};
}
template<class TYPE , unsigned int D1, unsigned int D2, class REP >
StatusCode Tuples::TupleObj::matrix ( const std::string 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 1979 of file TupleObj.h.

{
if ( invalid () ) { return InvalidTuple ; }
if ( rowWise () ) { return InvalidOperation ; }
// get the matrix itself
FMatrix* var = fMatrix ( name , (MIndex)D1 , (MIndex)D2 ) ;
if ( 0 == var ) { return InvalidColumn ; }
for ( size_t iCol = 0 ; iCol < D2 ; ++iCol )
{
for ( size_t iRow = 0 ; iRow < D1 ; ++iRow )
{ (*var)[iRow][iCol] = (float) mtrx(iRow,iCol) ; }
};
}
const std::string& Tuples::TupleObj::name ( ) const
inline

get the name

Definition at line 2083 of file TupleObj.h.

{ return m_name ; }
TupleObj& Tuples::TupleObj::operator= ( const TupleObj )
private

assignment is disabled

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

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 127 of file TuplePut.h.

{
if ( invalid () ) { return InvalidTuple ; } // RETURN
if ( !evtColType () ) { return InvalidOperation ; } // RETURN
// static block: The Reflex type description & the flag
static bool s_fail = false ; // STATIC
static ROOT::Reflex::Type s_type ; // STATIC
// check the status
if ( s_fail ) { return InvalidItem ; } // RETURN
else if ( !s_type )
{
const std::string class_name = System::typeinfoName ( typeid ( TYPE ) ) ;
s_type = ROOT::Reflex::Type::ByName( class_name ) ;
if ( !s_type )
{
s_fail = true ;
return Error ( " put('"+name+"'," + class_name +
") :Invalid ROOT::Reflex::Type", InvalidItem ) ; // RETURN
}
}
// the local storage of items
static Tuples::ItemStore<TYPE*> s_map ;
// get the variable by name:
NTuple::Item<TYPE*>* item = s_map.getItem ( name , this ) ;
if ( 0 == item )
{ return Error ( " put('" + name + "'): invalid item detected", InvalidItem ) ; }
// assign the item!
(*item) = const_cast<TYPE*> ( obj ) ; // THATS ALL!!
//
return StatusCode::SUCCESS ; // RETURN
}
unsigned long Tuples::TupleObj::refCount ( ) const
inline

return the reference counter

Returns
current reference counter

Definition at line 2093 of file TupleObj.h.

{ return m_refCount ; }
void Tuples::TupleObj::release ( )

release the reference to TupleObj if reference counter becomes zero, object will be automatically deleted

Definition at line 228 of file TupleObj.cpp.

{
// decrease the reference counter
if( 0 < refCount() ) { --m_refCount; }
// check references
if( 0 != refCount() ) { return; }
// delete the object
delete this ;
}
bool Tuples::TupleObj::rowWise ( ) const
inline

row wise NTuple ?

Definition at line 2116 of file TupleObj.h.

{ return CLID_RowWiseTuple == clid() ; }
Tuples::TupleObj::Short * Tuples::TupleObj::shorts ( const std::string name)
private

get the column

Definition at line 695 of file TupleObj.cpp.

{
if( m_shorts.end() != found ) { return found->second ; }
Short* item = new Short() ;
StatusCode sc = tuple()->addItem( name , *item );
if( sc.isFailure() )
{ Error ( "shorts ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "shorts ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::Short * Tuples::TupleObj::shorts ( const std::string name,
const short  minv,
const short  maxv 
)
private

get the column

Definition at line 710 of file TupleObj.cpp.

{
if( m_shorts.end() != found ) { return found->second ; }
Short* item = new Short() ;
const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
if( sc.isFailure() )
{ Error ( "shorts ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "shorts ('" + name + "'): item is not unique" ) ; }
return item ;
}
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 2088 of file TupleObj.h.

{ return m_tuple ; }
Tuples::Type Tuples::TupleObj::type ( ) const
inline

accessor to the N-Tuple type

Definition at line 2110 of file TupleObj.h.

{ return m_type ; }
Tuples::TupleObj::UChar * Tuples::TupleObj::uchars ( const std::string name)
private

get the column

Definition at line 663 of file TupleObj.cpp.

{
if( m_uchars.end() != found ) { return found->second ; }
UChar* item = new UChar() ;
StatusCode sc = tuple()->addItem( name , *item );
if( sc.isFailure() )
{ Error ( "uchars ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "uchars ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::UChar * Tuples::TupleObj::uchars ( const std::string name,
const unsigned char  minv,
const unsigned char  maxv 
)
private

get the column

Definition at line 678 of file TupleObj.cpp.

{
if( m_uchars.end() != found ) { return found->second ; }
UChar* item = new UChar() ;
const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
if( sc.isFailure() )
{ Error ( "uchars ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "uchars ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::UInt * Tuples::TupleObj::uints ( const std::string name)
private

get the column

Definition at line 791 of file TupleObj.cpp.

{
if( m_uints.end() != found ) { return found->second ; }
UInt* item = new UInt() ;
m_uints[ name ] = item ;
StatusCode sc = tuple()->addItem( name , *item );
if( sc.isFailure() )
{ Error ( "uints ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "uints ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::UInt * Tuples::TupleObj::uints ( const std::string name,
const unsigned int  minv,
const unsigned int  maxv 
)
private

get the column

Definition at line 806 of file TupleObj.cpp.

{
if( m_uints.end() != found ) { return found->second ; }
UInt* item = new UInt() ;
m_uints[ name ] = item ;
const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
if( sc.isFailure() )
{ Error ( "uints ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "uints ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::ULongLong * Tuples::TupleObj::ulonglongs ( const std::string name)
private

get the column

Definition at line 855 of file TupleObj.cpp.

{
if( m_ulonglongs.end() != found ) { return found->second ; }
StatusCode sc = tuple()->addItem( name , *item );
if( sc.isFailure() )
{ Error ( "ulonglongs ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "ULL" ) )
{ Error ( "ulonglongs ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::ULongLong * Tuples::TupleObj::ulonglongs ( const std::string name,
const unsigned long long  minv,
const unsigned long long  maxv 
)
private

get the column

Definition at line 870 of file TupleObj.cpp.

{
if( m_ulonglongs.end() != found ) { return found->second ; }
const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
if( sc.isFailure() )
{ Error ( "ulonglongs ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "ULL" ) )
{ Error ( "ulonglongs ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::UShort * Tuples::TupleObj::ushorts ( const std::string name)
private

get the column

Definition at line 727 of file TupleObj.cpp.

{
if( m_ushorts.end() != found ) { return found->second ; }
UShort* item = new UShort() ;
StatusCode sc = tuple()->addItem( name , *item );
if( sc.isFailure() )
{ Error ( "ushorts ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "ushorts ('" + name + "'): item is not unique" ) ; }
return item ;
}
Tuples::TupleObj::UShort * Tuples::TupleObj::ushorts ( const std::string name,
const unsigned short  minv,
const unsigned short  maxv 
)
private

get the column

Definition at line 742 of file TupleObj.cpp.

{
if( m_ushorts.end() != found ) { return found->second ; }
UShort* item = new UShort() ;
const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
if( sc.isFailure() )
{ Error ( "ushorts ('" + name + "'): item is not added", sc ) ; }
if ( !addItem ( name , "I" ) )
{ Error ( "ushorts ('" + name + "'): item is not unique" ) ; }
return item ;
}
bool Tuples::TupleObj::valid ( ) const
inline

valid pointer to tuple ?

Definition at line 2122 of file TupleObj.h.

{ return 0 != tuple() ; }
virtual StatusCode Tuples::TupleObj::Warning ( const std::string msg,
const StatusCode  sc = StatusCode::FAILURE 
) const
pure virtual
StatusCode Tuples::TupleObj::write ( )

write a record to NTuple

Returns
status code

Definition at line 240 of file TupleObj.cpp.

{
if ( invalid() ) { return InvalidTuple ; }
return tuple()->write() ;
}

Member Data Documentation

Addresses Tuples::TupleObj::m_addresses
mutableprivate

the actual storage of all 'Address' columns

Definition at line 2360 of file TupleObj.h.

FArrays Tuples::TupleObj::m_arraysf
mutableprivate

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

Definition at line 2366 of file TupleObj.h.

Bools Tuples::TupleObj::m_bools
mutableprivate

the actual storage of all 'bool' columns

Definition at line 2327 of file TupleObj.h.

Chars Tuples::TupleObj::m_chars
mutableprivate

the actual storage of all 'Int' columns

Definition at line 2330 of file TupleObj.h.

CLID Tuples::TupleObj::m_clid
private

tuple CLID

Definition at line 2318 of file TupleObj.h.

Doubles Tuples::TupleObj::m_doubles
mutableprivate

the actual storage of all 'Double' columns

Definition at line 2357 of file TupleObj.h.

FArrays Tuples::TupleObj::m_farrays
mutableprivate

the actual storage of all 'FArray' columns

Definition at line 2363 of file TupleObj.h.

Floats Tuples::TupleObj::m_floats
mutableprivate

the actual storage of all 'Float' columns

Definition at line 2354 of file TupleObj.h.

FMatrices Tuples::TupleObj::m_fmatrices
mutableprivate

the actual storage of all 'FArray' columns

Definition at line 2369 of file TupleObj.h.

Ints Tuples::TupleObj::m_ints
mutableprivate

the actual storage of all 'Int' columns

Definition at line 2342 of file TupleObj.h.

ItemMap Tuples::TupleObj::m_items
private

all booked types:

Definition at line 2375 of file TupleObj.h.

LongLongs Tuples::TupleObj::m_longlongs
mutableprivate

the actual storage of all 'longlong' columns

Definition at line 2348 of file TupleObj.h.

FMatrices Tuples::TupleObj::m_matricesf
mutableprivate

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

Definition at line 2372 of file TupleObj.h.

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

name

Definition at line 2312 of file TupleObj.h.

size_t Tuples::TupleObj::m_refCount
private

reference counter

Definition at line 2324 of file TupleObj.h.

Shorts Tuples::TupleObj::m_shorts
mutableprivate

the actual storage of all 'Int' columns

Definition at line 2336 of file TupleObj.h.

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

tuple itself

Definition at line 2315 of file TupleObj.h.

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

tuple 'type'

Definition at line 2321 of file TupleObj.h.

UChars Tuples::TupleObj::m_uchars
mutableprivate

the actual storage of all 'unsigned int' columns

Definition at line 2333 of file TupleObj.h.

UInts Tuples::TupleObj::m_uints
mutableprivate

the actual storage of all 'unsigned int' columns

Definition at line 2345 of file TupleObj.h.

ULongLongs Tuples::TupleObj::m_ulonglongs
mutableprivate

the actual storage of all 'ulonglong' columns

Definition at line 2351 of file TupleObj.h.

UShorts Tuples::TupleObj::m_ushorts
mutableprivate

the actual storage of all 'unsigned int' columns

Definition at line 2339 of file TupleObj.h.


The documentation for this class was generated from the following files:

Generated at Wed Nov 28 2012 12:17:44 for Gaudi Framework, version v23r5 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004