|
Gaudi Framework, version v23r2p1 |
| Home | Generated: Fri Jun 29 2012 |
Persistency service - to store histograms in ROOT format. More...
#include <PersSvc.h>


Public Member Functions | |
| virtual StatusCode | initialize () |
| Initialise the service. | |
| virtual StatusCode | finalize () |
| Finalise the service. | |
| virtual StatusCode | createRep (DataObject *pObject, IOpaqueAddress *&refpAddress) |
| Convert a collection of transient data objects into another representation. | |
| PersSvc (const std::string &name, ISvcLocator *svc) | |
| Standard constructor. | |
| virtual | ~PersSvc () |
| Standard destructor. | |
Private Attributes | |
| std::string | m_defFileName |
| Default file name. | |
| TFile * | m_hfile |
| Pointer to the ROOT file. | |
| bool | m_prtWar |
| Already printed a Warning. | |
| bool | m_alphaIds |
| Force alphabetic histograms/ntuple IDs. | |
| bool | m_outputEnabled |
| Flag to enable/disable the output to file. | |
Friends | |
| class | SvcFactory< PersSvc > |
Persistency service - to store histograms in ROOT format.
Definition at line 21 of file PersSvc.h.
| RootHistCnv::PersSvc::PersSvc | ( | const std::string & | name, |
| ISvcLocator * | svc | ||
| ) |
Standard constructor.
Definition at line 129 of file PersSvc.cpp.
: ConversionSvc(name, svc, ROOT_StorageType), m_hfile(0), m_prtWar(false) { declareProperty("OutputFile", m_defFileName = undefFileName); declareProperty("ForceAlphaIds", m_alphaIds = false); declareProperty("OutputEnabled", m_outputEnabled = true, "Flag to enable/disable the output to file."); }
| RootHistCnv::PersSvc::~PersSvc | ( | ) | [virtual] |
Standard destructor.
Definition at line 139 of file PersSvc.cpp.
| StatusCode RootHistCnv::PersSvc::createRep | ( | DataObject * | pObject, |
| IOpaqueAddress *& | refpAddress | ||
| ) | [virtual] |
Convert a collection of transient data objects into another representation.
Reimplemented from ConversionSvc.
Definition at line 78 of file PersSvc.cpp.
{
// There are objects in the HDS to be stored
if( m_outputEnabled && undefFileName != m_defFileName ) {
SmartDataPtr<DataObject> top(dataProvider(), stat_dir);
if ( 0 != top ) {
IRegistry* pReg = top->registry();
if ( pReg ) {
if ( top.ptr() == pObject ) {
TDirectory* pDir = m_hfile;
refpAddress = new RootObjAddress( repSvcType(),
CLID_DataObject,
stat_dir,
m_defFileName,
long(pDir),
long(0));
return StatusCode::SUCCESS;
}
else {
StatusCode sc = ConversionSvc::createRep(pObject, refpAddress);
if( sc.isFailure() ) {
MsgStream log( msgSvc(), name() );
log << MSG::ERROR
<< "Error while creating persistent Histogram:"
<< pReg->identifier()
<< endmsg;
}
return sc;
}
}
}
MsgStream err( msgSvc(), name() );
err << MSG::ERROR
<< "Internal error while creating Histogram persistent representations"
<< endmsg;
return StatusCode::FAILURE;
} else {
if (m_outputEnabled && !m_prtWar) {
m_prtWar = true;
MsgStream log( msgSvc(), name() );
log << MSG::WARNING
<< "no ROOT output file name, "
<< "Histograms cannot be persistified" << endmsg;
}
}
return StatusCode::SUCCESS;
}
| StatusCode RootHistCnv::PersSvc::finalize | ( | ) | [virtual] |
Finalise the service.
Reimplemented from ConversionSvc.
Definition at line 64 of file PersSvc.cpp.
{
// Close ROOT only if the output file name is defined
MsgStream log( msgSvc(), name() );
log << MSG::DEBUG << "RootHistCnv::PersSvc::finalize()" << endmsg;
if( undefFileName != m_defFileName ) {
m_hfile->Write("",TObject::kOverwrite);
m_hfile->Close();
}
return ConversionSvc::finalize();
}
| StatusCode RootHistCnv::PersSvc::initialize | ( | ) | [virtual] |
Initialise the service.
Reimplemented from ConversionSvc.
Definition at line 33 of file PersSvc.cpp.
{
MsgStream log( msgSvc(), name() );
StatusCode status = ConversionSvc::initialize();
if( status.isFailure() ) return status;
// Get my properties from the JobOptionsSvc
if (setProperties().isFailure()) {
log << MSG::ERROR << "Could not set my properties" << endmsg;
return StatusCode::FAILURE;
}
if (m_outputEnabled) {
// Initialize ROOT if output file name is defined
if( undefFileName != m_defFileName ) {
m_hfile = TFile::Open(m_defFileName.c_str(),"RECREATE","GAUDI Histograms");
} else {
m_hfile = 0;
}
log << MSG::INFO << "Writing ROOT histograms to: " << m_defFileName
<< endmsg;
}
else {
log << MSG::INFO << "Writing ROOT histograms disabled." << endmsg;
}
return StatusCode(StatusCode::SUCCESS,true);
}
friend class SvcFactory< PersSvc > [friend] |
bool RootHistCnv::PersSvc::m_alphaIds [private] |
TFile* RootHistCnv::PersSvc::m_hfile [private] |
bool RootHistCnv::PersSvc::m_outputEnabled [private] |
bool RootHistCnv::PersSvc::m_prtWar [private] |