The Gaudi Framework  v30r3 (a5ef0a68)
NTupleSvc.h
Go to the documentation of this file.
1 #ifndef GAUDI_NTUPLESVC_H
2 #define GAUDI_NTUPLESVC_H 1
3 
4 // Framework include files
5 #include "GaudiKernel/DataSvc.h"
8 
9 // STL include files
10 #include <map>
11 
23 class NTupleSvc : public extends<DataSvc, INTupleSvc, IDataSourceMgr>
24 {
25 protected:
26  struct Connection final {
28  Connection( IConversionSvc* s ) : service( s ) {}
29  Connection( const Connection& c ) : service( c.service ) {}
30  };
34 
35 public:
37  StatusCode initialize() override;
39  StatusCode reinitialize() override;
41  StatusCode finalize() override;
43  IConversionSvc* getDataLoader( IRegistry* pReg ) override;
44 
46  NTuple::Directory* createDirectory( DataObject* pParent, const std::string& title ) override;
48  NTuple::Directory* createDirectory( DataObject* pParent, long id ) override;
50  NTuple::Directory* createDirectory( const std::string& dirPath, long id ) override;
52  NTuple::Directory* createDirectory( const std::string& dirPath, const std::string& title ) override;
54  NTuple::Directory* createDirectory( const std::string& fullPath ) override;
55 
57  StatusCode create( const CLID& typ, const std::string& title, NTuple::Tuple*& refpTuple ) override;
59  NTuple::Tuple* book( const std::string& fullPath, const CLID& type, const std::string& title ) override;
61  NTuple::Tuple* book( const std::string& dirPath, const std::string& relPath, const CLID& type,
62  const std::string& title ) override;
64  NTuple::Tuple* book( const std::string& dirPath, long id, const CLID& type, const std::string& title ) override;
66  NTuple::Tuple* book( DataObject* pParent, const std::string& relPath, const CLID& type,
67  const std::string& title ) override;
69  NTuple::Tuple* book( DataObject* pParent, long id, const CLID& type, const std::string& title ) override;
71  NTuple::Tuple* access( const std::string& fullPath, const std::string& filename ) override;
73  StatusCode save( const std::string& fullPath ) override;
75  StatusCode save( NTuple::Tuple* tuple ) override;
77  StatusCode save( DataObject* pParent, const std::string& relPath ) override;
79  StatusCode writeRecord( NTuple::Tuple* tuple ) override;
81  StatusCode writeRecord( const std::string& fullPath ) override;
83  StatusCode writeRecord( DataObject* pParent, const std::string& relPath ) override;
85  StatusCode readRecord( NTuple::Tuple* tuple ) override;
87  StatusCode readRecord( const std::string& fullPath ) override;
89  StatusCode readRecord( DataObject* pParent, const std::string& relPath ) override;
90 
92  bool isConnected( const std::string& identifier ) const override;
94  StatusCode connect( const std::string& ident ) override;
96  StatusCode connect( const std::string& ident, std::string& logname ) override;
98  StatusCode disconnect( const std::string& nam ) override;
100  StatusCode disconnectAll() override;
101 
103  NTupleSvc( const std::string& name, ISvcLocator* svc );
104 
105 protected:
107  StatusCode createService( const std::string& nam, const std::string& typ, const std::vector<Prop>& props,
108  IConversionSvc*& pSvc );
110  void releaseConnection( Connection& c );
112  StatusCode attachTuple( const std::string& filename, const std::string& logname, const char typ, const long t );
115 
116  Gaudi::Property<DBaseEntries> m_input{this, "Input", {}, "input streams"};
117  Gaudi::Property<DBaseEntries> m_output{this, "Output", {}, "output streams"};
118 
120  Connections m_connections;
121 };
122 
123 #endif // GAUDI_NTUPLESVC_H
std::map< std::string, Connection > Connections
Definition: NTupleSvc.h:32
void releaseConnection(Connection &c)
Finalize single service.
Definition: NTupleSvc.cpp:167
std::vector< std::string > DBaseEntries
Definition: NTupleSvc.h:31
StatusCode writeRecord(NTuple::Tuple *tuple) override
Write single record to N tuple.
Definition: NTupleSvc.cpp:564
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:288
Implementation of property with value of concrete type.
Definition: Property.h:381
StatusCode initialize() override
DataSvc overrides: Initialize the service.
Definition: NTupleSvc.cpp:69
StatusCode reinitialize() override
DataSvc overrides: reinitialize service.
Definition: NTupleSvc.cpp:92
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:349
NTuple::Tuple * access(const std::string &fullPath, const std::string &filename) override
Access N tuple on disk.
Definition: NTupleSvc.cpp:522
Connection(IConversionSvc *s)
Definition: NTupleSvc.h:28
StatusCode disconnect(const std::string &nam) override
Close open connection.
Definition: NTupleSvc.cpp:176
StatusCode updateDirectories()
Update directory data.
Definition: NTupleSvc.cpp:113
StatusCode createService(const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc)
Create conversion service.
Definition: NTupleSvc.cpp:275
STL class.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:51
std::pair< std::string, std::string > Prop
Definition: NTupleSvc.h:33
IConversionSvc * service
Definition: NTupleSvc.h:27
StatusCode readRecord(NTuple::Tuple *tuple) override
Read single record from N tuple.
Definition: NTupleSvc.cpp:608
NTupleSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: NTupleSvc.cpp:62
Gaudi::Property< DBaseEntries > m_output
Definition: NTupleSvc.h:117
NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title) override
Create Ntuple directory and register it with the data store.
Definition: NTupleSvc.cpp:427
bool isConnected(const std::string &identifier) const override
Check if a datasource is connected.
Definition: NTupleSvc.cpp:95
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:407
StatusCode finalize() override
DataSvc overrides: stop the service.
Definition: NTupleSvc.cpp:196
IConversionSvc * getDataLoader(IRegistry *pReg) override
DataSvc overrides: Retrieve data loader.
Definition: NTupleSvc.cpp:102
NTuple service.
Definition: NTupleSvc.h:23
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
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:525
string s
Definition: gaudirun.py:253
Gaudi::Property< DBaseEntries > m_input
Definition: NTupleSvc.h:116
StatusCode connect(const std::string &ident) override
Add file to list I/O list.
Definition: NTupleSvc.cpp:205
StatusCode create(const CLID &typ, const std::string &title, NTuple::Tuple *&refpTuple) override
Create requested N tuple (Hide constructor)
Definition: NTupleSvc.cpp:329
Small class representing an N tuple directory in the transient store.
Definition: NTuple.h:978
StatusCode disconnectAll() override
Close all open connections.
Definition: NTupleSvc.cpp:188
StatusCode attachTuple(const std::string &filename, const std::string &logname, const char typ, const long t)
Attach output/input file.
Definition: NTupleSvc.cpp:462
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
Connection(const Connection &c)
Definition: NTupleSvc.h:29
Connections m_connections
Container of connection points.
Definition: NTupleSvc.h:120