| # Gaudi Framework, version v21r7p1 |

Home |  | Generated: 15 Feb 2010

# Tuples::TupleObj Class Reference

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

`#include <GaudiAlg/TupleObj.h>`

Inheritance diagram for Tuples::TupleObj:

[legend]
Collaboration diagram for Tuples::TupleObj:

[legend]

List of all members.

## Public Types
typedef NTuple::Item< int > | Int
| basic type for 'integer' items It has the fixed bit-length (32) for all platforms (?)
typedef NTuple::Item< float > | Float
| basic type for 'float/double' items It has the fixed bit-length (32) for all platforms (?)
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 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 long value)
| Set the value for the 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 short value)
| 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 char value)
| Set the value for selected tuple column.
StatusCode | column (const std::string &name, const unsigned char value)
| Set the value for the 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 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 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::string & | name () const
| get the name
NTuple::Tuple * | tuple () 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 CLID & | clid () 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 ItemMap & | items () 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, Int * > | Ints
| the actual storage type for integer columns
typedef GaudiUtils::HashMap < std::string, Float * > | Floats
| 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
Float * | floats (const std::string &name)
| get the column
Int * | ints (const std::string &name)
| get the column
Int * | ints (const std::string &name, const int minv, const int maxv)
| get the column
FArray * | fArray (const std::string &name, Int *item)
| get the column
FArray * | fArray (const std::string &name, const MIndex &rows)
| get the column
Address * | addresses (const std::string &name)
| get the column
FMatrix * | fMatrix (const std::string &name, Int *item, const MIndex &cols)
| get the column
FMatrix * | fMatrix (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
TupleObj & | operator= (const TupleObj &)
| assignment is disabled
## Private Attributes
std::string | m_name
| the name
NTuple::Tuple * | m_tuple
| tuple itself
CLID | m_clid
| tuple CLID
Tuples::Type | m_type
| tuple 'type'
size_t | m_refCount
| reference counter
Ints | m_ints
| the actual storage of columns
Floats | m_floats
| the actual storage of columns
Addresses | m_addresses
| the actual storage of columns
FArrays | m_farrays
| the actual storage of columns
FArrays | m_arraysf
| the actual storage of columns
FMatrices | m_fmatrices
| the actual storage of columns
FMatrices | m_matricesf
| the actual storage of columns
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 ibelyaev@physics.syr.edu

Date:
  2004-01-23

Definition at line 180 of file TupleObj.h.

## Member Typedef Documentation

typedef NTuple::Item<int> Tuples::TupleObj::Int

basic type for 'integer' items It has the fixed bit-length (32) for all platforms (?)

Definition at line 187 of file TupleObj.h.

typedef NTuple::Item<float> Tuples::TupleObj::Float

basic type for 'float/double' items It has the fixed bit-length (32) for all platforms (?)

Definition at line 192 of file TupleObj.h.

typedef NTuple::Item<IOpaqueAddress*> Tuples::TupleObj::Address

basic type for address items

Definition at line 195 of file TupleObj.h.

typedef NTuple::Array<float> Tuples::TupleObj::FArray

basic type for array of floats

Definition at line 198 of file TupleObj.h.

typedef NTuple::Matrix<float> Tuples::TupleObj::FMatrix

basic type for matrix of floats

Definition at line 201 of file TupleObj.h.

typedef unsigned short Tuples::TupleObj::MIndex

Definition at line 204 of file TupleObj.h.

typedef std::map<std::string,std::string> Tuples::TupleObj::ItemMap

Definition at line 207 of file TupleObj.h.

typedef GaudiUtils::HashMap<std::string,Int*> Tuples::TupleObj::Ints`[private]`

the actual storage type for integer columns

Definition at line 2022 of file TupleObj.h.

typedef GaudiUtils::HashMap<std::string,Float*> Tuples::TupleObj::Floats`[private]`

the actual storage type for float columns

Definition at line 2025 of file TupleObj.h.

typedef GaudiUtils::HashMap<std::string,Address*> Tuples::TupleObj::Addresses`[private]`

the actual storage type for address columns

Definition at line 2028 of file TupleObj.h.

typedef GaudiUtils::HashMap<std::string,FArray*> Tuples::TupleObj::FArrays`[private]`

the actual storage type for array columns

Definition at line 2031 of file TupleObj.h.

typedef GaudiUtils::HashMap<std::string,FMatrix*> Tuples::TupleObj::FMatrices`[private]`

the actual storage type for matrix columns

Definition at line 2034 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:

  | name | name of the object
  | tuple | pointer to standard Gaudi NTuple::Tuple object
  | clid | CLID_ColumnWiseTuple or CLID_RowWiseTuple
  | type | the type of the tuple

Definition at line 117 of file TupleObj.cpp.

    00122   : m_name     ( name )
    00123   , m_tuple    ( tuple )
    00124   , m_clid     ( clid )
    00125   , m_type     ( type )
    00126   // for error handling
    00127   , m_refCount ( 0 )
    00128   // columns
    00129   , m_ints      ()
    00130   , m_floats    ()
    00131   , m_addresses ()
    00132   , m_farrays   ()
    00133   , m_arraysf   ()
    00134   , m_fmatrices ()
    00135   , m_matricesf ()
    00136   //
    00137   , m_items     ()
    00138 {
    00139   // make counts
    00140   Tuples::Local::s_InstanceCounter.increment ( m_name ) ;
    00141 }

Tuples::TupleObj::~TupleObj | ( |  | ) | `[protected, virtual]`

destructor is protected

Definition at line 145 of file TupleObj.cpp.

    00146 {
    00147   {// delete 'long' columns
    00148     for( Ints::iterator it = m_ints.begin() ;
    00149          m_ints.end() != it ; ++it )
    00150     { if( 0 != it->second ) { delete it->second ; } }
    00151     m_ints.clear() ;
    00152   }
    00153   {// delete 'float' columns
    00154     for( Floats::iterator it = m_floats.begin() ;
    00155          m_floats.end() != it ; ++it )
    00156     { if( 0 != it->second ) { delete it->second ; } }
    00157     m_floats.clear() ;
    00158   }
    00159   {// delete 'fArray' columns
    00160     for( FArrays::iterator it = m_farrays.begin() ;
    00161          m_farrays.end() != it ; ++it )
    00162     { if( 0 != it->second ) { delete it->second ; } }
    00163     m_farrays.clear() ;
    00164   }
    00165   {// delete 'fArray' columns
    00166     for( FArrays::iterator it = m_arraysf.begin() ;
    00167          m_arraysf.end() != it ; ++it )
    00168     { if( 0 != it->second ) { delete it->second ; } }
    00169     m_arraysf.clear() ;
    00170   }
    00171   { // destroy and clean all "addresses"
    00172     for( Addresses::iterator it = m_addresses.begin() ;
    00173          m_addresses.end() != it ; ++it )
    00174     { if( 0 != it->second ) { delete it->second ; } }
    00175     m_addresses.clear();
    00176   }
    00177   { // destroy and clean all "matrices"
    00178     for( FMatrices::iterator it = m_fmatrices.begin() ;
    00179          m_fmatrices.end() != it ; ++it )
    00180     { if( 0 != it->second ) { delete it->second ; } }
    00181     m_fmatrices.clear();
    00182   }
    00183   { // destroy and clean all "matrices" (fixed)
    00184     for( FMatrices::iterator it = m_matricesf.begin() ;
    00185          m_matricesf.end() != it ; ++it )
    00186     { if( 0 != it->second ) { delete it->second ; } }
    00187     m_matricesf.clear();
    00188   }
    00189
    00190   // make counts
    00191   Tuples::Local::s_InstanceCounter.decrement ( m_name ) ;
    00192 }

Tuples::TupleObj::TupleObj | ( |  | ) | `[private]`

the default constructor is disabled

Tuples::TupleObj::TupleObj | ( | const TupleObj & |  | ) | `[private]`

copy constructor is disabled

## Member Function Documentation

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const int | value |
| ) |  |  | `[inline]`

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:

  | name | name of the column
  | value | value of the variable

Returns:
  status code

Definition at line 246 of file TupleObj.h.

    00248     {
    00249       if ( invalid() ) { return InvalidTuple  ; }
    00250       Int* item = ints( name ) ;
    00251       if ( 0 == item ) { return InvalidColumn ; }
    00252       *item = value ;
    00253       return StatusCode::SUCCESS ;
    00254     }

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const int | value,
|  | const int | minv,
|  | const int | maxv |
| ) |  |  | `[inline]`

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:

  | name | name of the column
  | value | value of the variable
  | minv | minimum value of the variable
  | maxv | maximum value of the variable

Returns:
  status code

Definition at line 273 of file TupleObj.h.

    00277     {
    00278       if ( invalid() ) { return InvalidTuple  ; }
    00279       Int* item = ints ( name , minv , maxv ) ;
    00280       if ( 0 == item ) { return InvalidColumn ; }
    00281       *item = value ;
    00282       return StatusCode::SUCCESS ;
    00283     }

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const unsigned int | value |
| ) |  |  | `[inline]`

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:

  | name | name of the column
  | value | value of the variable

Returns:
  status code

Definition at line 302 of file TupleObj.h.

    00304     {
    00305       StatusCode sc1 = StatusCode::SUCCESS ;
    00306       static const unsigned int s_max = std::numeric_limits<int>::max() ;
    00307       if ( s_max < value )
    00308       { sc1 = Warning
    00309           (" column('" + name + "'): truncate unsigned int" , TruncateValue ) ; }
    00310       const int val = (int) value ;
    00311       StatusCode sc2 = column ( name , val ) ;
    00312       return sc2.isFailure() ? sc2 : sc1 ;
    00313     }

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const long | 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

      int number = ... ;
      tuple -> column ( "num", number );

Warning:
  the value could be truncated to int

Parameters:

  | name | the name of the column
  | value | the value of the variable

Returns:
  status code

Definition at line 331 of file TupleObj.h.

    00333     {
    00334       StatusCode sc1 = StatusCode::SUCCESS ;
    00335       if ( sizeof(int) != sizeof(long)
    00336            && ( std::numeric_limits<int>::max() < value ||
    00337                 std::numeric_limits<int>::min() > value ) )
    00338       { sc1 = Warning (" column('" + name + "'): truncate long value" ,
    00339                        TruncateValue ) ; }
    00340       const int val = (int) value ;
    00341       StatusCode sc2 = column ( name , val ) ;
    00342       return sc2.isFailure() ? sc2 : sc1 ;
    00343     }

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const unsigned long | value |
| ) |  |  | `[inline]`

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 );

Warning:
  the value could be truncated to int

Parameters:

  | name | the name of the column
  | value | the value of the variable

Returns:
  status code

Definition at line 361 of file TupleObj.h.

    00363     {
    00364       StatusCode sc1 = StatusCode::SUCCESS ;
    00365       static const unsigned long s_max = std::numeric_limits<int>::max()  ;
    00366       if ( sizeof (int) != sizeof (unsigned long) && s_max < value )
    00367       { sc1 = Warning (" column('" + name + "'): truncate unsigned long value" ,
    00368                        TruncateValue ) ; }
    00369       const int val = (int) value ;
    00370       StatusCode sc2 = column ( name , val ) ;
    00371       return sc2.isFailure() ? sc2 : sc1 ;
    00372     }

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const short | value |
| ) |  |  | `[inline]`

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:

  | name | the name of the column
  | value | the value of the variable

Returns:
  status code

Definition at line 389 of file TupleObj.h.

    00391     {
    00392       return column
    00393         ( name  ,
    00394           value ,
    00395           std::numeric_limits<short>::min() ,
    00396           std::numeric_limits<short>::max() ) ;
    00397     }

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const unsigned short | value |
| ) |  |  | `[inline]`

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:

  | name | the name of the column
  | value | the value of the variable

Returns:
  status code

Definition at line 414 of file TupleObj.h.

    00416     {
    00417       return column
    00418         ( name  ,
    00419           value ,
    00420           std::numeric_limits<unsigned short>::min() ,
    00421           std::numeric_limits<unsigned short>::max() ) ;
    00422     }

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const char | value |
| ) |  |  | `[inline]`

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:

  | name | the name of the column
  | value | the value of tve variable

Returns:
  status code

Definition at line 439 of file TupleObj.h.

    00441     {
    00442       return column
    00443         ( name  ,
    00444           value ,
    00445           std::numeric_limits<char>::min() ,
    00446           std::numeric_limits<char>::max() ) ;
    00447     }

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const unsigned 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

      unsigned char number = ... ;
      tuple->column("num", number );

Parameters:

  | name | the name of the column
  | value | the value of tve variable

Returns:
  status code

Definition at line 464 of file TupleObj.h.

    00466     {
    00467       return column
    00468         ( name  ,
    00469           value ,
    00470           std::numeric_limits<unsigned char>::min() ,
    00471           std::numeric_limits<unsigned char>::max() ) ;
    00472     }

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:

  | name | the name of the column
  | value | the value of tve variable

Returns:
  status code

Definition at line 489 of file TupleObj.h.

    00491     {
    00492       return column
    00493         ( name  ,
    00494           value ,
    00495           std::numeric_limits<signed char>::min() ,
    00496           std::numeric_limits<signed char>::max() ) ;
    00497     }

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const float | value |
| ) |  |  | `[inline]`

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:

  | name | the name of the column
  | value | the value of the variable

Returns:
  status code

Definition at line 516 of file TupleObj.h.

    00518     {
    00519       if ( invalid() ) { return InvalidTuple  ; }
    00520       Float* item = floats ( name ) ;
    00521       if ( 0 == item ) { return InvalidColumn ; }
    00522       *item = value ;
    00523       return StatusCode::SUCCESS ;
    00524     }

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const double | value |
| ) |  |  | `[inline]`

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:

  | name | the name of the column
  | value | the value of the variable

Returns:
  status code

Definition at line 542 of file TupleObj.h.

    00544     {
    00545       StatusCode sc1 = StatusCode::SUCCESS ;
    00546       static const double s_max =      std::numeric_limits<float>::max() ;
    00547       static const double s_min = -1 * std::numeric_limits<float>::max() ;
    00548       if ( s_max < value || s_min > value  )
    00549       { sc1 = Warning (" column('" + name + "'): truncate double value " ,
    00550                        TruncateValue ) ; }
    00551       const float val = (float) value ;
    00552       StatusCode sc2 = column ( name , val ) ;
    00553       return sc2.isFailure() ? sc2 : sc1 ;
    00554     }

StatusCode Tuples::TupleObj::column | ( | const std::string & | name,
|  | const bool | value |
| ) |  |  | `[inline]`

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:

  | name | the name of the column
  | value | the value of the variable

Returns:
  status code

Definition at line 570 of file TupleObj.h.

    00572     {
    00573       const int val = value ;
    00574       return column ( name , val , 0 , 1 ) ;
    00575     }

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:

  | name | name of the column ("Address" is a recommended convention!)
  | address | IOpaqueAddress

Returns:
  status code

Definition at line 282 of file TupleObj.cpp.

    00284 {
    00285   if (  invalid    () ) { return InvalidTuple     ; }
    00286   if ( !evtColType () ) { return InvalidOperation ; }
    00287   if ( 0 == address )
    00288   { return Error ( "column('" + name +
    00289                    "') IOpaqueAddress* is NULL!" , InvalidObject ) ; }
    00290   Address* item = addresses( name );
    00291   if ( 0 == item      ) { return InvalidItem      ; }
    00292   *item = address ;
    00293   return StatusCode::SUCCESS ;
    00294 }

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:

  | address | IOpaqueAddress

Returns:
  status code

Definition at line 299 of file TupleObj.cpp.

    00300 {
    00301   return column ("Address" , address ) ;
    00302 }

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:

  | format | blank-separated list of variables, followed by variable number of arguments.

Attention:
  All variables are assumed to be `double` numbers

Author:
  Vanya Belyaev Ivan.Belyaev@itep.ru

Date:
  2002-10-30

decode arguments

Definition at line 252 of file TupleObj.cpp.

    00253 {
    00254   // check the underlying tuple
    00255   if ( invalid()      ) { return InvalidTuple ; }
    00256   // decode format string into tokens
    00257   Tokens tokens ;
    00258   tokenize( format , tokens , " ,;" );
    00259   if ( tokens.empty() ) { return StatusCode::SUCCESS ; }
    00261   va_list valist ;
    00262   va_start( valist , format ) ;
    00263   // loop over all tokens
    00264   StatusCode status = StatusCode::SUCCESS ;
    00265   for( Tokens::const_iterator token = tokens.begin() ;
    00266        tokens.end() != token && status.isSuccess() ; ++token )
    00267   {
    00268     const double val = va_arg( valist , double );
    00269     status = column( *token , val );
    00270     if( status.isFailure() )
    00271     { Error ( " fill(): Can not add column '" + *token + "' " ) ; }
    00272   }
    00273   // mandatory !!!
    00274   va_end( valist );
    00275   //
    00276   return status ;
    00277 }

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:

  | name | name of N-tuple item
  | first | begin of data sequence
  | last | end of data sequence
  | length | name of "length" item
  | maxv | maximal length of array

fill the array

Definition at line 696 of file TupleObj.h.

    00701     {
    00702       if ( invalid () ) { return InvalidTuple     ; }
    00703       if ( rowWise () ) { return InvalidOperation ; }
    00704
    00705       // adjust the length
    00706       if( first + maxv < last )
    00707       {
    00708         Warning(" farray('"+name+"'): array is overflow, skip extra items") ;
    00709         last = first + maxv ;
    00710       };
    00711
    00712       // get the length item
    00713       Int* len  = ints( length , 0 , maxv ) ;
    00714       if( 0 == len  ) { return InvalidColumn; }
    00715
    00716       // adjust the length item
    00717       *len = last - first ;
    00718
    00719       // get the array itself
    00720       FArray* var  = fArray ( name , len ) ;
    00721       if( 0 == var ) { return InvalidColumn ; }
    00722
    00724       size_t index = 0 ;
    00725       for( ; first != last ; ++first )
    00726       { (*var)[ index ] = (float)(*first) ; ++index ; }
    00727
    00728       return StatusCode::SUCCESS ;
    00729     }

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:

  | name | name of N-tuple item
  | data | data sequence
  | length | name of "length" item
  | maxv | maximal length of array

Definition at line 774 of file TupleObj.h.

    00778     { 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:

  | name | tuple item name
  | function | function to be applied
  | first | begin of data sequence
  | last | end of data sequence
  | length | name of "length" tuple name
  | maxv | maximal length of the array

Returns:
  status code

Definition at line 843 of file TupleObj.h.

    00849     {
    00850       if ( invalid () ) { return InvalidTuple     ; }
    00851       if ( rowWise () ) { return InvalidOperation ; }
    00852
    00853       // adjust the length
    00854       if( first + maxv < last )
    00855       {
    00856         Warning(" farray('"
    00857                 + name  + "'): array is overflow, skip extra entries") ;
    00858         last = first + maxv ;
    00859       };
    00860
    00861       // get the length item
    00862       Int* len  = ints( length , 0 , maxv ) ;
    00863       if( 0 == len  ) { return InvalidColumn ; }
    00864
    00865       // adjust the length
    00866       *len = last - first ;
    00867
    00868       // get the array itself
    00869       FArray*  var  = fArray ( name , len ) ;
    00870       if( 0 == var ) { return InvalidColumn ; }
    00871
    00872       // fill the array
    00873       size_t index = 0 ;
    00874       for( ; first != last ; ++first )
    00875       { (*var)[ index ] = function( *first )  ; ++index ; }
    00876
    00877       return StatusCode::SUCCESS ;
    00878     }

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:

  | name1 | the first tuple item name
  | func1 | the first function to be applied
  | name2 | the second tuple item name
  | func2 | the second function to be applied
  | first | begin of data sequence
  | last | end of data sequence
  | length | name of "length" tuple name
  | maxv | maximal length of the array

Returns:
  status code

Definition at line 912 of file TupleObj.h.

    00920     {
    00921       if ( invalid () ) { return InvalidTuple     ; }
    00922       if ( rowWise () ) { return InvalidOperation ; }
    00923
    00924       // adjust the lenfth
    00925       if( first + maxv < last )
    00926       {
    00927         Warning(" farray('"
    00928                 + name1 + ","
    00929                 + name2 + "'): array is overflow, skip extra entries") ;
    00930         Warning(" farray('"+name1+"'): array is overflow, skip extra items") ;
    00931         last = first + maxv ;
    00932       };
    00933
    00934       // get the length item
    00935       Int* len  = ints ( length , 0 , maxv ) ;
    00936       if ( 0 == len  ) { return InvalidColumn ; }
    00937
    00938       // adjust the length
    00939       *len = last - first ;
    00940
    00941       // get the array itself
    00942       FArray*  var1  = fArray ( name1 , len ) ;
    00943       if ( 0 == var1 ) { return InvalidColumn ; }
    00944
    00945       // get the array itself
    00946       FArray*  var2 = fArray ( name2 , len ) ;
    00947       if ( 0 == var2 ) { return InvalidColumn ; }
    00948
    00949       // fill the array
    00950       size_t index = 0 ;
    00951       for( ; first != last ; ++first )
    00952       {
    00953         ( *var1 ) [ index ] = func1 ( *first )  ;
    00954         ( *var2 ) [ index ] = func2 ( *first )  ;
    00955         ++index ;
    00956       }
    00957
    00958       return StatusCode::SUCCESS ;
    00959     }

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:

  | name1 | the first tuple item name
  | func1 | the first function to be applied
  | name2 | the second tuple item name
  | func2 | the second function to be applied
  | name3 | the third tuple item name
  | func3 | the third function to be applied
  | first | begin of data sequence
  | last | end of data sequence
  | length | name of "length" tuple name
  | maxv | maximal length of the array

Returns:
  status code

Definition at line 998 of file TupleObj.h.

    01008     {
    01009       if ( invalid () ) { return InvalidTuple     ; }
    01010       if ( rowWise () ) { return InvalidOperation ; }
    01011
    01012       // adjust the length
    01013       if( first + maxv < last )
    01014       {
    01015         Warning(" farray('"
    01016                 + name1 + ","
    01017                 + name2 + ","
    01018                 + name3 + "'): array is overflow, skip extra entries") ;
    01019         last = first + maxv ;
    01020       };
    01021
    01022       // get the length item
    01023       Int* len  = ints ( length , 0 , maxv ) ;
    01024       if( 0 == len   ) { return InvalidColumn ; }
    01025
    01026       // adjust the length
    01027       *len = last - first ;
    01028
    01029       // get the array itself
    01030       FArray*  var1  = fArray ( name1 , len ) ;
    01031       if( 0 == var1 ) { return InvalidColumn  ; }
    01032
    01033       // get the array itself
    01034       FArray*  var2 = fArray ( name2 , len ) ;
    01035       if( 0 == var2 ) { return InvalidColumn ; }
    01036
    01037       // get the array itself
    01038       FArray*  var3 = fArray ( name3 , len ) ;
    01039       if( 0 == var3 ) { return InvalidColumn ; }
    01040
    01041       // fill the array
    01042       size_t index = 0 ;
    01043       for( ; first != last ; ++first )
    01044       {
    01045         ( *var1 ) [ index ] = (float)func1 ( *first )  ;
    01046         ( *var2 ) [ index ] = (float)func2 ( *first )  ;
    01047         ( *var3 ) [ index ] = (float)func3 ( *first )  ;
    01048         ++index ;
    01049       }
    01050       return StatusCode::SUCCESS ;
    01051     }

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:

  | name1 | the first tuple item name
  | func1 | the first function to be applied
  | name2 | the second tuple item name
  | func2 | the second function to be applied
  | name3 | the third tuple item name
  | func3 | the third function to be applied
  | name4 | the fourth tuple item name
  | func4 | the fourth function to be applied
  | first | begin of data sequence
  | last | end of data sequence
  | length | name of "length" tuple name
  | maxv | maximal length of the array

Returns:
  status code

Definition at line 1093 of file TupleObj.h.

    01105     {
    01106       if ( invalid () ) { return InvalidTuple     ; }
    01107       if ( rowWise () ) { return InvalidOperation ; }
    01108
    01109       // adjust the length
    01110       if( first + maxv < last )
    01111       {
    01112         Warning(" farray('"
    01113                 + name1 + ","
    01114                 + name2 + ","
    01115                 + name3 + ","
    01116                 + name4 + "'): array is overflow, skip extra entries") ;
    01117         last = first + maxv ;
    01118       };
    01119
    01120       // get the length item
    01121       Int* len  = ints ( length , 0 , maxv ) ;
    01122       if( 0 == len  ) { return InvalidColumn ; }
    01123
    01124       // adjust the length
    01125       *len = last - first ;
    01126
    01127       // get the array itself
    01128       FArray*  var1  = fArray ( name1 , len ) ;
    01129       if( 0 == var1 ) { return InvalidColumn ; }
    01130
    01131       // get the array itself
    01132       FArray*  var2 = fArray ( name2 , len ) ;
    01133       if( 0 == var2 ) { return InvalidColumn ; }
    01134
    01135       // get the array itself
    01136       FArray*  var3 = fArray ( name3 , len ) ;
    01137       if( 0 == var3 ) { return InvalidColumn ; }
    01138
    01139       // get the array itself
    01140       FArray*  var4 = fArray ( name4 , len ) ;
    01141       if( 0 == var4 ) { return InvalidColumn ; }
    01142
    01143       // fill the array
    01144       size_t index = 0 ;
    01145       for( ; first != last ; ++first )
    01146       {
    01147         ( *var1 ) [ index ] = static_cast<float> ( func1 ( *first ) );
    01148         ( *var2 ) [ index ] = static_cast<float> ( func2 ( *first ) );
    01149         ( *var3 ) [ index ] = static_cast<float> ( func3 ( *first ) );
    01150         ( *var4 ) [ index ] = static_cast<float> ( func4 ( *first ) );
    01151         ++index ;
    01152       }
    01153
    01154       return StatusCode::SUCCESS ;
    01155     }

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<double> Row  ;
       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:

  | name | entry name in N-Tuple
  | data | matrix itself
  | rows | number of rows of matrix (variable)
  | cols | number of columns of matrix (fixed)
  | length | entry name in NTuple for number of matrix column
  | maxv | maximal number of rows in matrix

Author:
  Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr

Date:
  2005-05-01

fill the matrix

Definition at line 1210 of file TupleObj.h.

    01216     {
    01217       if ( invalid () ) { return InvalidTuple     ; }
    01218       if ( rowWise () ) { return InvalidOperation ; }
    01219
    01220       // adjust the length
    01221       if ( rows >= maxv )
    01222       {
    01223         Warning ( " fmatrix('"+name+"'): matrix is overflow, skip extra items") ;
    01224         rows = ( 0 < maxv ) ? ( maxv - 1 ) : 0 ;
    01225       };
    01226
    01227       // get the length item
    01228       Int* len  = ints( length , 0 , maxv ) ;
    01229       if ( 0 == len  ) { return InvalidColumn; }
    01230
    01231       // adjust the length item
    01232       *len = rows ;
    01233
    01234       // get the array itself
    01235       FMatrix* var  = fMatrix ( name , len  , cols ) ;
    01236       if ( 0 == var ) { return InvalidColumn ; }
    01237
    01239       for ( size_t iCol = 0 ; iCol < cols ; ++iCol )
    01240       {
    01241         for ( MIndex iRow = 0 ; iRow < rows ; ++iRow )
    01242         { (*var)[ iRow ] [ iCol ] = (float)(data[ iRow ][ iCol ]) ; }
    01243       };
    01244
    01245       return StatusCode::SUCCESS ;
    01246     }

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<double> Row  ;
        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:

  | name | entry name in N-Tuple
  | first | iterator for the first row of matrix
  | last | iterator for the last row of matrix
  | cols | number of columns for matrix (fixed!)
  | length | entry name in NTuple for number of matrix column
  | maxv | maximal number of rows in matrix

Author:
  Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr

Date:
  2005-05-01

fill the matrix

Definition at line 1285 of file TupleObj.h.

    01291     {
    01292       if ( invalid () ) { return InvalidTuple     ; }
    01293       if ( rowWise () ) { return InvalidOperation ; }
    01294
    01295       // adjust the length
    01296       if ( first + maxv < last )
    01297       {
    01298         Warning(" fmatrix('"+name+"'): matrix is overflow, skip extra items") ;
    01299         last = first + maxv ;
    01300       };
    01301
    01302       // get the length item
    01303       Int* len  = ints( length , 0 , maxv ) ;
    01304       if ( 0 == len  ) { return InvalidColumn; }
    01305
    01306       // adjust the length item
    01307       *len = last - first ;
    01308
    01309       // get the array itself
    01310       FMatrix* var  = fMatrix ( name , len , cols ) ;
    01311       if ( 0 == var ) { return InvalidColumn ; }
    01312
    01314       size_t iRow = 0 ;
    01315       for ( ; first != last ; ++first )
    01316       {
    01317         //
    01318         for ( MIndex iCol = 0 ; iCol < cols ; ++iCol )
    01319         { (*var)[ iRow ] [ iCol ] = (float)((*first)[ iCol ]) ; }
    01320         //
    01321         ++iRow ;
    01322       };
    01323
    01324       return StatusCode::SUCCESS ;
    01325     }

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!

        typedef std::vector<double> Array ;
        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:

  | name | entry 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
  | length | entry name in NTuple for number of matrix column
  | maxv | maximal number of rows in matrix

Author:
  Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr

Date:
  2005-05-01

fill the matrix

Definition at line 1406 of file TupleObj.h.

    01413     {
    01414       if ( invalid () ) { return InvalidTuple     ; }
    01415       if ( rowWise () ) { return InvalidOperation ; }
    01416
    01417       // adjust the length
    01418       if ( first + maxv < last )
    01419       {
    01420         Warning(" fmatrix('"+name+"'): matrix is overflow, skip extra items") ;
    01421         last = first + maxv ;
    01422       };
    01423
    01424       // get the length item
    01425       Int* len  = ints( length , 0 , maxv ) ;
    01426       if ( 0 == len  ) { return InvalidColumn; }
    01427
    01428       // adjust the length item
    01429       *len = last - first ;
    01430
    01431       // get the array itself
    01432       const size_t cols = funL - funF ;
    01433       FMatrix* var  = fMatrix ( name , len , cols ) ;
    01434       if ( 0 == var ) { return InvalidColumn ; }
    01435
    01437       size_t iRow = 0 ;
    01438       for ( ; first != last ; ++first )
    01439       {
    01440         //
    01441         for ( FUN fun = funF ; fun < funL ; ++fun )
    01442         { (*var)[ iRow ] [ fun - funF ] = (float)((*fun) ( *first )) ; }
    01443         //
    01444         ++iRow;
    01445       };
    01446
    01447       return StatusCode::SUCCESS ;
    01448     }

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:

  | name | N-Tuple entry name
  | first | begin-iterator for data sequence
  | last | end-iterator for data sequence

Author:
  Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr

Date:
  2005-05-01

fill the array

Definition at line 1475 of file TupleObj.h.

    01479     {
    01480       if ( invalid () ) { return InvalidTuple     ; }
    01481       if ( rowWise () ) { return InvalidOperation ; }
    01482
    01483       // get the length (fixed!)
    01484       const size_t length = last - first ;
    01485
    01486       // get the array itself
    01487       FArray* var  = fArray ( name , length ) ;
    01488       if ( 0 == var ) { return InvalidColumn ; }
    01489
    01491       size_t iCol = 0 ;
    01492       for ( ; first != last ; ++first )
    01493       { (*var)[ iCol ] = (float)(*first) ; ++iCol ; }
    01494
    01495       return StatusCode::SUCCESS ;
    01496     }

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 ) ;

      std::vector<long double> vct4(15) ;
      ...
      tuple -> array ( "vct4" , vct4 , 15 ) ;

Parameters:

  | name | N-Tuple entry name
  | data | data sequence
  | length | data length (fixed!)

Author:
  Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr

Date:
  2005-05-01

fill the array

Definition at line 1537 of file TupleObj.h.

    01540     {
    01541       if ( invalid () ) { return InvalidTuple     ; }
    01542       if ( rowWise () ) { return InvalidOperation ; }
    01543
    01544       // get the array itself
    01545       FArray* var  = fArray ( name , length ) ;
    01546       if ( 0 == var ) { return InvalidColumn ; }
    01547
    01549       for ( size_t index = 0 ; index < length ; ++index )
    01550       { (*var)[ index ] = (float) data[index] ; }
    01551
    01552       return StatusCode::SUCCESS ;
    01553     }

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:

  | name | N-Tupel entry name
  | data | data sequence

Author:
  Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr

Date:
  2005-05-01

Definition at line 1585 of file TupleObj.h.

    01587     { return array ( name , data.begin() , data.end() ) ; }

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<double> Row  ;
       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:

  | name | N-Tuple entry name
  | data | data source (matrix)
  | cols | number of columns
  | rows | number of rows

Author:
  Vanya BELYAEV Ivan.Belyaev@lapp.in2p3.fr

Date:
  2005-05-01

fill the matrix

Definition at line 1640 of file TupleObj.h.

    01644     {
    01645       if ( invalid () ) { return InvalidTuple     ; }
    01646       if ( rowWise () ) { return InvalidOperation ; }
    01647
    01648       // get the matrix itself
    01649       FMatrix* var  = fMatrix ( name , rows , cols ) ;
    01650       if ( 0 == var ) { return InvalidColumn ; }
    01651
    01653       for ( size_t iCol = 0 ; iCol < cols ; ++iCol )
    01654       {
    01655         for ( size_t iRow = 0 ; iRow < rows ; ++iRow )
    01656         { (*var)[iRow][iCol] = (float)(data[iRow][iCol]) ; }
    01657       };
    01658       return StatusCode::SUCCESS ;
    01659     }

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 ibelyaev@physics.syr.edu

Date:
  2006-11-26

Definition at line 1681 of file TupleObj.h.

    01683     {
    01684       if ( invalid() ) { return InvalidTuple ; }
    01685       // fill all separate columns:
    01686       StatusCode sc1 = this -> column ( name + "E" , v.E  () ) ;
    01687       StatusCode sc2 = this -> column ( name + "X" , v.Px () ) ;
    01688       StatusCode sc3 = this -> column ( name + "Y" , v.Py () ) ;
    01689       StatusCode sc4 = this -> column ( name + "Z" , v.Pz () ) ;
    01690       return
    01691         sc1.isFailure () ? sc1 :
    01692         sc2.isFailure () ? sc2 :
    01693         sc3.isFailure () ? sc3 :
    01694         sc4.isFailure () ? sc4 : StatusCode(StatusCode::SUCCESS) ;
    01695     }

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 ibelyaev@physics.syr.edu

Date:
  2006-11-26

fill separate columns

Definition at line 1715 of file TupleObj.h.

    01717     {
    01718       if ( invalid() ) { return InvalidTuple ; }
    01720       StatusCode sc1 = this -> column ( name + "X" , v.X () ) ;
    01721       StatusCode sc2 = this -> column ( name + "Y" , v.Y () ) ;
    01722       StatusCode sc3 = this -> column ( name + "Z" , v.Z () ) ;
    01723       return
    01724         sc1.isFailure () ? sc1 :
    01725         sc2.isFailure () ? sc2 :
    01726         sc3.isFailure () ? sc3 : StatusCode(StatusCode::SUCCESS) ;
    01727     }

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 ibelyaev@physics.syr.edu

Date:
  2006-11-26

fill separate columns

Definition at line 1747 of file TupleObj.h.

    01749     {
    01750       if ( invalid() ) { return InvalidTuple ; }
    01752       StatusCode sc1 = this -> column ( name + "X" , v.X () ) ;
    01753       StatusCode sc2 = this -> column ( name + "Y" , v.Y () ) ;
    01754       StatusCode sc3 = this -> column ( name + "Z" , v.Z () ) ;
    01755       return
    01756         sc1.isFailure () ? sc1 :
    01757         sc2.isFailure () ? sc2 :
    01758         sc3.isFailure () ? sc3 : StatusCode(StatusCode::SUCCESS) ;
    01759     }

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 ibelyaev@physics.syr.edu

Date:
  2006-11-26

Definition at line 1779 of file TupleObj.h.

    01781     {
    01782       return this->array( name , vect.begin() , vect.end() ) ;
    01783     }

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 ibelyaev@physics.syr.edu

Date:
  2006-11-26

fill the matrix

Definition at line 1795 of file TupleObj.h.

    01797     {
    01798       if ( invalid () ) { return InvalidTuple     ; }
    01799       if ( rowWise () ) { return InvalidOperation ; }
    01800
    01801       // get the matrix itself
    01802       FMatrix* var  = fMatrix ( name , (MIndex)D1 , (MIndex)D2 ) ;
    01803       if ( 0 == var   ) { return InvalidColumn ; }
    01804
    01806       for ( size_t iCol = 0 ; iCol < D2 ; ++iCol )
    01807       {
    01808         for ( size_t iRow = 0 ; iRow < D1 ; ++iRow )
    01809         { (*var)[iRow][iCol] = (float) mtrx(iRow,iCol) ; }
    01810       };
    01811
    01812       return StatusCode::SUCCESS ;
    01813     }

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 ibelyaev@physics.syr.edu

Date:
  2006-11-26

fill the matrix

Definition at line 1834 of file TupleObj.h.

    01838     {
    01839
    01840       if ( invalid () ) { return InvalidTuple     ; }
    01841       if ( rowWise () ) { return InvalidOperation ; }
    01842
    01843       typename GaudiUtils::VectorMap<KEY,VALUE>::const_iterator begin = info.begin () ;
    01844       typename GaudiUtils::VectorMap<KEY,VALUE>::const_iterator end   = info.end   () ;
    01845
    01846       // adjust the length
    01847       if ( maxv < info.size() )
    01848       {
    01849         Warning(" fmatrix('"+name+"'): matrix is overflow, skip extra items") ;
    01850         end = begin + maxv ;
    01851       } ;
    01852
    01853       // get the length item
    01854       Int* len  = ints( length , 0 , maxv ) ;
    01855       if ( 0 == len  ) { return InvalidColumn; }
    01856
    01857       // adjust the length item
    01858       *len = end - begin ;
    01859
    01860       // get the array itself
    01861       FMatrix* var  = fMatrix ( name , len , 2 ) ;
    01862       if ( 0 == var ) { return InvalidColumn ; }
    01863
    01865       size_t iRow = 0 ;
    01866       for ( ; begin != end ; ++begin)
    01867       {
    01868         //
    01869         (*var)[iRow][0] = (float) begin->first   ;
    01870         (*var)[iRow][1] = (float) begin->second  ;
    01871         //
    01872         ++iRow ;
    01873       } ;
    01874
    01875       return StatusCode::SUCCESS ;
    01876     }

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:

  | name | column name
  | obj | pointer to the object

Author:
  Vanya BELYAEV ibelyaev@physics.syr.edu

Date:
  2007-04-08

Attention:
  it requires POOL persistency

Parameters:

  | name | column name
  | obj | pointer to the object

Author:
  Vanya BELYAEV ibelyaev@physics.syr.edu

Date:
  2007-04-08

Definition at line 127 of file TuplePut.h.

    00128 {
    00129   if (  invalid    () ) { return InvalidTuple     ; }   // RETURN
    00130   if ( !evtColType () ) { return InvalidOperation ; }   // RETURN
    00131
    00132   // static block: The Reflex type description & the flag
    00133   static bool               s_fail = false ;                // STATIC
    00134   static ROOT::Reflex::Type s_type         ;                // STATIC
    00135   // check the status
    00136   if      (  s_fail  ) { return InvalidItem ; }                           // RETURN
    00137   else if ( !s_type  )
    00138   {
    00139     const std::string class_name = System::typeinfoName ( typeid ( TYPE ) ) ;
    00140     s_type = ROOT::Reflex::Type::ByName( class_name  ) ;
    00141     if ( !s_type )
    00142     {
    00143       s_fail = true ;
    00144       return Error ( " put('"+name+"'," + class_name +
    00145                      ") :Invalid ROOT::Reflex::Type", InvalidItem ) ;    // RETURN
    00146     }
    00147   }
    00148   // the local storage of items
    00149   static Tuples::ItemStore<TYPE*> s_map ;
    00150   // get the variable by name:
    00151   NTuple::Item<TYPE*>* item = s_map.getItem ( name , this ) ;
    00152   if ( 0 == item )
    00153   { return Error ( " put('" + name + "'): invalid item detected", InvalidItem ) ; }
    00154   // assign the item!
    00155   (*item) = const_cast<TYPE*> ( obj ) ;                    // THATS ALL!!
    00156   //
    00157   return StatusCode::SUCCESS ;                             // RETURN
    00158 }

StatusCode Tuples::TupleObj::write | ( |  | ) |

write a record to NTuple

Returns:
  status code

Definition at line 210 of file TupleObj.cpp.

    00211 {
    00212   if ( invalid()  ) { return InvalidTuple ; }
    00213   return tuple()->write() ;
    00214 }

const std::string& Tuples::TupleObj::name | ( |  | ) | const`[inline]`

get the name

Definition at line 1899 of file TupleObj.h.

    01899 { return m_name ; }

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

    01904 { return m_tuple ; }

unsigned long Tuples::TupleObj::refCount | ( |  | ) | const`[inline]`

return the reference counter

Returns:
  current reference counter

Definition at line 1909 of file TupleObj.h.

    01909 { return   m_refCount ; }

unsigned long Tuples::TupleObj::addRef | ( |  | ) | `[inline]`

add the reference to TupleObj

Returns:
  current reference counter

Definition at line 1914 of file TupleObj.h.

    01914 { 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 198 of file TupleObj.cpp.

    00199 {
    00200   // decrease the reference counter
    00201   if( 0 < refCount() ) { --m_refCount; }
    00202   // check references
    00203   if( 0 != refCount() ) { return; }
    00204   // delete the object
    00205   delete this  ;
    00206 }

const CLID& Tuples::TupleObj::clid | ( |  | ) | const`[inline]`

accessor to the N-Tuple CLID

Definition at line 1923 of file TupleObj.h.

    01923 { return m_clid ; }

Tuples::Type Tuples::TupleObj::type | ( |  | ) | const`[inline]`

accessor to the N-Tuple type

Definition at line 1926 of file TupleObj.h.

    01926 { return m_type ; }

bool Tuples::TupleObj::columnWise | ( |  | ) | const`[inline]`

column wise NTuple ?

Definition at line 1929 of file TupleObj.h.

    01929 { return CLID_ColumnWiseTuple == clid() ; }

bool Tuples::TupleObj::rowWise | ( |  | ) | const`[inline]`

row wise NTuple ?

Definition at line 1932 of file TupleObj.h.

    01932 { return CLID_RowWiseTuple    == clid() ; }

bool Tuples::TupleObj::evtColType | ( |  | ) | const`[inline]`

Event collection ?

Definition at line 1935 of file TupleObj.h.

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

bool Tuples::TupleObj::valid | ( |  | ) | const`[inline]`

valid pointer to tuple ?

Definition at line 1938 of file TupleObj.h.

    01938 { return 0 != tuple() ; }

bool Tuples::TupleObj::invalid | ( |  | ) | const`[inline]`

invalid pointer to tuple ?

Definition at line 1941 of file TupleObj.h.

    01941 { return 0 == tuple() ; }

bool Tuples::TupleObj::addItem | ( | const std::string & | name,
|  | const std::string & | type |
| ) |  |  | `[inline]`

add the item name into the list of known items

Parameters:

  | name | the name of the item
  | type | the type of the item

Returns:
  true if the name is indeed added

Definition at line 1950 of file TupleObj.h.

    01952     { return m_items.insert ( std::make_pair ( name , type ) ).second ; }

bool Tuples::TupleObj::goodItem | ( | const std::string & | name | ) | const`[inline]`

check the uniqueness of the name

Parameters:

  | name | the name of the item

Returns:
  true if the name is indeed unique

Definition at line 1958 of file TupleObj.h.

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

const ItemMap& Tuples::TupleObj::items | ( |  | ) | const`[inline]`

get the full list of booked items

Definition at line 1962 of file TupleObj.h.

    01962 { return m_items ; }

virtual StatusCode Tuples::TupleObj::Error | ( | const std::string & | msg,
|  | const StatusCode | sc = `StatusCode::FAILURE` |
| ) |  |  | const`[pure virtual]`

Implemented in Tuples::detail::TupleObjImp< HANDLER1, HANDLER2 >.

virtual StatusCode Tuples::TupleObj::Warning | ( | const std::string & | msg,
|  | const StatusCode | sc = `StatusCode::FAILURE` |
| ) |  |  | const`[pure virtual]`

Implemented in Tuples::detail::TupleObjImp< HANDLER1, HANDLER2 >.

Tuples::TupleObj::Float * Tuples::TupleObj::floats | ( | const std::string & | name | ) | `[private]`

get the column

Definition at line 305 of file TupleObj.cpp.

    00306 {
    00307   Floats::iterator found = m_floats.find( name ) ;
    00308   if ( m_floats.end() != found ) { return found->second ; }
    00309   Float* item = new Float() ;
    00310   m_floats[ name ] = item ;
    00311   const StatusCode sc = tuple()->addItem( name , *item );
    00312   if ( sc.isFailure() )
    00313   { Error ( " floats ('" + name + "'): item is not added",  sc ) ; }
    00314   if ( !addItem ( name , "F" ) )
    00315   { Error ( " floats ('" + name + "'): item is not unique"     ) ; }
    00316   return item ;
    00317 }

Tuples::TupleObj::Int * Tuples::TupleObj::ints | ( | const std::string & | name | ) | `[private]`

get the column

Definition at line 320 of file TupleObj.cpp.

    00321 {
    00322   Ints::iterator found = m_ints.find( name ) ;
    00323   if( m_ints.end() != found ) { return found->second ; }
    00324   Int* item = new Int() ;
    00325   m_ints[ name ] = item ;
    00326   StatusCode sc = tuple()->addItem( name , *item );
    00327   if( sc.isFailure() )
    00328   { Error ( " ints ('" + name + "'): item is not added",  sc ) ; }
    00329   if ( !addItem ( name , "L" ) )
    00330   { Error ( " ints ('" + name + "'): item is not unique"     ) ; }
    00331   return item ;
    00332 }

Tuples::TupleObj::Int * Tuples::TupleObj::ints | ( | const std::string & | name,
|  | const int | minv,
|  | const int | maxv |
| ) |  |  | `[private]`

get the column

Definition at line 335 of file TupleObj.cpp.

    00338 {
    00339   Ints::iterator found = m_ints.find( name ) ;
    00340   if( m_ints.end() != found ) { return found->second ; }
    00341   Int* item = new Int() ;
    00342   m_ints[ name ] = item ;
    00343   const StatusCode sc = tuple()->addItem( name , *item , minv , maxv );
    00344   if( sc.isFailure() )
    00345   { Error ( " ints ('" + name + "'): item is not added",  sc ) ; }
    00346   if ( !addItem ( name , "L" ) )
    00347   { Error ( " ints ('" + name + "'): item is not unique"     ) ; }
    00348   return item ;
    00349 }

Tuples::TupleObj::FArray * Tuples::TupleObj::fArray | ( | const std::string & | name,
|  | Int * | item |
| ) |  |  | `[private]`

get the column

Definition at line 369 of file TupleObj.cpp.

    00371 {
    00372   // existing array ?
    00373   FArrays::iterator found = m_farrays.find( name ) ;
    00374   if( m_farrays.end() != found ) { return found->second ; }
    00375   // create new array
    00376   FArray* array = new FArray () ;
    00377   m_farrays[ name] =      array    ;
    00378   const StatusCode sc = tuple() -> addIndexedItem( name , *length , *array) ;
    00379   if( sc.isFailure() )
    00380   { Error ( " farray ('" + name + "'): item is not added",  sc ) ; }
    00381   if ( !addItem ( name , "FArray" ) )
    00382   { Error ( " farray ('" + name + "'): item is not unique"     ) ; }
    00383   return array ;
    00384 }

Tuples::TupleObj::FArray * Tuples::TupleObj::fArray | ( | const std::string & | name,
|  | const MIndex & | rows |
| ) |  |  | `[private]`

get the column

Definition at line 389 of file TupleObj.cpp.

    00391 {
    00392   // existing array ?
    00393   FArrays::iterator found = m_arraysf.find( name ) ;
    00394   if( m_arraysf.end() != found ) { return found->second ; }
    00395   // create new array
    00396   FArray* array = new FArray () ;
    00397   m_arraysf[ name] =      array    ;
    00398   const StatusCode sc = tuple() -> addItem ( name , rows , *array) ;
    00399   if( sc.isFailure() )
    00400   { Error ( " array ('" + name + "'): item is not added",  sc ) ; }
    00401   if ( !addItem ( name , "FArray" ) )
    00402   { Error ( " array ('" + name + "'): item is not unique"     ) ; }
    00403   return array ;
    00404 }

Tuples::TupleObj::Address * Tuples::TupleObj::addresses | ( | const std::string & | name | ) | `[private]`

get the column

Definition at line 352 of file TupleObj.cpp.

    00353 {
    00354   Addresses::iterator found = m_addresses.find( name ) ;
    00355   if( m_addresses.end() != found ) { return found->second ; }
    00356   Address* item = new Address() ;
    00357   m_addresses[ name ] = item ;
    00358   const StatusCode sc = tuple()->addItem( name , *item );
    00359   if( sc.isFailure() )
    00360   { Error ( " addresses ('" + name + "'): item is not added",  sc ) ; }
    00361   if ( !addItem ( name , "IOpaqueAddress*" ) )
    00362   { Error ( " addresses ('" + name + "'): item is not unique"     ) ; }
    00363   return item ;
    00364 }

Tuples::TupleObj::FMatrix * Tuples::TupleObj::fMatrix | ( | const std::string & | name,
|  | Int * | item,
|  | const MIndex & | cols |
| ) |  |  | `[private]`

get the column

Definition at line 410 of file TupleObj.cpp.

    00413 {
    00414   // existing array ?
    00415   FMatrices::iterator found = m_fmatrices.find( name ) ;
    00416   if( m_fmatrices.end() != found ) { return found->second ; }
    00417   // create new array
    00418   FMatrix* matrix = new FMatrix () ;
    00419   m_fmatrices[ name] =  matrix   ;
    00420   const StatusCode sc =
    00421     tuple() -> addIndexedItem( name , *length , cols , *matrix ) ;
    00422   if( sc.isFailure() )
    00423   { Error ( " fmatrix ('" + name + "'): item is not added",  sc ) ; }
    00424   if ( !addItem ( name , "FMatrix" ) )
    00425   { Error ( " fmatrix ('" + name + "'): item is not unique"     ) ; }
    00426   return matrix ;
    00427 }

Tuples::TupleObj::FMatrix * Tuples::TupleObj::fMatrix | ( | const std::string & | name,
|  | const MIndex & | rows,
|  | const MIndex & | cols |
| ) |  |  | `[private]`

get the column

Definition at line 433 of file TupleObj.cpp.

    00436 {
    00437   // existing array ?
    00438   FMatrices::iterator found = m_matricesf.find( name ) ;
    00439   if( m_matricesf.end() != found ) { return found->second ; }
    00440   // create new array
    00441   FMatrix* matrix = new FMatrix () ;
    00442   m_matricesf[ name] =  matrix   ;
    00443   const StatusCode sc =
    00444     tuple() -> addItem( name , rows , cols , *matrix ) ;
    00445   if( sc.isFailure() )
    00446   { Error ( " matrix ('" + name + "'): item is not added",  sc ) ; }
    00447   if ( !addItem ( name , "FMatrix" ) )
    00448   { Error ( " matrix ('" + name + "'): item is not unique"     ) ; }
    00449   return matrix ;
    00450 }

TupleObj& Tuples::TupleObj::operator= | ( | const TupleObj & |  | ) | `[private]`

assignment is disabled

## Member Data Documentation

std::string Tuples::TupleObj::m_name`[private]`

the name

Definition at line 2039 of file TupleObj.h.

NTuple::Tuple* Tuples::TupleObj::m_tuple`[private]`

tuple itself

Definition at line 2042 of file TupleObj.h.

CLID Tuples::TupleObj::m_clid`[private]`

tuple CLID

Definition at line 2045 of file TupleObj.h.

Tuples::Type Tuples::TupleObj::m_type`[private]`

tuple 'type'

Definition at line 2048 of file TupleObj.h.

size_t Tuples::TupleObj::m_refCount`[private]`

reference counter

Definition at line 2051 of file TupleObj.h.

Ints Tuples::TupleObj::m_ints`[mutable, private]`

the actual storage of columns

Definition at line 2054 of file TupleObj.h.

Floats Tuples::TupleObj::m_floats`[mutable, private]`

the actual storage of columns

Definition at line 2057 of file TupleObj.h.

Addresses Tuples::TupleObj::m_addresses`[mutable, private]`

the actual storage of columns

Definition at line 2060 of file TupleObj.h.

FArrays Tuples::TupleObj::m_farrays`[mutable, private]`

the actual storage of columns

Definition at line 2063 of file TupleObj.h.

FArrays Tuples::TupleObj::m_arraysf`[mutable, private]`

the actual storage of columns

Definition at line 2066 of file TupleObj.h.

FMatrices Tuples::TupleObj::m_fmatrices`[mutable, private]`

the actual storage of columns

Definition at line 2069 of file TupleObj.h.

FMatrices Tuples::TupleObj::m_matricesf`[mutable, private]`

the actual storage of columns

Definition at line 2072 of file TupleObj.h.

ItemMap Tuples::TupleObj::m_items`[private]`

all booked types:

Definition at line 2075 of file TupleObj.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7p1/GaudiAlg/GaudiAlg/TupleObj.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7p1/GaudiAlg/GaudiAlg/TuplePut.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r7p1/GaudiAlg/src/lib/TupleObj.cpp