2 #include "GaudiKernel/IOpaqueAddress.h"
3 #include "GaudiKernel/IRegistry.h"
4 #include "GaudiKernel/MsgStream.h"
5 #include "GaudiKernel/IJobOptionsSvc.h"
6 #include "GaudiKernel/ISvcLocator.h"
7 #include "GaudiKernel/Bootstrap.h"
30 std::unique_ptr<PropertyMgr> pmgr (
new PropertyMgr() );
35 jobSvc->setMyProperties(
"RFileCnv",pmgr.get()) );
48 unsigned long* ipar = (
unsigned long*)pAddress->
ipar();
49 char mode[2] = { char(ipar[1]), 0 };
51 std::string fname = pAddress->
par()[0];
52 std::string ooname = pAddress->
par()[1];
54 const std::string* spar = pAddress->
par();
56 std::string oname = spar[1].substr(spar[1].find(
"/",1)+1);
60 static TROOT
root(
"root",
"ROOT I/O");
63 log <<
MSG::VERBOSE <<
"ROOT already initialized, debug = "
69 if ( mode[0] ==
'O' ) {
71 if (findTFile(ooname,rfile).isFailure()) {
73 log <<
MSG::INFO <<
"opening Root file \"" << fname <<
"\" for reading"
76 rfile = TFile::Open(fname.c_str(),
"READ");
77 if ( rfile != 0 && rfile->IsOpen() ) {
78 regTFile(ooname,rfile).ignore();
80 ipar[0] = (
unsigned long)rfile;
88 log <<
MSG::ERROR <<
"Couldn't open \"" << fname <<
"\" for reading"
94 log <<
MSG::DEBUG <<
"Root file \"" << fname <<
"\" already opened"
100 }
else if ( mode[0] ==
'U' ) {
102 log <<
MSG::INFO <<
"opening Root file \"" << fname <<
"\" for updating"
108 }
else if ( mode[0] ==
'N' ) {
110 log <<
MSG::INFO <<
"opening Root file \"" << fname <<
"\" for writing";
111 if ( !m_compLevel.empty() )
112 { log <<
", CompressionLevel='" << m_compLevel <<
"'"; }
115 rfile = TFile::Open( fname.c_str(),
"RECREATE",
"Gaudi Trees" );
116 if ( ! ( rfile && rfile->IsOpen() ) ) {
117 log <<
MSG::ERROR <<
"Could not open file " << fname <<
" for writing"
121 if ( !m_compLevel.empty() )
124 rfile->SetCompressionSettings(settings.
level());
127 regTFile(ooname,rfile).ignore();
131 ipar[0] = (
unsigned long)rfile;
162 std::string ooname = pAddress->
par()[1];
165 if ( pFile && pFile->
isOpen() ) {
167 unsigned long* ipar = (
unsigned long*)pAddress->
ipar();
168 if (findTFile(ooname,rfile).isFailure()) {
173 rfile->Write(0,TObject::kOverwrite);
virtual const std::string * par() const =0
Retrieve String parameters.
Definition of the MsgStream class used to transmit messages.
void setOpen(bool flag)
Set "open" flag.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
MSG::Level level()
Retrieve output level.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
StatusCode initialize() override
Initialize the converter.
#define DECLARE_NAMESPACE_CONVERTER_FACTORY(n, x)
Property manager helper class.
IRegistry * registry() const
Get pointer to Registry.
virtual StatusCode updateRep(IOpaqueAddress *pAddress, DataObject *pObject)
Convert the transient object to the requested representation.
NTuple converter class definition.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Main interface for the JobOptions service.
GAUDI_API ISvcLocator * svcLocator()
Property * declareProperty(const std::string &name, TYPE &value, const std::string &doc="none")
Declare a property (templated)
This class is used for returning status codes from appropriate routines.
Create persistent and transient representations of data store directories.
virtual StatusCode createObj(IOpaqueAddress *pAddress, DataObject *&refpObject)
Create the transient representation of an object.
Simple class to decode a ROOT compression settings string, of the form '
:' into the integ...
bool isOpen() const
Access "open" flag.
std::string m_compLevel
Compression setting.
virtual IOpaqueAddress * address() const =0
Retrieve opaque storage address.
virtual StatusCode initialize()
Initialise.
int level() const
Get the level.
virtual StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress)
Convert the transient object to the requested representation.
Opaque address interface definition.
A DataObject is the base class of any identifiable object on any data store.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
Small class representing an N tuple file in the transient store.