All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Tuples::Tuple Class Reference

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

#include <GaudiAlg/Tuple.h>

Collaboration diagram for Tuples::Tuple:

Public Member Functions

 Tuple (TupleObj *tuple)
 standard constructor More...
 
 Tuple (const Tuple &tuple)
 copy constructor More...
 
virtual ~Tuple ()
 destructor More...
 
Tupleoperator= (const Tuple &tuple)
 assignment operator Tuples could be assigned in a safe way More...
 
TupleObjoperator-> () const
 get the pointer to the underlying object More...
 
bool valid () const
 check the validity of the tuple object More...
 

Protected Member Functions

TupleObjtuple () const
 Return the underlying tuple object. More...
 

Private Member Functions

 Tuple ()
 default constructor is private More...
 

Private Attributes

TupleObjm_tuple
 The tuple object. More...
 

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

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

All these techniques could be easily combined in arbitrary ways

See also
GaudiTupleAlg
TupleObj
Author
Vanya BELYAEV Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru
Date
2003-02-24

Definition at line 115 of file Tuple.h.

Constructor & Destructor Documentation

Tuples::Tuple::Tuple ( Tuples::TupleObj tuple)

standard constructor

Standard constructor.

Parameters
tuplepointer to "real" tuple object

Definition at line 24 of file Tuple.cpp.

25  : m_tuple( tuple )
26 {
27  if( 0 != m_tuple ) { m_tuple -> addRef () ; }
28 }
TupleObj * m_tuple
The tuple object.
Definition: Tuple.h:158
Tuples::Tuple::Tuple ( const Tuple tuple)

copy constructor

Definition at line 35 of file Tuple.cpp.

36  : m_tuple ( tuple.m_tuple )
37 {
38  if( 0 != m_tuple ) { m_tuple ->addRef() ; }
39 }
TupleObj * m_tuple
The tuple object.
Definition: Tuple.h:158
unsigned long addRef()
add the reference to TupleObj
Definition: TupleObj.h:2098
NTuple::Tuple * m_tuple
tuple itself
Definition: TupleObj.h:2315
TupleObj * tuple() const
Return the underlying tuple object.
Definition: Tuple.h:148
Tuples::Tuple::~Tuple ( )
virtual

destructor

Definition at line 68 of file Tuple.cpp.

69 {
70  if( 0 != m_tuple ) { m_tuple->release() ; }
71 }
void release()
release the reference to TupleObj if reference counter becomes zero, object will be automatically del...
Definition: TupleObj.cpp:228
TupleObj * m_tuple
The tuple object.
Definition: Tuple.h:158
Tuples::Tuple::Tuple ( )
private

default constructor is private

Member Function Documentation

TupleObj* Tuples::Tuple::operator-> ( ) const
inline

get the pointer to the underlying object

Returns
pointer to underlying TupleObj

Definition at line 140 of file Tuple.h.

140 { return tuple () ; }
TupleObj * tuple() const
Return the underlying tuple object.
Definition: Tuple.h:148
Tuples::Tuple & Tuples::Tuple::operator= ( const Tuple tuple)

assignment operator Tuples could be assigned in a safe way

Parameters
tupletuple to be assigned

Definition at line 48 of file Tuple.cpp.

49 {
50  // self assigenment
51  if( &tuple == this ) { return *this; }
52  // temporary variable
54  // increse reference count
55  if( 0 != tmp ) { tmp -> addRef () ; }
56  // decrease reference count
57  if( 0 != m_tuple ) { m_tuple -> release () ; }
58  // assign
59  m_tuple = tmp ;
60  //
61  return *this ;
62 }
A simple wrapper class over standard Gaudi NTuple::Tuple facility.
Definition: TupleObj.h:180
TupleObj * m_tuple
The tuple object.
Definition: Tuple.h:158
NTuple::Tuple * m_tuple
tuple itself
Definition: TupleObj.h:2315
TupleObj * tuple() const
Return the underlying tuple object.
Definition: Tuple.h:148
TupleObj* Tuples::Tuple::tuple ( ) const
inlineprotected

Return the underlying tuple object.

Definition at line 148 of file Tuple.h.

148 { return m_tuple ; }
TupleObj * m_tuple
The tuple object.
Definition: Tuple.h:158
bool Tuples::Tuple::valid ( ) const
inline

check the validity of the tuple object

Definition at line 143 of file Tuple.h.

143 { return 0 != tuple () ; }
TupleObj * tuple() const
Return the underlying tuple object.
Definition: Tuple.h:148

Member Data Documentation

TupleObj* Tuples::Tuple::m_tuple
private

The tuple object.

Definition at line 158 of file Tuple.h.


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