| # Gaudi Framework, version v22r4 |

Home |  | Generated: Fri Sep 2 2011

Public Types | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes

# 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<IOpaqueAddress*> Tuples::TupleObj::Address

basic type for address items

Definition at line 195 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 NTuple::Array<float> Tuples::TupleObj::FArray

basic type for array of floats

Definition at line 198 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 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 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,FMatrix*> Tuples::TupleObj::FMatrices`[private]`

the actual storage type for matrix columns

Definition at line 2034 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 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 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 std::map<std::string,std::string> Tuples::TupleObj::ItemMap

Definition at line 207 of file TupleObj.h.

typedef unsigned short Tuples::TupleObj::MIndex

Definition at line 204 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.

      : m_name     ( name )
      , m_tuple    ( tuple )
      , m_clid     ( clid )
      , m_type     ( type )
      // for error handling
      , m_refCount ( 0 )
      // columns
      , m_ints      ()
      , m_floats    ()
      , m_addresses ()
      , m_farrays   ()
      , m_arraysf   ()
      , m_fmatrices ()
      , m_matricesf ()
      //
      , m_items     ()
    {
      // make counts
      Tuples::Local::s_InstanceCounter.increment ( m_name ) ;
    }

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

destructor is protected

Definition at line 145 of file TupleObj.cpp.

    {
      {// delete 'long' columns
        for( Ints::iterator it = m_ints.begin() ;
             m_ints.end() != it ; ++it )
        { if( 0 != it->second ) { delete it->second ; } }
        m_ints.clear() ;
      }
      {// delete 'float' columns
        for( Floats::iterator it = m_floats.begin() ;
             m_floats.end() != it ; ++it )
        { if( 0 != it->second ) { delete it->second ; } }
        m_floats.clear() ;
      }
      {// delete 'fArray' columns
        for( FArrays::iterator it = m_farrays.begin() ;
             m_farrays.end() != it ; ++it )
        { if( 0 != it->second ) { delete it->second ; } }
        m_farrays.clear() ;
      }
      {// delete 'fArray' columns
        for( FArrays::iterator it = m_arraysf.begin() ;
             m_arraysf.end() != it ; ++it )
        { if( 0 != it->second ) { delete it->second ; } }
        m_arraysf.clear() ;
      }
      { // destroy and clean all "addresses"
        for( Addresses::iterator it = m_addresses.begin() ;
             m_addresses.end() != it ; ++it )
        { if( 0 != it->second ) { delete it->second ; } }
        m_addresses.clear();
      }
      { // destroy and clean all "matrices"
        for( FMatrices::iterator it = m_fmatrices.begin() ;
             m_fmatrices.end() != it ; ++it )
        { if( 0 != it->second ) { delete it->second ; } }
        m_fmatrices.clear();
      }
      { // destroy and clean all "matrices" (fixed)
        for( FMatrices::iterator it = m_matricesf.begin() ;
             m_matricesf.end() != it ; ++it )
        { if( 0 != it->second ) { delete it->second ; } }
        m_matricesf.clear();
      }

      // make counts
      Tuples::Local::s_InstanceCounter.decrement ( m_name ) ;
    }

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:

  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.

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

    { return ++m_refCount ; }

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

get the column

Definition at line 352 of file TupleObj.cpp.

    {
      Addresses::iterator found = m_addresses.find( name ) ;
      if( m_addresses.end() != found ) { return found->second ; }
      Address* item = new Address() ;
      m_addresses[ name ] = item ;
      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:

  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.

        {
          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 ; }

          return StatusCode::SUCCESS ;
        }

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.

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

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.

        {
          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] ; }

          return StatusCode::SUCCESS ;
        }

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.

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

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

accessor to the N-Tuple CLID

Definition at line 1923 of file TupleObj.h.

    { return m_clid ; }

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.

        {
          if ( invalid() ) { return InvalidTuple  ; }
          Int* item = ints ( name , minv , maxv ) ;
          if ( 0 == item ) { return InvalidColumn ; }
          *item = value ;
          return StatusCode::SUCCESS ;
        }

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.

        {
          StatusCode sc1 = StatusCode::SUCCESS ;
          if ( sizeof(int) != sizeof(long)
               && ( std::numeric_limits<int>::max() < value ||
                    std::numeric_limits<int>::min() > value ) )
          { sc1 = Warning (" column('" + name + "'): truncate long value" ,
                           TruncateValue ) ; }
          const int val = (int) value ;
          StatusCode sc2 = column ( name , val ) ;
          return sc2.isFailure() ? sc2 : sc1 ;
        }

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.

        {
          return column
            ( name  ,
              value ,
              std::numeric_limits<char>::min() ,
              std::numeric_limits<char>::max() ) ;
        }

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.

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

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.

        {
          return column
            ( name  ,
              value ,
              std::numeric_limits<unsigned char>::min() ,
              std::numeric_limits<unsigned char>::max() ) ;
        }

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.

        {
          return column
            ( name  ,
              value ,
              std::numeric_limits<signed char>::min() ,
              std::numeric_limits<signed char>::max() ) ;
        }

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.

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

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.

        {
          if ( invalid() ) { return InvalidTuple  ; }
          Float* item = floats ( name ) ;
          if ( 0 == item ) { return InvalidColumn ; }
          *item = value ;
          return StatusCode::SUCCESS ;
        }

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.

        {
          if ( invalid() ) { return InvalidTuple  ; }
          Int* item = ints( name ) ;
          if ( 0 == item ) { return InvalidColumn ; }
          *item = value ;
          return StatusCode::SUCCESS ;
        }

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.

        {
          StatusCode sc1 = StatusCode::SUCCESS ;
          static const double s_max =      std::numeric_limits<float>::max() ;
          static const double s_min = -1 * std::numeric_limits<float>::max() ;
          if ( s_max < value || s_min > value  )
          { sc1 = Warning (" column('" + name + "'): truncate double value " ,
                           TruncateValue ) ; }
          const float val = (float) value ;
          StatusCode sc2 = column ( name , val ) ;
          return sc2.isFailure() ? sc2 : sc1 ;
        }

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.

        {
          StatusCode sc1 = StatusCode::SUCCESS ;
          static const unsigned int s_max = std::numeric_limits<int>::max() ;
          if ( s_max < value )
          { sc1 = Warning
              (" column('" + name + "'): truncate unsigned int" , TruncateValue ) ; }
          const int val = (int) value ;
          StatusCode sc2 = column ( name , val ) ;
          return sc2.isFailure() ? sc2 : sc1 ;
        }

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.

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

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.

        {
          return column
            ( name  ,
              value ,
              std::numeric_limits<short>::min() ,
              std::numeric_limits<short>::max() ) ;
        }

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.

        {
          return column
            ( name  ,
              value ,
              std::numeric_limits<unsigned short>::min() ,
              std::numeric_limits<unsigned short>::max() ) ;
        }

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.

    {
      if (  invalid    () ) { return InvalidTuple     ; }
      if ( !evtColType () ) { return InvalidOperation ; }
      if ( 0 == address )
      { return Error ( "column('" + name +
                       "') IOpaqueAddress* is NULL!" , InvalidObject ) ; }
      Address* item = addresses( name );
      if ( 0 == item      ) { return InvalidItem      ; }
      *item = address ;
      return StatusCode::SUCCESS ;
    }

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.

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

Date:
  2006-11-26

Definition at line 1681 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 ibelyaev@physics.syr.edu

Date:
  2006-11-26

fill separate columns

Definition at line 1715 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 1929 of file TupleObj.h.

    { return CLID_ColumnWiseTuple == clid() ; }

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

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

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

Event collection ?

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

  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.

        {
          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 ; }

          return StatusCode::SUCCESS ;
        }

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.

        { 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.

        {
          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 ; }

          return StatusCode::SUCCESS ;
        }

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.

        {
          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") ;
            Warning(" farray('"+name1+"'): 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
          *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 ;
          }

          return StatusCode::SUCCESS ;
        }

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.

        {
          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") ;
            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 ;
          }
          return StatusCode::SUCCESS ;
        }

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.

        {
          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") ;
            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 ;
          }

          return StatusCode::SUCCESS ;
        }

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.

    {
      // existing array ?
      FArrays::iterator found = m_arraysf.find( name ) ;
      if( m_arraysf.end() != found ) { return found->second ; }
      // create new array
      FArray* array = new FArray () ;
      m_arraysf[ name] =      array    ;
      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 ;
    }

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

get the column

Definition at line 369 of file TupleObj.cpp.

    {
      // existing array ?
      FArrays::iterator found = m_farrays.find( name ) ;
      if( m_farrays.end() != found ) { return found->second ; }
      // create new array
      FArray* array = new FArray () ;
      m_farrays[ name] =      array    ;
      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 ;
    }

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.

    {
      // 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
      StatusCode status = StatusCode::SUCCESS ;
      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 305 of file TupleObj.cpp.

    {
      Floats::iterator found = m_floats.find( name ) ;
      if ( m_floats.end() != found ) { return found->second ; }
      Float* item = new Float() ;
      m_floats[ name ] = item ;
      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 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.

        {

          if ( invalid () ) { return InvalidTuple     ; }
          if ( rowWise () ) { return InvalidOperation ; }

          typename GaudiUtils::VectorMap<KEY,VALUE>::const_iterator begin = info.begin () ;
          typename GaudiUtils::VectorMap<KEY,VALUE>::const_iterator end   = info.end   () ;

          // 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 ;
          } ;

          return StatusCode::SUCCESS ;
        }

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.

    {
      // existing array ?
      FMatrices::iterator found = m_fmatrices.find( name ) ;
      if( m_fmatrices.end() != found ) { return found->second ; }
      // create new array
      FMatrix* matrix = new FMatrix () ;
      m_fmatrices[ name] =  matrix   ;
      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 ;
    }

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.

        {
          if ( invalid () ) { return InvalidTuple     ; }
          if ( rowWise () ) { return InvalidOperation ; }

          // adjust the length
          if ( first + maxv < last )
          {
            Warning(" fmatrix('"+name+"'): matrix 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
          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;
          };

          return StatusCode::SUCCESS ;
        }

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.

        {
          if ( invalid () ) { return InvalidTuple     ; }
          if ( rowWise () ) { return InvalidOperation ; }

          // adjust the length
          if ( first + maxv < last )
          {
            Warning(" fmatrix('"+name+"'): matrix 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
          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 ;
          };

          return StatusCode::SUCCESS ;
        }

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.

    {
      // existing array ?
      FMatrices::iterator found = m_matricesf.find( name ) ;
      if( m_matricesf.end() != found ) { return found->second ; }
      // create new array
      FMatrix* matrix = new FMatrix () ;
      m_matricesf[ name] =  matrix   ;
      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 ;
    }

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.

        {
          if ( invalid () ) { return InvalidTuple     ; }
          if ( rowWise () ) { return InvalidOperation ; }

          // adjust the length
          if ( rows >= maxv )
          {
            Warning ( " fmatrix('"+name+"'): matrix is overflow, skip extra items") ;
            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 ]) ; }
          };

          return StatusCode::SUCCESS ;
        }

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.

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

    {
      Ints::iterator found = m_ints.find( name ) ;
      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 , "L" ) )
      { 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 335 of file TupleObj.cpp.

    {
      Ints::iterator found = m_ints.find( name ) ;
      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 , "L" ) )
      { Error ( " ints ('" + name + "'): item is not unique"     ) ; }
      return item ;
    }

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

invalid pointer to tuple ?

Definition at line 1941 of file TupleObj.h.

    { return 0 == tuple() ; }

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

get the full list of booked items

Definition at line 1962 of file TupleObj.h.

    { return m_items ; }

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.

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

          return StatusCode::SUCCESS ;
        }

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.

        {
          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]) ; }
          };
          return StatusCode::SUCCESS ;
        }

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

get the name

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

  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.

    {
      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 1909 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 198 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 1932 of file TupleObj.h.

    { return CLID_RowWiseTuple    == clid() ; }

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.

    { return m_tuple ; }

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

accessor to the N-Tuple type

Definition at line 1926 of file TupleObj.h.

    { return m_type ; }

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

valid pointer to tuple ?

Definition at line 1938 of file TupleObj.h.

    { return 0 != tuple() ; }

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

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

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

write a record to NTuple

Returns:
  status code

Definition at line 210 of file TupleObj.cpp.

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

## Member Data Documentation

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

the actual storage of columns

Definition at line 2060 of file TupleObj.h.

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

the actual storage of columns

Definition at line 2066 of file TupleObj.h.

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

tuple CLID

Definition at line 2045 of file TupleObj.h.

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

the actual storage of columns

Definition at line 2063 of file TupleObj.h.

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

the actual storage of columns

Definition at line 2057 of file TupleObj.h.

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

the actual storage of columns

Definition at line 2069 of file TupleObj.h.

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

the actual storage of columns

Definition at line 2054 of file TupleObj.h.

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

all booked types:

Definition at line 2075 of file TupleObj.h.

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

the actual storage of columns

Definition at line 2072 of file TupleObj.h.

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

the name

Definition at line 2039 of file TupleObj.h.

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

reference counter

Definition at line 2051 of file TupleObj.h.

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

tuple itself

Definition at line 2042 of file TupleObj.h.

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

tuple 'type'

Definition at line 2048 of file TupleObj.h.

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

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

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines