The Gaudi Framework  v33r1 (b1225454)
NTupleSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2019 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 #ifndef GAUDI_NTUPLESVC_H
12 #define GAUDI_NTUPLESVC_H 1
13 
14 // Framework include files
15 #include "GaudiKernel/DataSvc.h"
17 #include "GaudiKernel/INTupleSvc.h"
18 
19 // STL include files
20 #include <map>
21 
33 class NTupleSvc : public extends<DataSvc, INTupleSvc, IDataSourceMgr> {
34 protected:
35  struct Connection final {
38  Connection( const Connection& c ) : service( c.service ) {}
39  };
42 
43 public:
45  StatusCode initialize() override;
47  StatusCode reinitialize() override;
49  StatusCode finalize() override;
51  IConversionSvc* getDataLoader( IRegistry* pReg ) override;
52 
54  NTuple::Directory* createDirectory( DataObject* pParent, const std::string& title ) override;
56  NTuple::Directory* createDirectory( DataObject* pParent, long id ) override;
58  NTuple::Directory* createDirectory( const std::string& dirPath, long id ) override;
60  NTuple::Directory* createDirectory( const std::string& dirPath, const std::string& title ) override;
62  NTuple::Directory* createDirectory( const std::string& fullPath ) override;
63 
65  StatusCode create( const CLID& typ, const std::string& title, NTuple::Tuple*& refpTuple ) override;
67  NTuple::Tuple* book( const std::string& fullPath, const CLID& type, const std::string& title ) override;
69  NTuple::Tuple* book( const std::string& dirPath, const std::string& relPath, const CLID& type,
70  const std::string& title ) override;
72  NTuple::Tuple* book( const std::string& dirPath, long id, const CLID& type, const std::string& title ) override;
74  NTuple::Tuple* book( DataObject* pParent, const std::string& relPath, const CLID& type,
75  const std::string& title ) override;
77  NTuple::Tuple* book( DataObject* pParent, long id, const CLID& type, const std::string& title ) override;
79  NTuple::Tuple* access( const std::string& fullPath, const std::string& filename ) override;
81  StatusCode save( const std::string& fullPath ) override;
83  StatusCode save( NTuple::Tuple* tuple ) override;
85  StatusCode save( DataObject* pParent, const std::string& relPath ) override;
87  StatusCode writeRecord( NTuple::Tuple* tuple ) override;
89  StatusCode writeRecord( const std::string& fullPath ) override;
91  StatusCode writeRecord( DataObject* pParent, const std::string& relPath ) override;
93  StatusCode readRecord( NTuple::Tuple* tuple ) override;
95  StatusCode readRecord( const std::string& fullPath ) override;
97  StatusCode readRecord( DataObject* pParent, const std::string& relPath ) override;
98 
100  bool isConnected( const std::string& identifier ) const override;
102  StatusCode connect( const std::string& ident ) override;
104  StatusCode connect( const std::string& ident, std::string& logname ) override;
106  StatusCode disconnect( const std::string& nam ) override;
108  StatusCode disconnectAll() override;
109 
111  NTupleSvc( const std::string& name, ISvcLocator* svc );
112 
113 protected:
115  StatusCode createService( const std::string& nam, const std::string& typ, const std::vector<Prop>& props,
116  IConversionSvc*& pSvc );
118  void releaseConnection( Connection& c );
120  StatusCode attachTuple( const std::string& filename, const std::string& logname, const char typ, const long t );
123 
124  Gaudi::Property<DBaseEntries> m_input{this, "Input", {}, "input streams"};
125  Gaudi::Property<DBaseEntries> m_output{this, "Output", {}, "output streams"};
126 
129 };
130 
131 #endif // GAUDI_NTUPLESVC_H
void releaseConnection(Connection &c)
Finalize single service.
Definition: NTupleSvc.cpp:158
std::vector< std::string > DBaseEntries
Definition: NTupleSvc.h:40
StatusCode writeRecord(NTuple::Tuple *tuple) override
Write single record to N tuple.
Definition: NTupleSvc.cpp:530
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:35
Implementation of property with value of concrete type.
Definition: Property.h:370
StatusCode initialize() override
DataSvc overrides: Initialize the service.
Definition: NTupleSvc.cpp:67
bool isConnected(const std::string &identifier) const override
Check if a datasource is connected.
Definition: NTupleSvc.cpp:92
StatusCode reinitialize() override
DataSvc overrides: reinitialize service.
Definition: NTupleSvc.cpp:89
std::map< std::string, Connection > m_connections
Container of connection points.
Definition: NTupleSvc.h:128
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
NTuple::Tuple * access(const std::string &fullPath, const std::string &filename) override
Access N tuple on disk.
Definition: NTupleSvc.cpp:494
Connection(IConversionSvc *s)
Definition: NTupleSvc.h:37
StatusCode disconnect(const std::string &nam) override
Close open connection.
Definition: NTupleSvc.cpp:166
STL class.
StatusCode updateDirectories()
Update directory data.
Definition: NTupleSvc.cpp:108
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
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:61
std::pair< std::string, std::string > Prop
Definition: NTupleSvc.h:41
IConversionSvc * service
Definition: NTupleSvc.h:36
StatusCode readRecord(NTuple::Tuple *tuple) override
Read single record from N tuple.
Definition: NTupleSvc.cpp:570
NTupleSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: NTupleSvc.cpp:61
Gaudi::Property< DBaseEntries > m_output
Definition: NTupleSvc.h:125
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
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:385
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:98
NTuple service.
Definition: NTupleSvc.h:33
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
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
string s
Definition: gaudirun.py:328
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
StatusCode create(const CLID &typ, const std::string &title, NTuple::Tuple *&refpTuple) override
Create requested N tuple (Hide constructor)
Definition: NTupleSvc.cpp:311
Small class representing an N tuple directory in the transient store.
Definition: NTuple.h:911
StatusCode disconnectAll() override
Close all open connections.
Definition: NTupleSvc.cpp:175
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
Connection(const Connection &c)
Definition: NTupleSvc.h:38