Gaudi Framework, version v24r2

Home   Generated: Wed Dec 4 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
Gaudi::RootCnvSvc Class Reference

Description: More...

#include <src/RootCnvSvc.h>

Inheritance diagram for Gaudi::RootCnvSvc:
Inheritance graph
[legend]
Collaboration diagram for Gaudi::RootCnvSvc:
Collaboration graph
[legend]

Public Member Functions

 RootCnvSvc (const std::string &name, ISvcLocator *svc)
 Standard constructor.
 
virtual ~RootCnvSvc ()
 Standard destructor.
 
virtual StatusCode updateServiceState (IOpaqueAddress *)
 Update state of the service.
 
StatusCode error (const std::string &msg)
 Standard way to print errors.
 
StatusCode connectDatabase (const std::string &dataset, int mode, RootDataConnection **con)
 Connect the output file to the service with open mode.
 
virtual StatusCode initialize ()
 ConversionSvc overload: initialize Db service.
 
virtual StatusCode finalize ()
 ConversionSvc overload: Finalize Db service.
 
virtual IConvertercreateConverter (long typ, const CLID &wanted, const ICnvFactory *fac)
 ConversionSvc overload: Create new Converter using factory.
 
virtual void loadConverter (DataObject *pObj)
 ConversionSvc overload: Load the class (dictionary) for the converter.
 
virtual StatusCode connectOutput (const std::string &outputFile, const std::string &openMode)
 Connect the output file to the service with open mode.
 
virtual StatusCode connectOutput (const std::string &outputFile)
 Connect the output file to the service.
 
virtual StatusCode commitOutput (const std::string &outputFile, bool do_commit)
 Commit pending output.
 
virtual StatusCode disconnect (const std::string &dbName)
 Disconnect from an existing data stream.
 
virtual StatusCode createAddress (long svc_type, const CLID &clid, const std::string *par, const unsigned long *ip, IOpaqueAddress *&refpAddress)
 IAddressCreator implementation: Address creation.
 
virtual StatusCode createAddress (long svc_type, const CLID &clid, const std::string &refAddress, IOpaqueAddress *&refpAddress)
 IAddressCreator implementation: Creates an address in string form to object form.
 
virtual StatusCode createNullRep (const std::string &path)
 Insert null marker for not existent transient object.
 
virtual StatusCode createNullRef (const std::string &path)
 Insert null marker for not existent transient object.
 
virtual StatusCode i__createRep (DataObject *pObj, IOpaqueAddress *&refpAddr)
 Convert the transient object to the requested persistent representation.
 
virtual StatusCode i__fillRepRefs (IOpaqueAddress *pAddr, DataObject *pObj)
 Resolve the references of the converted object.
 
virtual StatusCode i__createObj (IOpaqueAddress *pAddr, DataObject *&refpObj)
 Create transient object from persistent data.
 
virtual StatusCode i__fillObjRefs (IOpaqueAddress *pAddr, DataObject *pObj)
 Resolve the references of the created transient object.
 
- Public Member Functions inherited from ConversionSvc
virtual long repSvcType () const
 Retrieve the class type of the data store the converter uses.
 
const CLIDobjType () const
 Implementation of IConverter: dummy call.
 
virtual StatusCode setDataProvider (IDataProviderSvc *pService)
 Implementation of IConverter: Set Data provider service.
 
virtual SmartIF
< IDataProviderSvc > & 
dataProvider () const
 Implementation of IConverter: Get Data provider service.
 
virtual StatusCode setConversionSvc (IConversionSvc *svc)
 Implementation of IConverter: Set conversion service the converter is connected to.
 
virtual SmartIF< IConversionSvc > & conversionSvc () const
 Implementation of IConverter: Get conversion service the converter is connected to.
 
virtual StatusCode setAddressCreator (IAddressCreator *creator)
 Set address creator facility.
 
virtual SmartIF
< IAddressCreator > & 
addressCreator () const
 Retrieve address creator facility.
 
virtual StatusCode createObj (IOpaqueAddress *pAddress, DataObject *&refpObject)
 Implementation of IConverter: Create the transient representation of an object.
 
virtual StatusCode fillObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Resolve the references of the created transient object.
 
virtual StatusCode updateObj (IOpaqueAddress *pAddress, DataObject *refpObject)
 Implementation of IConverter: Update the transient object from the other representation.
 
virtual StatusCode updateObjRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the references of an updated transient object.
 
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Implementation of IConverter: Convert the transient object to the requested representation.
 
virtual StatusCode fillRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Resolve the references of the converted object.
 
virtual StatusCode updateRep (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the converted representation of a transient object.
 
virtual StatusCode updateRepRefs (IOpaqueAddress *pAddress, DataObject *pObject)
 Implementation of IConverter: Update the references of an already converted object.
 
virtual StatusCode addConverter (const CLID &clid)
 Add converter object to conversion service.
 
virtual StatusCode addConverter (IConverter *pConverter)
 Add converter object to conversion service.
 
virtual StatusCode removeConverter (const CLID &clid)
 Remove converter object from conversion service (if present).
 
virtual IConverterconverter (const CLID &wanted)
 Retrieve converter from list.
 
virtual StatusCode convertAddress (const IOpaqueAddress *pAddress, std::string &refAddress)
 Convert an address to string form.
 
 ConversionSvc (const std::string &name, ISvcLocator *svc, long type)
 Standard Constructor.
 
- Public Member Functions inherited from extends2< Service, IConversionSvc, IAddressCreator >
 extends2 (A1 a1, A2 a2, A3 a3)
 Templated constructor with 3 arguments.
 
 extends2 (A1 a1, A2 a2)
 Templated constructor with 2 arguments.
 
 extends2 (A1 a1)
 Templated constructor with 1 argument.
 
 extends2 ()
 Default constructor.
 
virtual void * i_cast (const InterfaceID &tid) const
 Implementation of IInterface::i_cast.
 
virtual StatusCode queryInterface (const InterfaceID &ti, void **pp)
 Implementation of IInterface::queryInterface.
 
virtual std::vector< std::stringgetInterfaceNames () const
 Implementation of IInterface::getInterfaceNames.
 
virtual ~extends2 ()
 Virtual destructor.
 
- Public Member Functions inherited from Service
virtual unsigned long release ()
 Release Interface instance.
 
virtual const std::stringname () const
 Retrieve name of the service.
 
virtual StatusCode configure ()
 
virtual StatusCode start ()
 
virtual StatusCode stop ()
 
virtual StatusCode terminate ()
 
virtual Gaudi::StateMachine::State FSMState () const
 
virtual Gaudi::StateMachine::State targetFSMState () const
 
virtual StatusCode reinitialize ()
 
virtual StatusCode restart ()
 
virtual StatusCode sysInitialize ()
 Initialize Service.
 
virtual StatusCode sysStart ()
 Initialize Service.
 
virtual StatusCode sysStop ()
 Initialize Service.
 
virtual StatusCode sysFinalize ()
 Finalize Service.
 
virtual StatusCode sysReinitialize ()
 Re-initialize the Service.
 
virtual StatusCode sysRestart ()
 Re-initialize the Service.
 
virtual StatusCode setProperty (const Property &p)
 
virtual StatusCode setProperty (const std::string &s)
 
virtual StatusCode setProperty (const std::string &n, const std::string &v)
 
virtual StatusCode getProperty (Property *p) const
 
virtual const PropertygetProperty (const std::string &name) const
 
virtual StatusCode getProperty (const std::string &n, std::string &v) const
 
virtual const std::vector
< Property * > & 
getProperties () const
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value
 
 Service (const std::string &name, ISvcLocator *svcloc)
 Standard Constructor.
 
SmartIF< ISvcLocator > & serviceLocator () const
 Retrieve pointer to service locator.
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job.
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist.
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist.
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property.
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties.
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked.
 
- Public Member Functions inherited from CommonMessaging< implements3< IService, IProperty, IStateful > >
 CommonMessaging (const A1 &a1, const A2 &a2, const A3 &a3)
 Templated constructor with 3 arguments.
 
 CommonMessaging (const A1 &a1, const A2 &a2)
 Templated constructor with 2 arguments.
 
 CommonMessaging (const A1 &a1)
 Templated constructor with 1 argument.
 
 CommonMessaging ()
 Default constructor.
 
virtual ~CommonMessaging ()
 Virtual destructor.
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service.
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream.
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts.
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS)
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL)
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR)
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING)
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO)
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG)
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO)
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream
 
- Public Member Functions inherited from extend_interfaces2< I1, I2 >
virtual ~extend_interfaces2 ()
 Virtual destructor.
 

Protected Member Functions

TClass * getClass (DataObject *pObject)
 Helper: Get TClass for a given DataObject pointer.
 
MsgStreamlog () const
 Helper: Use message streamer.
 
- Protected Member Functions inherited from ConversionSvc
virtual ~ConversionSvc ()
 Standard Destructor.
 
virtual StatusCode configureConverter (long typ, const CLID &clid, IConverter *cnv)
 Configure the new converter before initialize is called.
 
virtual StatusCode initializeConverter (long typ, const CLID &clid, IConverter *cnv)
 Initialize the new converter.
 
virtual StatusCode activateConverter (long typ, const CLID &clid, IConverter *cnv)
 Activate the new converter after initialization.
 
virtual SmartIF
< IAddressCreator > & 
addressCreator ()
 Retrieve address creation interface.
 
StatusCode makeCall (int typ, bool ignore_add, bool ignore_obj, bool update, IOpaqueAddress *&pAddress, DataObject *&pObject)
 

Protected Attributes

Gaudi::IIODataManagerm_ioMgr
 Reference to the I/O data manager.
 
IIncidentSvcm_incidentSvc
 Reference to incident service.
 
Gaudi::RootDataConnectionm_current
 On writing: reference to active output stream.
 
TClass * m_classRefs
 TClass pointer to reference class.
 
TClass * m_classDO
 TClass pointer to DataObject class.
 
RootConnectionSetupm_setup
 Setup structure (ref-counted) and passed to data connections.
 
std::string m_currSection
 Property: ROOT section name.
 
bool m_incidentEnabled
 Property: Flag to enable incidents on FILE_OPEN.
 
std::string m_shareFiles
 Property: Share files ? If set to YES, files will not be closed on finalize.
 
std::string m_recordName
 Property: Records name to fire incident for file records.
 
std::string m_ioPerfStats
 Property: Enable TTree IOperfStats if not empty; otherwise perf stat file name.
 
std::string m_compression
 Property: Compression-algorithm:compression-level.
 
int m_autoFlush
 Property: AutoFlush parameter for ROOT TTree (Number of events between auto flushes)
 
int m_basketSize
 Property: Basket optimization parameter for ROOT TTree (total basket size)
 
int m_bufferSize
 Property: Buffer size optimization parameter for ROOT TTree.
 
int m_splitLevel
 Property: Split level optimization parameter for ROOT TTree.
 
std::set< std::stringm_badFiles
 Set with bad files/tables.
 
MsgStreamm_log
 Message streamer.
 
- Protected Attributes inherited from ConversionSvc
SmartIF< IDataProviderSvcm_dataSvc
 Pointer to data provider service.
 
SmartIF< IAddressCreatorm_addressCreator
 Pointer to the address creation service interface.
 
SmartIF< IConversionSvcm_cnvSvc
 Pointer to the IConversionSvc interface of this.
 
long m_type
 Conversion service type.
 
Workersm_workers
 List of conversion workers.
 

Additional Inherited Members

- Public Types inherited from ConversionSvc
typedef std::vector< WorkerEntryWorkers
 

Detailed Description

Description:

RootCnvSvc class implementation definition.

Author
Markus Frank
Version
1.0
Date
20/12/2009

Definition at line 54 of file RootCnvSvc.h.

Constructor & Destructor Documentation

RootCnvSvc::RootCnvSvc ( const std::string name,
ISvcLocator svc 
)

Standard constructor.

Definition at line 50 of file RootCnvSvc.cpp.

{
declareProperty("IOPerfStats", m_ioPerfStats);
declareProperty("ShareFiles", m_shareFiles = "NO");
declareProperty("EnableIncident", m_incidentEnabled = true);
declareProperty("RecordsName", m_recordName = "/FileRecords");
declareProperty("LoadSection", m_setup->loadSection = "Event");
// ROOT Write parameters
declareProperty("AutoFlush", m_autoFlush = 100);
declareProperty("BasketSize", m_basketSize = 2*MBYTE);
declareProperty("BufferSize", m_bufferSize = 2*kBYTE);
declareProperty("SplitLevel", m_splitLevel = 0);
declareProperty("GlobalCompression",m_compression); // empty: do nothing
// ROOT Read parameters: must be shared for the entire file!
declareProperty("CacheSize", m_setup->cacheSize = 10*MBYTE);
declareProperty("LearnEntries", m_setup->learnEntries = 10);
}
RootCnvSvc::~RootCnvSvc ( )
virtual

Standard destructor.

Definition at line 78 of file RootCnvSvc.cpp.

{
if (m_setup) m_setup->release();
}

Member Function Documentation

StatusCode RootCnvSvc::commitOutput ( const std::string outputFile,
bool  do_commit 
)
virtual

Commit pending output.

Parameters
outputFileString containig output file
do_commitif true commit the output and flush eventually pending items to the database if false, discard pending buffers. Note: The possibility to commit or rollback depends on the database technology used!
Returns
Status code indicating success or failure.

fill NULL pointers to all branches, which have less entries than the section branch

Reimplemented from ConversionSvc.

Definition at line 327 of file RootCnvSvc.cpp.

{
if ( m_current ) {
size_t len = m_currSection.find('/',1);
string section = m_currSection.substr(1,len==string::npos ? string::npos : len-1);
TBranch* b = m_current->getBranch(section, m_currSection);
if ( b ) {
Long64_t evt = b->GetEntries();
TTree* t = b->GetTree();
TObjArray* a = t->GetListOfBranches();
Int_t nb = a->GetEntriesFast();
for(Int_t i=0; i<nb; ++i) {
TBranch* br_ptr = (TBranch*)a->UncheckedAt(i);
Long64_t br_evt = br_ptr->GetEntries();
if ( br_evt < evt ) {
Long64_t num = evt-br_evt;
br_ptr->SetAddress(0);
while(num>0) {
br_ptr->Fill();
--num;
}
log() << "commit: Added " << long(evt-br_evt)
<< " Section: " << evt << " Branch: " << br_ptr->GetEntries()
<< " RefNo: " << br_ptr->GetEntries()-1
<< " NULL entries to:" << br_ptr->GetName() << endmsg;
}
}
b->GetTree()->SetEntries(evt);
if ( evt == 1 ) {
b->GetTree()->OptimizeBaskets(m_basketSize,1.1,"");
}
if ( evt > 0 && (evt%m_autoFlush)==0 ) {
if ( evt == m_autoFlush ) {
b->GetTree()->SetAutoFlush(m_autoFlush);
b->GetTree()->OptimizeBaskets(m_basketSize,1.,"");
}
else {
b->GetTree()->FlushBaskets();
}
}
log() << MSG::DEBUG << "Set section entries of " << m_currSection
<< " to " << long(evt) << " entries." << endmsg;
}
else {
return error("commitOutput> Failed to update entry numbers on "+dsn);
}
}
return S_OK;
}
StatusCode RootCnvSvc::connectDatabase ( const std::string dataset,
int  mode,
RootDataConnection **  con 
)

Connect the output file to the service with open mode.

Parameters
datasetString containig file name
modeString containig opening mode
Returns
Status code indicating success or failure.

Definition at line 223 of file RootCnvSvc.cpp.

{
try {
IDataConnection* c = m_ioMgr->connection(dataset);
bool fire_incident = false;
*con = 0;
if ( !c ) {
auto_ptr<RootDataConnection> connection(new RootDataConnection(this,dataset,m_setup));
? m_ioMgr->connectWrite(connection.get(),IDataConnection::IoType(mode),"ROOT")
: m_ioMgr->connectRead(false,connection.get());
c = sc.isSuccess() ? m_ioMgr->connection(dataset) : 0;
if ( c ) {
bool writable = 0 != (mode&(IDataConnection::UPDATE|IDataConnection::RECREATE));
fire_incident = m_incidentEnabled && (0 != (mode&(IDataConnection::UPDATE|IDataConnection::READ)));
if ( writable ) {
m_incidentSvc->fireIncident(ContextIncident<TFile*>(connection->pfn(),"CONNECTED_OUTPUT",connection->file()));
}
if ( 0 != (mode&IDataConnection::READ) ) {
if ( !m_ioPerfStats.empty() ) {
connection->enableStatistics(m_setup->loadSection);
}
}
connection.release();
}
else {
m_incidentSvc->fireIncident(Incident(dataset,mode == IDataConnection::READ
// An error message was already printed by the IODataManager. no need to do it here!
}
}
if ( pc ) {
if ( !pc->isConnected() ) pc->connectRead();
*con = pc;
pc->resetAge();
pc->addClient(this);
}
if ( *con ) {
if ( fire_incident ) {
IOpaqueAddress* pAddr = 0;
string fid = pc->fid();
string section = m_recordName[0] == '/' ? m_recordName.substr(1) : m_recordName;
TBranch* b = pc->getBranch(section,m_recordName);
if ( b ) {
const string par[2] = { fid, m_recordName };
unsigned long ipar[2] = { (unsigned long)(*con), (unsigned long)b->GetEntries()-1 };
for(int i=0; i<b->GetEntries(); ++i) {
ipar[1] = i;
if ( !pc->mergeFIDs().empty() )
fid = pc->mergeFIDs()[i];
if ( !createAddress(repSvcType(),CLID_DataObject,par,ipar,pAddr).isSuccess() ) {
log() << "Failed to create address for " << m_recordName << " in:" << fid
<< " [" << pc->fid() << "][" << i << "]" << endmsg;
continue;
}
log() << "Prepare " << m_recordName << " " << fid << " [" << par[0] << "][" << i << "]" << endmsg;
}
}
else {
log() << "No valid Records " << m_recordName << " present in:" << pc->fid() << endmsg;
}
}
// We can remove retired connections, which are no longer used....
IIODataManager::Connections cons = m_ioMgr->connections(this);
for(IIODataManager::Connections::iterator i=cons.begin(); i != cons.end(); ++i) {
if ( (*i) != *con && !(*i)->isConnected() ) {
RootDataConnection* pc = dynamic_cast<RootDataConnection*>(*i);
if ( pc && pc->lookupClient(this) ) {
size_t num_client = pc->removeClient(this);
if ( num_client == 0 ) {
if ( m_ioMgr->disconnect(pc).isSuccess() ) {
log() << MSG::INFO << "Removed disconnected IO stream:" << pc->fid()
<< " [" << pc->pfn() << "]" << endmsg;
delete pc;
}
}
}
}
}
return S_OK;
}
return S_FAIL;
}
catch (exception& e) {
return error(string("connectDatabase> Caught exception:")+e.what());
}
catch (...) {
return error("connectDatabase> Unknown Fatal Exception for "+dataset);
}
}
virtual StatusCode Gaudi::RootCnvSvc::connectOutput ( const std::string outputFile,
const std::string openMode 
)
virtual

Connect the output file to the service with open mode.

Parameters
outputFileString containig output file
openModeString containig opening mode of the output file
Returns
Status code indicating success or failure.

Reimplemented from ConversionSvc.

virtual StatusCode Gaudi::RootCnvSvc::connectOutput ( const std::string outputFile)
virtual

Connect the output file to the service.

Parameters
outputFileString containig output file
Returns
Status code indicating success or failure.

Reimplemented from ConversionSvc.

StatusCode RootCnvSvc::createAddress ( long  svc_type,
const CLID clid,
const std::string par,
const unsigned long *  ip,
IOpaqueAddress *&  refpAddress 
)
virtual

IAddressCreator implementation: Address creation.

Create an address using the link infotmation together with the triple (database name/container name/object name).

Parameters
refLinkReference to abstract link information
dbNameDatabase name
containerNameObject container name
refpAddressOpaque address information to retrieve object
Returns
StatusCode indicating SUCCESS or failure

Reimplemented from ConversionSvc.

Definition at line 386 of file RootCnvSvc.cpp.

{
refpAddress = new RootAddress(typ,clid,par[0],par[1],ip[0],ip[1]);
return S_OK;
}
virtual StatusCode Gaudi::RootCnvSvc::createAddress ( long  svc_type,
const CLID clid,
const std::string refAddress,
IOpaqueAddress *&  refpAddress 
)
inlinevirtual

IAddressCreator implementation: Creates an address in string form to object form.

Parameters
svc_typeTechnology identifier encapsulated in this address.
clidClass identifier of the DataObject represented by the opaque address
addressInput address.
refpAddressOutput address in string form.
Returns
Status code indicating success or failure.

Reimplemented from ConversionSvc.

Definition at line 206 of file RootCnvSvc.h.

{
return this->ConversionSvc::createAddress(svc_type,clid,refAddress,refpAddress);
}
IConverter * RootCnvSvc::createConverter ( long  typ,
const CLID wanted,
const ICnvFactory *  fac 
)
virtual

ConversionSvc overload: Create new Converter using factory.

Reimplemented from ConversionSvc.

Definition at line 157 of file RootCnvSvc.cpp.

{
if ( wanted == CLID_StatisticsFile )
return new RootDatabaseCnv(typ,wanted,serviceLocator().get(),this);
else if ( wanted == CLID_StatisticsDirectory )
return new RootDirectoryCnv(typ,wanted,serviceLocator().get(),this);
else if ( wanted == CLID_RowWiseTuple )
return new RootNTupleCnv(typ,wanted,serviceLocator().get(),this);
else if ( wanted == CLID_ColumnWiseTuple )
return new RootNTupleCnv(typ,wanted,serviceLocator().get(),this);
else
return new RootConverter(typ,wanted,serviceLocator().get(),this);
}
StatusCode RootCnvSvc::createNullRef ( const std::string path)
virtual

Insert null marker for not existent transient object.

Parameters
path[IN] Path to the (null-)object
Returns
Status code indicating success or failure.

Definition at line 405 of file RootCnvSvc.cpp.

{
RootObjectRefs* refs = 0;
size_t len = path.find('/',1);
string section = path.substr(1,len==string::npos ? string::npos : len-1);
m_current->save(section,path+"#R",0,refs,m_bufferSize,m_splitLevel);
log() << MSG::VERBOSE << "Writing object:" << path << " "
<< ret.first << " " << hex << ret.second << dec << " [NULL]" << endmsg;
return S_OK;
}
StatusCode RootCnvSvc::createNullRep ( const std::string path)
virtual

Insert null marker for not existent transient object.

Parameters
path[IN] Path to the (null-)object
Returns
Status code indicating success or failure.

Definition at line 397 of file RootCnvSvc.cpp.

{
size_t len = path.find('/',1);
string section = path.substr(1,len==string::npos ? string::npos : len-1);
m_current->saveObj(section,path,0,0,m_bufferSize,m_splitLevel);
return S_OK;
}
StatusCode RootCnvSvc::disconnect ( const std::string dbName)
virtual

Disconnect from an existing data stream.

Parameters
dbNameString containing name of the database
Returns
Status code indicating success or failure.

Definition at line 380 of file RootCnvSvc.cpp.

{
IDataConnection* c = m_ioMgr->connection(dataset);
return c ? m_ioMgr->disconnect(c) : S_FAIL;
}
StatusCode RootCnvSvc::error ( const std::string msg)

Standard way to print errors.

after the printout an exception is thrown.

Parameters
msg[IN] Message string to be printed.
Returns
Status code returning failure.

Definition at line 83 of file RootCnvSvc.cpp.

{
if ( m_log ) {
log() << MSG::ERROR << "Error: " << msg << endmsg;
return S_FAIL;
}
m << MSG::ERROR << "Error: " << msg << endmsg;
return S_FAIL;
}
StatusCode RootCnvSvc::finalize ( )
virtual

ConversionSvc overload: Finalize Db service.

Reimplemented from ConversionSvc.

Definition at line 126 of file RootCnvSvc.cpp.

{
log() << MSG::INFO;
if ( m_ioMgr ) {
IIODataManager::Connections cons = m_ioMgr->connections(0);
for(IIODataManager::Connections::iterator i=cons.begin(); i != cons.end(); ++i) {
RootDataConnection* pc = dynamic_cast<RootDataConnection*>(*i);
if ( pc ) {
if ( pc->owner() == this && !m_ioPerfStats.empty() ) {
pc->saveStatistics(m_ioPerfStats);
}
if ( pc->lookupClient(this) ) {
size_t num_clients = pc->removeClient(this);
if ( num_clients == 0 ) {
if ( m_ioMgr->disconnect(pc).isSuccess() ) {
log() << "Disconnected data IO:" << pc->fid()
<< " [" << pc->pfn() << "]" << endmsg;
delete pc;
}
}
}
}
}
releasePtr(m_ioMgr);
}
deletePtr(m_log);
releasePtr(m_incidentSvc);
}
TClass * RootCnvSvc::getClass ( DataObject pObject)
protected

Helper: Get TClass for a given DataObject pointer.

Definition at line 187 of file RootCnvSvc.cpp.

{
map<CLID, TClass*>::iterator i=s_classesClids.find(pObject->clID());
if ( i != s_classesClids.end() ) return (*i).second;
loadConverter(pObject);
i=s_classesClids.find(pObject->clID());
if ( i != s_classesClids.end() ) return (*i).second;
string cname = System::typeinfoName(typeid(*pObject));
throw runtime_error("Unknown ROOT class for object:"+cname);
return 0;
}
StatusCode RootCnvSvc::i__createObj ( IOpaqueAddress pAddr,
DataObject *&  refpObj 
)
virtual

Create transient object from persistent data.

Parameters
pAddr[IN] Pointer to object address.
refpObj[OUT] Location to pointer to store data object
Returns
Status code indicating success or failure.

Definition at line 480 of file RootCnvSvc.cpp.

{
refpObj = 0;
if ( pA ) {
const string* par = pA->par();
unsigned long* ipar = const_cast<unsigned long*>(pA->ipar());
if ( sc.isSuccess() ) {
ipar[0] = (unsigned long)con;
DataObject* pObj = 0;
size_t len = par[1].find('/',1);
string section = par[1].substr(1,len==string::npos ? string::npos : len-1);
int nb = con->loadObj(section,par[1],ipar[1],pObj);
if ( nb > 1 || (nb == 1 && pObj->clID() == CLID_DataObject) ) {
refpObj = pObj;
return S_OK;
}
delete pObj;
}
string tag = par[0]+":"+par[1];
if ( m_badFiles.find(tag) == m_badFiles.end() ) {
return error("createObj> Cannot access the object:"+tag);
}
return S_FAIL;
}
return S_FAIL;
}
StatusCode RootCnvSvc::i__createRep ( DataObject pObj,
IOpaqueAddress *&  refpAddr 
)
virtual

Convert the transient object to the requested persistent representation.

Parameters
pObj[IN] Pointer to data object
refpAddr[OUT] Location to store pointer to object address.
Returns
Status code indicating success or failure.

Definition at line 417 of file RootCnvSvc.cpp.

{
refpAddr = 0;
if ( pObj ) {
CLID clid = pObj->clID();
IRegistry* pR = pObj->registry();
string p[2] = {m_current->fid(), pR->identifier()};
TClass* cl = (clid == CLID_DataObject) ? m_classDO : getClass(pObj);
size_t len = p[1].find('/',1);
string sect = p[1].substr(1,len==string::npos ? string::npos : len-1);
m_current->saveObj(sect,p[1],cl,pObj,m_bufferSize,m_splitLevel,true);
if ( ret.first > 1 || (clid == CLID_DataObject && ret.first==1) ) {
unsigned long ip[2] = {0,ret.second};
if ( m_currSection.empty() ) m_currSection = p[1];
return createAddress(repSvcType(),clid,p,ip,refpAddr);
}
return error("Failed to write object data for:"+p[1]);
}
return error("createRep> Current Database is invalid!");
}
StatusCode RootCnvSvc::i__fillObjRefs ( IOpaqueAddress pAddr,
DataObject pObj 
)
virtual

Resolve the references of the created transient object.

Parameters
pAddr[IN] Pointer to object address.
pObj[IN] Pointer to data object
Returns
Status code indicating success or failure.

Definition at line 511 of file RootCnvSvc.cpp.

{
if ( pA && pObj ) {
const unsigned long* ipar = pA->ipar();
if ( con ) {
const string* par = pA->par();
size_t len = par[1].find('/',1);
string section = par[1].substr(1,len==string::npos ? string::npos : len-1);
int nb = con->loadRefs(section,par[1],ipar[1],refs);
if ( nb >= 1 ) {
string npar[3];
unsigned long nipar[2];
IRegistry* pR = pObj->registry();
LinkManager* mgr = pObj->linkMgr();
bool active = log().isActive();
for(vector<int>::const_iterator i=refs.links.begin(); i!=refs.links.end();++i) {
mgr->addLink(con->getLink(*i),0);
}
for(size_t j=0, n=refs.refs.size(); j<n; ++j) {
const RootRef& r = refs.refs[j];
npar[0] = con->getDb(r.dbase);
npar[1] = con->getCont(r.container);
npar[2] = con->getLink(r.link);
nipar[0] = 0;
nipar[1] = r.entry;
StatusCode sc = addressCreator()->createAddress(r.svc,r.clid,npar,nipar,nPA);
if ( sc.isSuccess() ) {
if ( active ) {
log() << isvc->name() << " -> Register:" << pA->registry()->identifier()
<< "#" << npar[2] << "[" << r.entry << "]" << endmsg;
}
sc = dataMgr->registerAddress(pA->registry(),npar[2],nPA);
if ( sc.isSuccess() ) {
continue;
}
}
log() << MSG::ERROR << con->fid() << ": Failed to create address!!!!" << endmsg;
return S_FAIL;
}
return pObj->update();
}
else if ( nb < 0 ) {
string tag = par[0]+":"+par[1];
if ( m_badFiles.find(tag) == m_badFiles.end() ) {
return error("createObj> Cannot access the object:"+tag+" [Corrupted file]");
}
}
}
return S_FAIL;
}
return error("read> Cannot read object -- no valid object address present ");
}
StatusCode RootCnvSvc::i__fillRepRefs ( IOpaqueAddress pAddr,
DataObject pObj 
)
virtual

Resolve the references of the converted object.

Parameters
pAddr[IN] Pointer to object address.
pObj[IN] Pointer to data object
Returns
Status code indicating success or failure.

Definition at line 439 of file RootCnvSvc.cpp.

{
if ( pObj ) {
typedef vector<IRegistry*> Leaves;
Leaves leaves;
IRegistry* pR = pObj->registry();
if ( dataMgr ) {
StatusCode status = dataMgr->objectLeaves(pObj, leaves);
if ( status.isSuccess() ) {
const string& id = pR->identifier();
size_t len = id.find('/',1);
string sect = id.substr(1,len==string::npos ? string::npos : len-1);
LinkManager* pLinks = pObj->linkMgr();
for(Leaves::iterator i=leaves.begin(), iend=leaves.end(); i != iend; ++i) {
if ( (*i)->address() ) {
m_current->makeRef(*i,ref);
ref.entry = (*i)->address()->ipar()[1];
refs.refs.push_back(ref);
}
}
for(int i = 0, n=pLinks->size(); i < n; ++i) {
LinkManager::Link* lnk = pLinks->link(i);
int link_id = m_current->makeLink(lnk->path());
refs.links.push_back(link_id);
}
m_current->save(sect,id+"#R",m_classRefs,&refs,m_bufferSize,m_splitLevel,true);
if ( ret.first > 1 ) {
log() << MSG::DEBUG << "Writing object:" << id << " "
<< ret.first << " " << hex << ret.second << dec << endmsg;
return S_OK;
}
}
}
}
return S_FAIL;
}
StatusCode RootCnvSvc::initialize ( )
virtual

ConversionSvc overload: initialize Db service.

Reimplemented from ConversionSvc.

Definition at line 94 of file RootCnvSvc.cpp.

{
string cname;
if ( !status.isSuccess() ) {
return error("Failed to initialize ConversionSvc base class.");
}
m_log = new MsgStream(msgSvc(),name());
if ( !m_compression.empty() ) {
log() << MSG::INFO << "Setting global ROOT compression to:" << m_compression << endmsg;
if ( !(status=RootConnectionSetup::setCompression(m_compression)).isSuccess() ) {
return error("Unable to interprete ROOT compression encoding:"+m_compression);
}
}
if( !(status=service("IODataManager", m_ioMgr)).isSuccess() )
return error("Unable to localize interface from service:IODataManager");
if( !(status=service("IncidentSvc", m_incidentSvc)).isSuccess() )
return error("Unable to localize interface from service:IncidentSvc");
m_setup->setIncidentSvc(m_incidentSvc);
cname = System::typeinfoName(typeid(DataObject));
m_classDO = gROOT->GetClass(cname.c_str());
if ( 0 == m_classDO )
return error("Unable to load class description for DataObject");
m_classRefs = gROOT->GetClass(cname.c_str());
if ( 0 == m_classRefs )
return error("Unable to load class description for ObjectRefs");
return S_OK;
}
void RootCnvSvc::loadConverter ( DataObject pObj)
virtual

ConversionSvc overload: Load the class (dictionary) for the converter.

Reimplemented from ConversionSvc.

Definition at line 171 of file RootCnvSvc.cpp.

{
if (pObject) {
string cname = System::typeinfoName(typeid(*pObject));
log() << MSG::DEBUG << "Trying to 'Autoload' dictionary for class " << cname << endmsg;
TClass* cl = s_classesNames[cname];
if ( 0 == cl ) {
cl = gROOT->GetClass(cname.c_str());
if ( cl ) {
s_classesNames[cname] = cl;
s_classesClids[pObject->clID()] = cl;
}
}
}
}
MsgStream& Gaudi::RootCnvSvc::log ( ) const
inlineprotected

Helper: Use message streamer.

Definition at line 101 of file RootCnvSvc.h.

{ return *m_log; }
virtual StatusCode Gaudi::RootCnvSvc::updateServiceState ( IOpaqueAddress )
inlinevirtual

Update state of the service.

Reimplemented from ConversionSvc.

Definition at line 112 of file RootCnvSvc.h.

{ return StatusCode::SUCCESS; }

Member Data Documentation

int Gaudi::RootCnvSvc::m_autoFlush
protected

Property: AutoFlush parameter for ROOT TTree (Number of events between auto flushes)

Definition at line 84 of file RootCnvSvc.h.

std::set<std::string> Gaudi::RootCnvSvc::m_badFiles
protected

Set with bad files/tables.

Definition at line 93 of file RootCnvSvc.h.

int Gaudi::RootCnvSvc::m_basketSize
protected

Property: Basket optimization parameter for ROOT TTree (total basket size)

Definition at line 86 of file RootCnvSvc.h.

int Gaudi::RootCnvSvc::m_bufferSize
protected

Property: Buffer size optimization parameter for ROOT TTree.

Definition at line 88 of file RootCnvSvc.h.

TClass* Gaudi::RootCnvSvc::m_classDO
protected

TClass pointer to DataObject class.

Definition at line 66 of file RootCnvSvc.h.

TClass* Gaudi::RootCnvSvc::m_classRefs
protected

TClass pointer to reference class.

Definition at line 64 of file RootCnvSvc.h.

std::string Gaudi::RootCnvSvc::m_compression
protected

Property: Compression-algorithm:compression-level.

Definition at line 81 of file RootCnvSvc.h.

Gaudi::RootDataConnection* Gaudi::RootCnvSvc::m_current
protected

On writing: reference to active output stream.

Definition at line 62 of file RootCnvSvc.h.

std::string Gaudi::RootCnvSvc::m_currSection
protected

Property: ROOT section name.

Definition at line 70 of file RootCnvSvc.h.

bool Gaudi::RootCnvSvc::m_incidentEnabled
protected

Property: Flag to enable incidents on FILE_OPEN.

Definition at line 73 of file RootCnvSvc.h.

IIncidentSvc* Gaudi::RootCnvSvc::m_incidentSvc
protected

Reference to incident service.

Definition at line 60 of file RootCnvSvc.h.

Gaudi::IIODataManager* Gaudi::RootCnvSvc::m_ioMgr
protected

Reference to the I/O data manager.

Definition at line 58 of file RootCnvSvc.h.

std::string Gaudi::RootCnvSvc::m_ioPerfStats
protected

Property: Enable TTree IOperfStats if not empty; otherwise perf stat file name.

Definition at line 79 of file RootCnvSvc.h.

MsgStream* Gaudi::RootCnvSvc::m_log
protected

Message streamer.

Definition at line 96 of file RootCnvSvc.h.

std::string Gaudi::RootCnvSvc::m_recordName
protected

Property: Records name to fire incident for file records.

Definition at line 77 of file RootCnvSvc.h.

RootConnectionSetup* Gaudi::RootCnvSvc::m_setup
protected

Setup structure (ref-counted) and passed to data connections.

Definition at line 68 of file RootCnvSvc.h.

std::string Gaudi::RootCnvSvc::m_shareFiles
protected

Property: Share files ? If set to YES, files will not be closed on finalize.

Definition at line 75 of file RootCnvSvc.h.

int Gaudi::RootCnvSvc::m_splitLevel
protected

Property: Split level optimization parameter for ROOT TTree.

Definition at line 90 of file RootCnvSvc.h.


The documentation for this class was generated from the following files:

Generated at Wed Dec 4 2013 14:33:21 for Gaudi Framework, version v24r2 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004