| # Gaudi Framework, version v20r2
Generated: 18 Jul 2008

- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Search for |

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Tuples::Tuple Class Reference

`#include <GaudiAlg/Tuple.h>`

Collaboration diagram for Tuples::Tuple:

[legend]
List of all members.

## Detailed Description

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

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

Usially 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 throught different files. And even minor modification of the structure of teh ntuple will reqire the modification of at least 2 methods and 2 files.

The `Tuples::Tuple` wrapper over standard Gaudi `NTuple::Tuple` class solves all abouve 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 Tuple object:

      Tuple tuple = nTuple( "some more or less uniqe 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 uniqe 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 uniqe 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  () ;
      }

All these techniques could be easily combined in arbitrary ways

See also:
  GaudiTupleAlg

  TupleObj

Author:
  Vanya BELYAEV Ivan.Belyaev@itep.ru

Date:
  2003-02-24

Definition at line 116 of file Tuple.h.

## Public Member Functions
| Tuple (TupleObj *tuple)
| standard constructor
| Tuple (const Tuple &tuple)
| copy constructor
virtual | ~Tuple ()
| destructor
Tuple & | operator= (const Tuple &tuple)
| assignment operator Tuples could be assigned in a safe way
TupleObj * | operator-> () const
| get the pointer to the underlying object
const bool | valid () const
| check the validity of the tuple object
## Protected Member Functions
TupleObj * | tuple () const
| Return the underlying tuple object.
## Private Member Functions
| Tuple ()
| default constructor is private
## Private Attributes
TupleObj * | m_tuple
| The tuple object.

## Constructor & Destructor Documentation

Tuples::Tuple::Tuple | ( | TupleObj * | tuple | ) |

standard constructor

Parameters:

  | tuple | pointer to "real" tuple object

Definition at line 24 of file Tuple.cpp.

References m_tuple.

    00025   : m_tuple( tuple )
    00026 {
    00027   if( 0 != m_tuple ) { m_tuple -> addRef () ; }
    00028 };

Tuples::Tuple::Tuple | ( | const Tuple & | tuple | ) |

copy constructor

Definition at line 35 of file Tuple.cpp.

References Tuples::TupleObj::addRef(), and m_tuple.

    00036   : m_tuple ( tuple.m_tuple )
    00037 {
    00038   if( 0 != m_tuple ) { m_tuple ->addRef() ; }
    00039 };

Tuples::Tuple::~Tuple | ( |  | ) | `[virtual]`

destructor

Definition at line 68 of file Tuple.cpp.

References m_tuple, and Tuples::TupleObj::release().

    00069 {
    00070   if( 0 != m_tuple ) { m_tuple->release() ; }
    00071 };

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

default constructor is private

## Member Function Documentation

Tuples::Tuple & Tuples::Tuple::operator= | ( | const Tuple & | tuple | ) |

assignment operator Tuples could be assigned in a safe way

Parameters:

  | tuple | tuple to be assigned

Definition at line 48 of file Tuple.cpp.

References m_tuple, Tuples::TupleObj::m_tuple, and tuple().

    00049 {
    00050   // self assigenment
    00051   if( &tuple == this ) { return *this; }
    00052   // temporary variable
    00053   Tuples::TupleObj* tmp = tuple.m_tuple ;
    00054   // increse reference count
    00055   if( 0 !=    tmp  ) { tmp     -> addRef  () ; }
    00056   // decrease reference count
    00057   if( 0 != m_tuple ) { m_tuple -> release () ; }
    00058   // assigne
    00059   m_tuple = tmp ;
    00060   //
    00061   return *this ;
    00062 };

TupleObj* Tuples::Tuple::operator-> | ( |  | ) | const`[inline]`

get the pointer to the underlying object

Returns:
  pointer to underlying TupleObj

Definition at line 141 of file Tuple.h.

References tuple().

    00141 { return      tuple () ; }

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

check the validity of the tuple object

Definition at line 144 of file Tuple.h.

References tuple().

Referenced by _fill(), GaudiPython::TupleDecorator::array(), GaudiPython::TupleDecorator::column(), GaudiPython::TupleDecorator::farray(), GaudiPython::TupleDecorator::fmatrix(), GaudiPython::TupleDecorator::matrix(), GaudiPython::TupleDecorator::ntuple(), GaudiPython::TupleDecorator::nTuple(), operator<<(), GaudiPython::TupleDecorator::valid(), and GaudiPython::TupleDecorator::write().

    00144 { return 0 != tuple () ; }

TupleObj* Tuples::Tuple::tuple | ( |  | ) | const`[inline, protected]`

Return the underlying tuple object.

Definition at line 149 of file Tuple.h.

References m_tuple.

Referenced by GaudiPython::TupleDecorator::ntuple(), GaudiPython::TupleDecorator::nTuple(), operator->(), operator=(), GaudiTuples< PBASE >::printEvtCols(), GaudiTuples< PBASE >::printTuples(), and valid().

    00149 { return m_tuple ; }

## Member Data Documentation

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

The tuple object.

Definition at line 159 of file Tuple.h.

Referenced by operator=(), Tuple(), tuple(), and ~Tuple().

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiAlg/v11r1/GaudiAlg/Tuple.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v20r2/GaudiAlg/v11r1/src/lib/Tuple.cpp