The Gaudi Framework  master (82fdf313)
Loading...
Searching...
No Matches
NTupleSvc.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 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#pragma once
12
13// Framework include files
14#include <GaudiKernel/DataSvc.h>
17
18// STL include files
19#include <map>
20
32class NTupleSvc : public extends<DataSvc, INTupleSvc, IDataSourceMgr> {
33protected:
34 struct Connection final {
37 Connection( const Connection& c ) : service( c.service ) {}
38 };
39 typedef std::vector<std::string> DBaseEntries;
40 typedef std::pair<std::string, std::string> Prop;
41
42public:
44 StatusCode initialize() override;
46 StatusCode reinitialize() override;
48 StatusCode finalize() override;
50 IConversionSvc* getDataLoader( IRegistry* pReg ) override;
51
53 NTuple::Directory* createDirectory( DataObject* pParent, const std::string& title ) override;
55 NTuple::Directory* createDirectory( DataObject* pParent, long id ) override;
57 NTuple::Directory* createDirectory( const std::string& dirPath, long id ) override;
59 NTuple::Directory* createDirectory( const std::string& dirPath, const std::string& title ) override;
61 NTuple::Directory* createDirectory( const std::string& fullPath ) override;
62
64 StatusCode create( const CLID& typ, const std::string& title, NTuple::Tuple*& refpTuple ) override;
66 NTuple::Tuple* book( const std::string& fullPath, const CLID& type, const std::string& title ) override;
68 NTuple::Tuple* book( const std::string& dirPath, const std::string& relPath, const CLID& type,
69 const std::string& title ) override;
71 NTuple::Tuple* book( const std::string& dirPath, long id, const CLID& type, const std::string& title ) override;
73 NTuple::Tuple* book( DataObject* pParent, const std::string& relPath, const CLID& type,
74 const std::string& title ) override;
76 NTuple::Tuple* book( DataObject* pParent, long id, const CLID& type, const std::string& title ) override;
78 NTuple::Tuple* access( const std::string& fullPath, const std::string& filename ) override;
80 StatusCode save( const std::string& fullPath ) override;
82 StatusCode save( NTuple::Tuple* tuple ) override;
84 StatusCode save( DataObject* pParent, const std::string& relPath ) override;
86 StatusCode writeRecord( NTuple::Tuple* tuple ) override;
88 StatusCode writeRecord( const std::string& fullPath ) override;
90 StatusCode writeRecord( DataObject* pParent, const std::string& relPath ) override;
92 StatusCode readRecord( NTuple::Tuple* tuple ) override;
94 StatusCode readRecord( const std::string& fullPath ) override;
96 StatusCode readRecord( DataObject* pParent, const std::string& relPath ) override;
97
99 bool isConnected( const std::string& identifier ) const override;
100
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
113protected:
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
127 Gaudi::Property<int> m_basketsize{ this, "BasketSize", 32000, "BasketSize" }; // ROOT default
129 std::map<std::string, Connection> m_connections;
130};
unsigned int CLID
Class ID definition.
Definition ClassID.h:16
A DataObject is the base class of any identifiable object on any data store.
Definition DataObject.h:37
Implementation of property with value of concrete type.
Definition PropertyFwd.h:27
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition IRegistry.h:29
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition ISvcLocator.h:42
Abstract base class which allows the user to interact with the actual N tuple implementation.
Definition NTuple.h:380
NTuple::Directory * createDirectory(DataObject *pParent, const std::string &title) override
Create Ntuple directory and register it with the data store.
Gaudi::Property< int > m_basketsize
Definition NTupleSvc.h:127
Gaudi::Property< DBaseEntries > m_output
Definition NTupleSvc.h:125
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:89
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.
Definition NTupleSvc.cpp:61
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
Definition NTupleSvc.h:124
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.
std::vector< std::string > DBaseEntries
Definition NTupleSvc.h:39
StatusCode reinitialize() override
DataSvc overrides: reinitialize service.
Definition NTupleSvc.cpp:86
StatusCode updateDirectories()
Update directory data.
std::pair< std::string, std::string > Prop
Definition NTupleSvc.h:40
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.
Definition NTupleSvc.cpp:95
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.
Definition NTupleSvc.h:129
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.
const std::string & name() const override
Retrieve name of the service.
Definition Service.cpp:333
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
Base class used to extend a class implementing other interfaces.
Definition extends.h:19
Small class representing an N tuple directory in the transient store.
Definition NTuple.h:906
Connection(IConversionSvc *s)
Definition NTupleSvc.h:36
Connection(const Connection &c)
Definition NTupleSvc.h:37
IConversionSvc * service
Definition NTupleSvc.h:35