32#define GAUDISVC_NTUPLESVC_CPP
96 if ( !pRegistry )
return nullptr;
99 auto idx = full.find( SEPARATOR, len + 1 );
100 std::string path = ( idx == std::string::npos ) ? full : full.substr( 0, idx );
106 long need_update = 0;
111 std::vector<IRegistry*> leaves;
115 for (
auto d = leaves.begin(); d != leaves.end(); d++ ) {
116 if ( !( *d )->object() )
continue;
119 unsigned long typ = pA->
ipar()[1];
120 if ( typ !=
'R' && typ !=
'N' && typ !=
'U' )
continue;
123 if ( !svc )
continue;
127 DataObject* obj = r->object();
128 if ( obj ) sel.push_back( obj );
134 if ( !status.isSuccess() ) iret = status;
139 if ( !status.isSuccess() ) iret = status;
142 if ( iret.
isSuccess() ) need_update += sel.size();
150 if ( need_update > 0 ) {
info() <<
"NTuples saved successfully" <<
endmsg; }
157 if ( isvc ) isvc->finalize().ignore();
158 c.service->release();
189 return connect( ident, logName );
197 std::vector<Prop> props;
198 long loc = ident.find(
" " );
199 std::string filename, auth, svc =
"", db_typ =
"";
200 logname = ident.substr( 0, loc );
204 for (
auto attrib : Parser( ident.substr( loc + 1 ) ) ) {
210 filename = std::move( attrib.value );
213 switch (
::toupper( attrib.value[0] ) ) {
232 db_typ = std::move( attrib.value );
235 props.emplace_back( attrib.tag, attrib.value );
251 error() <<
"Cannot add " << ident <<
" invalid filename!" <<
endmsg;
267 StatusCode sts = appPropMgr->getProperty( &sp );
269 error() <<
"Could not get NTuple Persistency format"
270 <<
" from ApplicationMgr properties" <<
endmsg;
275 if ( sp.value() ==
"HBOOK" ) {
277 }
else if ( sp.value() ==
"ROOT" ) {
280 error() <<
"Unknown NTuple Persistency format: " << sp.value() <<
endmsg;
284 if ( !typ.empty() && typ != sp.value() ) {
285 warning() <<
"NTuple persistency type is " << sp.value() <<
"." <<
endmsg <<
"Type given by job option "
286 <<
"NTupleSvc.Input/Output ignored!" <<
endmsg;
302 auto status = pService->sysInitialize();
303 if ( !status.isSuccess() )
return status;
311 if ( typ == CLID_ColumnWiseTuple ) {
313 }
else if ( typ == CLID_RowWiseTuple ) {
329 std::string path = fullPath;
330 assert( !path.empty() );
331 if ( path[0] != SEPARATOR ) {
338 error() <<
"Cannot book N-tuple " << path <<
" (Exists already)" <<
endmsg;
341 auto sep = path.rfind( SEPARATOR );
342 if ( sep == std::string::npos ) {
343 error() <<
"Cannot book N-tuple " << path <<
" (Invalid path)" <<
endmsg;
347 std::string p_path( path, 0, sep );
348 std::string o_path( path, sep, path.length() );
351 error() <<
"Cannot book N-tuple " << path <<
" (Invalid parent directory)" <<
endmsg;
356 if ( !tup ) {
error() <<
"Cannot book N-tuple " << path <<
" (Unknown reason)" <<
endmsg; }
362 const std::string& title ) {
363 std::string full = dirPath;
364 assert( !relPath.empty() );
365 if ( relPath[0] != SEPARATOR ) full += SEPARATOR;
367 return book( full, type, title );
372 return book( dirPath, std::to_string(
id ), type, title );
377 const std::string& title ) {
383 status =
create( type, title, pObj );
396 return book( pParent, std::to_string(
id ), type, title );
401 assert( !relPath.empty() );
406 if ( relPath[0] !=
'/' ) full +=
"/";
426 assert( !relPath.empty() );
427 std::string full = dirPath;
428 if ( relPath[0] !=
'/' ) full +=
"/";
442 entryname += logname;
446 info() <<
"Added stream file:" << filename <<
" as " << logname <<
endmsg;
451 error() <<
"Cannot add file:" << filename <<
" as " << logname <<
endmsg;
460 auto sep2 = fullPath.rfind( SEPARATOR );
461 if ( sep2 != std::string::npos ) {
462 std::string relPath = fullPath.substr( 0, sep2 );
497 return status.
isSuccess() ?
save( pObj ) : Status::INVALID_OBJ_PATH;
507 if ( pSvc && pReg ) {
513 return Status::NO_DATA_LOADER;
516 return Status::INVALID_OBJECT;
523 return status.
isSuccess() ?
save( pObj ) : Status::INVALID_OBJ_PATH;
546 return Status::NO_DATA_LOADER;
549 return Status::INVALID_OBJECT;
580 status = pSvc->
updateObj( pAddr, n_tuple );
584 status = Status::NO_DATA_LOADER;
585 }
catch ( ... ) { status = Status::INVALID_OBJECT; }
const long HBOOK_StorageType
unsigned int CLID
Class ID definition.
const long TEST_StorageType
const long ROOT_StorageType
void toupper(std::string &s)
std::vector< DataObject * > IDataSelector
This is only a placeholder to allow me compiling until the responsible guy does his work!
DEST ** pp_cast(SRC **ptr)
Small function to be used instead of the construct (void**)&pointer, which produces,...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
#define DECLARE_NAMESPACE_OBJECT_FACTORY(n, x)
#define DECLARE_COMPONENT(type)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
Base class for all conversion services.
A DataObject is the base class of any identifiable object on any data store.
IRegistry * registry() const
Get pointer to Registry.
virtual unsigned long release()
release reference to object
StatusCode setRoot(std::string root_name, DataObject *pRootObj) override
Initialize data store for new event by giving new event path and root object.
StatusCode finalize() override
Service initialization.
Gaudi::Property< std::string > m_rootName
StatusCode findObject(std::string_view fullPath, DataObject *&pObject) override
Find object identified by its full path in the data store.
StatusCode objectLeaves(const DataObject *pObject, std::vector< IRegistry * > &refLeaves) override
IDataManagerSvc: Explore the object store: retrieve all leaves attached to the object.
StatusCode initialize() override
Service initialization.
StatusCode unregisterObject(std::string_view fullPath) override
Unregister object from the data store.
StatusCode registerObject(std::string_view parentPath, std::string_view objPath, DataObject *pObject) override
Register object with the data store.
Gaudi::Property< CLID > m_rootCLID
StatusCode retrieveObject(IRegistry *pDirectory, std::string_view path, DataObject *&pObject) override
Retrieve object from data store.
StatusCode registerAddress(std::string_view fullPath, IOpaqueAddress *pAddress) override
IDataManagerSvc: Register object address with the data store.
StatusCode clearStore() override
IDataManagerSvc: Remove all data objects in the data store.
Implementation of property with value of concrete type.
Parse attribute strings allowing iteration over the various attributes.
Generic Transient Address.
unsigned long release() override
release reference to object
virtual StatusCode updateRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an already converted object.
virtual StatusCode setDataProvider(IDataProviderSvc *pService)=0
Set Data provider service.
virtual StatusCode updateObj(IOpaqueAddress *pAddress, DataObject *refpObject)=0
Update the transient object from the other representation.
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the converted representation of a transient object.
virtual long repSvcType() const =0
Retrieve the class type of the data store the converter uses.
virtual StatusCode updateObjRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Update the references of an updated transient object.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)=0
Convert the transient object to the requested representation.
virtual StatusCode fillRepRefs(IOpaqueAddress *pAddress, DataObject *pObject)=0
Resolve the references of the converted object.
Definition of the basic interface.
virtual unsigned long addRef() const =0
Increment the reference count of Interface instance.
Opaque address interface definition.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
The IProperty is the basic interface for all components which have properties that can be set or get.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
virtual const id_type & identifier() const =0
Full identifier (or key)
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual void setAddress(IOpaqueAddress *pAddress)=0
Set/Update Opaque storage address.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Abstract base class which allows the user to interact with the actual N tuple implementation.
IConversionSvc * conversionService() const
Access conversion service.
void setTupleService(INTupleSvc *svc)
Access conversion service.
void setConversionService(IConversionSvc *svc)
Access conversion service.
NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title) override
Create Ntuple directory and register it with the data store.
Gaudi::Property< DBaseEntries > m_output
StatusCode initialize() override
DataSvc overrides: Initialize the service.
bool isConnected(const std::string &identifier) const override
Check if a datasource is connected.
NTuple::Tuple * access(const std::string &fullPath, const std::string &filename) override
Access N tuple on disk.
NTupleSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
StatusCode attachTuple(const std::string &filename, const std::string &logname, const char typ, const long t)
Attach output/input file.
StatusCode disconnect(const std::string &nam) override
Close open connection.
Gaudi::Property< DBaseEntries > m_input
StatusCode connect(const std::string &ident) override
Add file to list I/O list.
StatusCode finalize() override
DataSvc overrides: stop the service.
NTuple::Tuple * book(const std::string &fullPath, const CLID &type, const std::string &title) override
Book Ntuple and register it with the data store.
StatusCode disconnectAll() override
Close all open connections.
StatusCode reinitialize() override
DataSvc overrides: reinitialize service.
StatusCode updateDirectories()
Update directory data.
StatusCode create(const CLID &typ, const std::string &title, NTuple::Tuple *&refpTuple) override
Create requested N tuple (Hide constructor)
IConversionSvc * getDataLoader(IRegistry *pReg) override
DataSvc overrides: Retrieve data loader.
void releaseConnection(Connection &c)
Finalize single service.
StatusCode save(const std::string &fullPath) override
Save N tuple to disk. Must be called in order to close the ntuple file properly.
std::map< std::string, Connection > m_connections
Container of connection points.
StatusCode readRecord(NTuple::Tuple *tuple) override
Read single record from N tuple.
StatusCode writeRecord(NTuple::Tuple *tuple) override
Write single record to N tuple.
StatusCode createService(const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc)
Create conversion service.
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
const std::string & name() const override
Retrieve name of the service.
Small smart pointer class with automatic reference counting for IInterface.
This class is used for returning status codes from appropriate routines.
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
::details::reverse_wrapper< T > reverse(T &&iterable)
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.
Small class representing an N tuple directory in the transient store.