The Gaudi Framework  v40r0 (475e45c1)
RootCnvSvc.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 //====================================================================
12 // RootCnvSvc definition
13 //--------------------------------------------------------------------
14 //
15 // Author : M.Frank
16 //====================================================================
17 #pragma once
18 
19 // Framework include files
20 #include <GaudiKernel/ClassID.h>
22 #include <GaudiKernel/DataObject.h>
24 
25 // C++ include files
26 #include <set>
27 
28 // Forward declarations
29 struct IDataManagerSvc;
30 class IIncidentSvc;
31 class TClass;
32 
33 // ROOT include files
34 #include <TBranch.h>
35 #include <TClass.h>
36 #include <TROOT.h>
37 #include <TTree.h>
38 
39 // #include "RootCnv/RootPerfMonSvc.h"
40 
41 /*
42  * Gaudi namespace declaration
43  */
44 namespace Gaudi {
45 
46  // Forward declarations
47  class IDataConnection;
48  class RootDataConnection;
49  class RootConnectionSetup;
50 
62  protected:
64  this, "IOPerfStats", "", "Enable TTree IOperfStats if not empty; otherwise perf stat file name" };
65  Gaudi::Property<std::string> m_shareFiles{ this, "ShareFiles", "NO",
66  "Share files? If set to YES, files will not be closed on finalize" };
67  Gaudi::Property<bool> m_incidentEnabled{ this, "EnableIncident", true, "Flag to enable incidents on FILE_OPEN" };
68  Gaudi::Property<std::string> m_recordName{ this, "RecordsName", "/FileRecords",
69  "Records name to fire incident for file records" };
70 
71  // ROOT Write parameters
72  Gaudi::Property<int> m_minBufferSize{ this, "MinBufferSize", 2 * 1024 /*kBYTE*/,
73  "Minimum buffer size to use for writing TTree baskets" };
74  Gaudi::Property<int> m_maxBufferSize{ this, "MaxBufferSize", 100 * 1024 * 1024 /*MBYTE*/,
75  "Maximum buffer size to use for writing TTree baskets" };
76  Gaudi::Property<int> m_approxEventsPerBasket{ this, "ApproxEventsPerBasket", 1000,
77  "Resize TBasket buffers to fit approximately this many events" };
78  Gaudi::Property<int> m_splitLevel{ this, "SplitLevel", 0, "Split level optimization parameter for ROOT TTree" };
79  Gaudi::Property<std::string> m_compression{ this, "GlobalCompression", "",
80  "Compression-algorithm:compression-level, empty: do nothing" };
81 
87  Gaudi::RootDataConnection* m_current = nullptr;
89  TClass* m_classRefs = nullptr;
91  TClass* m_classDO = nullptr;
93  std::shared_ptr<RootConnectionSetup> m_setup;
95  std::string m_currSection;
96 
98  std::set<std::string> m_badFiles;
99 
101  std::unique_ptr<MsgStream> m_log;
102 
104  TClass* getClass( DataObject* pObject );
106  MsgStream& log() const { return *m_log; }
107 
108  public:
110  RootCnvSvc( const std::string& name, ISvcLocator* svc );
111 
113  StatusCode updateServiceState( IOpaqueAddress* /* pAddress */ ) override { return StatusCode::SUCCESS; }
114 
120  StatusCode error( const std::string& msg );
121 
128  StatusCode connectDatabase( const std::string& dataset, int mode, RootDataConnection** con );
129 
131  StatusCode initialize() override;
132 
134  StatusCode finalize() override;
135 
137  IConverter* createConverter( long typ, const CLID& wanted, const ICnvFactory* fac ) override;
138 
140  void loadConverter( DataObject* pObj ) override;
141 
148  StatusCode connectOutput( const std::string& outputFile, const std::string& openMode ) override;
149 
155  StatusCode connectOutput( const std::string& outputFile ) override;
156 
167  StatusCode commitOutput( const std::string& outputFile, bool do_commit ) override;
168 
174  virtual StatusCode disconnect( const std::string& dbName );
175 
187  StatusCode createAddress( long svc_type, const CLID& clid, const std::string* par, const unsigned long* ip,
188  IOpaqueAddress*& refpAddress ) override;
189 
199  StatusCode createAddress( long svc_type, const CLID& clid, const std::string& refAddress,
200  IOpaqueAddress*& refpAddress ) override {
201  return this->ConversionSvc::createAddress( svc_type, clid, refAddress, refpAddress );
202  }
203 
210  virtual StatusCode createNullRep( const std::string& path );
211 
218  virtual StatusCode createNullRef( const std::string& path );
219 
227  virtual StatusCode i__createRep( DataObject* pObj, IOpaqueAddress*& refpAddr );
228 
236  virtual StatusCode i__fillRepRefs( IOpaqueAddress* pAddr, DataObject* pObj );
237 
245  virtual StatusCode i__createObj( IOpaqueAddress* pAddr, DataObject*& refpObj );
246 
254  virtual StatusCode i__fillObjRefs( IOpaqueAddress* pAddr, DataObject* pObj );
255  };
256 } // namespace Gaudi
ConversionSvc
Definition: ConversionSvc.h:53
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:47
AtlasMCRecoFullPrecedenceDump.path
path
Definition: AtlasMCRecoFullPrecedenceDump.py:49
Gaudi::RootCnvSvc
Definition: RootCnvSvc.h:61
IOpaqueAddress
Definition: IOpaqueAddress.h:28
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:199
ClassID.h
ISvcLocator
Definition: ISvcLocator.h:42
IConverter
Definition: IConverter.h:65
GaudiMP.FdsRegistry.msg
msg
Definition: FdsRegistry.py:19
Gaudi::RootCnvSvc::m_log
std::unique_ptr< MsgStream > m_log
Message streamer.
Definition: RootCnvSvc.h:101
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:85
Gaudi::RootCnvSvc::m_badFiles
std::set< std::string > m_badFiles
Set with bad files/tables.
Definition: RootCnvSvc.h:98
StatusCode
Definition: StatusCode.h:64
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:106
Gaudi::RootCnvSvc::updateServiceState
StatusCode updateServiceState(IOpaqueAddress *) override
Update state of the service.
Definition: RootCnvSvc.h:113
Gaudi::RootCnvSvc::m_ioMgr
SmartIF< Gaudi::IIODataManager > m_ioMgr
Reference to the I/O data manager.
Definition: RootCnvSvc.h:83
SmartIF< Gaudi::IIODataManager >
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:16
MsgStream
Definition: MsgStream.h:29
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:99
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:37
Gaudi::RootCnvSvc::m_currSection
std::string m_currSection
Property: ROOT section name.
Definition: RootCnvSvc.h:95
ConversionSvc.h
IIncidentSvc
Definition: IIncidentSvc.h:30
Gaudi::RootCnvSvc::m_setup
std::shared_ptr< RootConnectionSetup > m_setup
Setup structure (ref-counted) and passed to data connections.
Definition: RootCnvSvc.h:93
GAUDI_API
#define GAUDI_API
Definition: Kernel.h:83
Gaudi::Property< std::string >