The Gaudi Framework  v33r0 (d5ea422b)
NTupleSvc Class Reference

NTuple service. More...

#include <src/NTupleSvc/NTupleSvc.h>

Inheritance diagram for NTupleSvc:
Collaboration diagram for NTupleSvc:

Classes

struct  Connection
 

Public Member Functions

StatusCode initialize () override
 DataSvc overrides: Initialize the service. More...
 
StatusCode reinitialize () override
 DataSvc overrides: reinitialize service. More...
 
StatusCode finalize () override
 DataSvc overrides: stop the service. More...
 
IConversionSvcgetDataLoader (IRegistry *pReg) override
 DataSvc overrides: Retrieve data loader. More...
 
NTuple::DirectorycreateDirectory (DataObject *pParent, const std::string &title) override
 Create Ntuple directory and register it with the data store. More...
 
NTuple::DirectorycreateDirectory (DataObject *pParent, long id) override
 Create Ntuple directory and register it with the data store. More...
 
NTuple::DirectorycreateDirectory (const std::string &dirPath, long id) override
 Create Ntuple directory and register it with the data store. More...
 
NTuple::DirectorycreateDirectory (const std::string &dirPath, const std::string &title) override
 Create Ntuple directory and register it with the data store. More...
 
NTuple::DirectorycreateDirectory (const std::string &fullPath) override
 Create Ntuple directory and register it with the data store. More...
 
StatusCode create (const CLID &typ, const std::string &title, NTuple::Tuple *&refpTuple) override
 Create requested N tuple (Hide constructor) More...
 
NTuple::Tuplebook (const std::string &fullPath, const CLID &type, const std::string &title) override
 Book Ntuple and register it with the data store. More...
 
NTuple::Tuplebook (const std::string &dirPath, const std::string &relPath, const CLID &type, const std::string &title) override
 Book Ntuple and register it with the data store. More...
 
NTuple::Tuplebook (const std::string &dirPath, long id, const CLID &type, const std::string &title) override
 Book Ntuple and register it with the data store. More...
 
NTuple::Tuplebook (DataObject *pParent, const std::string &relPath, const CLID &type, const std::string &title) override
 Book Ntuple and register it with the data store. More...
 
NTuple::Tuplebook (DataObject *pParent, long id, const CLID &type, const std::string &title) override
 Book Ntuple and register it with the data store. More...
 
NTuple::Tupleaccess (const std::string &fullPath, const std::string &filename) override
 Access N tuple on disk. More...
 
StatusCode save (const std::string &fullPath) override
 Save N tuple to disk. Must be called in order to close the ntuple file properly. More...
 
StatusCode save (NTuple::Tuple *tuple) override
 Save N tuple to disk. Must be called in order to close the ntuple file properly. More...
 
StatusCode save (DataObject *pParent, const std::string &relPath) override
 Save N tuple to disk. Must be called in order to close the ntuple file properly. More...
 
StatusCode writeRecord (NTuple::Tuple *tuple) override
 Write single record to N tuple. More...
 
StatusCode writeRecord (const std::string &fullPath) override
 Write single record to N tuple. More...
 
StatusCode writeRecord (DataObject *pParent, const std::string &relPath) override
 Write single record to N tuple. More...
 
StatusCode readRecord (NTuple::Tuple *tuple) override
 Read single record from N tuple. More...
 
StatusCode readRecord (const std::string &fullPath) override
 Read single record from N tuple. More...
 
StatusCode readRecord (DataObject *pParent, const std::string &relPath) override
 Read single record from N tuple. More...
 
bool isConnected (const std::string &identifier) const override
 Check if a datasource is connected. More...
 
StatusCode connect (const std::string &ident) override
 Add file to list I/O list. More...
 
StatusCode connect (const std::string &ident, std::string &logname) override
 Add file to list I/O list. More...
 
StatusCode disconnect (const std::string &nam) override
 Close open connection. More...
 
StatusCode disconnectAll () override
 Close all open connections. More...
 
 NTupleSvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor. More...
 
- Public Member Functions inherited from extends< DataSvc, INTupleSvc, IDataSourceMgr >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from DataSvc
CLID rootCLID () const override
 IDataManagerSvc: Accessor for root event CLID. More...
 
const std::stringrootName () const override
 IDataManagerSvc: Accessor for root event name. More...
 
StatusCode registerAddress (std::string_view fullPath, IOpaqueAddress *pAddress) override
 IDataManagerSvc: Register object address with the data store. More...
 
StatusCode registerAddress (IRegistry *parentObj, std::string_view objectPath, IOpaqueAddress *pAddress) override
 IDataManagerSvc: Register object address with the data store. More...
 
StatusCode unregisterAddress (std::string_view fullPath) override
 IDataManagerSvc: Unregister object address from the data store. More...
 
StatusCode unregisterAddress (IRegistry *pParent, std::string_view objPath) override
 IDataManagerSvc: Unregister object address from the data store. More...
 
StatusCode objectLeaves (const DataObject *pObject, std::vector< IRegistry * > &refLeaves) override
 IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object. More...
 
StatusCode objectLeaves (const IRegistry *pRegistry, std::vector< IRegistry * > &refLeaves) override
 IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object. More...
 
StatusCode objectParent (const DataObject *pObject, IRegistry *&refpParent) override
 IDataManagerSvc: Explore the object store: retrieve the object's parent. More...
 
StatusCode objectParent (const IRegistry *pRegistry, IRegistry *&refpParent) override
 IDataManagerSvc: Explore the object store: retrieve the object's parent. More...
 
StatusCode clearSubTree (std::string_view sub_tree_path) override
 IDataManagerSvc: Remove all data objects below the sub tree identified by its full path name. More...
 
StatusCode clearSubTree (DataObject *pObject) override
 IDataManagerSvc: Remove all data objects below the sub tree identified by the object. More...
 
StatusCode clearStore () override
 IDataManagerSvc: Remove all data objects in the data store. More...
 
StatusCode traverseSubTree (std::string_view sub_tree_path, IDataStoreAgent *pAgent) override
 IDataManagerSvc: Analyze by traversing all data objects below the sub tree identified by its full path name. More...
 
StatusCode traverseSubTree (DataObject *pObject, IDataStoreAgent *pAgent) override
 IDataManagerSvc: Analyze by traversing all data objects below the sub tree. More...
 
StatusCode traverseTree (IDataStoreAgent *pAgent) override
 IDataManagerSvc: Analyze by traversing all data objects in the data store. More...
 
StatusCode setRoot (std::string root_name, DataObject *pRootObj) override
 Initialize data store for new event by giving new event path and root object. More...
 
virtual StatusCode i_setRoot (std::string root_name, DataObject *pRootObj)
 Initialize data store for new event by giving new event path and root object. More...
 
StatusCode setRoot (std::string root_path, IOpaqueAddress *pRootAddr) override
 Initialize data store for new event by giving new event path and address of root object. More...
 
virtual StatusCode i_setRoot (std::string root_path, IOpaqueAddress *pRootAddr)
 Initialize data store for new event by giving new event path and address of root object. More...
 
StatusCode setDataLoader (IConversionSvc *svc, IDataProviderSvc *dpsvc=nullptr) override
 IDataManagerSvc: IDataManagerSvc: Pass a default data loader to the service and optionally a data provider. More...
 
StatusCode addPreLoadItem (const DataStoreItem &item) override
 Add an item to the preload list. More...
 
StatusCode removePreLoadItem (const DataStoreItem &item) override
 Remove an item from the preload list. More...
 
StatusCode resetPreLoad () override
 Clear the preload list. More...
 
virtual StatusCode preLoad (int depth, int load_depth, DataObject *pObject)
 Execute one level of preloading and recursively load until the final level is reached. More...
 
StatusCode preLoad () override
 load all preload items of the list More...
 
StatusCode registerObject (std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
 Register object with the data store. More...
 
StatusCode registerObject (DataObject *parentObj, std::string_view objPath, DataObject *pObject) override
 Register object with the data store. More...
 
StatusCode unregisterObject (std::string_view fullPath) override
 Unregister object from the data store. More...
 
StatusCode unregisterObject (DataObject *pObject) override
 Unregister object from the data store. More...
 
StatusCode unregisterObject (DataObject *pObject, std::string_view objectPath) override
 Unregister object from the data store. More...
 
StatusCode retrieveObject (IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
 Retrieve object from data store. More...
 
StatusCode findObject (std::string_view fullPath, DataObject *&pObject) override
 Find object identified by its full path in the data store. More...
 
StatusCode findObject (IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
 Find object identified by its full path in the data store. More...
 
StatusCode linkObject (IRegistry *from, std::string_view objPath, DataObject *to) override
 Add a link to another object. More...
 
StatusCode linkObject (std::string_view fullPath, DataObject *to) override
 Add a link to another object. More...
 
StatusCode unlinkObject (IRegistry *from, std::string_view objPath) override
 Remove a link to another object. More...
 
StatusCode unlinkObject (DataObject *fromObj, std::string_view objPath) override
 Remove a link to another object. More...
 
StatusCode unlinkObject (std::string_view fullPath) override
 Remove a link to another object. More...
 
StatusCode updateObject (IRegistry *pDirectory) override
 Update object identified by its directory entry. More...
 
StatusCode updateObject (DataObject *toUpdate) override
 Update object. More...
 
StatusCode initialize () override
 Service initialization. More...
 
StatusCode reinitialize () override
 Service initialization. More...
 
StatusCode finalize () override
 Service initialization. More...
 
 DataSvc (const DataSvc &)=delete
 copy constructor disabled More...
 
DataSvcoperator= (const DataSvc &)=delete
 Fake assignment operator (never implemented). More...
 
virtual StatusCode registerAddress (std::string_view fullPath, IOpaqueAddress *pAddress)=0
 Register object address with the data store. More...
 
StatusCode registerAddress (DataObject *parentObj, std::string_view objectPath, IOpaqueAddress *pAddress)
 Register object address with the data store. More...
 
virtual StatusCode registerAddress (IRegistry *parentObj, std::string_view objectPath, IOpaqueAddress *pAddress)=0
 Register object address with the data store. More...
 
virtual StatusCode unregisterAddress (std::string_view fullPath)=0
 Unregister object address from the data store. More...
 
StatusCode unregisterAddress (DataObject *pParent, std::string_view objPath)
 Unregister object address from the data store. More...
 
virtual StatusCode unregisterAddress (IRegistry *pParent, std::string_view objPath)=0
 Unregister object address from the data store. More...
 
StatusCode registerObject (std::string_view fullPath, DataObject *pObject)
 Register object with the data store. More...
 
virtual StatusCode registerObject (std::string_view parentPath, std::string_view objectPath, DataObject *pObject)=0
 Register object with the data store. More...
 
StatusCode registerObject (std::string_view parentPath, int item, DataObject *pObject)
 Register object with the data store. More...
 
virtual StatusCode registerObject (DataObject *parentObj, std::string_view objectPath, DataObject *pObject)=0
 Register object with the data store. More...
 
StatusCode registerObject (DataObject *parentObj, int item, DataObject *pObject)
 Register object with the data store. More...
 
virtual StatusCode retrieveObject (IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
 Retrieve object identified by its directory entry. More...
 
StatusCode retrieveObject (std::string_view fullPath, DataObject *&pObject)
 Retrieve object identified by its full path from the data store. More...
 
StatusCode retrieveObject (std::string_view parentPath, std::string_view objectPath, DataObject *&pObject)
 Retrieve object from data store. More...
 
StatusCode retrieveObject (std::string_view parentPath, int item, DataObject *&pObject)
 Retrieve object from data store. More...
 
StatusCode retrieveObject (DataObject *parentObj, std::string_view objectPath, DataObject *&pObject)
 Retrieve object from data store. More...
 
StatusCode retrieveObject (DataObject *parentObj, int item, DataObject *&pObject)
 Retrieve object from data store. More...
 
virtual StatusCode findObject (IRegistry *pDirectory, std::string_view path, DataObject *&pObject)=0
 Find object identified by its directory entry. More...
 
virtual StatusCode findObject (std::string_view fullPath, DataObject *&pObject)=0
 Find object identified by its full path in the data store. More...
 
StatusCode findObject (std::string_view parentPath, std::string_view objectPath, DataObject *&pObject)
 Find object identified by its parent object and the path to the object relative to the parent. More...
 
StatusCode findObject (std::string_view parentPath, int item, DataObject *&pObject)
 Find object identified by its parent object and an integer identifier in the data store. More...
 
StatusCode findObject (DataObject *parentObj, std::string_view objectPath, DataObject *&pObject)
 Find object identified by its parent object and the path to the object relative to the parent. More...
 
StatusCode findObject (DataObject *parentObj, int item, DataObject *&pObject)
 Find object identified by its parent object and an integer identifier in the data store. More...
 
virtual StatusCode linkObject (IRegistry *from, std::string_view objPath, DataObject *toObj)=0
 Add a link to another object. More...
 
StatusCode linkObject (std::string_view fromPath, std::string_view objPath, DataObject *toObj)
 Add a link to another object. More...
 
StatusCode linkObject (DataObject *fromObj, std::string_view objPath, DataObject *toObj)
 Add a link to another object. More...
 
virtual StatusCode linkObject (std::string_view fullPath, DataObject *toObj)=0
 Add a link to another object. More...
 
virtual StatusCode unlinkObject (IRegistry *from, std::string_view objPath)=0
 Remove a link to another object. More...
 
StatusCode unlinkObject (std::string_view fromPath, std::string_view objPath)
 Remove a link to another object. More...
 
virtual StatusCode unlinkObject (DataObject *fromObj, std::string_view objPath)=0
 Remove a link to another object. More...
 
virtual StatusCode unlinkObject (std::string_view fullPath)=0
 Remove a link to another object. More...
 
- Public Member Functions inherited from extends< Service, IDataProviderSvc, IDataManagerSvc >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode declareTool (ToolHandle< T > &handle, std::string toolTypeAndName, bool createIf=true)
 Declare used tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 PropertyHolder ()=default
 
Gaudi::Details::PropertyBasedeclareProperty (Gaudi::Details::PropertyBase &prop)
 Declare a property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, TYPE &value, const std::string &doc="none")
 Helper to wrap a regular data member and use it as a regular property. More...
 
Gaudi::Details::PropertyBasedeclareProperty (const std::string &name, Gaudi::Property< TYPE, VERIFIER, HANDLERS > &prop, const std::string &doc="none")
 Declare a PropertyBase instance setting name and documentation. More...
 
Gaudi::Details::PropertyBasedeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="")
 Declare a remote property. More...
 
StatusCode setProperty (const Gaudi::Details::PropertyBase &p) override
 set the property form another property More...
 
StatusCode setProperty (const std::string &s) override
 set the property from the formatted string More...
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 set the property from name and the value More...
 
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
StatusCode getProperty (Gaudi::Details::PropertyBase *p) const override
 get the property More...
 
const Gaudi::Details::PropertyBasegetProperty (const std::string &name) const override
 get the property by name More...
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 convert the property to the string More...
 
const std::vector< Gaudi::Details::PropertyBase * > & getProperties () const override
 get all properties More...
 
bool hasProperty (const std::string &name) const override
 Return true if we have a property with the given name. More...
 
 PropertyHolder (const PropertyHolder &)=delete
 
PropertyHolderoperator= (const PropertyHolder &)=delete
 
- Public Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level msgLevel () const
 get the cached level (originally extracted from the embedded MsgStream) More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const
 Backward compatibility function for getting the output level. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
const SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 

Protected Types

typedef std::vector< std::stringDBaseEntries
 
typedef std::pair< std::string, std::stringProp
 

Protected Member Functions

StatusCode createService (const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc)
 Create conversion service. More...
 
void releaseConnection (Connection &c)
 Finalize single service. More...
 
StatusCode attachTuple (const std::string &filename, const std::string &logname, const char typ, const long t)
 Attach output/input file. More...
 
StatusCode updateDirectories ()
 Update directory data. More...
 
- Protected Member Functions inherited from DataSvc
bool checkRoot ()
 Check if root path is valid. More...
 
virtual DataObjectcreateDefaultObject () const
 Create default objects in case forced creation of leaves is requested. More...
 
virtual StatusCode loadObject (IRegistry *pNode)
 Invoke Persistency service to create transient object from its persistent representation. More...
 
virtual StatusCode loadObject (IConversionSvc *pLoader, IRegistry *pNode)
 Invoke Persistency service to create transient object from its persistent representation. More...
 
StatusCode retrieveEntry (DataSvcHelpers::RegistryEntry *pNode, std::string_view path, DataSvcHelpers::RegistryEntry *&pEntry)
 Retrieve registry entry from store. More...
 
DataObjecthandleDataFault (IRegistry *pReg, std::string_view path="")
 Invoke data fault handling if enabled. More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
Gaudi::Details::PropertyBaseproperty (const std::string &name) const
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
MSG::Level setUpMessaging () const
 Set up local caches. More...
 
MSG::Level resetMessaging ()
 Reinitialize internal states. More...
 
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Protected Attributes

Gaudi::Property< DBaseEntriesm_input {this, "Input", {}, "input streams"}
 
Gaudi::Property< DBaseEntriesm_output {this, "Output", {}, "output streams"}
 
std::map< std::string, Connectionm_connections
 Container of connection points. More...
 
- Protected Attributes inherited from DataSvc
SmartIF< IIncidentSvcm_incidentSvc = nullptr
 Pointer to incident service. More...
 
Gaudi::Property< CLIDm_rootCLID {this, "RootCLID", 110 , "CLID of root entry"}
 
Gaudi::Property< std::stringm_rootName {this, "RootName", "/Event", "name of root entry"}
 
std::unique_ptr< DataSvcHelpers::RegistryEntrym_root
 Pointer to root entry. More...
 
- Protected Attributes inherited from Service
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::Property< int > m_outputLevel {this, "OutputLevel", MSG::NIL, "output level"}
 
Gaudi::Property< bool > m_auditInit {this, "AuditServices", false, " unused"}
 
Gaudi::Property< bool > m_auditorInitialize {this, "AuditInitialize", false, "trigger auditor on initialize()"}
 
Gaudi::Property< bool > m_auditorStart {this, "AuditStart", false, "trigger auditor on start()"}
 
Gaudi::Property< bool > m_auditorStop {this, "AuditStop", false, "trigger auditor on stop()"}
 
Gaudi::Property< bool > m_auditorFinalize {this, "AuditFinalize", false, "trigger auditor on finalize()"}
 
Gaudi::Property< bool > m_auditorReinitialize {this, "AuditReinitialize", false, "trigger auditor on reinitialize()"}
 
Gaudi::Property< bool > m_auditorRestart {this, "AuditRestart", false, "trigger auditor on restart()"}
 
SmartIF< IAuditorSvcm_pAuditorSvc
 Auditor Service. More...
 

Additional Inherited Members

- Public Types inherited from extends< DataSvc, INTupleSvc, IDataSourceMgr >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from extends< Service, IDataProviderSvc, IDataManagerSvc >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces... >
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
using Factory = Gaudi::PluginService::Factory< IService *(const std::string &, ISvcLocator *)>
 
- Public Types inherited from PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
using PropertyHolderImpl = PropertyHolder< CommonMessaging< implements< IService, IProperty, IStateful > > >
 Typedef used to refer to this class from derived classes, as in. More...
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces... >
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids... >::type
 take union of the ext_iids of all Interfaces... More...
 

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 33 of file NTupleSvc.h.

Member Typedef Documentation

◆ DBaseEntries

Definition at line 40 of file NTupleSvc.h.

◆ Prop

Definition at line 41 of file NTupleSvc.h.

Constructor & Destructor Documentation

◆ NTupleSvc()

NTupleSvc::NTupleSvc ( const std::string name,
ISvcLocator svc 
)

Standard Constructor.

Definition at line 61 of file NTupleSvc.cpp.

61  : base_class( name, svc ) {
62  m_rootName = "/NTUPLES";
63  m_rootCLID = CLID_DataObject;
64 }
Gaudi::Property< CLID > m_rootCLID
Definition: DataSvc.h:61
Gaudi::Property< std::string > m_rootName
Definition: DataSvc.h:62
extends base_class
Typedef to this class.
Definition: extends.h:24
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284

Member Function Documentation

◆ access()

NTuple::Tuple * NTupleSvc::access ( const std::string fullPath,
const std::string filename 
)
override

Access N tuple on disk.

Definition at line 494 of file NTupleSvc.cpp.

494 { return nullptr; }

◆ attachTuple()

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 436 of file NTupleSvc.cpp.

437  {
438  DataObject* p;
439  // First get the root object
440  StatusCode status = retrieveObject( m_rootName.value(), p );
441  if ( status.isSuccess() ) {
442  // Now add the registry entry to the store
443  std::string entryname = m_rootName;
444  entryname += '/';
445  entryname += logname;
446  GenericAddress* pA = new GenericAddress( t, CLID_NTupleFile, filename, entryname, 0, typ );
447  status = registerAddress( p, logname, pA );
448  if ( status.isSuccess() ) {
449  info() << "Added stream file:" << filename << " as " << logname << endmsg;
450  return status;
451  }
452  pA->release();
453  }
454  error() << "Cannot add file:" << filename << " as " << logname << endmsg;
455  return status;
456 }
unsigned long release() override
release reference to object
Gaudi::Property< std::string > m_rootName
Definition: DataSvc.h:62
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Generic Transient Address.
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isSuccess() const
Definition: StatusCode.h:361
StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
Definition: DataSvc.cpp:225
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
Retrieve object from data store.
Definition: DataSvc.cpp:628
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ book() [1/5]

NTuple::Tuple * NTupleSvc::book ( const std::string fullPath,
const CLID type,
const std::string title 
)
override

Book Ntuple and register it with the data store.

Definition at line 330 of file NTupleSvc.cpp.

330  {
331  DataObject* pObj = nullptr;
332  std::string path = fullPath;
333  assert( !path.empty() );
334  if ( path[0] != SEPARATOR ) {
335  path = m_rootName;
336  path += SEPARATOR;
337  path += fullPath;
338  }
339  StatusCode status = retrieveObject( path, pObj );
340  if ( status.isSuccess() ) {
341  error() << "Cannot book N-tuple " << path << " (Exists already)" << endmsg;
342  return nullptr;
343  }
344  auto sep = path.rfind( SEPARATOR );
345  if ( sep == std::string::npos ) {
346  error() << "Cannot book N-tuple " << path << " (Invalid path)" << endmsg;
347  return nullptr;
348  }
349 
350  std::string p_path( path, 0, sep );
351  std::string o_path( path, sep, path.length() );
352  DataObject* dir = createDirectory( p_path );
353  if ( !dir ) {
354  error() << "Cannot book N-tuple " << path << " (Invalid parent directory)" << endmsg;
355  return nullptr;
356  }
357 
358  NTuple::Tuple* tup = book( dir, o_path, type, title );
359  if ( !tup ) { error() << "Cannot book N-tuple " << path << " (Unknown reason)" << endmsg; }
360  return tup;
361 }
constexpr char SEPARATOR
Gaudi::Property< std::string > m_rootName
Definition: DataSvc.h:62
NTuple::Tuple * book(const std::string &fullPath, const CLID &type, const std::string &title) override
Book Ntuple and register it with the data store.
Definition: NTupleSvc.cpp:330
STL class.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title) override
Create Ntuple directory and register it with the data store.
Definition: NTupleSvc.cpp:403
bool isSuccess() const
Definition: StatusCode.h:361
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:385
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
Retrieve object from data store.
Definition: DataSvc.cpp:628
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ book() [2/5]

NTuple::Tuple * NTupleSvc::book ( const std::string dirPath,
const std::string relPath,
const CLID type,
const std::string title 
)
override

Book Ntuple and register it with the data store.

Definition at line 364 of file NTupleSvc.cpp.

365  {
366  std::string full = dirPath;
367  assert( !relPath.empty() );
368  if ( relPath[0] != SEPARATOR ) full += SEPARATOR;
369  full += relPath;
370  return book( full, type, title );
371 }
T empty(T... args)
constexpr char SEPARATOR
NTuple::Tuple * book(const std::string &fullPath, const CLID &type, const std::string &title) override
Book Ntuple and register it with the data store.
Definition: NTupleSvc.cpp:330
STL class.

◆ book() [3/5]

NTuple::Tuple * NTupleSvc::book ( const std::string dirPath,
long  id,
const CLID type,
const std::string title 
)
override

Book Ntuple and register it with the data store.

Definition at line 374 of file NTupleSvc.cpp.

374  {
375  return book( dirPath, std::to_string( id ), type, title );
376 }
T to_string(T... args)
NTuple::Tuple * book(const std::string &fullPath, const CLID &type, const std::string &title) override
Book Ntuple and register it with the data store.
Definition: NTupleSvc.cpp:330

◆ book() [4/5]

NTuple::Tuple * NTupleSvc::book ( DataObject pParent,
const std::string relPath,
const CLID type,
const std::string title 
)
override

Book Ntuple and register it with the data store.

Definition at line 379 of file NTupleSvc.cpp.

380  {
381  NTuple::Tuple* pObj = nullptr;
382  // Check if object is already present
383  StatusCode status = findObject( pParent, relPath, *pp_cast<DataObject>( &pObj ) );
384  // No ? Then create it!
385  if ( !status.isSuccess() ) {
386  status = create( type, title, pObj );
387  if ( status.isSuccess() ) {
388  // Finally register the created N tuple with the store
389  status = registerObject( pParent, relPath, pObj );
390  if ( status.isSuccess() ) return pObj;
391  pObj->release();
392  }
393  }
394  return nullptr;
395 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isSuccess() const
Definition: StatusCode.h:361
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:385
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:56
StatusCode registerObject(std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
Register object with the data store.
Definition: DataSvc.cpp:303
StatusCode create(const CLID &typ, const std::string &title, NTuple::Tuple *&refpTuple) override
Create requested N tuple (Hide constructor)
Definition: NTupleSvc.cpp:311
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Definition: DataSvc.cpp:650

◆ book() [5/5]

NTuple::Tuple * NTupleSvc::book ( DataObject pParent,
long  id,
const CLID type,
const std::string title 
)
override

Book Ntuple and register it with the data store.

Definition at line 398 of file NTupleSvc.cpp.

398  {
399  return book( pParent, std::to_string( id ), type, title );
400 }
T to_string(T... args)
NTuple::Tuple * book(const std::string &fullPath, const CLID &type, const std::string &title) override
Book Ntuple and register it with the data store.
Definition: NTupleSvc.cpp:330

◆ connect() [1/2]

StatusCode NTupleSvc::connect ( const std::string ident)
override

Add file to list I/O list.

Definition at line 190 of file NTupleSvc.cpp.

190  {
191  std::string logName;
192  return connect( ident, logName );
193 }
STL class.
StatusCode connect(const std::string &ident) override
Add file to list I/O list.
Definition: NTupleSvc.cpp:190

◆ connect() [2/2]

StatusCode NTupleSvc::connect ( const std::string ident,
std::string logname 
)
override

Add file to list I/O list.

Definition at line 195 of file NTupleSvc.cpp.

195  {
196  DataObject* pO = nullptr;
197  StatusCode status = findObject( m_rootName.value(), pO );
198  if ( status.isSuccess() ) {
199  char typ = 0;
200  std::vector<Prop> props;
201  long loc = ident.find( " " );
202  std::string filename, auth, svc = "", db_typ = "";
203  logname = ident.substr( 0, loc );
204  using Parser = Gaudi::Utils::AttribStringParser;
205  // we assume that there is always a " "
206  // (but if it is not there, we probably will not match the pattern)
207  for ( auto attrib : Parser( ident.substr( loc + 1 ) ) ) {
208  switch ( ::toupper( attrib.tag[0] ) ) {
209  case 'A':
210  break;
211  case 'F': // FILE='<file name>'
212  case 'D': // DATAFILE='<file name>'
213  filename = std::move( attrib.value );
214  break;
215  case 'O': // OPT='<NEW<CREATE,WRITE>, UPDATE, READ>'
216  switch ( ::toupper( attrib.value[0] ) ) {
217  case 'C':
218  case 'N':
219  case 'W':
220  typ = 'N';
221  break;
222  case 'U':
223  typ = 'U';
224  break;
225  case 'O':
226  case 'R':
227  typ = 'O';
228  break;
229  default:
230  typ = 0;
231  break;
232  }
233  break;
234  case 'T': // TYP='<HBOOK,ROOT,OBJY,...>'
235  db_typ = std::move( attrib.value );
236  break;
237  default:
238  props.emplace_back( attrib.tag, attrib.value );
239  break;
240  }
241  }
242  if ( 0 != typ ) {
243  IConversionSvc* pSvc = nullptr;
244  status = createService( name() + '.' + logname, db_typ, props, pSvc );
245  if ( status.isSuccess() ) {
246  status = attachTuple( filename, logname, typ, pSvc->repSvcType() );
247  if ( status.isSuccess() ) {
248  m_connections.insert( {m_rootName + '/' + logname, Connection( pSvc )} );
249  return StatusCode::SUCCESS;
250  }
251  }
252  }
253  }
254  error() << "Cannot add " << ident << " invalid filename!" << endmsg;
255  return StatusCode::FAILURE;
256 }
Parse attribute strings allowing iteration over the various attributes.
Gaudi::Property< std::string > m_rootName
Definition: DataSvc.h:62
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
std::map< std::string, Connection > m_connections
Container of connection points.
Definition: NTupleSvc.h:128
StatusCode createService(const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc)
Create conversion service.
Definition: NTupleSvc.cpp:258
STL class.
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isSuccess() const
Definition: StatusCode.h:361
T move(T... args)
T find(T... args)
STL class.
constexpr static const auto FAILURE
Definition: StatusCode.h:97
T substr(T... args)
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Definition: DataSvc.cpp:650
StatusCode attachTuple(const std::string &filename, const std::string &logname, const char typ, const long t)
Attach output/input file.
Definition: NTupleSvc.cpp:436
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202
T emplace_back(T... args)

◆ create()

StatusCode NTupleSvc::create ( const CLID typ,
const std::string title,
NTuple::Tuple *&  refpTuple 
)
override

Create requested N tuple (Hide constructor)

Eventually allow loading through factory?

Definition at line 311 of file NTupleSvc.cpp.

311  {
312  NTuple::TupleImp* pTuple = nullptr;
314  if ( typ == CLID_ColumnWiseTuple ) {
315  pTuple = new NTuple::ColumnWiseTuple( title );
316  } else if ( typ == CLID_RowWiseTuple ) {
317  pTuple = new NTuple::RowWiseTuple( title );
318  } else {
320  }
321  if ( pTuple ) {
322  pTuple->setTupleService( this );
323  status = StatusCode::SUCCESS;
324  }
325  refpTuple = pTuple;
326  return status;
327 }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
void setTupleService(INTupleSvc *svc)
Access conversion service.
constexpr static const auto FAILURE
Definition: StatusCode.h:97

◆ createDirectory() [1/5]

NTuple::Directory * NTupleSvc::createDirectory ( DataObject pParent,
const std::string title 
)
override

Create Ntuple directory and register it with the data store.

Definition at line 403 of file NTupleSvc.cpp.

403  {
404  assert( !relPath.empty() );
405  if ( pParent ) {
406  IRegistry* pDir = pParent->registry();
407  if ( pDir ) {
408  std::string full = pDir->identifier();
409  if ( relPath[0] != '/' ) full += "/";
410  full += relPath;
411  return createDirectory( full );
412  }
413  }
414  return nullptr;
415 }
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:82
STL class.
NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title) override
Create Ntuple directory and register it with the data store.
Definition: NTupleSvc.cpp:403
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
virtual const id_type & identifier() const =0
Full identifier (or key)

◆ createDirectory() [2/5]

NTuple::Directory * NTupleSvc::createDirectory ( DataObject pParent,
long  id 
)
override

Create Ntuple directory and register it with the data store.

Definition at line 418 of file NTupleSvc.cpp.

418  {
419  return createDirectory( pParent, std::to_string( id ) );
420 }
T to_string(T... args)
NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title) override
Create Ntuple directory and register it with the data store.
Definition: NTupleSvc.cpp:403

◆ createDirectory() [3/5]

NTuple::Directory * NTupleSvc::createDirectory ( const std::string dirPath,
long  id 
)
override

Create Ntuple directory and register it with the data store.

Definition at line 423 of file NTupleSvc.cpp.

423  {
424  return createDirectory( dirPath, std::to_string( id ) );
425 }
T to_string(T... args)
NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title) override
Create Ntuple directory and register it with the data store.
Definition: NTupleSvc.cpp:403

◆ createDirectory() [4/5]

NTuple::Directory * NTupleSvc::createDirectory ( const std::string dirPath,
const std::string title 
)
override

Create Ntuple directory and register it with the data store.

Definition at line 428 of file NTupleSvc.cpp.

428  {
429  assert( !relPath.empty() );
430  std::string full = dirPath;
431  if ( relPath[0] != '/' ) full += "/";
432  full += relPath;
433  return createDirectory( full );
434 }
STL class.
NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title) override
Create Ntuple directory and register it with the data store.
Definition: NTupleSvc.cpp:403

◆ createDirectory() [5/5]

NTuple::Directory * NTupleSvc::createDirectory ( const std::string fullPath)
override

Create Ntuple directory and register it with the data store.

Definition at line 459 of file NTupleSvc.cpp.

459  {
460  NTuple::Directory* p = nullptr;
461  StatusCode status = findObject( fullPath, *pp_cast<DataObject>( &p ) );
462  if ( !status.isSuccess() ) {
463  auto sep2 = fullPath.rfind( SEPARATOR );
464  if ( sep2 != std::string::npos ) {
465  std::string relPath = fullPath.substr( 0, sep2 );
466  p = createDirectory( relPath );
467  if ( p ) {
468  p = new NTuple::Directory();
469  // Finally register the created N tuple with the store
470  status = registerObject( fullPath, p );
471  if ( status.isSuccess() ) {
472  // ...starting from the file entries
473  IConversionSvc* svc = getDataLoader( p->registry() );
474  if ( svc ) {
475  IOpaqueAddress* pAddr = nullptr;
476  status = svc->createRep( p, pAddr );
477  if ( status.isSuccess() ) {
478  p->registry()->setAddress( pAddr );
479  status = svc->fillRepRefs( pAddr, p );
480  if ( status.isSuccess() ) return p;
481  }
482  }
483  unregisterObject( p );
484  }
485  p->release();
486  p = nullptr;
487  }
488  }
489  }
490  return p;
491 }
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:82
constexpr char SEPARATOR
T rfind(T... args)
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
STL class.
StatusCode unregisterObject(std::string_view fullPath) override
Unregister object from the data store.
Definition: DataSvc.cpp:383
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title) override
Create Ntuple directory and register it with the data store.
Definition: NTupleSvc.cpp:403
bool isSuccess() const
Definition: StatusCode.h:361
virtual unsigned long release()
release reference to object
Definition: DataObject.cpp:56
IConversionSvc * getDataLoader(IRegistry *pReg) override
DataSvc overrides: Retrieve data loader.
Definition: NTupleSvc.cpp:98
virtual void setAddress(IOpaqueAddress *pAddress)=0
Set/Update Opaque storage address.
StatusCode registerObject(std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
Register object with the data store.
Definition: DataSvc.cpp:303
T substr(T... args)
Small class representing an N tuple directory in the transient store.
Definition: NTuple.h:911
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Definition: DataSvc.cpp:650
Opaque address interface definition.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.

◆ createService()

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

Definition at line 258 of file NTupleSvc.cpp.

259  {
261  // Get the value of the Stat persistancy mechanism from the AppMgr
262  auto appPropMgr = serviceLocator()->as<IProperty>();
263  if ( !appPropMgr ) {
264  // Report an error and return the FAILURE status code
265  error() << "Could not get PropMgr" << endmsg;
266  return StatusCode::FAILURE;
267  }
268 
269  Gaudi::Property<std::string> sp( "HistogramPersistency", "" );
270  StatusCode sts = appPropMgr->getProperty( &sp );
271  if ( !sts.isSuccess() ) {
272  error() << "Could not get NTuple Persistency format"
273  << " from ApplicationMgr properties" << endmsg;
274  return sts;
275  }
276 
277  long storage_typ = TEST_StorageType;
278  if ( sp.value() == "HBOOK" ) {
279  storage_typ = HBOOK_StorageType;
280  } else if ( sp.value() == "ROOT" ) {
281  storage_typ = ROOT_StorageType;
282  } else {
283  error() << "Unknown NTuple Persistency format: " << sp.value() << endmsg;
284  return StatusCode::FAILURE;
285  }
286 
287  if ( !typ.empty() && typ != sp.value() ) {
288  warning() << "NTuple persistency type is " << sp.value() << "." << endmsg << "Type given by job option "
289  << "NTupleSvc.Input/Output ignored!" << endmsg;
290  }
291 
292  // debug() << "storage type: " << m_storageType << endmsg;
293 
294  // FIXME: (MCl) why NTupleSvc has to directly create a ConversionSvc?
295  IInterface* iface = new ConversionSvc( name() + "Conversions", serviceLocator(), storage_typ );
296  auto pService = SmartIF<IService>( iface );
297  if ( !pService ) return StatusCode::FAILURE;
298 
299  auto cnvSvc = pService.as<IConversionSvc>();
300  if ( !cnvSvc ) return StatusCode::FAILURE;
301 
302  pSvc = cnvSvc.get();
303  pSvc->addRef(); // make sure the caller gets a pSvc which points at something
304  // with a refCount of (at least) one...
305  auto status = pService->sysInitialize();
306  if ( !status.isSuccess() ) return status;
307  return pSvc->setDataProvider( this );
308 }
const long TEST_StorageType
Definition: ClassID.h:59
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:287
T empty(T... args)
const long HBOOK_StorageType
Definition: ClassID.h:66
Implementation of property with value of concrete type.
Definition: Property.h:370
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
SmartIF< IFace > as()
Definition: ISvcLocator.h:113
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:284
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
Definition of the basic interface.
Definition: IInterface.h:254
const long ROOT_StorageType
Definition: ClassID.h:62
bool isSuccess() const
Definition: StatusCode.h:361
constexpr static const auto FAILURE
Definition: StatusCode.h:97
virtual unsigned long addRef()=0
Increment the reference count of Interface instance.
Base class for all conversion services.
Definition: ConversionSvc.h:55
The IProperty is the basic interface for all components which have properties that can be set or get.
Definition: IProperty.h:30
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ disconnect()

StatusCode NTupleSvc::disconnect ( const std::string nam)
override

Close open connection.

Definition at line 166 of file NTupleSvc.cpp.

166  {
167  auto i = m_connections.find( nam );
168  if ( i == m_connections.end() ) return StatusCode::FAILURE;
169  releaseConnection( i->second );
170  m_connections.erase( i );
171  return StatusCode::SUCCESS;
172 }
void releaseConnection(Connection &c)
Finalize single service.
Definition: NTupleSvc.cpp:158
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
std::map< std::string, Connection > m_connections
Container of connection points.
Definition: NTupleSvc.h:128
constexpr static const auto FAILURE
Definition: StatusCode.h:97

◆ disconnectAll()

StatusCode NTupleSvc::disconnectAll ( )
override

Close all open connections.

Definition at line 175 of file NTupleSvc.cpp.

175  {
176  for ( auto& i : m_connections ) releaseConnection( i.second );
177  m_connections.clear();
178  return StatusCode::SUCCESS;
179 }
void releaseConnection(Connection &c)
Finalize single service.
Definition: NTupleSvc.cpp:158
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
std::map< std::string, Connection > m_connections
Container of connection points.
Definition: NTupleSvc.h:128

◆ finalize()

StatusCode NTupleSvc::finalize ( )
override

DataSvc overrides: stop the service.

stop the service.

Definition at line 182 of file NTupleSvc.cpp.

182  {
183  StatusCode status = updateDirectories();
184  status = clearStore();
185  status = DataSvc::finalize();
186  status = disconnectAll();
187  return status;
188 }
StatusCode updateDirectories()
Update directory data.
Definition: NTupleSvc.cpp:108
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
StatusCode finalize() override
Service initialization.
Definition: DataSvc.cpp:855
StatusCode disconnectAll() override
Close all open connections.
Definition: NTupleSvc.cpp:175
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
Definition: DataSvc.cpp:111

◆ getDataLoader()

IConversionSvc * NTupleSvc::getDataLoader ( IRegistry pReg)
overridevirtual

DataSvc overrides: Retrieve data loader.

DataSvc override: Retrieve data loader.

Reimplemented from DataSvc.

Definition at line 98 of file NTupleSvc.cpp.

98  {
99  if ( !pRegistry ) return nullptr;
100  std::string full = pRegistry->identifier();
101  auto len = m_rootName.length();
102  auto idx = full.find( SEPARATOR, len + 1 );
103  std::string path = ( idx == std::string::npos ) ? full : full.substr( 0, idx );
104  auto i = m_connections.find( path );
105  return ( i != m_connections.end() ) ? i->second.service : nullptr;
106 }
constexpr char SEPARATOR
Gaudi::Property< std::string > m_rootName
Definition: DataSvc.h:62
std::map< std::string, Connection > m_connections
Container of connection points.
Definition: NTupleSvc.h:128
STL class.

◆ initialize()

StatusCode NTupleSvc::initialize ( )
override

DataSvc overrides: Initialize the service.

Definition at line 67 of file NTupleSvc.cpp.

67  {
69  if ( status.isSuccess() ) {
70  status = setProperties();
71  if ( status.isSuccess() ) {
72  StatusCode iret( StatusCode::SUCCESS, true );
74  status = setRoot( m_rootName, root );
75  for ( auto& i : m_output ) {
76  iret = connect( i );
77  if ( !iret.isSuccess() ) status = iret;
78  }
79  for ( auto& j : m_input ) {
80  iret = connect( j );
81  if ( !iret.isSuccess() ) status = iret;
82  }
83  }
84  }
85  return status;
86 }
StatusCode setRoot(std::string root_name, DataObject *pRootObj) override
Initialize data store for new event by giving new event path and root object.
Definition: DataSvc.cpp:142
Gaudi::Property< std::string > m_rootName
Definition: DataSvc.h:62
constexpr static const auto SUCCESS
Definition: StatusCode.h:96
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
Gaudi::Property< DBaseEntries > m_output
Definition: NTupleSvc.h:125
bool isSuccess() const
Definition: StatusCode.h:361
StatusCode setProperties()
Method for setting declared properties to the values specified for the job.
Definition: Service.cpp:290
StatusCode initialize() override
Service initialization.
Definition: DataSvc.cpp:822
Gaudi::Property< DBaseEntries > m_input
Definition: NTupleSvc.h:124
StatusCode connect(const std::string &ident) override
Add file to list I/O list.
Definition: NTupleSvc.cpp:190
Small class representing an N tuple directory in the transient store.
Definition: NTuple.h:911
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40

◆ isConnected()

bool NTupleSvc::isConnected ( const std::string identifier) const
override

Check if a datasource is connected.

Definition at line 92 of file NTupleSvc.cpp.

92  {
93  auto i = m_connections.find( identifier );
94  return i != m_connections.end();
95 }
std::map< std::string, Connection > m_connections
Container of connection points.
Definition: NTupleSvc.h:128

◆ readRecord() [1/3]

StatusCode NTupleSvc::readRecord ( NTuple::Tuple tuple)
override

Read single record from N tuple.

Definition at line 570 of file NTupleSvc.cpp.

570  {
571  StatusCode status = Status::INVALID_OBJECT;
572  NTuple::TupleImp* tuple = (NTuple::TupleImp*)n_tuple;
573  if ( tuple ) {
574  try {
575  IConversionSvc* pSvc = tuple->conversionService();
576  if ( !pSvc ) {
577  pSvc = getDataLoader( n_tuple->registry() );
578  tuple->setConversionService( pSvc );
579  }
580  if ( pSvc ) {
581  IRegistry* pReg = n_tuple->registry();
582  IOpaqueAddress* pAddr = pReg->address();
583  status = pSvc->updateObj( pAddr, n_tuple );
584  if ( status.isSuccess() ) { status = pSvc->updateObjRefs( pAddr, n_tuple ); }
585  return status;
586  }
587  status = Status::NO_DATA_LOADER;
588  } catch ( ... ) { status = Status::INVALID_OBJECT; }
589  }
590  return status;
591 }
IConversionSvc * conversionService() const
Access conversion service.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
bool isSuccess() const
Definition: StatusCode.h:361
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
IConversionSvc * getDataLoader(IRegistry *pReg) override
DataSvc overrides: Retrieve data loader.
Definition: NTupleSvc.cpp:98
void setConversionService(IConversionSvc *svc)
Access conversion service.
Opaque address interface definition.

◆ readRecord() [2/3]

StatusCode NTupleSvc::readRecord ( const std::string fullPath)
override

Read single record from N tuple.

Definition at line 594 of file NTupleSvc.cpp.

594  {
595  NTuple::Tuple* pObj = nullptr;
596  StatusCode status = findObject( fullPath, *pp_cast<DataObject>( &pObj ) ); // Check if object is present
597  return status.isSuccess() ? readRecord( pObj ) : Status::INVALID_OBJ_PATH;
598 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
StatusCode readRecord(NTuple::Tuple *tuple) override
Read single record from N tuple.
Definition: NTupleSvc.cpp:570
bool isSuccess() const
Definition: StatusCode.h:361
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:385
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Definition: DataSvc.cpp:650

◆ readRecord() [3/3]

StatusCode NTupleSvc::readRecord ( DataObject pParent,
const std::string relPath 
)
override

Read single record from N tuple.

Definition at line 601 of file NTupleSvc.cpp.

601  {
602  NTuple::Tuple* pObj = nullptr;
603  StatusCode status = findObject( pParent, relPath, *pp_cast<DataObject>( &pObj ) ); // Check if object is present
604  return status.isSuccess() ? readRecord( pObj ) : Status::INVALID_OBJ_PATH;
605 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
StatusCode readRecord(NTuple::Tuple *tuple) override
Read single record from N tuple.
Definition: NTupleSvc.cpp:570
bool isSuccess() const
Definition: StatusCode.h:361
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:385
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Definition: DataSvc.cpp:650

◆ reinitialize()

StatusCode NTupleSvc::reinitialize ( )
override

DataSvc overrides: reinitialize service.

Initialize the service.

Definition at line 89 of file NTupleSvc.cpp.

89 { return StatusCode::SUCCESS; }
constexpr static const auto SUCCESS
Definition: StatusCode.h:96

◆ releaseConnection()

void NTupleSvc::releaseConnection ( Connection c)
protected

Finalize single service.

Definition at line 158 of file NTupleSvc.cpp.

158  {
159  SmartIF<IService> isvc( c.service );
160  if ( isvc ) isvc->finalize().ignore();
161  c.service->release();
162  c.service = nullptr;
163 }

◆ save() [1/3]

StatusCode NTupleSvc::save ( const std::string fullPath)
override

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

Definition at line 497 of file NTupleSvc.cpp.

497  {
498  NTuple::Tuple* pObj = nullptr;
499  StatusCode status = findObject( fullPath, *pp_cast<DataObject>( &pObj ) ); // Check if object is present
500  return status.isSuccess() ? save( pObj ) : Status::INVALID_OBJ_PATH;
501 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isSuccess() const
Definition: StatusCode.h:361
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:385
StatusCode save(const std::string &fullPath) override
Save N tuple to disk. Must be called in order to close the ntuple file properly.
Definition: NTupleSvc.cpp:497
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Definition: DataSvc.cpp:650

◆ save() [2/3]

StatusCode NTupleSvc::save ( NTuple::Tuple tuple)
override

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

Definition at line 504 of file NTupleSvc.cpp.

504  {
505  NTuple::TupleImp* tuple = (NTuple::TupleImp*)n_tuple;
506  if ( tuple ) {
507  try {
508  IConversionSvc* pSvc = tuple->conversionService();
509  IRegistry* pReg = tuple->registry();
510  if ( pSvc && pReg ) {
511  IOpaqueAddress* pAddr = pReg->address();
512  StatusCode sc = pSvc->updateRep( pAddr, n_tuple );
513  if ( sc.isSuccess() ) sc = pSvc->updateRepRefs( pAddr, n_tuple );
514  return sc;
515  }
516  return Status::NO_DATA_LOADER;
517  } catch ( ... ) {}
518  }
519  return Status::INVALID_OBJECT;
520 }
IRegistry * registry() const
Get pointer to Registry.
Definition: DataObject.h:82
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an already converted object.
IConversionSvc * conversionService() const
Access conversion service.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the converted representation of a transient object.
bool isSuccess() const
Definition: StatusCode.h:361
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
Opaque address interface definition.

◆ save() [3/3]

StatusCode NTupleSvc::save ( DataObject pParent,
const std::string relPath 
)
override

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

Definition at line 523 of file NTupleSvc.cpp.

523  {
524  NTuple::Tuple* pObj = nullptr;
525  StatusCode status = findObject( pParent, relPath, *pp_cast<DataObject>( &pObj ) ); // Check if object is present
526  return status.isSuccess() ? save( pObj ) : Status::INVALID_OBJ_PATH;
527 }
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isSuccess() const
Definition: StatusCode.h:361
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:385
StatusCode save(const std::string &fullPath) override
Save N tuple to disk. Must be called in order to close the ntuple file properly.
Definition: NTupleSvc.cpp:497
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Definition: DataSvc.cpp:650

◆ updateDirectories()

StatusCode NTupleSvc::updateDirectories ( )
protected

Update directory data.

Definition at line 108 of file NTupleSvc.cpp.

108  {
109  long need_update = 0;
110  DataObject* pO = nullptr;
111  StatusCode iret = findObject( m_rootName.value(), pO );
112  // debug() << "in finalize()" << endmsg;
113  if ( iret.isSuccess() ) {
115  iret = objectLeaves( pO, leaves );
116  if ( iret.isSuccess() ) {
117  // Only traverse the tree below the files
118  for ( auto d = leaves.begin(); d != leaves.end(); d++ ) {
119  if ( !( *d )->object() ) continue;
120  IOpaqueAddress* pA = ( *d )->address();
121  if ( !pA ) continue;
122  unsigned long typ = pA->ipar()[1];
123  if ( typ != 'R' && typ != 'N' && typ != 'U' ) continue;
124  // ...starting from the file entries: first save the directories/ntuples
125  IConversionSvc* svc = getDataLoader( *d );
126  if ( !svc ) continue;
127 
129  IDataManagerSvc::traverseSubTree( ( *d )->object(), [&sel]( IRegistry* r, int ) {
130  DataObject* obj = r->object();
131  if ( obj ) sel.push_back( obj );
132  return true;
133  } ).ignore();
134  for ( DataObject* o : reverse( sel ) ) {
135  IRegistry* r = o->registry();
136  auto status = svc->updateRep( r->address(), o );
137  if ( !status.isSuccess() ) iret = status;
138  }
139  for ( DataObject* o : reverse( sel ) ) {
140  IRegistry* r = o->registry();
141  auto status = svc->updateRepRefs( r->address(), o );
142  if ( !status.isSuccess() ) iret = status;
143  }
144 
145  if ( iret.isSuccess() ) need_update += sel.size();
146  }
147  }
148  }
149  if ( !iret.isSuccess() ) {
150  error() << "ERROR while saving NTuples" << endmsg;
151  return iret;
152  }
153  if ( need_update > 0 ) { info() << "NTuples saved successfully" << endmsg; }
154  return iret;
155 }
virtual StatusCode traverseSubTree(std::string_view sub_tree_path, IDataStoreAgent *pAgent)=0
Analyse by traversing all data objects below the sub tree identified by its full path name.
::details::reverse_wrapper< T > reverse(T &&iterable)
Definition: reverse.h:59
Gaudi::Property< std::string > m_rootName
Definition: DataSvc.h:62
T end(T... args)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an already converted object.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves) override
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
Definition: DataSvc.cpp:208
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the converted representation of a transient object.
bool isSuccess() const
Definition: StatusCode.h:361
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual DataObject * object() const =0
Retrieve object behind the link.
IConversionSvc * getDataLoader(IRegistry *pReg) override
DataSvc overrides: Retrieve data loader.
Definition: NTupleSvc.cpp:98
T begin(T... args)
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Definition: DataSvc.cpp:650
Opaque address interface definition.
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:40
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:202

◆ writeRecord() [1/3]

StatusCode NTupleSvc::writeRecord ( NTuple::Tuple tuple)
override

Write single record to N tuple.

Definition at line 530 of file NTupleSvc.cpp.

530  {
531  NTuple::TupleImp* tuple = (NTuple::TupleImp*)n_tuple;
532  if ( tuple ) {
533  try {
534  IConversionSvc* pSvc = tuple->conversionService();
535  if ( !pSvc ) {
536  pSvc = getDataLoader( n_tuple->registry() );
537  tuple->setConversionService( pSvc );
538  }
539  if ( pSvc ) {
540  IRegistry* pReg = n_tuple->registry();
541  IOpaqueAddress* pAddr = pReg->address();
542  StatusCode status = pSvc->createRep( n_tuple, pAddr );
543  if ( status.isSuccess() ) {
544  pReg->setAddress( pAddr );
545  status = pSvc->fillRepRefs( pAddr, n_tuple );
546  }
547  return status;
548  }
549  return Status::NO_DATA_LOADER;
550  } catch ( ... ) {}
551  }
552  return Status::INVALID_OBJECT;
553 }
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
IConversionSvc * conversionService() const
Access conversion service.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:32
bool isSuccess() const
Definition: StatusCode.h:361
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
IConversionSvc * getDataLoader(IRegistry *pReg) override
DataSvc overrides: Retrieve data loader.
Definition: NTupleSvc.cpp:98
virtual void setAddress(IOpaqueAddress *pAddress)=0
Set/Update Opaque storage address.
void setConversionService(IConversionSvc *svc)
Access conversion service.
Opaque address interface definition.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.

◆ writeRecord() [2/3]

StatusCode NTupleSvc::writeRecord ( const std::string fullPath)
override

Write single record to N tuple.

Definition at line 556 of file NTupleSvc.cpp.

556  {
557  NTuple::Tuple* pObj = nullptr;
558  StatusCode status = findObject( fullPath, *pp_cast<DataObject>( &pObj ) ); // Check if object is present
559  return status.isSuccess() ? writeRecord( pObj ) : Status::INVALID_OBJ_PATH;
560 }
StatusCode writeRecord(NTuple::Tuple *tuple) override
Write single record to N tuple.
Definition: NTupleSvc.cpp:530
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isSuccess() const
Definition: StatusCode.h:361
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:385
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Definition: DataSvc.cpp:650

◆ writeRecord() [3/3]

StatusCode NTupleSvc::writeRecord ( DataObject pParent,
const std::string relPath 
)
override

Write single record to N tuple.

Definition at line 563 of file NTupleSvc.cpp.

563  {
564  NTuple::Tuple* pObj = nullptr;
565  StatusCode status = findObject( pParent, relPath, *pp_cast<DataObject>( &pObj ) ); // Check if object is present
566  return status.isSuccess() ? writeRecord( pObj ) : Status::INVALID_OBJ_PATH;
567 }
StatusCode writeRecord(NTuple::Tuple *tuple) override
Write single record to N tuple.
Definition: NTupleSvc.cpp:530
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
bool isSuccess() const
Definition: StatusCode.h:361
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:385
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
Definition: DataSvc.cpp:650

Member Data Documentation

◆ m_connections

std::map<std::string, Connection> NTupleSvc::m_connections
protected

Container of connection points.

Definition at line 128 of file NTupleSvc.h.

◆ m_input

Gaudi::Property<DBaseEntries> NTupleSvc::m_input {this, "Input", {}, "input streams"}
protected

Definition at line 124 of file NTupleSvc.h.

◆ m_output

Gaudi::Property<DBaseEntries> NTupleSvc::m_output {this, "Output", {}, "output streams"}
protected

Definition at line 125 of file NTupleSvc.h.


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