The Gaudi Framework  v30r4 (9b837755)
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  };
33 
34 public:
36  StatusCode initialize() override;
38  StatusCode reinitialize() override;
40  StatusCode finalize() override;
42  IConversionSvc* getDataLoader( IRegistry* pReg ) override;
43 
45  NTuple::Directory* createDirectory( DataObject* pParent, const std::string& title ) override;
47  NTuple::Directory* createDirectory( DataObject* pParent, long id ) override;
49  NTuple::Directory* createDirectory( const std::string& dirPath, long id ) override;
51  NTuple::Directory* createDirectory( const std::string& dirPath, const std::string& title ) override;
53  NTuple::Directory* createDirectory( const std::string& fullPath ) override;
54 
56  StatusCode create( const CLID& typ, const std::string& title, NTuple::Tuple*& refpTuple ) override;
58  NTuple::Tuple* book( const std::string& fullPath, const CLID& type, const std::string& title ) override;
60  NTuple::Tuple* book( const std::string& dirPath, const std::string& relPath, const CLID& type,
61  const std::string& title ) override;
63  NTuple::Tuple* book( const std::string& dirPath, long id, const CLID& type, const std::string& title ) override;
65  NTuple::Tuple* book( DataObject* pParent, const std::string& relPath, const CLID& type,
66  const std::string& title ) override;
68  NTuple::Tuple* book( DataObject* pParent, long id, const CLID& type, const std::string& title ) override;
70  NTuple::Tuple* access( const std::string& fullPath, const std::string& filename ) override;
72  StatusCode save( const std::string& fullPath ) override;
74  StatusCode save( NTuple::Tuple* tuple ) override;
76  StatusCode save( DataObject* pParent, const std::string& relPath ) override;
78  StatusCode writeRecord( NTuple::Tuple* tuple ) override;
80  StatusCode writeRecord( const std::string& fullPath ) override;
82  StatusCode writeRecord( DataObject* pParent, const std::string& relPath ) override;
84  StatusCode readRecord( NTuple::Tuple* tuple ) override;
86  StatusCode readRecord( const std::string& fullPath ) override;
88  StatusCode readRecord( DataObject* pParent, const std::string& relPath ) override;
89 
91  bool isConnected( const std::string& identifier ) const override;
93  StatusCode connect( const std::string& ident ) override;
95  StatusCode connect( const std::string& ident, std::string& logname ) override;
97  StatusCode disconnect( const std::string& nam ) override;
99  StatusCode disconnectAll() override;
100 
102  NTupleSvc( const std::string& name, ISvcLocator* svc );
103 
104 protected:
106  StatusCode createService( const std::string& nam, const std::string& typ, const std::vector<Prop>& props,
107  IConversionSvc*& pSvc );
109  void releaseConnection( Connection& c );
111  StatusCode attachTuple( const std::string& filename, const std::string& logname, const char typ, const long t );
114 
115  Gaudi::Property<DBaseEntries> m_input{this, "Input", {}, "input streams"};
116  Gaudi::Property<DBaseEntries> m_output{this, "Output", {}, "output streams"};
117 
120 };
121 
122 #endif // GAUDI_NTUPLESVC_H
void releaseConnection(Connection &c)
Finalize single service.
Definition: NTupleSvc.cpp:155
std::vector< std::string > DBaseEntries
Definition: NTupleSvc.h:31
StatusCode writeRecord(NTuple::Tuple *tuple) override
Write single record to N tuple.
Definition: NTupleSvc.cpp:552
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:383
StatusCode initialize() override
DataSvc overrides: Initialize the service.
Definition: NTupleSvc.cpp:58
StatusCode reinitialize() override
DataSvc overrides: reinitialize service.
Definition: NTupleSvc.cpp:81
std::map< std::string, Connection > m_connections
Container of connection points.
Definition: NTupleSvc.h:119
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:335
NTuple::Tuple * access(const std::string &fullPath, const std::string &filename) override
Access N tuple on disk.
Definition: NTupleSvc.cpp:512
Connection(IConversionSvc *s)
Definition: NTupleSvc.h:28
StatusCode disconnect(const std::string &nam) override
Close open connection.
Definition: NTupleSvc.cpp:164
STL class.
StatusCode updateDirectories()
Update directory data.
Definition: NTupleSvc.cpp:102
StatusCode createService(const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc)
Create conversion service.
Definition: NTupleSvc.cpp:261
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:32
IConversionSvc * service
Definition: NTupleSvc.h:27
StatusCode readRecord(NTuple::Tuple *tuple) override
Read single record from N tuple.
Definition: NTupleSvc.cpp:596
NTupleSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: NTupleSvc.cpp:51
Gaudi::Property< DBaseEntries > m_output
Definition: NTupleSvc.h:116
NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title) override
Create Ntuple directory and register it with the data store.
Definition: NTupleSvc.cpp:415
bool isConnected(const std::string &identifier) const override
Check if a datasource is connected.
Definition: NTupleSvc.cpp:84
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:182
IConversionSvc * getDataLoader(IRegistry *pReg) override
DataSvc overrides: Retrieve data loader.
Definition: NTupleSvc.cpp:91
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:515
string s
Definition: gaudirun.py:253
Gaudi::Property< DBaseEntries > m_input
Definition: NTupleSvc.h:115
StatusCode connect(const std::string &ident) override
Add file to list I/O list.
Definition: NTupleSvc.cpp:191
StatusCode create(const CLID &typ, const std::string &title, NTuple::Tuple *&refpTuple) override
Create requested N tuple (Hide constructor)
Definition: NTupleSvc.cpp:315
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:174
StatusCode attachTuple(const std::string &filename, const std::string &logname, const char typ, const long t)
Attach output/input file.
Definition: NTupleSvc.cpp:452
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