| The Gaudi Framework v32r1 (f65d50dc)

RootDatabaseCnv.cpp
Go to the documentation of this file.
1 //------------------------------------------------------------------------------
2 //
3 // Implementation of class : RootDatabaseCnv
4 //
5 // Author : Markus Frank
6 //
7 //------------------------------------------------------------------------------
8 // Framework include files
9 #include "RootCnv/RootDatabaseCnv.h"
10 #include "RootCnv/RootDataConnection.h"
11
12 #include "GaudiKernel/IOpaqueAddress.h"
13 #include "GaudiKernel/IRegistry.h"
14 #include "GaudiKernel/NTuple.h"
15
16 #if 0
17 DECLARE_COMPONENT_WITH_ID(RootDatabaseCnv,
18 ConverterID(ROOT_StorageType,CLID_StatisticsFile) )
19 #endif
20
21 using namespace Gaudi;
22 using namespace std;
23
24 // Standard Constructor
25 RootDatabaseCnv::RootDatabaseCnv( long typ, const CLID& cl, ISvcLocator* svc, RootCnvSvc* mgr )
26 : RootDirectoryCnv( typ, cl, svc, mgr ) {}
27
28 // Create database object
29 StatusCode RootDatabaseCnv::createObj( IOpaqueAddress* pAddr, DataObject*& refpObj ) {
30 StatusCode status = StatusCode::FAILURE;
31 if ( pAddr ) {
32 RootDataConnection* con = nullptr;
33 IRegistry* pReg = pAddr->registry();
34 const unsigned long* ipars = pAddr->ipar();
35 const string* spars = pAddr->par();
36 char mode = char( ipars[1] );
37 string fname = spars[0];
38 auto oname = pReg->name();
39 bool recrea = mode == 'R';
40 bool create = mode == 'N';
41 bool update = mode == 'U';
42 bool read = mode == 'O';
43 const CLID& clid = objType();
44 status = StatusCode::SUCCESS;
45 string cntName = containerName( pReg );
46 if ( create ) {
47 m_dbMgr->connectDatabase( fname, IDataConnection::CREATE, &con ).ignore();
48 status = saveDescription( fname, cntName, "File containing statistics results.", "", clid );
49 if ( status.isSuccess() ) {
50 log() << MSG::INFO << "Opened NEW Database file:" << fname << " as " << oname << endmsg;
51 }
52 } else if ( update ) {
53 m_dbMgr->connectDatabase( fname, IDataConnection::UPDATE, &con ).ignore();
54 status = saveDescription( fname, cntName, "File containing statistics results.", "", clid );
55 if ( status.isSuccess() ) {
56 log() << MSG::INFO << "Connect to existing Database file:" << fname << " as " << oname << " for UPDATE"
57 << endmsg;
58 }
59 } else if ( read ) {
60 status = m_dbMgr->connectDatabase( fname, IDataConnection::READ, &con );
61 if ( status.isSuccess() ) {
62 log() << MSG::INFO << "Connect to existing Database file:" << fname << " as " << oname << " for READ" << endmsg;
63 }
64 } else if ( recrea ) {
65 m_dbMgr->connectDatabase( fname, IDataConnection::RECREATE, &con ).ignore();
66 status = saveDescription( fname, cntName, "File containing statistics results.", "", clid );
67 if ( status.isSuccess() ) {
68 log() << MSG::INFO << "Recreate Database file:" << fname << " as " << oname << endmsg;
69 }
70 } else {
71 log() << MSG::ERROR << "Don't know what to do:" << fname << endmsg;
72 status = StatusCode::FAILURE;
73 }
74 // Now create object
75 if ( status.isSuccess() ) {
76 NTuple::File* pFile = new NTuple::File( objType(), fname, oname );
77 pFile->setOpen( false );
78 refpObj = pFile;
79 }
80 }
81 return status;
82 }
IOpaqueAddress::par
virtual const std::string * par() const =0
Retrieve String parameters.
NTuple::File::setOpen
void setOpen(bool flag)
Set "open" flag.
Definition: NTuple.h:944
ISvcLocator
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
Gaudi::RootDatabaseCnv::containerName
const std::string containerName(IRegistry *) const override
Retrieve the name of the container a given object is placed into.
Definition: RootDatabaseCnv.h:44
NTuple.h
RootDatabaseCnv.h
Gaudi::RootConverter::m_dbMgr
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:35
StatusCode::SUCCESS
constexpr static const auto SUCCESS
Definition: StatusCode.h:85
Gaudi::RootCnvSvc
Description:
Definition: RootCnvSvc.h:52
std
STL namespace.
hivetimeline.read
def read(f, regex='.*', skipevents=0)
Definition: hivetimeline.py:22
IRegistry::name
virtual const name_type & name() const =0
Name of the directory (or key)
Gaudi::RootCnvSvc::connectDatabase
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:194
Gaudi::IDataConnection::RECREATE
Definition: IIODataManager.h:39
Gaudi::IDataConnection::READ
Definition: IIODataManager.h:39
IOpaqueAddress::registry
virtual IRegistry * registry() const =0
Update branch name.
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
Gaudi::RootStatCnv::log
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:38
Gaudi::RootDatabaseCnv
Statistics file converter class definition.
Definition: RootDatabaseCnv.h:28
Gaudi::RootStatCnv::saveDescription
StatusCode saveDescription(const std::string &path, const std::string &ident, const std::string &desc, const std::string &opt, const CLID &clid)
Save statistics object description.
Definition: RootStatCnv.cpp:99
IRegistry.h
IRegistry
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
ROOT_StorageType
const long ROOT_StorageType
Definition: ClassID.h:52
RootDataConnection.h
CLID
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
StatusCode::isSuccess
bool isSuccess() const
Definition: StatusCode.h:267
Gaudi::IDataConnection::UPDATE
Definition: IIODataManager.h:39
IOpaqueAddress.h
Gaudi::RootDirectoryCnv
Description: NTuple directory converter class definition Definition of the converter to manage the di...
Definition: RootDirectoryCnv.h:30
StatusCode::ignore
const StatusCode & ignore() const
Ignore/check StatusCode.
Definition: StatusCode.h:153
Gaudi::IDataConnection::CREATE
Definition: IIODataManager.h:39
Gaudi::RootDatabaseCnv::createObj
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&refpObj) override
Converter overrides: Create transient object from persistent data.
Definition: RootDatabaseCnv.cpp:29
StatusCode::FAILURE
constexpr static const auto FAILURE
Definition: StatusCode.h:86
MSG::ERROR
Definition: IMessageSvc.h:15
Gaudi::RootDatabaseCnv::RootDatabaseCnv
RootDatabaseCnv(long typ, const CLID &, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.
Definition: RootDatabaseCnv.cpp:25
DECLARE_COMPONENT_WITH_ID
#define DECLARE_COMPONENT_WITH_ID(type, id)
Definition: PluginServiceV1.h:47
IOpaqueAddress
Opaque address interface definition.
Definition: IOpaqueAddress.h:23
MSG::INFO
Definition: IMessageSvc.h:15
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
Gaudi::RootDataConnection
Concrete implementation of the IDataConnection interface to access ROOT files.
Definition: RootDataConnection.h:93
IOpaqueAddress::ipar
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
GaudiPython.Pythonizations.update
update
Definition: Pythonizations.py:119
Converter::objType
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:13
ConverterID
Definition: Converter.h:134
NTuple::File
Small class representing an N tuple file in the transient store.
Definition: NTuple.h:910