All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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
11 
13 #include "GaudiKernel/IRegistry.h"
14 #include "GaudiKernel/NTuple.h"
15 
16 #if 0
18  ConverterID(ROOT_StorageType,CLID_StatisticsFile) )
19 #endif
20 
21 using namespace Gaudi;
22 using namespace std;
23 
24 // Standard Constructor
26 : RootDirectoryCnv(typ, cl, svc, mgr)
27 {
28 }
29 
30 // Create database object
34  if ( pAddr ) {
35  RootDataConnection* con = nullptr;
36  IRegistry* pReg = pAddr->registry();
37  const unsigned long* ipars = pAddr->ipar();
38  const string* spars = pAddr->par();
39  char mode = char(ipars[1]);
40  string fname = spars[0];
41  string oname = pReg->name();
42  bool recrea = mode == 'R';
43  bool create = mode == 'N';
44  bool update = mode == 'U';
45  bool read = mode == 'O';
46  const CLID& clid = objType();
47  status = StatusCode::SUCCESS;
48  string cntName = containerName(pReg);
49  if ( create ) {
51  status = saveDescription(fname, cntName, "File containing statistics results.","", clid);
52  if ( status.isSuccess() ) {
53  log() << MSG::INFO << "Opened NEW Database file:"
54  << fname << " as " << oname << endmsg;
55  }
56  }
57  else if ( update ) {
59  status = saveDescription(fname, cntName, "File containing statistics results.","", clid);
60  if ( status.isSuccess() ) {
61  log() << MSG::INFO << "Connect to existing Database file:"
62  << fname << " as " << oname << " for UPDATE" << endmsg;
63  }
64  }
65  else if ( read ) {
66  status = m_dbMgr->connectDatabase(fname,IDataConnection::READ,&con);
67  if ( status.isSuccess() ) {
68  log() << MSG::INFO << "Connect to existing Database file:"
69  << fname << " as " << oname << " for READ" << endmsg;
70  }
71  }
72  else if ( recrea ) {
74  status = saveDescription(fname, cntName, "File containing statistics results.","", clid);
75  if ( status.isSuccess() ) {
76  log() << MSG::INFO << "Recreate Database file:" << fname << " as " << oname << endmsg;
77  }
78  }
79  else {
80  log() << MSG::ERROR << "Don't know what to do:" << fname << endmsg;
81  status = StatusCode::FAILURE;
82  }
83  // Now create object
84  if ( status.isSuccess() ) {
85  NTuple::File* pFile = new NTuple::File(objType(), fname, oname);
86  pFile->setOpen(false);
87  refpObj = pFile;
88  }
89  }
90  return status;
91 }
92 
MsgStream & log() const
Helper to use mesage logger.
Definition: RootStatCnv.h:38
#define DECLARE_COMPONENT_WITH_ID(type, id)
Definition: PluginService.h:39
void setOpen(bool flag)
Set "open" flag.
Definition: NTuple.h:1140
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
Definition: ISvcLocator.h:25
const CLID & objType() const override
Retrieve the class type of objects the converter produces.
Definition: Converter.cpp:14
const std::string containerName(IRegistry *) const override
Retrieve the name of the container a given object is placed into.
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:74
RootCnvSvc * m_dbMgr
Conversion service needed for proper operation to forward requests.
Definition: RootConverter.h:36
virtual IRegistry * registry() const =0
Update branch name.
Description:
Definition: RootCnvSvc.h:53
STL namespace.
def read(f, regex='.*', skipevents=0)
Definition: hivetimeline.py:19
virtual const name_type & name() const =0
Name of the directory (or key)
StatusCode connectDatabase(const std::string &dataset, int mode, RootDataConnection **con)
Connect the output file to the service with open mode.
Definition: RootCnvSvc.cpp:207
virtual const std::string * par() const =0
Retrieve String parameters.
virtual const unsigned long * ipar() const =0
Access to generic link parameters.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
Statistics file converter class definition.
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.
The IRegistry represents the entry door to the environment any data object residing in a transient da...
Definition: IRegistry.h:22
const long ROOT_StorageType
Definition: ClassID.h:52
unsigned int CLID
Class ID definition.
Definition: ClassID.h:8
Description: NTuple directory converter class definition Definition of the converter to manage the di...
StatusCode createObj(IOpaqueAddress *pAddr, DataObject *&refpObj) override
Converter overrides: Create transient object from persistent data.
RootDatabaseCnv(long typ, const CLID &, ISvcLocator *svc, RootCnvSvc *mgr)
Initializing Constructor.
Opaque address interface definition.
void ignore() const
Definition: StatusCode.h:106
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
Concrete implementation of the IDataConnection interface to access ROOT files.
Helper functions to set/get the application return code.
Definition: __init__.py:1
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
Small class representing an N tuple file in the transient store.
Definition: NTuple.h:1088