The Gaudi Framework  master (37c0b60a)
NTupleSvc.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 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;
101 
103  StatusCode connect( const std::string& ident ) override;
105  StatusCode connect( const std::string& ident, std::string& logname ) override;
107  StatusCode disconnect( const std::string& nam ) override;
109  StatusCode disconnectAll() override;
110 
112  NTupleSvc( const std::string& name, ISvcLocator* svc );
113 
114 protected:
116  StatusCode createService( const std::string& nam, const std::string& typ, const std::vector<Prop>& props,
117  IConversionSvc*& pSvc );
119  void releaseConnection( Connection& c );
121  StatusCode attachTuple( const std::string& filename, const std::string& logname, const char typ, const long t );
124 
125  Gaudi::Property<DBaseEntries> m_input{ this, "Input", {}, "input streams" };
126  Gaudi::Property<DBaseEntries> m_output{ this, "Output", {}, "output streams" };
127 
128  Gaudi::Property<int> m_basketsize{ this, "BasketSize", 32000, "BasketSize" }; // ROOT default
131 };
132 
133 #endif // GAUDI_NTUPLESVC_H
NTupleSvc
Definition: NTupleSvc.h:33
NTupleSvc::m_connections
std::map< std::string, Connection > m_connections
Container of connection points.
Definition: NTupleSvc.h:130
NTupleSvc::createDirectory
NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title) override
Create Ntuple directory and register it with the data store.
Definition: NTupleSvc.cpp:400
NTupleSvc::attachTuple
StatusCode attachTuple(const std::string &filename, const std::string &logname, const char typ, const long t)
Attach output/input file.
Definition: NTupleSvc.cpp:433
std::string
STL class.
NTupleSvc::writeRecord
StatusCode writeRecord(NTuple::Tuple *tuple) override
Write single record to N tuple.
Definition: NTupleSvc.cpp:527
NTuple::Directory
Small class representing an N tuple directory in the transient store.
Definition: NTuple.h:914
NTupleSvc::updateDirectories
StatusCode updateDirectories()
Update directory data.
Definition: NTupleSvc.cpp:105
std::pair< std::string, std::string >
NTupleSvc::Connection::service
IConversionSvc * service
Definition: NTupleSvc.h:36
gaudirun.s
string s
Definition: gaudirun.py:346
std::vector< std::string >
check_ParticleID.props
props
Definition: check_ParticleID.py:21
ISvcLocator
Definition: ISvcLocator.h:46
NTupleSvc::Prop
std::pair< std::string, std::string > Prop
Definition: NTupleSvc.h:41
NTupleSvc::reinitialize
StatusCode reinitialize() override
DataSvc overrides: reinitialize service.
Definition: NTupleSvc.cpp:86
NTupleSvc::book
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:327
NTupleSvc::DBaseEntries
std::vector< std::string > DBaseEntries
Definition: NTupleSvc.h:40
NTupleSvc::m_output
Gaudi::Property< DBaseEntries > m_output
Definition: NTupleSvc.h:126
gaudirun.c
c
Definition: gaudirun.py:525
IRegistry
Definition: IRegistry.h:32
NTupleSvc::Connection::Connection
Connection(const Connection &c)
Definition: NTupleSvc.h:38
bug_34121.t
t
Definition: bug_34121.py:31
IDataSourceMgr.h
NTupleSvc::connect
StatusCode connect(const std::string &ident) override
Add file to list I/O list.
Definition: NTupleSvc.cpp:187
Service::name
const std::string & name() const override
Retrieve name of the service
Definition: Service.cpp:332
StatusCode
Definition: StatusCode.h:65
NTupleSvc::finalize
StatusCode finalize() override
DataSvc overrides: stop the service.
Definition: NTupleSvc.cpp:179
NTupleSvc::access
NTuple::Tuple * access(const std::string &fullPath, const std::string &filename) override
Access N tuple on disk.
Definition: NTupleSvc.cpp:491
NTupleSvc::m_input
Gaudi::Property< DBaseEntries > m_input
Definition: NTupleSvc.h:125
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
std::map
STL class.
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:20
NTupleSvc::create
StatusCode create(const CLID &typ, const std::string &title, NTuple::Tuple *&refpTuple) override
Create requested N tuple (Hide constructor)
Definition: NTupleSvc.cpp:308
NTupleSvc::Connection
Definition: NTupleSvc.h:35
NTupleSvc::releaseConnection
void releaseConnection(Connection &c)
Finalize single service.
Definition: NTupleSvc.cpp:155
NTupleSvc::disconnect
StatusCode disconnect(const std::string &nam) override
Close open connection.
Definition: NTupleSvc.cpp:163
gaudirun.type
type
Definition: gaudirun.py:160
NTupleSvc::isConnected
bool isConnected(const std::string &identifier) const override
Check if a datasource is connected.
Definition: NTupleSvc.cpp:89
NTupleSvc::createService
StatusCode createService(const std::string &nam, const std::string &typ, const std::vector< Prop > &props, IConversionSvc *&pSvc)
Create conversion service.
Definition: NTupleSvc.cpp:255
NTuple::Tuple
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition: NTuple.h:388
NTupleSvc::disconnectAll
StatusCode disconnectAll() override
Close all open connections.
Definition: NTupleSvc.cpp:172
DataObject
Definition: DataObject.h:36
GaudiConfig2.semantics.ident
ident
Definition: semantics.py:198
NTupleSvc::Connection::Connection
Connection(IConversionSvc *s)
Definition: NTupleSvc.h:37
NTupleSvc::NTupleSvc
NTupleSvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
Definition: NTupleSvc.cpp:61
NTupleSvc::initialize
StatusCode initialize() override
DataSvc overrides: Initialize the service.
Definition: NTupleSvc.cpp:67
NTupleSvc::readRecord
StatusCode readRecord(NTuple::Tuple *tuple) override
Read single record from N tuple.
Definition: NTupleSvc.cpp:567
NTupleSvc::getDataLoader
IConversionSvc * getDataLoader(IRegistry *pReg) override
DataSvc overrides: Retrieve data loader.
Definition: NTupleSvc.cpp:95
graphanalysis.filename
filename
Definition: graphanalysis.py:130
DataSvc.h
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:37
INTupleSvc.h
NTupleSvc::save
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:494
NTupleSvc::m_basketsize
Gaudi::Property< int > m_basketsize
Definition: NTupleSvc.h:128
IConversionSvc
Definition: IConversionSvc.h:47