The Gaudi Framework  v38r1p1 (ae26267b)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules 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 (std::shared_ptr< TupleObj > tuple)
 standard constructor More...
 
virtual ~Tuple ()=default
 
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 ()
 

Private Attributes

std::shared_ptr< TupleObjm_tuple
 The (shared) 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 126 of file Tuple.h.

Constructor & Destructor Documentation

◆ Tuple()

Tuples::Tuple::Tuple ( std::shared_ptr< TupleObj tuple)
inline

standard constructor

Parameters
tuplepointer to "real" tuple object

Definition at line 132 of file Tuple.h.

132 : m_tuple( std::move( tuple ) ) {}

◆ ~Tuple()

virtual Tuples::Tuple::~Tuple ( )
virtualdefault

Member Function Documentation

◆ operator->()

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

get the pointer to the underlying object

Returns
pointer to underlying TupleObj

Definition at line 139 of file Tuple.h.

139 { return m_tuple.get(); }

◆ tuple()

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

Definition at line 145 of file Tuple.h.

145 { return m_tuple.get(); }

◆ valid()

bool Tuples::Tuple::valid ( ) const
inline

check the validity of the tuple object

Definition at line 142 of file Tuple.h.

142 { return static_cast<bool>( m_tuple ); }

Member Data Documentation

◆ m_tuple

std::shared_ptr<TupleObj> Tuples::Tuple::m_tuple
private

The (shared) tuple object.

Definition at line 149 of file Tuple.h.


The documentation for this class was generated from the following file:
GaudiAlg.TupleUtils.nTuple
def nTuple(dirpath, ID, ID2=None, topdir=None, LUN="FILE1")
Definition: TupleUtils.py:84
std::move
T move(T... args)
Gaudi::Units::GeV
constexpr double GeV
Definition: SystemOfUnits.h:179
Tuples::Tuple::tuple
TupleObj * tuple()
Definition: Tuple.h:145
GaudiAlg.Algs.column
column
Definition: Algs.py:1212
Tuples::Tuple::m_tuple
std::shared_ptr< TupleObj > m_tuple
The (shared) tuple object.
Definition: Tuple.h:149
Tuples::Tuple::Tuple
Tuple(std::shared_ptr< TupleObj > tuple)
standard constructor
Definition: Tuple.h:132
Gaudi::Utils::Histos::fill
GAUDI_API void fill(AIDA::IHistogram1D *histo, const double value, const double weight=1.0)
simple function to fill AIDA::IHistogram1D objects
Definition: Fill.cpp:45