| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

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

# GaudiTuples< PBASE > Class Template Reference

Templated base class providing common 'ntupling' methods. More...

`#include <GaudiAlg/GaudiTuples.h>`

Collaboration diagram for GaudiTuples< PBASE >:
[legend]

List of all members.

## Public Types
typedef GaudiAlg::HistoID | HistoID
| the actual type for histogram identifier
typedef Tuples::Tuple | Tuple
| the actual type of the tuple
typedef GaudiAlg::TupleID | TupleID
| the actual type of N-tuple ID
typedef GaudiAlg::TupleMapTitle | TupleMapTitle
| the actual type of (title) -> (tuple) mappping
typedef GaudiAlg::TupleMapID | TupleMapID
| the actual type of (Numeric ID) -> (tuple) mappping
## Public Member Functions
Tuple | nTuple (const std::string &title, const CLID &clid=CLID_ColumnWiseTuple) const
| Access an N-Tuple object (book on-demand) with unique identifier.
Tuple | nTuple (const TupleID &ID, const std::string &title, const CLID &clid=CLID_ColumnWiseTuple) const
| Access an N-Tuple object (book on-demand) with forced identifier.
Tuple | evtCol (const std::string &title, const CLID &clid=CLID_ColumnWiseTuple) const
| Access an Event Tag Collection object (book on-demand) with unique identifier.
Tuple | evtCol (const TupleID &ID, const std::string &title, const CLID &clid=CLID_ColumnWiseTuple) const
| Access an Event Tag Collection object (book on-demand) with forced identifier.
bool | produceNTuples () const
| get the flag for N-Tuple production (property "NTupleProduce")
bool | splitNTupleDir () const
| get the flag for N-Tuple path split (property "NTupleSplitDir")
const std::string & | nTupleLUN () const
| get the logical unit for N-Tuples (property "NTupleLUN")
const std::string & | nTupleTopDir () const
| get the top-level N-Tuple directory (property "NTupleTopDir")
const std::string & | nTupleDir () const
| get the N-Tuple directory (property "NTupleDir")
TupleID::NumericID | nTupleOffSet () const
| get the value for N-Tuple offset (property "NTupleOffSet")
std::string | nTuplePath () const
| get the constructed N-Tuple path
bool | produceEvtCols () const
| get the flag for Event Tag Collection production (property "EvtColsProduce")
bool | splitEvtColDir () const
| get the flag for Event Tag Collection path split (property "EvtColsSplitDir")
const std::string & | evtColLUN () const
| get the logical unit for Event Tag Collections (property "EvtColsLUN")
const std::string & | evtColTopDir () const
| get the top-level Event Tag Collection directory (property "EvtColsTopDir")
const std::string & | evtColDir () const
| get the Event Tag Collection directory (property "EvtColsDir")
TupleID::NumericID | evtColOffSet () const
| get the value for Event Tag Collection offset (property "EvtColsOffSet")
std::string | evtColPath () const
| get the constructed Event Tag Collection path
bool | tuplesPrint () const
| print tuples at finalization
bool | evtColsPrint () const
| print event collections at finalization
long | printTuples () const
| perform the actual printout of N-tuples
long | printEvtCols () const
| perform the actual printout of Event Tag Collections
bool | nTupleExists (const TupleID &ID) const
| check the existence AND validity of the N-Tuple with the given ID
bool | evtColExists (const TupleID &ID) const
| check the existence AND validity of the Event Tag Collection with the given ID
| GaudiTuples (const std::string &name, ISvcLocator *pSvcLocator)
| Algorithm constructor.
| GaudiTuples (const std::string &type, const std::string &name, const IInterface *parent)
| Tool constructor.
virtual | ~GaudiTuples ()
| Destructor.
## Protected Member Functions
const TupleMapTitle & | nTupleMapTitle () const
| access to the all ntuples by title
const TupleMapTitle & | evtColMapTitle () const
| access to the all evet tag collections by title
const TupleMapID & | nTupleMapID () const
| access to the all ntuples by numeric ID
const TupleMapID & | evtColMapID () const
| access to the all evet tag collections by numeric ID
virtual Tuples::TupleObj * | createNTuple (const std::string &name, NTuple::Tuple *tuple, const CLID &clid) const
| create TupleObj
virtual Tuples::TupleObj * | createEvtCol (const std::string &name, NTuple::Tuple *tuple, const CLID &clid) const
| create TupleObj for event tag collection
virtual StatusCode | initialize ()
| standard initialization method
virtual StatusCode | finalize ()
| standard finalization method
## Private Member Functions
void | initGaudiTuplesConstructor ()
| Constructor initialization and job options.
void | printNTupleHandler (Property &)
| handler for "NTuplePrint" property
void | printEvtColHandler (Property &)
| handler for "EvtColsPrint" property
## Private Attributes
bool | m_produceNTuples
| flag to switch ON/OFF the ntuple filling and booking
bool | m_splitNTupleDir
| flag to indicate splitting of tuple directories (useful for HBOOK)
std::string | m_nTupleLUN
| name of logical unit for tuple directory
std::string | m_nTupleTopDir
| top level tuple directory
std::string | m_nTupleDir
| local tuple directory
TupleID::NumericID | m_nTupleOffSet
| the offset for ntuple numerical ID
bool | m_produceEvtCols
| flag to switch ON/OFF the ntuple filling and booking
bool | m_splitEvtColDir
| flag to indicate splitting of tuple directories (useful for HBOOK)
std::string | m_evtColLUN
| name of Logical Unit for tuple directory
std::string | m_evtColTopDir
| top level tuple directory
std::string | m_evtColDir
| local tuple directory
TupleID::NumericID | m_evtColOffSet
| the offset for ntuple numerical ID
bool | m_tuplesPrint
| print tuples at finalization?
bool | m_evtColsPrint
| print event collections at finalization
TupleMapTitle | m_nTupleMapTitle
| the actual storage of ntuples by title
TupleMapID | m_nTupleMapID
| the actual storage of ntuples by ID
TupleMapTitle | m_evtColMapTitle
| the actual storage of event collections by title
TupleMapID | m_evtColMapID
| the actual storage of event collections by ID

## Detailed Description

### template<class PBASE>
class GaudiTuples< PBASE >

Templated base class providing common 'ntupling' methods.

Author:
  Chris Jones Christopher.Rob.Jones@cern.ch
  Vanya BELYAEV Ivan.Belyaev@itep.ru

Date:
  2005-08-08

Definition at line 37 of file GaudiTuples.h.

## Member Typedef Documentation

template<class PBASE>

typedef GaudiAlg::HistoID GaudiTuples< PBASE >::HistoID

the actual type for histogram identifier

Definition at line 42 of file GaudiTuples.h.

template<class PBASE>

typedef Tuples::Tuple GaudiTuples< PBASE >::Tuple

the actual type of the tuple

Reimplemented in TupleTool.

Definition at line 44 of file GaudiTuples.h.

template<class PBASE>

typedef GaudiAlg::TupleID GaudiTuples< PBASE >::TupleID

the actual type of N-tuple ID

Reimplemented in TupleTool.

Definition at line 46 of file GaudiTuples.h.

template<class PBASE>

typedef GaudiAlg::TupleMapID GaudiTuples< PBASE >::TupleMapID

the actual type of (Numeric ID) -> (tuple) mappping

Definition at line 50 of file GaudiTuples.h.

template<class PBASE>

typedef GaudiAlg::TupleMapTitle GaudiTuples< PBASE >::TupleMapTitle

the actual type of (title) -> (tuple) mappping

Definition at line 48 of file GaudiTuples.h.

## Constructor & Destructor Documentation

template<class PBASE>

GaudiTuples< PBASE >::GaudiTuples | ( | const std::string & | name,
|  | ISvcLocator * | pSvcLocator
| ) |  |

Algorithm constructor.

template<class PBASE>

GaudiTuples< PBASE >::GaudiTuples | ( | const std::string & | type,
|  | const std::string & | name,
|  | const IInterface * | parent
| ) |  |

Tool constructor.

template<class PBASE >

GaudiTuples< PBASE >::~GaudiTuples | ( | ) | `[virtual]`

Destructor.

Definition at line 38 of file GaudiTuples.icpp.

    {}

## Member Function Documentation

template<class PBASE >

Tuples::TupleObj * GaudiTuples< PBASE >::createEvtCol | ( | const std::string & | name,
|  | NTuple::Tuple * | tuple,
|  | const CLID & | clid
| ) |  | const`[protected, virtual]`

create TupleObj for event tag collection

Attention:
  The method should never used directly by users

Parameters:

  name | name/title
  tuple | the underlying ntuple implementation
  clid | unique classID for ntuple

Returns:
  pointer to newly created TupelObj

Definition at line 357 of file GaudiTuples.icpp.

    {
      return Tuples::createTupleObj
        ( this , "EvtCol '" + name  + "'" , tuple , clid , Tuples::EVTCOL ) ;
    }

template<class PBASE >

Tuples::TupleObj * GaudiTuples< PBASE >::createNTuple | ( | const std::string & | name,
|  | NTuple::Tuple * | tuple,
|  | const CLID & | clid
| ) |  | const`[protected, virtual]`

create TupleObj

Attention:
  The method should never used directly by users

Parameters:

  name | name/title
  tuple | the underlying ntuple implementation
  clid | unique classID for ntuple

Returns:
  pointer to newly created TupleObj

Definition at line 343 of file GaudiTuples.icpp.

    {
      return Tuples::createTupleObj
        ( this , "Tuple '" + name  + "'" , tuple , clid , Tuples::NTUPLE ) ;
    }

template<class PBASE >

Tuples::Tuple GaudiTuples< PBASE >::evtCol | ( | const TupleID & | ID,
|  | const std::string & | title,
|  | const CLID & | clid = `CLID_ColumnWiseTuple`
| ) |  | const

Access an Event Tag Collection object (book on-demand) with forced identifier.

      // Book Ntuple with a numeric ID
      Tuple tuple = evtCol(  1,  "My Tag Collection" ) ;
      // ... or
      Tuple tuple = evtCol( "1", "My Tag Collection" ) ;

      // ... or, Book Ntuple with a literal ID
      Tuple tuple = evtCol( "mytuple", "My Tag Collection" ) ;

      // ... or, Book Ntuple with a literal ID in a sub-dir
      Tuple tuple = evtCol( "subdir/mytuple", "My Tag Collection" ) ;

      // Fill and write
      tuple->column( "A" , sin(0.1) );
      tuple->column( "B" , cos(0.1) );
      tuple->column( "C" , tan(0.1) );
      tuple->write();

Attention:
  If the Event Tag Collection with given ID is already booked through automatic assignment of Event Tag Collection ID, the error will not be detected. Therefore it is recommended to use a non-trivial Event Tag Collection ID offset (property "EvtColOffSet") if one need to combine these techniques together It is still desirable to use the unique Event Tag Collection title to avoid a bad interference.

Parameters:

  ID | The forced Event Tag Collection ID
  title | Unique title for Event Tag Collection
  clid | N-Tuple class identifier (row or column wise)

Returns:
  ntuple The Event Tag Collection object

Reimplemented in TupleTool.

Definition at line 281 of file GaudiTuples.icpp.

    {
      // Check ID
      if ( ID.undefined() )
      { this->Error("Undefined NTuple ID : Title='"+title1+"'"); return Tuple(0); }

      // look up in the table
      Tuples::TupleObj* tuple = m_evtColMapID[ID] ;
      if ( 0 != tuple ) { return Tuple( tuple ) ; }                   // RETURN

      // convert ID to the string
      const std::string tID = ID.idAsString() ;

      // adjust the NTuple title
      const std::string title = title1.empty() ? ( "EvtCol #" + tID ) : title1 ;

      // book new ntuple
      if( produceEvtCols() )
      {
        // book NTuple
        NTuple::Tuple* tup = 0;
        if (  ID.numeric() )
        {
          tup = this->evtColSvc()->book ( evtColPath() , ID.numericID() , clid , title ) ;
        }
        else if ( ID.literal() )
        {
          tup = this->evtColSvc()->book ( evtColPath() , ID.literalID() , clid , title ) ;
        }
        else { this->Error( "Undefined NTuple ID" ); }

        // assertion
        this->Assert( 0 != tup , "Could not book the EvtCol='" + title + "'" ) ;
        // some printout
        if( 0 != tup -> registry() && this->msgLevel(MSG::DEBUG) )
        { this->debug() << "Booked EvtCol '" << title << "' ID=" << tID
                        << "' Path='" << evtColPath() << "' TS='"
                        << tup -> registry() -> identifier() << "'" << endmsg ; }

        tuple = createEvtCol ( title , tup                , clid ) ;
      }
      else
      {
        tuple = createEvtCol ( title , (NTuple::Tuple*) 0 , clid ) ;
      }
      // increment the reference
      tuple -> addRef();
      //
      m_evtColMapID [ ID ] = tuple ;
      //
      tuple -> addRef();
      m_evtColMapTitle[ title ] = tuple ;
      // return
      return Tuple( tuple ) ;
    }

template<class PBASE >

Tuples::Tuple GaudiTuples< PBASE >::evtCol | ( | const std::string & | title,
|  | const CLID & | clid = `CLID_ColumnWiseTuple`
| ) |  | const

Access an Event Tag Collection object (book on-demand) with unique identifier.

      Tuple tuple = evtCol( "My Tag Collection" ) ;
      tuple->column( "A" , sin(0.1) );
      tuple->column( "B" , cos(0.1) );
      tuple->column( "C" , tan(0.1) );
      tuple->write();

The Event Tag Collection will get a unique identifier automatically assigned which by default will be equal to the histogram title. An option exists to instead use numerical IDs. In this case the first Event Tag Collection booked will be ID=1 the next ID=2 and so on. Note though this scheme is not recommended as it does NOT guarantee predictability of the ID a given Event Tag Collection will be given when filled under conditional statements, since in these circumstances the order in which the Event Tag Collection are first filled, and thus booked, will depend on the nature of the first few events read. This is particularly problematic when users submit many parallel 'sub-jobs' and then attempt to merge the final output ROOT (or HBOOK) files, since a given Event Tag Collection could have different IDs in each of the sub-jobs. Consequently it is strongly recommended that users do not use numerical automatic IDs unless they are sure they understand what they are doing.

Parameters:

  title | Unique title for Event Tag Collection
  clid | N-Tuple class identifier (row or column wise)

Returns:
  ntuple The Event Tag Collection object

Reimplemented in TupleTool.

Definition at line 182 of file GaudiTuples.icpp.

    {
      // look up in the table
      Tuples::TupleObj* tuple = m_evtColMapTitle[ title ]  ;
      if ( 0 != tuple ) { return Tuple( tuple ) ; }                   // RETURN
      // Create the tuple ID
      TupleID ID;
      if ( this->useNumericAutoIDs() || title.empty() )
      {
        if ( ! this->useNumericAutoIDs() )
        {
          this -> Warning( "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for evtCol ID",
                           StatusCode::SUCCESS );
        }
        // proposed the tuple ID
        ID = TupleID ( m_evtColMapID.size() + 1 + evtColOffSet() ) ;
        // adjust the proposed ID
        while ( nTupleExists(ID) || evtColExists(ID) )
        { ID = TupleID ( ID.numeric() + 1 ) ; }
      }
      else
      {
        // use the title to create a unique literal ID
        ID = TupleID( this->convertTitleToID(title) );
        // Just in case ...
        while ( nTupleExists(ID) || evtColExists(ID) )
        { ID = TupleID ( ID.idAsString()+"_" ) ; }
      }
      // return
      return evtCol( ID , title , clid ) ;
    }

template<class PBASE>

const std::string& GaudiTuples< PBASE >::evtColDir | ( | ) | const`[inline]`

get the Event Tag Collection directory (property "EvtColsDir")

Definition at line 234 of file GaudiTuples.h.

    { return m_evtColDir      ; }

template<class PBASE >

bool GaudiTuples< PBASE >::evtColExists | ( | const TupleID & | ID ) | const

check the existence AND validity of the Event Tag Collection with the given ID

Definition at line 433 of file GaudiTuples.icpp.

    { return m_evtColMapID.end() != m_evtColMapID.find ( ID ) ; }

template<class PBASE>

const std::string& GaudiTuples< PBASE >::evtColLUN | ( | ) | const`[inline]`

get the logical unit for Event Tag Collections (property "EvtColsLUN")

Definition at line 230 of file GaudiTuples.h.

    { return m_evtColLUN      ; }

template<class PBASE>

const TupleMapID& GaudiTuples< PBASE >::evtColMapID | ( | ) | const`[inline, protected]`

access to the all evet tag collections by numeric ID

Definition at line 275 of file GaudiTuples.h.

    { return m_evtColMapID    ; }

template<class PBASE>

const TupleMapTitle& GaudiTuples< PBASE >::evtColMapTitle | ( | ) | const`[inline, protected]`

access to the all evet tag collections by title

Definition at line 271 of file GaudiTuples.h.

    { return m_evtColMapTitle ; }

template<class PBASE>

TupleID::NumericID GaudiTuples< PBASE >::evtColOffSet | ( | ) | const`[inline]`

get the value for Event Tag Collection offset (property "EvtColsOffSet")

Definition at line 236 of file GaudiTuples.h.

    { return m_evtColOffSet   ; }

template<class PBASE>

std::string GaudiTuples< PBASE >::evtColPath | ( | ) | const`[inline]`

get the constructed Event Tag Collection path

Definition at line 238 of file GaudiTuples.h.

      {
        std::string path = evtColLUN() + "/" + evtColTopDir() + evtColDir();
        return ( splitEvtColDir() ? dirHbookName( path ) : path );
      }

template<class PBASE>

bool GaudiTuples< PBASE >::evtColsPrint | ( | ) | const`[inline]`

print event collections at finalization

Definition at line 246 of file GaudiTuples.h.

    { return m_evtColsPrint ; }

template<class PBASE>

const std::string& GaudiTuples< PBASE >::evtColTopDir | ( | ) | const`[inline]`

get the top-level Event Tag Collection directory (property "EvtColsTopDir")

Definition at line 232 of file GaudiTuples.h.

    { return m_evtColTopDir   ; }

template<class PBASE >

StatusCode GaudiTuples< PBASE >::finalize | ( | void | ) | `[protected, virtual]`

standard finalization method

Returns:
  status code

Reimplemented in GaudiTupleAlg, and GaudiTupleTool.

Definition at line 92 of file GaudiTuples.icpp.

    {
      if ( !( nTupleMapTitle () . empty () &&
              nTupleMapID    () . empty () &&
              evtColMapTitle () . empty () &&
              evtColMapID    () . empty ()
              ) )
      {
        const int nNtuples = nTupleMapID () . size () ;
        const int nEvtCols = evtColMapID () . size ();
        this->always()
          << "Booked " << nNtuples << " N-Tuples and " << nEvtCols
          << " Event Tag Collections" << endmsg ;
      }

      if ( produceNTuples () && tuplesPrint  () ) { printTuples  () ; }
      if ( produceEvtCols () && evtColsPrint () ) { printEvtCols () ; }

      { // release ntuples and clear the container
        for( TupleMapTitle::iterator itup = m_nTupleMapTitle.begin() ;
             m_nTupleMapTitle.end() != itup ; ++itup )
        { if( 0 != itup->second ) { itup->second->release() ; } }
        m_nTupleMapTitle.clear() ;
      }
      { // release ntuples and clear the container
        for( TupleMapID::iterator itup = m_nTupleMapID.begin() ;
             m_nTupleMapID.end() != itup ; ++itup )
        { if( 0 != itup->second ) { itup->second->release() ; } }
        m_nTupleMapID.clear();
      }
      { // release ntuples and clear the container
        for( TupleMapTitle::iterator itup = m_evtColMapTitle.begin() ;
             m_evtColMapTitle.end() != itup ; ++itup )
        { if( 0 != itup->second ) { itup->second->release() ; } }
        m_evtColMapTitle.clear();
      }
      { // release ntuples and clear the container
        for( TupleMapID::iterator itup = m_evtColMapID.begin() ;
             m_evtColMapID.end() != itup ; ++itup )
        { if( 0 != itup->second ) { itup->second->release() ; } }
        m_evtColMapID.clear() ;
      }
      // finalize base class
      return PBASE::finalize();
    }

template<class PBASE>

void GaudiTuples< PBASE >::initGaudiTuplesConstructor | ( | ) | `[inline, private]`

Constructor initialization and job options.

Definition at line 338 of file GaudiTuples.h.

      {
        m_produceNTuples = true ;     // Switch ON/OFF ntuple production
        m_splitNTupleDir = false ;    // for HBOOK it is better to use 'true'
        m_nTupleLUN      = "FILE1" ;  // logical unit for ntuples
        m_nTupleTopDir   = "" ;       // top level ntuple directory
        m_nTupleDir      = this->name() ;   // ntuple directory
        m_nTupleOffSet   = 0  ;       // offset for ntuples
        //
        m_produceEvtCols = false ;    // Switch ON/OFF ntupel production
        m_splitEvtColDir = false ;    // for HBOOK it is better to use 'true'
        m_evtColLUN      = "EVTCOL" ; // logical unit for ntuples
        m_evtColTopDir   = ""    ;    // top level ntuple directory
        m_evtColDir      = this->name() ;   // ntuple directory
        m_evtColOffSet   = 0   ;      // offset for ntuples
        //
        m_tuplesPrint    = true  ;    // print tuples at end of job
        m_evtColsPrint   = false  ;   // print event collections at end of job
        //
        this -> declareProperty
          ( "NTupleProduce"  , m_produceNTuples         ,
            "General switch to enable/disable N-tuples" ) ;
        this -> declareProperty
          ( "NTuplePrint"    , m_tuplesPrint    ,
            "Print N-tuple statistics"        )
          -> declareUpdateHandler ( &GaudiTuples<PBASE>::printNTupleHandler , this ) ;
        this -> declareProperty
          ( "NTupleSplitDir" , m_splitNTupleDir ,
            "Split long directory names into short pieces (suitable for HBOOK)" ) ;
        this -> declareProperty
          ( "NTupleOffSet"   , m_nTupleOffSet   ,
            "Offset for numerical N-tuple ID" ) ;
        this -> declareProperty
          ( "NTupleLUN"      , m_nTupleLUN      ,
            "Logical File Unit for N-tuples"  ) ;
        this -> declareProperty
          ( "NTupleTopDir"   , m_nTupleTopDir   ,
            "Top-level directory for N-Tuples") ;
        this -> declareProperty
          ( "NTupleDir"      , m_nTupleDir      ,
            "Subdirectory for N-Tuples"       ) ;
        // ========================================================================
        this -> declareProperty
          ( "EvtColsProduce" , m_produceEvtCols ,
            "General switch to enable/disable Event Tag Collections" ) ;
        this -> declareProperty
          ( "EvtColsPrint"   , m_evtColsPrint   ,
            "Print statistics for Event Tag Collections " )
          -> declareUpdateHandler ( &GaudiTuples<PBASE>::printEvtColHandler , this ) ;
        this -> declareProperty
          ( "EvtColSplitDir" , m_splitEvtColDir ,
            "Split long directory names into short pieces" ) ;
        this -> declareProperty
          ( "EvtColOffSet"   , m_evtColOffSet   ,
            "Offset for numerical N-tuple ID" ) ;
        this -> declareProperty
          ( "EvtColLUN"      , m_evtColLUN      ,
            "Logical File Unit for Event Tag Collections"   ) ;
        this -> declareProperty
          ( "EvtColTopDir"   , m_evtColTopDir   ,
            "Top-level directory for Event Tag Collections" ) ;
        this -> declareProperty
          ( "EvtColDir"      , m_evtColDir      ,
            "Subdirectory for Event Tag Collections"        ) ;
        // ========================================================================
      }

template<class PBASE >

StatusCode GaudiTuples< PBASE >::initialize | ( | ) | `[protected, virtual]`

standard initialization method

Returns:
  status code

Reimplemented in GaudiTupleAlg, and GaudiTupleTool.

Definition at line 49 of file GaudiTuples.icpp.

    {
      // initialize base class
      const StatusCode sc = PBASE::initialize();
      if ( sc.isFailure() ) return sc;

      if ( produceNTuples() )
      {
        // check the existance of service
        if ( this->ntupleSvc() == 0 )
        { return  this->Error( "INTupleSvc* points to NULL!" ); }
        // Print ntuple path
        this->Print( "The N-Tuple   path is set to be '" + nTuplePath() + "'",
                     StatusCode(StatusCode::SUCCESS, true) , MSG::DEBUG);
      }
      else
      { this->debug() << "Production of N-Tuples is switched OFF" << endmsg; }

      if ( produceEvtCols() )
      {
        // check the existance of service
        if ( 0 == this->evtColSvc() )
        { return  this->Error( "INTupleSvc* points to NULL!" ); }
        // Print EvtCol path
        this->Print( "The EventCol  path is set to be '" + evtColPath() + "'",
                     StatusCode(StatusCode::SUCCESS, true) , MSG::DEBUG );
      }
      else
      { this->debug() << "Production of Event Collections is switched OFF" << endmsg; }

      return sc;
    }

template<class PBASE >

Tuples::Tuple GaudiTuples< PBASE >::nTuple | ( | const TupleID & | ID,
|  | const std::string & | title,
|  | const CLID & | clid = `CLID_ColumnWiseTuple`
| ) |  | const

Access an N-Tuple object (book on-demand) with forced identifier.

      // Book Ntuple with a numeric ID
      Tuple tuple = nTuple(  1,  "My tuple" ) ;
      // ... or
      Tuple tuple = nTuple( "1", "My tuple" ) ;

      // ... or, Book Ntuple with a literal ID
      Tuple tuple = nTuple( "mytuple", "My tuple" ) ;

      // ... or, Book Ntuple with a literal ID in a sub-dir
      Tuple tuple = nTuple( "subdir/mytuple", "My tuple" ) ;

      // Fill and write NTuple
      tuple->column( "A" , sin(0.1) );
      tuple->column( "B" , cos(0.1) );
      tuple->column( "C" , tan(0.1) );
      tuple->write();

Attention:
  If the N-Tuple with given ID is already booked through automatic assignment of N-Tuple ID, the error will not be detected. Therefore it is recommended to use a non-trivial N-Tuple ID offset (property "NTupleOffSet") if one need to combine these techniques together It is still desirable to use the unique N-Tuple title to avoid a bad interference.

Parameters:

  ID | The forced N-Tuple ID
  title | Unique title for N-Tuple
  clid | N-Tuple class identifier (row or column wise)

Returns:
  ntuple The ntuple object

Reimplemented in TupleTool.

Definition at line 221 of file GaudiTuples.icpp.

    {
      // Check ID
      if ( ID.undefined() )
      { this->Error("Undefined NTuple ID : Title='"+title1+"'"); return Tuple(0); }

      // look up in the table
      Tuples::TupleObj * tuple = m_nTupleMapID[ ID ] ;
      if( 0 != tuple ) { return Tuple( tuple ) ; }                   // RETURN

      // convert ID to the string
      const std::string tID = ID.idAsString() ;

      // adjust the NTuple title
      const std::string title = title1.empty() ? ( "NTuple #" + tID ) : title1 ;

      // book new ntuple
      if( produceNTuples() )
      {
        // book NTupel
        NTuple::Tuple * tup = 0;
        if ( ID.numeric() )
        {
          tup = this->ntupleSvc() -> book ( nTuplePath() , ID.numericID() , clid , title );
        }
        else if ( ID.literal() )
        {
          tup = this->ntupleSvc() -> book ( nTuplePath() , ID.literalID() , clid , title );
        }
        else { this->Error( "Undefined NTuple ID" ); }

        // assertion
        this->Assert( 0 != tup , "Could not book the N-Tuple='" + title + "'" ) ;
        // some printout
        if( 0 != tup -> registry() && this->msgLevel(MSG::DEBUG) )
        { this->debug() << "Booked NTuple '" << title << "' ID=" << tID
                        << "' Path='"  << nTuplePath() << "' TS='"
                        << tup -> registry() -> identifier() << "'" << endmsg; }

        tuple = createNTuple ( title , tup                , clid ) ;
      }
      else
      {
        tuple = createNTuple ( title , (NTuple::Tuple*) 0 , clid ) ;
      }
      // increment the reference
      tuple -> addRef();
      //
      m_nTupleMapID [ ID ] = tuple ;
      //
      tuple -> addRef();
      m_nTupleMapTitle[ title ] = tuple ;
      // return
      return Tuple( tuple ) ;
    }

template<class PBASE >

Tuples::Tuple GaudiTuples< PBASE >::nTuple | ( | const std::string & | title,
|  | const CLID & | clid = `CLID_ColumnWiseTuple`
| ) |  | const

Access an N-Tuple object (book on-demand) with unique identifier.

      Tuple tuple = nTuple( "My N-Tuple" ) ;
      tuple->column( "A" , sin(0.1) );
      tuple->column( "B" , cos(0.1) );
      tuple->column( "C" , tan(0.1) );
      tuple->write();

Attention:
  The NTuple will get a unique identifier automatically assigned which by default will be equal to the histogram title. An option exists to instead use numerical IDs. In this case the first NTuple booked will be ID=1 the next ID=2 and so on. Note though this scheme is not recommended as it does NOT guarantee predictability of the ID a given NTuple will be given when filled under conditional statements, since in these circumstances the order in which the NTuple are first filled, and thus booked, will depend on the nature of the first few events read. This is particularly problematic when users submit many parallel 'sub-jobs' and then attempt to merge the final output ROOT (or HBOOK) files, since a given NTuple could have different IDs in each of the sub-jobs. Consequently it is strongly recommended that users do not use numerical automatic IDs unless they are sure they understand what they are doing.

Parameters:

  title | Unique title for N-Tuple
  clid | N-Tuple class identifier (row or column wise)

Returns:
  ntuple The ntuple object

Reimplemented in TupleTool.

Definition at line 143 of file GaudiTuples.icpp.

    {
      // look up in the table
      Tuples::TupleObj* tuple = m_nTupleMapTitle[ title ]  ;
      if ( 0 != tuple ) { return Tuple( tuple ) ; }                  // RETURN
      // Create the tuple ID
      TupleID ID;
      if ( this->useNumericAutoIDs() || title.empty() )
      {
        if ( ! this->useNumericAutoIDs() )
        {
          this -> Warning( "Cannot generate automatic literal ID from an empty title ! Using numeric ID instead for nTuple ID",
                           StatusCode::SUCCESS );
        }
        // propose the tuple ID
        ID = TupleID ( m_nTupleMapID.size() + 1 + nTupleOffSet() );
        // adjust the proposed ID
        while ( nTupleExists(ID) || evtColExists(ID) )
        { ID = TupleID ( ID.numeric() + 1 ) ; }
      }
      else
      {
        // use the title to create a unique literal ID
        ID = TupleID( this->convertTitleToID(title) );
        // Just in case ...
        while ( nTupleExists(ID) || evtColExists(ID) )
        { ID = TupleID(ID.idAsString()+"_"); }
      }
      // return
      return nTuple( ID , title , clid ) ;
    }

template<class PBASE>

const std::string& GaudiTuples< PBASE >::nTupleDir | ( | ) | const`[inline]`

get the N-Tuple directory (property "NTupleDir")

Definition at line 216 of file GaudiTuples.h.

    { return m_nTupleDir      ; }

template<class PBASE >

bool GaudiTuples< PBASE >::nTupleExists | ( | const TupleID & | ID ) | const

check the existence AND validity of the N-Tuple with the given ID

Definition at line 427 of file GaudiTuples.icpp.

    { return m_nTupleMapID.end() != m_nTupleMapID.find ( ID ) ; }

template<class PBASE>

const std::string& GaudiTuples< PBASE >::nTupleLUN | ( | ) | const`[inline]`

get the logical unit for N-Tuples (property "NTupleLUN")

Definition at line 212 of file GaudiTuples.h.

    { return m_nTupleLUN      ; }

template<class PBASE>

const TupleMapID& GaudiTuples< PBASE >::nTupleMapID | ( | ) | const`[inline, protected]`

access to the all ntuples by numeric ID

Definition at line 273 of file GaudiTuples.h.

    { return m_nTupleMapID    ; }

template<class PBASE>

const TupleMapTitle& GaudiTuples< PBASE >::nTupleMapTitle | ( | ) | const`[inline, protected]`

access to the all ntuples by title

Definition at line 269 of file GaudiTuples.h.

    { return m_nTupleMapTitle ; }

template<class PBASE>

TupleID::NumericID GaudiTuples< PBASE >::nTupleOffSet | ( | ) | const`[inline]`

get the value for N-Tuple offset (property "NTupleOffSet")

Definition at line 218 of file GaudiTuples.h.

    { return m_nTupleOffSet   ; }

template<class PBASE>

std::string GaudiTuples< PBASE >::nTuplePath | ( | ) | const`[inline]`

get the constructed N-Tuple path

Definition at line 220 of file GaudiTuples.h.

      {
        const std::string path = nTupleLUN() + "/" + nTupleTopDir() + nTupleDir();
        return ( splitNTupleDir() ? dirHbookName( path ) : path ) ;
      }

template<class PBASE>

const std::string& GaudiTuples< PBASE >::nTupleTopDir | ( | ) | const`[inline]`

get the top-level N-Tuple directory (property "NTupleTopDir")

Definition at line 214 of file GaudiTuples.h.

    { return m_nTupleTopDir   ; }

template<class PBASE >

void GaudiTuples< PBASE >::printEvtColHandler | ( | Property & | ) | `[private]`

handler for "EvtColsPrint" property

Definition at line 449 of file GaudiTuples.icpp.

    {
      // no action if not yet initialized
      if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
      if ( this -> evtColsPrint() ) { this -> printEvtCols () ; }
    }

template<class PBASE >

long GaudiTuples< PBASE >::printEvtCols | ( | ) | const

perform the actual printout of Event Tag Collections

Returns:
  number of active Event Tag Collections

Definition at line 397 of file GaudiTuples.icpp.

    {
      if ( evtColMapTitle().empty() && evtColMapID().empty() )
      { this->always() << "No Event Tag Collections are booked" << endmsg ; }
      else
      { this->always() << "List of booked Event Tag Collections in directory "
                       << "\"" << evtColPath() << "\"" << endmsg ; }

      // helper container to sort it:
      typedef std::map<TupleID,const Tuples::TupleObj*> OrderedMapType;
      OrderedMapType OrderedMap ( evtColMapID().begin() , evtColMapID().end() ) ;
      //
      for ( OrderedMapType::const_iterator entry = OrderedMap.begin() ;
            OrderedMap.end() != entry ; ++entry )
      {
        if ( 0 == entry->second ) { continue ; }
        const NTuple::Tuple* tuple = entry->second->tuple() ;
        if ( 0 == tuple )
        { this->error() << " NTuple::Tuple* points to NULL" << endmsg ; continue ; }
        this->always() << GaudiAlg::PrintTuple::print ( tuple , entry->first )
                       << " Items:"
                       << Gaudi::Utils::toString ( entry->second->items() ) << endmsg ;
      }
      //
      return this->evtColMapID().size() ;
    }

template<class PBASE >

void GaudiTuples< PBASE >::printNTupleHandler | ( | Property & | ) | `[private]`

handler for "NTuplePrint" property

Definition at line 439 of file GaudiTuples.icpp.

    {
      // no action if not yet initialized
      if ( this -> FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
      if ( this -> tuplesPrint() ) { this -> printTuples () ; }
    }

template<class PBASE >

long GaudiTuples< PBASE >::printTuples | ( | ) | const

perform the actual printout of N-tuples

Returns:
  number of active N-Tuples

Definition at line 368 of file GaudiTuples.icpp.

    {

      if ( nTupleMapTitle().empty() && nTupleMapID().empty() )
      { if (this->msgLevel(MSG::DEBUG)) this->debug() << "No N-Tuples   are booked" << endmsg ; }
      else
      { this->always() << "List of booked N-Tuples in directory "
                       << "\"" << nTuplePath() << "\"" << endmsg ; }

      // helper container to sort it:
      typedef std::map<TupleID,const Tuples::TupleObj*> OrderedMapType;
      OrderedMapType OrderedMap ( nTupleMapID().begin() , nTupleMapID().end() ) ;
      //
      for ( OrderedMapType::const_iterator entry = OrderedMap.begin() ;
            OrderedMap.end() != entry ; ++entry )
      {
        if ( 0 == entry->second ) { continue ; }
        const NTuple::Tuple* tuple = entry->second->tuple() ;
        if ( 0 == tuple )
        { this->error() << " NTuple::Tuple* points to NULL" << endmsg ; continue ; }
        this->always() << GaudiAlg::PrintTuple::print ( tuple , entry->first ) << endmsg ;
      }
      //
      return this->nTupleMapID().size() ;
    }

template<class PBASE>

bool GaudiTuples< PBASE >::produceEvtCols | ( | ) | const`[inline]`

get the flag for Event Tag Collection production (property "EvtColsProduce")

Definition at line 226 of file GaudiTuples.h.

    { return m_produceEvtCols ; }

template<class PBASE>

bool GaudiTuples< PBASE >::produceNTuples | ( | ) | const`[inline]`

get the flag for N-Tuple production (property "NTupleProduce")

Definition at line 208 of file GaudiTuples.h.

    { return m_produceNTuples ; }

template<class PBASE>

bool GaudiTuples< PBASE >::splitEvtColDir | ( | ) | const`[inline]`

get the flag for Event Tag Collection path split (property "EvtColsSplitDir")

Definition at line 228 of file GaudiTuples.h.

    { return m_splitEvtColDir ; }

template<class PBASE>

bool GaudiTuples< PBASE >::splitNTupleDir | ( | ) | const`[inline]`

get the flag for N-Tuple path split (property "NTupleSplitDir")

Definition at line 210 of file GaudiTuples.h.

    { return m_splitNTupleDir ; }

template<class PBASE>

bool GaudiTuples< PBASE >::tuplesPrint | ( | ) | const`[inline]`

print tuples at finalization

Definition at line 244 of file GaudiTuples.h.

    { return m_tuplesPrint  ; }

## Member Data Documentation

template<class PBASE>

std::string GaudiTuples< PBASE >::m_evtColDir`[private]`

local tuple directory

Definition at line 436 of file GaudiTuples.h.

template<class PBASE>

std::string GaudiTuples< PBASE >::m_evtColLUN`[private]`

name of Logical Unit for tuple directory

Definition at line 432 of file GaudiTuples.h.

template<class PBASE>

TupleMapID GaudiTuples< PBASE >::m_evtColMapID`[mutable, private]`

the actual storage of event collections by ID

Definition at line 453 of file GaudiTuples.h.

template<class PBASE>

TupleMapTitle GaudiTuples< PBASE >::m_evtColMapTitle`[mutable, private]`

the actual storage of event collections by title

Definition at line 451 of file GaudiTuples.h.

template<class PBASE>

TupleID::NumericID GaudiTuples< PBASE >::m_evtColOffSet`[private]`

the offset for ntuple numerical ID

Definition at line 438 of file GaudiTuples.h.

template<class PBASE>

bool GaudiTuples< PBASE >::m_evtColsPrint`[private]`

print event collections at finalization

Definition at line 443 of file GaudiTuples.h.

template<class PBASE>

std::string GaudiTuples< PBASE >::m_evtColTopDir`[private]`

top level tuple directory

Definition at line 434 of file GaudiTuples.h.

template<class PBASE>

std::string GaudiTuples< PBASE >::m_nTupleDir`[private]`

local tuple directory

Definition at line 423 of file GaudiTuples.h.

template<class PBASE>

std::string GaudiTuples< PBASE >::m_nTupleLUN`[private]`

name of logical unit for tuple directory

Definition at line 419 of file GaudiTuples.h.

template<class PBASE>

TupleMapID GaudiTuples< PBASE >::m_nTupleMapID`[mutable, private]`

the actual storage of ntuples by ID

Definition at line 448 of file GaudiTuples.h.

template<class PBASE>

TupleMapTitle GaudiTuples< PBASE >::m_nTupleMapTitle`[mutable, private]`

the actual storage of ntuples by title

Definition at line 446 of file GaudiTuples.h.

template<class PBASE>

TupleID::NumericID GaudiTuples< PBASE >::m_nTupleOffSet`[private]`

the offset for ntuple numerical ID

Definition at line 425 of file GaudiTuples.h.

template<class PBASE>

std::string GaudiTuples< PBASE >::m_nTupleTopDir`[private]`

top level tuple directory

Definition at line 421 of file GaudiTuples.h.

template<class PBASE>

bool GaudiTuples< PBASE >::m_produceEvtCols`[private]`

flag to switch ON/OFF the ntuple filling and booking

Definition at line 428 of file GaudiTuples.h.

template<class PBASE>

bool GaudiTuples< PBASE >::m_produceNTuples`[private]`

flag to switch ON/OFF the ntuple filling and booking

Definition at line 415 of file GaudiTuples.h.

template<class PBASE>

bool GaudiTuples< PBASE >::m_splitEvtColDir`[private]`

flag to indicate splitting of tuple directories (useful for HBOOK)

Definition at line 430 of file GaudiTuples.h.

template<class PBASE>

bool GaudiTuples< PBASE >::m_splitNTupleDir`[private]`

flag to indicate splitting of tuple directories (useful for HBOOK)

Definition at line 417 of file GaudiTuples.h.

template<class PBASE>

bool GaudiTuples< PBASE >::m_tuplesPrint`[private]`

print tuples at finalization?

Definition at line 441 of file GaudiTuples.h.

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

- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiAlg/GaudiAlg/GaudiTuples.h
- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiAlg/GaudiAlg/GaudiTuples.icpp

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