The Gaudi Framework  master (37c0b60a)
RootCnvSvc.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 //====================================================================
12 // RootCnvSvc definition
13 //--------------------------------------------------------------------
14 //
15 // Author : M.Frank
16 //====================================================================
17 #ifndef GAUDIROOTCNV_GAUDIROOTCNVSVC_H
18 #define GAUDIROOTCNV_GAUDIROOTCNVSVC_H
19 
20 // Framework include files
21 #include <GaudiKernel/ClassID.h>
23 #include <GaudiKernel/DataObject.h>
25 
26 // C++ include files
27 #include <set>
28 
29 // Forward declarations
30 struct IDataManagerSvc;
31 class IIncidentSvc;
32 class TClass;
33 
34 // ROOT include files
35 #include <TBranch.h>
36 #include <TClass.h>
37 #include <TROOT.h>
38 #include <TTree.h>
39 
40 // #include "RootCnv/RootPerfMonSvc.h"
41 
42 /*
43  * Gaudi namespace declaration
44  */
45 namespace Gaudi {
46 
47  // Forward declarations
48  class IDataConnection;
49  class RootDataConnection;
50  class RootConnectionSetup;
51 
63  protected:
65  this, "IOPerfStats", "", "Enable TTree IOperfStats if not empty; otherwise perf stat file name" };
66  Gaudi::Property<std::string> m_shareFiles{ this, "ShareFiles", "NO",
67  "Share files? If set to YES, files will not be closed on finalize" };
68  Gaudi::Property<bool> m_incidentEnabled{ this, "EnableIncident", true, "Flag to enable incidents on FILE_OPEN" };
69  Gaudi::Property<std::string> m_recordName{ this, "RecordsName", "/FileRecords",
70  "Records name to fire incident for file records" };
71 
72  // ROOT Write parameters
73  Gaudi::Property<int> m_minBufferSize{ this, "MinBufferSize", 2 * 1024 /*kBYTE*/,
74  "Minimum buffer size to use for writing TTree baskets" };
75  Gaudi::Property<int> m_maxBufferSize{ this, "MaxBufferSize", 100 * 1024 * 1024 /*MBYTE*/,
76  "Maximum buffer size to use for writing TTree baskets" };
77  Gaudi::Property<int> m_approxEventsPerBasket{ this, "ApproxEventsPerBasket", 1000,
78  "Resize TBasket buffers to fit approximately this many events" };
79  Gaudi::Property<int> m_splitLevel{ this, "SplitLevel", 0, "Split level optimization parameter for ROOT TTree" };
80  Gaudi::Property<std::string> m_compression{ this, "GlobalCompression", "",
81  "Compression-algorithm:compression-level, empty: do nothing" };
82 
88  Gaudi::RootDataConnection* m_current = nullptr;
90  TClass* m_classRefs = nullptr;
92  TClass* m_classDO = nullptr;
97 
100 
103 
105  TClass* getClass( DataObject* pObject );
107  MsgStream& log() const { return *m_log; }
108 
109  public:
111  RootCnvSvc( const std::string& name, ISvcLocator* svc );
112 
114  StatusCode updateServiceState( IOpaqueAddress* /* pAddress */ ) override { return StatusCode::SUCCESS; }
115 
121  StatusCode error( const std::string& msg );
122 
129  StatusCode connectDatabase( const std::string& dataset, int mode, RootDataConnection** con );
130 
132  StatusCode initialize() override;
133 
135  StatusCode finalize() override;
136 
138  IConverter* createConverter( long typ, const CLID& wanted, const ICnvFactory* fac ) override;
139 
141  void loadConverter( DataObject* pObj ) override;
142 
149  StatusCode connectOutput( const std::string& outputFile, const std::string& openMode ) override;
150 
156  StatusCode connectOutput( const std::string& outputFile ) override;
157 
168  StatusCode commitOutput( const std::string& outputFile, bool do_commit ) override;
169 
175  virtual StatusCode disconnect( const std::string& dbName );
176 
188  StatusCode createAddress( long svc_type, const CLID& clid, const std::string* par, const unsigned long* ip,
189  IOpaqueAddress*& refpAddress ) override;
190 
200  StatusCode createAddress( long svc_type, const CLID& clid, const std::string& refAddress,
201  IOpaqueAddress*& refpAddress ) override {
202  return this->ConversionSvc::createAddress( svc_type, clid, refAddress, refpAddress );
203  }
204 
211  virtual StatusCode createNullRep( const std::string& path );
212 
219  virtual StatusCode createNullRef( const std::string& path );
220 
228  virtual StatusCode i__createRep( DataObject* pObj, IOpaqueAddress*& refpAddr );
229 
237  virtual StatusCode i__fillRepRefs( IOpaqueAddress* pAddr, DataObject* pObj );
238 
246  virtual StatusCode i__createObj( IOpaqueAddress* pAddr, DataObject*& refpObj );
247 
255  virtual StatusCode i__fillObjRefs( IOpaqueAddress* pAddr, DataObject* pObj );
256  };
257 } // namespace Gaudi
258 
259 #endif // GAUDIROOTCNV_GAUDIROOTCNVSVC_H
ConversionSvc
Definition: ConversionSvc.h:55
std::string
STL class.
std::shared_ptr
STL class.
ConversionSvc::createAddress
StatusCode createAddress(long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress) override
Create a Generic address using explicit arguments to identify a single object.
Definition: ConversionSvc.cpp:300
IDataManagerSvc
Definition: IDataManagerSvc.h:55
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
Gaudi::RootCnvSvc
Definition: RootCnvSvc.h:62
IOpaqueAddress
Definition: IOpaqueAddress.h:33
Gaudi::RootCnvSvc::createAddress
StatusCode createAddress(long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress) override
IAddressCreator implementation: Creates an address in string form to object form.
Definition: RootCnvSvc.h:200
ClassID.h
ISvcLocator
Definition: ISvcLocator.h:46
IConverter
Definition: IConverter.h:68
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:19
Gaudi::RootCnvSvc::m_log
std::unique_ptr< MsgStream > m_log
Message streamer.
Definition: RootCnvSvc.h:102
IIODataManager.h
Gaudi::RootDataConnection
Definition: RootDataConnection.h:112
compareOutputFiles.par
par
Definition: compareOutputFiles.py:477
Gaudi::RootCnvSvc::m_incidentSvc
SmartIF< IIncidentSvc > m_incidentSvc
Reference to incident service.
Definition: RootCnvSvc.h:86
Gaudi::RootCnvSvc::m_badFiles
std::set< std::string > m_badFiles
Set with bad files/tables.
Definition: RootCnvSvc.h:99
StatusCode
Definition: StatusCode.h:65
Gaudi::RootCnvSvc::connectOutput
StatusCode connectOutput(const std::string &outputFile) override
Connect the output file to the service.
Gaudi::RootCnvSvc::log
MsgStream & log() const
Helper: Use message streamer.
Definition: RootCnvSvc.h:107
Gaudi::RootCnvSvc::updateServiceState
StatusCode updateServiceState(IOpaqueAddress *) override
Update state of the service.
Definition: RootCnvSvc.h:114
Gaudi::RootCnvSvc::m_ioMgr
SmartIF< Gaudi::IIODataManager > m_ioMgr
Reference to the I/O data manager.
Definition: RootCnvSvc.h:84
SmartIF< Gaudi::IIODataManager >
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:18
MsgStream
Definition: MsgStream.h:33
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition: __init__.py:1
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:100
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
Gaudi::RootCnvSvc::connectOutput
StatusCode connectOutput(const std::string &outputFile, const std::string &openMode) override
Connect the output file to the service with open mode.
DataObject.h
GaudiPython.Bindings.getClass
def getClass(name, libs=[])
Definition: Bindings.py:204
DataObject
Definition: DataObject.h:36
Gaudi::RootCnvSvc::m_currSection
std::string m_currSection
Property: ROOT section name.
Definition: RootCnvSvc.h:96
ConversionSvc.h
IIncidentSvc
Definition: IIncidentSvc.h:33
std::unique_ptr< MsgStream >
Gaudi::RootCnvSvc::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Setup structure (ref-counted) and passed to data connections.
Definition: RootCnvSvc.h:94
std::set< std::string >
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:81
Gaudi::Property< std::string >