| # Gaudi Framework, version v21r10p1 |

Home |  | Generated: 29 Jul 2010

# NTupleSvc Class Reference

NTuple service. More...

`#include <NTupleSvc.h>`

Inheritance diagram for NTupleSvc:

[legend]
Collaboration diagram for NTupleSvc:

[legend]

List of all members.

## Public Member Functions
virtual StatusCode | initialize ()
| DataSvc overrides: Initialize the service.
virtual StatusCode | reinitialize ()
| DataSvc overrides: reinitialize service.
virtual StatusCode | finalize ()
| DataSvc overrides: stop the service.
virtual IConversionSvc * | getDataLoader (IRegistry *pReg)
| DataSvc overrides: Retrieve data loader.
virtual NTuple::Directory * | createDirectory (DataObject *pParent, const std::string &title)
| Create Ntuple directory and register it with the data store.
virtual NTuple::Directory * | createDirectory (DataObject *pParent, long id)
| Create Ntuple directory and register it with the data store.
virtual NTuple::Directory * | createDirectory (const std::string &dirPath, long id)
| Create Ntuple directory and register it with the data store.
virtual NTuple::Directory * | createDirectory (const std::string &dirPath, const std::string &title)
| Create Ntuple directory and register it with the data store.
virtual NTuple::Directory * | createDirectory (const std::string &fullPath)
| Create Ntuple directory and register it with the data store.
virtual StatusCode | create (const CLID &typ, const std::string &title, NTuple::Tuple *&refpTuple)
| Create requested N tuple (Hide constructor).
virtual NTuple::Tuple * | book (const std::string &fullPath, const CLID &type, const std::string &title)
| Book Ntuple and register it with the data store.
virtual NTuple::Tuple * | book (const std::string &dirPath, const std::string &relPath, const CLID &type, const std::string &title)
| Book Ntuple and register it with the data store.
virtual NTuple::Tuple * | book (const std::string &dirPath, long id, const CLID &type, const std::string &title)
| Book Ntuple and register it with the data store.
virtual NTuple::Tuple * | book (DataObject *pParent, const std::string &relPath, const CLID &type, const std::string &title)
| Book Ntuple and register it with the data store.
virtual NTuple::Tuple * | book (DataObject *pParent, long id, const CLID &type, const std::string &title)
| Book Ntuple and register it with the data store.
virtual NTuple::Tuple * | access (const std::string &fullPath, const std::string &filename)
| Access N tuple on disk.
virtual StatusCode | save (const std::string &fullPath)
| Save N tuple to disk. Must be called in order to close the ntuple file properly.
virtual StatusCode | save (NTuple::Tuple *tuple)
| Save N tuple to disk. Must be called in order to close the ntuple file properly.
virtual StatusCode | save (DataObject *pParent, const std::string &relPath)
| Save N tuple to disk. Must be called in order to close the ntuple file properly.
virtual StatusCode | writeRecord (NTuple::Tuple *tuple)
| Write single record to N tuple.
virtual StatusCode | writeRecord (const std::string &fullPath)
| Write single record to N tuple.
virtual StatusCode | writeRecord (DataObject *pParent, const std::string &relPath)
| Write single record to N tuple.
virtual StatusCode | readRecord (NTuple::Tuple *tuple)
| Read single record from N tuple.
virtual StatusCode | readRecord (const std::string &fullPath)
| Read single record from N tuple.
virtual StatusCode | readRecord (DataObject *pParent, const std::string &relPath)
| Read single record from N tuple.
virtual bool | isConnected (const std::string &identifier) const
| Check if a datasource is connected.
virtual StatusCode | connect (const std::string &ident)
| Add file to list I/O list.
virtual StatusCode | connect (const std::string &ident, std::string &logname)
| Add file to list I/O list.
virtual StatusCode | disconnect (const std::string &nam)
| Close open connection.
virtual StatusCode | disconnectAll ()
| Close all open connections.
| NTupleSvc (const std::string &name, ISvcLocator *svc)
| Standard Constructor.
virtual | ~NTupleSvc ()
| Standard Destructor.
## Protected Types
typedef std::vector< std::string > | DBaseEntries
typedef std::map< std::string, Connection > | Connections
typedef std::pair< std::string, std::string > | Prop
## Protected Member Functions
StatusCode | createService (const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc)
| Create conversion service.
void | releaseConnection (Connection &c)
| Finalize single service.
StatusCode | attachTuple (const std::string &filename, const std::string &logname, const char typ, const long t)
| Attach output/input file.
StatusCode | updateDirectories ()
| Update directory data.
## Protected Attributes
DBaseEntries | m_output
| Output streams.
DBaseEntries | m_input
| Input streams.
Connections | m_connections
| Container of connection points.
## Friends
class | SvcFactory< NTupleSvc >
## Classes
struct | Connection

## Detailed Description

NTuple service.

See the Interface definition files for more detailed documentation of the implementing class. Base class: Gaudi/DataSvc/DataSvc.h Generic N tuple service interface: Gaudi/Interfaces/INTupleSvc.h Generic IAddressCreator interface: Gaudi/Interfaces/IAddressCreator.h Generic IConversionSvc interface: Gaudi/Interfaces/IConversionSvc.h

Author:
  M.Frank

Definition at line 27 of file NTupleSvc.h.

## Member Typedef Documentation

typedef std::vector< std::string > NTupleSvc::DBaseEntries`[protected]`

Definition at line 37 of file NTupleSvc.h.

typedef std::map<std::string, Connection> NTupleSvc::Connections`[protected]`

Definition at line 38 of file NTupleSvc.h.

typedef std::pair<std::string,std::string> NTupleSvc::Prop`[protected]`

Definition at line 39 of file NTupleSvc.h.

## Constructor & Destructor Documentation

NTupleSvc::NTupleSvc | ( | const std::string & | name,
|  | ISvcLocator * | svc |
| ) |  |  |

Standard Constructor.

Selector factory instantiation.

Standard Constructor

Definition at line 54 of file NTupleSvc.cpp.

    00055  : base_class(name, svc)
    00056 {
    00057   declareProperty("Input",  m_input);
    00058   declareProperty("Output", m_output);
    00059   m_rootName = "/NTUPLES";
    00060   m_rootCLID = CLID_DataObject;
    00061 }

NTupleSvc::~NTupleSvc | ( |  | ) | `[virtual]`

Standard Destructor.

Definition at line 64 of file NTupleSvc.cpp.

    00064                         {
    00065 }

## Member Function Documentation

StatusCode NTupleSvc::initialize | ( |  | ) | `[virtual]`

DataSvc overrides: Initialize the service.

Initialize the service.

Reimplemented from DataSvc.

Reimplemented in TagCollectionSvc.

Definition at line 68 of file NTupleSvc.cpp.

    00068                                      {
    00069   StatusCode status = DataSvc::initialize();
    00070   if ( status.isSuccess() )   {
    00071     status = setProperties();
    00072     if ( status.isSuccess() )   {
    00073       StatusCode iret(StatusCode::SUCCESS,true);
    00074       DataObject* root = new NTuple::Directory();
    00075       status = setRoot(m_rootName, root);
    00076       for ( DBaseEntries::iterator i = m_output.begin(); i != m_output.end(); ++i )    {
    00077         iret = connect(*i);
    00078         if ( !iret.isSuccess() )    {
    00079           status = iret;
    00080         }
    00081       }
    00082       for ( DBaseEntries::iterator j = m_input.begin(); j != m_input.end(); ++j )    {
    00083         iret = connect(*j);
    00084         if ( !iret.isSuccess() )    {
    00085           status = iret;
    00086         }
    00087       }
    00088     }
    00089   }
    00090   return status;
    00091 }

StatusCode NTupleSvc::reinitialize | ( |  | ) | `[virtual]`

DataSvc overrides: reinitialize service.

Initialize the service.

Reimplemented from DataSvc.

Definition at line 94 of file NTupleSvc.cpp.

    00094                                    {
    00095   return StatusCode::SUCCESS;
    00096 }

StatusCode NTupleSvc::finalize | ( |  | ) | `[virtual]`

DataSvc overrides: stop the service.

stop the service.

Reimplemented from DataSvc.

Reimplemented in TagCollectionSvc.

Definition at line 209 of file NTupleSvc.cpp.

    00209                                     {
    00210   StatusCode status = updateDirectories();
    00211   status = clearStore();
    00212   status = DataSvc::finalize();
    00213   status = disconnectAll();
    00214   return status;
    00215 }

IConversionSvc * NTupleSvc::getDataLoader | ( | IRegistry * | pReg | ) | `[virtual]`

DataSvc overrides: Retrieve data loader.

DataSvc override: Retrieve data loader.

Reimplemented from DataSvc.

Definition at line 105 of file NTupleSvc.cpp.

    00105                                                                 {
    00106   if ( 0 != pRegistry )    {
    00107     std::string full = pRegistry->identifier();
    00108     size_t len = m_rootName.length();
    00109     size_t idx = full.find(SEPARATOR,len+1);
    00110     std::string path = (idx==std::string::npos) ? full : full.substr(0, idx);
    00111     Connections::iterator i = m_connections.find(path);
    00112     if ( i != m_connections.end() )   {
    00113       return (*i).second.service;
    00114     }
    00115   }
    00116   return 0;
    00117 }

NTuple::Directory * NTupleSvc::createDirectory | ( | DataObject * | pParent,
|  | const std::string & | title |
| ) |  |  | `[virtual]`

Create Ntuple directory and register it with the data store.

Definition at line 456 of file NTupleSvc.cpp.

    00457                                                                            {
    00458   if ( 0 != pParent )   {
    00459     IRegistry* pDir = pParent->registry();
    00460     if ( 0 != pDir )    {
    00461       std::string full = pDir->identifier();
    00462       full += (relPath[0]=='/') ? "" : "/";
    00463       full += relPath;
    00464       return createDirectory(full);
    00465     }
    00466   }
    00467   return 0;
    00468 }

NTuple::Directory * NTupleSvc::createDirectory | ( | DataObject * | pParent,
|  | long | id |
| ) |  |  | `[virtual]`

Create Ntuple directory and register it with the data store.

Definition at line 471 of file NTupleSvc.cpp.

    00471                                                                             {
    00472   char txt[32];
    00473   return createDirectory( pParent, ::_itoa(id, txt,10) );
    00474 }

NTuple::Directory * NTupleSvc::createDirectory | ( | const std::string & | dirPath,
|  | long | id |
| ) |  |  | `[virtual]`

Create Ntuple directory and register it with the data store.

Definition at line 477 of file NTupleSvc.cpp.

    00477                                                                                  {
    00478   char txt[32];
    00479   return createDirectory( dirPath, ::_itoa(id, txt,10) );
    00480 }

NTuple::Directory * NTupleSvc::createDirectory | ( | const std::string & | dirPath,
|  | const std::string & | title |
| ) |  |  | `[virtual]`

Create Ntuple directory and register it with the data store.

Definition at line 483 of file NTupleSvc.cpp.

    00483                                                                                                    {
    00484   std::string full = dirPath;
    00485   full += (relPath[0]=='/') ? "" : "/";
    00486   full += relPath;
    00487   return createDirectory(full);
    00488 }

NTuple::Directory * NTupleSvc::createDirectory | ( | const std::string & | fullPath | ) | `[virtual]`

Create Ntuple directory and register it with the data store.

Definition at line 514 of file NTupleSvc.cpp.

    00514                                                                         {
    00515   NTuple::Directory* p = 0;
    00516   StatusCode status = findObject(fullPath, *pp_cast<DataObject>(&p));
    00517   if ( !status.isSuccess() )   {
    00518     int sep2 = fullPath.rfind(SEPARATOR);
    00519     if ( sep2 > 0 )   {
    00520       std::string relPath = fullPath.substr(0, sep2);
    00521       p = createDirectory(relPath);
    00522       if ( 0 != p )    {
    00523         p = new NTuple::Directory();
    00524         // Finally register the created N tuple with the store
    00525         status = registerObject(fullPath, p);
    00526         if ( status.isSuccess() )    {
    00527           // ...starting from the file entries
    00528           IConversionSvc* svc = getDataLoader(p->registry());
    00529           if ( 0 != svc )   {
    00530             IOpaqueAddress* pAddr = 0;
    00531             status = svc->createRep (p, pAddr);
    00532             if ( status.isSuccess() )   {
    00533               p->registry()->setAddress(pAddr);
    00534               status = svc->fillRepRefs (pAddr, p);
    00535               if ( status.isSuccess() )   {
    00536                 return p;
    00537               }
    00538             }
    00539           }
    00540           unregisterObject(p);
    00541         }
    00542         p->release();
    00543         p = 0;
    00544       }
    00545     }
    00546   }
    00547   try {
    00548     p = dynamic_cast<NTuple::Directory*>(p);
    00549     return p;
    00550   }
    00551   catch (...) {
    00552   }
    00553   return 0;
    00554 }

StatusCode NTupleSvc::create | ( | const CLID & | typ,
|  | const std::string & | title,
|  | NTuple::Tuple *& | refpTuple |
| ) |  |  | `[virtual]`

Create requested N tuple (Hide constructor).

Eventually allow loading through factory?

Definition at line 358 of file NTupleSvc.cpp.

    00358                                                                                                  {
    00359   NTuple::TupleImp* pTuple = 0;
    00360   StatusCode status = StatusCode::FAILURE;
    00361   if ( typ == CLID_ColumnWiseTuple )    {
    00362     pTuple = new NTuple::ColumnWiseTuple( title );
    00363   }
    00364   else if ( typ == CLID_RowWiseTuple )    {
    00365     pTuple = new NTuple::RowWiseTuple( title );
    00366   }
    00367   else    {
    00369   }
    00370   if ( 0 != pTuple )      {
    00371     pTuple->setTupleService(this);
    00372     status = StatusCode::SUCCESS;
    00373   }
    00374   refpTuple = pTuple;
    00375   return status;
    00376 }

NTuple::Tuple * NTupleSvc::book | ( | const std::string & | fullPath,
|  | const CLID & | type,
|  | const std::string & | title |
| ) |  |  | `[virtual]`

Book Ntuple and register it with the data store.

Definition at line 379 of file NTupleSvc.cpp.

    00379                                                                                                   {
    00380   DataObject* pObj = 0;
    00381   std::string path = fullPath;
    00382   MsgStream log(msgSvc(), name());
    00383   if ( path[0] != SEPARATOR )   {
    00384     path = m_rootName;
    00385     path += SEPARATOR;
    00386     path += fullPath;
    00387   }
    00388   StatusCode status = retrieveObject(path, pObj);
    00389   if ( !status.isSuccess() )    {
    00390     int sep = path.rfind(SEPARATOR);
    00391     if ( sep > 0 )    {
    00392       std::string p_path (path, 0, sep);
    00393       std::string o_path (path, sep, path.length());
    00394       DataObject* dir = createDirectory(p_path);
    00395       if ( 0 != dir )   {
    00396         NTuple::Tuple* tup = book( dir, o_path, type, title);
    00397         if ( 0 == tup )   {
    00398           log << MSG::ERROR << "Cannot book N-tuple " << path << " (Unknown reason)" << endmsg;
    00399         }
    00400         return tup;
    00401       }
    00402       log << MSG::ERROR << "Cannot book N-tuple " << path << " (Invalid parent directory)" << endmsg;
    00403       return 0;
    00404     }
    00405     log << MSG::ERROR << "Cannot book N-tuple " << path << " (Invalid path)" << endmsg;
    00406     return 0;
    00407   }
    00408   log << MSG::ERROR << "Cannot book N-tuple " << path << " (Exists already)" << endmsg;
    00409   return 0;
    00410 }

NTuple::Tuple * NTupleSvc::book | ( | const std::string & | dirPath,
|  | const std::string & | relPath,
|  | const CLID & | type,
|  | const std::string & | title |
| ) |  |  | `[virtual]`

Book Ntuple and register it with the data store.

Definition at line 413 of file NTupleSvc.cpp.

    00413                                                                                                                            {
    00414   std::string full = dirPath;
    00415   if (relPath[0] != SEPARATOR) full += SEPARATOR;
    00416   full += relPath;
    00417   return book(full, type, title);
    00418 }

NTuple::Tuple * NTupleSvc::book | ( | const std::string & | dirPath,
|  | long | id,
|  | const CLID & | type,
|  | const std::string & | title |
| ) |  |  | `[virtual]`

Book Ntuple and register it with the data store.

Definition at line 421 of file NTupleSvc.cpp.

    00421                                                                                                           {
    00422   char txt[32];
    00423   return book( dirPath, _itoa(id, txt, 10), type, title);
    00424 }

NTuple::Tuple * NTupleSvc::book | ( | DataObject * | pParent,
|  | const std::string & | relPath,
|  | const CLID & | type,
|  | const std::string & | title |
| ) |  |  | `[virtual]`

Book Ntuple and register it with the data store.

Definition at line 427 of file NTupleSvc.cpp.

    00427                                                                                                                       {
    00428   NTuple::Tuple* pObj = 0;
    00429   // Check if object is already present
    00430   StatusCode status = findObject(pParent, relPath, *pp_cast<DataObject>(&pObj));
    00431   // No ? Then create it!
    00432   if ( !status.isSuccess() )    {
    00433     status = create( type, title, pObj);
    00434     if ( status.isSuccess() )   {
    00435       // Finally register the created N tuple with the store
    00436       status = registerObject(pParent, relPath, pObj);
    00437       if ( status.isSuccess() )    {
    00438         return pObj;
    00439       }
    00440       pObj->release();
    00441     }
    00442   }
    00443   return 0;
    00444 }

NTuple::Tuple * NTupleSvc::book | ( | DataObject * | pParent,
|  | long | id,
|  | const CLID & | type,
|  | const std::string & | title |
| ) |  |  | `[virtual]`

Book Ntuple and register it with the data store.

Definition at line 447 of file NTupleSvc.cpp.

    00450                                                          {
    00451   char txt[32];
    00452   return book( pParent, ::_itoa(id, txt,10), type, title);
    00453 }

NTuple::Tuple * NTupleSvc::access | ( | const std::string & | fullPath,
|  | const std::string & | filename |
| ) |  |  | `[virtual]`

Access N tuple on disk.

Definition at line 557 of file NTupleSvc.cpp.

    00557                                                                   {
    00558   MsgStream log ( msgSvc(), name() );
    00559   return 0;
    00560 }

StatusCode NTupleSvc::save | ( | const std::string & | fullPath | ) | `[virtual]`

Save N tuple to disk. Must be called in order to close the ntuple file properly.

Definition at line 563 of file NTupleSvc.cpp.

    00563                                                      {
    00564   MsgStream log ( msgSvc(), name() );
    00565   NTuple::Tuple* pObj = 0;
    00566   StatusCode status = findObject(fullPath, *pp_cast<DataObject>(&pObj));  // Check if object is  present
    00567   if ( status.isSuccess() )   {
    00568     return save ( pObj );
    00569   }
    00570   return INVALID_OBJ_PATH;
    00571 }

StatusCode NTupleSvc::save | ( | NTuple::Tuple * | tuple | ) | `[virtual]`

Save N tuple to disk. Must be called in order to close the ntuple file properly.

Definition at line 574 of file NTupleSvc.cpp.

    00574                                                 {
    00575   NTuple::TupleImp* tuple = (NTuple::TupleImp*)n_tuple;
    00576   if ( 0 != tuple )   {
    00577     try   {
    00578       IConversionSvc* pSvc = tuple->conversionService();
    00579       IRegistry*      pReg = tuple->registry();
    00580       if ( 0 != pSvc && 0 != pReg )    {
    00581         IOpaqueAddress* pAddr = pReg->address();
    00582         StatusCode status = pSvc->updateRep(pAddr, n_tuple);
    00583         if ( status.isSuccess() )   {
    00584           status = pSvc->updateRepRefs(pAddr, n_tuple);
    00585         }
    00586         return status;
    00587       }
    00588       return IDataProviderSvc::NO_DATA_LOADER;
    00589     }
    00590     catch(...)    {
    00591     }
    00592   }
    00593   return INVALID_OBJECT;
    00594 }

StatusCode NTupleSvc::save | ( | DataObject * | pParent,
|  | const std::string & | relPath |
| ) |  |  | `[virtual]`

Save N tuple to disk. Must be called in order to close the ntuple file properly.

Definition at line 597 of file NTupleSvc.cpp.

    00597                                                                          {
    00598   NTuple::Tuple* pObj = 0;
    00599   StatusCode status = findObject(pParent, relPath, *pp_cast<DataObject>(&pObj));  // Check if object is  present
    00600   if ( status.isSuccess() )   {
    00601     return save ( pObj );
    00602   }
    00603   return INVALID_OBJ_PATH;
    00604 }

StatusCode NTupleSvc::writeRecord | ( | NTuple::Tuple * | tuple | ) | `[virtual]`

Write single record to N tuple.

Definition at line 607 of file NTupleSvc.cpp.

    00607                                                           {
    00608   NTuple::TupleImp* tuple = (NTuple::TupleImp*)n_tuple;
    00609   if ( 0 != tuple )   {
    00610     try   {
    00611       IConversionSvc* pSvc = tuple->conversionService();
    00612       if ( 0 == pSvc )    {
    00613         pSvc = getDataLoader(n_tuple->registry());
    00614         tuple->setConversionService(pSvc);
    00615       }
    00616       if ( 0 != pSvc )    {
    00617         IRegistry* pReg = n_tuple->registry();
    00618         IOpaqueAddress* pAddr = pReg->address();
    00619         StatusCode status = pSvc->createRep(n_tuple, pAddr);
    00620         if ( status.isSuccess() )   {
    00621           pReg->setAddress(pAddr);
    00622           status = pSvc->fillRepRefs(pAddr, n_tuple);
    00623         }
    00624         return status;
    00625       }
    00626       return IDataProviderSvc::NO_DATA_LOADER;
    00627     }
    00628     catch(...)    {
    00629     }
    00630   }
    00631   return INVALID_OBJECT;
    00632 }

StatusCode NTupleSvc::writeRecord | ( | const std::string & | fullPath | ) | `[virtual]`

Write single record to N tuple.

Definition at line 635 of file NTupleSvc.cpp.

    00635                                                               {
    00636   NTuple::Tuple* pObj = 0;
    00637   StatusCode status = findObject(fullPath, *pp_cast<DataObject>(&pObj));  // Check if object is  present
    00638   if ( status.isSuccess() )   {
    00639     return writeRecord ( pObj );
    00640   }
    00641   return INVALID_OBJ_PATH;
    00642 }

StatusCode NTupleSvc::writeRecord | ( | DataObject * | pParent,
|  | const std::string & | relPath |
| ) |  |  | `[virtual]`

Write single record to N tuple.

Definition at line 645 of file NTupleSvc.cpp.

    00645                                                                                   {
    00646   NTuple::Tuple* pObj = 0;
    00647   StatusCode status = findObject(pParent, relPath, *pp_cast<DataObject>(&pObj));  // Check if object is  present
    00648   if ( status.isSuccess() )   {
    00649     return writeRecord ( pObj );
    00650   }
    00651   return INVALID_OBJ_PATH;
    00652 }

StatusCode NTupleSvc::readRecord | ( | NTuple::Tuple * | tuple | ) | `[virtual]`

Read single record from N tuple.

Definition at line 655 of file NTupleSvc.cpp.

    00655                                                         {
    00656   StatusCode status = INVALID_OBJECT;
    00657   NTuple::TupleImp* tuple = (NTuple::TupleImp*)n_tuple;
    00658   if ( 0 != tuple )   {
    00659     try   {
    00660       IConversionSvc* pSvc = tuple->conversionService();
    00661       if ( 0 == pSvc )    {
    00662         pSvc = getDataLoader(n_tuple->registry());
    00663         tuple->setConversionService(pSvc);
    00664       }
    00665       if ( 0 != pSvc )    {
    00666         IRegistry*      pReg  = n_tuple->registry();
    00667         IOpaqueAddress* pAddr = pReg->address();
    00668         status = pSvc->updateObj(pAddr, n_tuple);
    00669         if ( status.isSuccess() )   {
    00670           status = pSvc->updateObjRefs(pAddr, n_tuple);
    00671         }
    00672         return status;
    00673       }
    00674       status = IDataProviderSvc::NO_DATA_LOADER;
    00675     }
    00676     catch(...)    {
    00677       status = INVALID_OBJECT;
    00678     }
    00679   }
    00680   return status;
    00681 }

StatusCode NTupleSvc::readRecord | ( | const std::string & | fullPath | ) | `[virtual]`

Read single record from N tuple.

Definition at line 684 of file NTupleSvc.cpp.

    00684                                                            {
    00685   NTuple::Tuple* pObj = 0;
    00686   StatusCode status = findObject(fullPath, *pp_cast<DataObject>(&pObj));  // Check if object is  present
    00687   if ( status.isSuccess() )   {
    00688     return readRecord ( pObj );
    00689   }
    00690   return INVALID_OBJ_PATH;
    00691 }

StatusCode NTupleSvc::readRecord | ( | DataObject * | pParent,
|  | const std::string & | relPath |
| ) |  |  | `[virtual]`

Read single record from N tuple.

Definition at line 694 of file NTupleSvc.cpp.

    00694                                                                                {
    00695   NTuple::Tuple* pObj = 0;
    00696   StatusCode status = findObject(pParent, relPath, *pp_cast<DataObject>(&pObj));  // Check if object is  present
    00697   if ( status.isSuccess() )   {
    00698     return readRecord ( pObj );
    00699   }
    00700   return INVALID_OBJ_PATH;
    00701 }

bool NTupleSvc::isConnected | ( | const std::string & | identifier | ) | const`[virtual]`

Check if a datasource is connected.

Definition at line 99 of file NTupleSvc.cpp.

    00099                                                                 {
    00100   Connections::const_iterator i = m_connections.find(identifier);
    00101   return !(i==m_connections.end());
    00102 }

StatusCode NTupleSvc::connect | ( | const std::string & | ident | ) | `[virtual]`

Add file to list I/O list.

Definition at line 217 of file NTupleSvc.cpp.

    00217                                                        {
    00218   std::string logName;
    00219   return connect(ident, logName);
    00220 }

StatusCode NTupleSvc::connect | ( | const std::string & | ident,
|  | std::string & | logname |
| ) |  |  | `[virtual]`

Add file to list I/O list.

Reimplemented in TagCollectionSvc.

Definition at line 222 of file NTupleSvc.cpp.

    00222                                                                            {
    00223   MsgStream log ( msgSvc(), name() );
    00224   DataObject* pO = 0;
    00225   StatusCode status = findObject(m_rootName, pO);
    00226   if ( status.isSuccess() )   {
    00227     char typ=0;
    00228     Tokenizer tok(true);
    00229     std::vector<Prop> props;
    00230     long loc = ident.find(" ");
    00231     std::string filename, auth, svc = "", db_typ = "";
    00232     logname = ident.substr(0,loc);
    00233     tok.analyse(ident.substr(loc+1,ident.length()), " ", "", "", "=", "'", "'");
    00234     for ( Tokenizer::Items::iterator i = tok.items().begin(); i != tok.items().end(); ++i)    {
    00235       const std::string& tag = (*i).tag();
    00236       switch( ::toupper(tag[0]) )   {
    00237       case 'A':
    00238         break;
    00239       case 'F':   // FILE='<file name>'
    00240       case 'D':   // DATAFILE='<file name>'
    00241         filename = (*i).value();
    00242         break;
    00243       case 'O':   // OPT='<NEW<CREATE,WRITE>, UPDATE, READ>'
    00244         switch( ::toupper((*i).value()[0]) )   {
    00245         case 'C':
    00246         case 'N':
    00247         case 'W':
    00248           typ = 'N';
    00249           break;
    00250         case 'U':
    00251           typ = 'U';
    00252           break;
    00253         case 'O':
    00254         case 'R':
    00255           typ = 'O';
    00256           break;
    00257         default:
    00258           typ = 0;
    00259           break;
    00260         }
    00261         break;
    00262       case 'T':   // TYP='<HBOOK,ROOT,OBJY,...>'
    00263         db_typ = (*i).value();
    00264         break;
    00265       default:
    00266         props.push_back( Prop((*i).tag(), (*i).value()));
    00267         break;
    00268       }
    00269     }
    00270     if ( 0 != typ )    {
    00271       IConversionSvc* pSvc = 0;
    00272       status = createService(name()+'.'+logname, db_typ, props, pSvc);
    00273       if ( status.isSuccess() )   {
    00274         status = attachTuple(filename, logname, typ, pSvc->repSvcType());
    00275         if ( status.isSuccess() )    {
    00276           m_connections.insert(Connections::value_type(m_rootName+'/'+logname,Connection(pSvc)));
    00277           return StatusCode::SUCCESS;
    00278         }
    00279       }
    00280     }
    00281   }
    00282   log << MSG::ERROR << "Cannot add " << ident << " invalid filename!" << endmsg;
    00283   return StatusCode::FAILURE;
    00284 }

StatusCode NTupleSvc::disconnect | ( | const std::string & | nam | ) | `[virtual]`

Close open connection.

Definition at line 189 of file NTupleSvc.cpp.

    00189                                                           {
    00190   Connections::iterator i = m_connections.find(nam);
    00191   if ( i != m_connections.end() )    {
    00192     releaseConnection((*i).second);
    00193     m_connections.erase(i);
    00194     return StatusCode::SUCCESS;
    00195   }
    00196   return StatusCode::FAILURE;
    00197 }

StatusCode NTupleSvc::disconnectAll | ( |  | ) | `[virtual]`

Close all open connections.

Definition at line 200 of file NTupleSvc.cpp.

    00200                                          {
    00201   for(Connections::iterator i = m_connections.begin(); i != m_connections.end(); ++i) {
    00202     releaseConnection((*i).second);
    00203   }
    00204   m_connections.erase(m_connections.begin(), m_connections.end());
    00205   return StatusCode::SUCCESS;
    00206 }

StatusCode NTupleSvc::createService | ( | const std::string & | nam,
|  | const std::string & | typ,
|  | const std::vector< Prop > & | props,
|  | IConversionSvc *& | pSvc |
| ) |  |  | `[protected]`

Create conversion service.

CGL: set the storage type

Reimplemented in TagCollectionSvc.

Definition at line 286 of file NTupleSvc.cpp.

    00290 {
    00291   MsgStream log ( msgSvc(), name() );
    00293   // Get the value of the Stat persistancy mechanism from the AppMgr
    00294   IProperty*   appPropMgr = 0;
    00295   StatusCode sts = serviceLocator()->queryInterface(IProperty::interfaceID(), pp_cast<void>(&appPropMgr) );
    00296   if( !sts.isSuccess() ) {
    00297    // Report an error and return the FAILURE status code
    00298    log << MSG::ERROR << "Could not get PropMgr" << endmsg;
    00299    return sts;
    00300   }
    00301
    00302   StringProperty sp("HistogramPersistency","");
    00303   sts = appPropMgr->getProperty( &sp );
    00304   if ( !sts.isSuccess() ) {
    00305    log << MSG::ERROR << "Could not get NTuple Persistency format"
    00306        << " from ApplicationMgr properties" << endmsg;
    00307    return sts;
    00308   }
    00309
    00310   long storage_typ = TEST_StorageType;
    00311   if ( sp.value() == "HBOOK" ) {
    00312     storage_typ = HBOOK_StorageType;
    00313   }
    00314   else if ( sp.value() == "ROOT" ) {
    00315     storage_typ = ROOT_StorageType;
    00316   }
    00317   else {
    00318     appPropMgr->release();
    00319     log << MSG::ERROR << "Unknown NTuple Persistency format: " << sp.value() << endmsg;
    00320     return StatusCode::FAILURE;
    00321   }
    00322   // Clean up
    00323   appPropMgr->release();
    00324
    00325   if ( typ.length() > 0 && typ != sp.value() )    {
    00326     log << MSG::WARNING << "NTuple persistency type is "
    00327         << sp.value() << "." << endmsg
    00328         << "Type given by job option "
    00329         << "NTupleSvc.Input/Output ignored!" << endmsg;
    00330   }
    00331
    00332   //      log << MSG::DEBUG << "storage type: " << m_storageType << endmsg;
    00333
    00334   // FIXME: (MCl) why NTupleSvc has to directly create a ConversionSvc?
    00335   IService* pService = 0;
    00336   IInterface* iface = new ConversionSvc(name()+"Conversions", serviceLocator(), storage_typ);
    00337   StatusCode status = iface->queryInterface(IService::interfaceID(), pp_cast<void>(&pService));
    00338   if ( status.isSuccess() )   {
    00339     status = iface->queryInterface(IConversionSvc::interfaceID(), pp_cast<void>(&pSvc));
    00340     if ( !status.isSuccess() )   {
    00341       pService->release();
    00342       return status;
    00343     }
    00344   }
    00345   status = pService->sysInitialize();
    00346   if ( !status.isSuccess() )    {
    00347     return status;
    00348   }
    00349   pService->release();
    00350   status = pSvc->setDataProvider(this);
    00351   if ( !status.isSuccess() )    {
    00352     return status;
    00353   }
    00354   return status;
    00355 }

void NTupleSvc::releaseConnection | ( | Connection & | c | ) | `[protected]`

Finalize single service.

Definition at line 179 of file NTupleSvc.cpp.

    00179                                                 {
    00180   SmartIF<IService> isvc( c.service );
    00181   if ( isvc.isValid( ) )   {
    00182     isvc->finalize().ignore();
    00183   }
    00184   c.service->release();
    00185   c.service = 0;
    00186 }

StatusCode NTupleSvc::attachTuple | ( | const std::string & | filename,
|  | const std::string & | logname,
|  | const char | typ,
|  | const long | t |
| ) |  |  | `[protected]`

Attach output/input file.

Definition at line 490 of file NTupleSvc.cpp.

    00490                                                                                                                      {
    00491   MsgStream log(msgSvc(), name());
    00492   DataObject* p;
    00493   // First get the root object
    00494   StatusCode status = retrieveObject(m_rootName, p);
    00495   if ( status.isSuccess() )   {
    00496     // Now add the registry entry to the store
    00497     std::string entryname = m_rootName;
    00498     entryname += '/';
    00499     entryname += logname;
    00500     GenericAddress* pA =
    00501        new GenericAddress(t, CLID_NTupleFile, filename, entryname, 0, typ);
    00502     status = registerAddress(p, logname, pA);
    00503     if ( status.isSuccess() )    {
    00504       log << MSG::INFO << "Added stream file:" << filename << " as " << logname << endmsg;
    00505       return status;
    00506     }
    00507     pA->release();
    00508   }
    00509   log << MSG::ERROR << "Cannot add file:" << filename << " as " << logname << endmsg;
    00510   return status;
    00511 }

StatusCode NTupleSvc::updateDirectories | ( |  | ) | `[protected]`

Update directory data.

Definition at line 119 of file NTupleSvc.cpp.

    00119                                           {
    00120   typedef std::vector<IRegistry*> Leaves;
    00121   long need_update = 0;
    00122   DataObject* pO = 0;
    00123   StatusCode iret = findObject(m_rootName, pO);
    00124   MsgStream log ( msgSvc(), name() );
    00125   //  log << MSG::DEBUG << "in finalize()" << endmsg;
    00126   if ( iret.isSuccess() )   {
    00127     Leaves leaves;
    00128     iret = objectLeaves(pO, leaves);
    00129     if ( iret.isSuccess() )    {
    00130       // Only traverse the tree below the files
    00131       for ( Leaves::iterator d = leaves.begin(); d != leaves.end(); d++ )    {
    00132         if ( (*d)->object() )   {
    00133           IOpaqueAddress* pA = (*d)->address();
    00134           if ( pA )   {
    00135             unsigned long typ = pA->ipar()[1];
    00136             if ( typ == 'R' || typ == 'N' || typ == 'U' )   {
    00137               // ...starting from the file entries: first save the directories/ntuples
    00138               IConversionSvc* svc = getDataLoader(*d);
    00139               if ( 0 != svc )   {
    00140                 StatusCode status;
    00141                 DataSelectionAgent agent;
    00142                 IDataSelector*     sel = agent.selectedObjects();
    00143                 traverseSubTree ( (*d)->object(), &agent ).ignore();
    00144                 for(int i = sel->size()-1; i >= 0; i-- )    {
    00145                   DataObject* o = (*sel)[i];
    00146                   IRegistry*  r = o->registry();
    00147                   status = svc->updateRep(r->address(), o);
    00148                   if ( !status.isSuccess() )    {
    00149                     iret = status;
    00150                   }
    00151                 }
    00152                 for(int j = sel->size()-1; j >= 0; j-- )    {
    00153                   DataObject* o = (*sel)[j];
    00154                   IRegistry*  r = o->registry();
    00155                   status = svc->updateRepRefs(r->address(), o);
    00156                   if ( !status.isSuccess() )    {
    00157                     iret = status;
    00158                   }
    00159                 }
    00160                 if ( iret.isSuccess() ) need_update += sel->size();
    00161               }
    00162             }
    00163           }
    00164         }
    00165       }
    00166     }
    00167   }
    00168   if ( !iret.isSuccess() )    {
    00169     log << MSG::ERROR << "ERROR while saving NTuples" << endmsg;
    00170     return iret;
    00171   }
    00172   else if ( need_update > 0 )    {
    00173     log << MSG::INFO << "NTuples saved successfully" << endmsg;
    00174   }
    00175   return iret;
    00176 }

## Friends And Related Function Documentation

friend class SvcFactory< NTupleSvc >`[friend]`

Definition at line 36 of file NTupleSvc.h.

## Member Data Documentation

DBaseEntries NTupleSvc::m_output`[protected]`

Output streams.

Definition at line 126 of file NTupleSvc.h.

DBaseEntries NTupleSvc::m_input`[protected]`

Input streams.

Definition at line 128 of file NTupleSvc.h.

Connections NTupleSvc::m_connections`[protected]`

Container of connection points.

Definition at line 130 of file NTupleSvc.h.

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

- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiSvc/src/NTupleSvc/NTupleSvc.h
- /afs/cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v21r10p1/GaudiSvc/src/NTupleSvc/NTupleSvc.cpp