Gaudi Framework, version v20r2

Generated: 18 Jul 2008

HistogramPersistencySvc Class Reference

#include <HistogramPersistencySvc.h>

Inheritance diagram for HistogramPersistencySvc:

Inheritance graph
[legend]
Collaboration diagram for HistogramPersistencySvc:

Collaboration graph
[legend]
List of all members.

Detailed Description

HistogramPersistencySvc class implementation definition.

System: The LHCb Offline System

Package: HistogramPersistencySvc

Dependencies:

History:

 +---------+----------------------------------------------+---------+
 |    Date |                 Comment                      | Who     |
 +---------+----------------------------------------------+---------+
 | 3/11/98 | Initial version                              | M.Frank |
 +---------+----------------------------------------------+---------+
 
Author:
Markus Frank
Version:
1.0

Definition at line 48 of file HistogramPersistencySvc.h.

Public Types

typedef std::vector< std::stringStrings
 the actual type for the vector of strings
typedef std::set< std::stringSet
 for report: unconverted histograms

Public Member Functions

PersistencySvc overrides
virtual StatusCode initialize ()
 Initialize the service.
virtual StatusCode reinitialize ()
 Reinitialize the service.
virtual StatusCode finalize ()
 Finalize the service.
virtual StatusCode createRep (DataObject *pObject, IOpaqueAddress *&refpAddress)
 Implementation of IConverter: Convert the transient object to the requested representation.

Protected Attributes

std::string m_histPersName
 Name of the Hist Pers type.
std::string m_outputFile
 Name of the outputFile.
Strings m_convert
 the list of patterns to be converted
Strings m_exclude
 the list of patterns to be excludes
Set m_converted
 for the final report: the list of converted histograms
Set m_excluded
 for the final report: the list of excluded histograms

Friends

class SvcFactory< HistogramPersistencySvc >
class Factory< HistogramPersistencySvc, IService *(std::string, ISvcLocator *)>


Member Typedef Documentation

typedef std::vector<std::string> HistogramPersistencySvc::Strings

the actual type for the vector of strings

Definition at line 77 of file HistogramPersistencySvc.h.

typedef std::set<std::string> HistogramPersistencySvc::Set

for report: unconverted histograms

Definition at line 79 of file HistogramPersistencySvc.h.


Constructor & Destructor Documentation

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

Standard Constructor.

Definition at line 241 of file HistogramPersistencySvc.cpp.

References std::vector< _Tp, _Alloc >::push_back().

00243   :  PersistencySvc(name, svc)
00244   //
00245   , m_convert   () 
00246   , m_exclude   () 
00247   , m_converted () 
00248   , m_excluded  ()
00249   //
00250 {
00251   std::vector<std::string> defServices;
00252   defServices.push_back("HbookHistSvc");
00253   defServices.push_back("RootHistSvc");
00254   m_svcNames.set(defServices);
00255   declareProperty ("HistogramPersistency", m_histPersName = "");
00256   declareProperty ("OutputFile", m_outputFile = "");
00257   //
00258   declareProperty 
00259     ("ConvertHistos" , m_convert , 
00260      "The list of patterns to be accepted for conversion" ) ;
00261   //
00262   declareProperty 
00263     ("ExcludeHistos" , m_exclude , 
00264      "The list of patterns to be excluded for conversion" ) ;
00265 }

HistogramPersistencySvc::~HistogramPersistencySvc (  )  [virtual]

Standard Destructor.

Definition at line 269 of file HistogramPersistencySvc.cpp.

00269 {}

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

Standard Constructor.

Definition at line 241 of file HistogramPersistencySvc.cpp.

References std::vector< _Tp, _Alloc >::push_back().

00243   :  PersistencySvc(name, svc)
00244   //
00245   , m_convert   () 
00246   , m_exclude   () 
00247   , m_converted () 
00248   , m_excluded  ()
00249   //
00250 {
00251   std::vector<std::string> defServices;
00252   defServices.push_back("HbookHistSvc");
00253   defServices.push_back("RootHistSvc");
00254   m_svcNames.set(defServices);
00255   declareProperty ("HistogramPersistency", m_histPersName = "");
00256   declareProperty ("OutputFile", m_outputFile = "");
00257   //
00258   declareProperty 
00259     ("ConvertHistos" , m_convert , 
00260      "The list of patterns to be accepted for conversion" ) ;
00261   //
00262   declareProperty 
00263     ("ExcludeHistos" , m_exclude , 
00264      "The list of patterns to be excluded for conversion" ) ;
00265 }

HistogramPersistencySvc::~HistogramPersistencySvc (  )  [virtual]

Standard Destructor.

Definition at line 269 of file HistogramPersistencySvc.cpp.

00269 {}


Member Function Documentation

StatusCode HistogramPersistencySvc::initialize (  )  [virtual]

Initialize the service.

Reimplemented from PersistencySvc.

Definition at line 82 of file HistogramPersistencySvc.cpp.

References PersistencySvc::initialize(), StatusCode::isSuccess(), and reinitialize().

00082                                                    {
00083   StatusCode status = PersistencySvc::initialize();
00084   if ( status.isSuccess() )   {
00085     status = reinitialize();
00086   }
00087   return status;
00088 }

StatusCode HistogramPersistencySvc::reinitialize (  )  [virtual]

Reinitialize the service.

Reimplemented from Service.

Definition at line 92 of file HistogramPersistencySvc.cpp.

References IJobOptionsSvc::addPropertyToCatalogue(), PersistencySvc::conversionSvc(), PersistencySvc::enable(), endreq(), StatusCode::FAILURE, MSG::FATAL, StatusCode::ignore(), SmartIFBase< TYPE >::isValid(), m_histPersName, m_outputFile, Service::msgSvc(), Service::name(), IInterface::release(), PersistencySvc::service(), Service::serviceLocator(), PersistencySvc::setConversionSvc(), Service::setProperty(), StatusCode::SUCCESS, and MSG::WARNING.

Referenced by initialize().

00093 {
00094   MsgStream log(msgSvc(), name());
00095   // Obtain the IProperty of the ApplicationMgr
00096   SmartIF<IProperty> prpMgr(serviceLocator());
00097   if ( !prpMgr.isValid() )   {
00098     log << MSG::FATAL << "IProperty interface not found in ApplicationMgr." << endreq;
00099     return StatusCode::FAILURE;
00100   }
00101   else {
00102     setProperty(prpMgr->getProperty("HistogramPersistency")).ignore();
00103   }
00104   
00105   // To keep backward compatibility, we set the property of conversion service
00106   // into JobOptions catalogue
00107   if( m_outputFile != "" ) {
00108     IJobOptionsSvc* joptsvc;
00109     if( serviceLocator()->service("JobOptionsSvc", joptsvc ).isSuccess() ) {
00110       StringProperty p("OutputFile", m_outputFile);
00111       if ( m_histPersName == "ROOT" ) {
00112         joptsvc->addPropertyToCatalogue("RootHistSvc", p).ignore();
00113       } else if (m_histPersName == "HBOOK" ) {
00114         joptsvc->addPropertyToCatalogue("HbookHistSvc", p).ignore();
00115       }
00116       joptsvc->release();
00117     }
00118   }
00119 
00120   // Load the Histogram persistency service that's required as default
00121   setConversionSvc(0).ignore();
00122   if ( m_histPersName == "ROOT" ) {
00123     setConversionSvc(service("RootHistSvc")).ignore();
00124     if ( !conversionSvc() ) {
00125       return StatusCode::FAILURE;
00126     }
00127     enable(true);
00128   }
00129   else if ( m_histPersName == "HBOOK" ) {
00130     setConversionSvc(service("HbookHistSvc")).ignore();
00131     if ( !conversionSvc() ) {
00132       return StatusCode::FAILURE;
00133     }
00134     enable(true);
00135   }
00136   else if ( m_histPersName == "NONE" ) {
00137     enable(false);
00138     log << MSG::WARNING << "Histograms saving not required." << endreq;
00139   }
00140   else {
00141     setConversionSvc(service(m_histPersName)).ignore();
00142     if ( !conversionSvc() ) {
00143       return StatusCode::FAILURE;
00144     }
00145     enable(true);
00146     log << MSG::WARNING << "Unknown Histogram Persistency Mechanism " << m_histPersName << endreq;
00147   }
00148   return StatusCode::SUCCESS;
00149 }

StatusCode HistogramPersistencySvc::finalize (  )  [virtual]

Finalize the service.

Reimplemented from PersistencySvc.

Definition at line 48 of file HistogramPersistencySvc.cpp.

References MSG::DEBUG, std::endl(), endreq(), PersistencySvc::finalize(), MSG::INFO, and name.

00049 {
00050   //
00051   MsgStream log ( msgSvc() , name() );
00052   if ( !(m_convert.empty() && m_exclude.empty()) )
00053   { // print message if any of the two properties is used
00054     log << MSG::INFO  << "Histograms Converted/Excluded: " 
00055         << m_converted.size() << "/" << m_excluded.size() << endreq ;
00056   }
00057   //
00058   if ( !m_excluded.empty() ) 
00059   {
00060     log << MSG::DEBUG << "Excluded  Histos : #" << m_excluded.size() ;
00061     for ( Set::const_iterator item = m_excluded.begin() ; 
00062           m_excluded.end() != item ; ++item ) 
00063     { log << std::endl << "  '" << (*item) << "'" ; }
00064     log << endreq ;
00065   }
00066   //
00067   if ( !m_converted.empty() ) 
00068   {
00069     log << MSG::DEBUG << "Converted Histos : #" << m_converted.size() ;
00070     for ( Set::const_iterator item = m_converted.begin() ; 
00071           m_converted.end() != item ; ++item ) 
00072     { log << std::endl << "  '" << (*item) << "'" ; }
00073     log << endreq ;
00074   }
00075   //
00076   StatusCode status = PersistencySvc::finalize();
00077   return status;
00078 }

StatusCode HistogramPersistencySvc::createRep ( DataObject pObject,
IOpaqueAddress *&  refpAddress 
) [virtual]

Implementation of IConverter: Convert the transient object to the requested representation.

Reimplemented from PersistencySvc.

Definition at line 199 of file HistogramPersistencySvc.cpp.

References PersistencySvc::createRep(), match(), oname(), and Gaudi::Utils::Histos::path().

00201 {
00202   // enable the conversion 
00203   enable ( true ) ;
00204   // conversion is possible ?
00205   if ( "NONE" == m_histPersName ) 
00206   {
00207     enable ( false ) ; 
00208     return PersistencySvc::createRep ( pObj , refpAddr ) ;   // RETURN 
00209   }
00210   // histogram ?
00211   if ( 0 != dynamic_cast<AIDA::IBaseHistogram*> ( pObj ) ) 
00212   {
00213     bool select = false ;
00214     // Empty ConvertHistos property means convert all
00215     if ( m_convert.empty() ) { select = true ; }
00216     else  
00217     {
00218       for ( Strings::const_iterator item = m_convert.begin() ; 
00219             m_convert.end() != item ; ++item ) 
00220       { if ( match ( pObj , *item ) ) { select = true ; break ; } }
00221     }
00222     // exclude ?
00223     for ( Strings::const_iterator item = m_exclude.begin() ;
00224           m_exclude.end() != item && select ; ++item ) 
00225     { if ( match ( pObj , *item ) ) { select = false ; break ; } }
00226     //
00227     enable ( select ) ;
00228     //
00229     const std::string& path = oname ( pObj ) ;
00230     //
00231     if ( !select ) { m_excluded.insert  ( path ) ; }
00232     else           { m_converted.insert ( path ) ; }
00233   }
00234   //
00235   return PersistencySvc::createRep ( pObj , refpAddr ) ;     // RETURN 
00236 }


Friends And Related Function Documentation

friend class SvcFactory< HistogramPersistencySvc > [friend]

Definition at line 51 of file HistogramPersistencySvc.h.

friend class Factory< HistogramPersistencySvc, IService *(std::string, ISvcLocator *)> [friend]

Definition at line 52 of file HistogramPersistencySvc.h.


Member Data Documentation

std::string HistogramPersistencySvc::m_histPersName [protected]

Name of the Hist Pers type.

Definition at line 83 of file HistogramPersistencySvc.h.

Referenced by reinitialize().

std::string HistogramPersistencySvc::m_outputFile [protected]

Name of the outputFile.

Definition at line 85 of file HistogramPersistencySvc.h.

Referenced by reinitialize().

Strings HistogramPersistencySvc::m_convert [protected]

the list of patterns to be converted

Definition at line 87 of file HistogramPersistencySvc.h.

Strings HistogramPersistencySvc::m_exclude [protected]

the list of patterns to be excludes

Definition at line 89 of file HistogramPersistencySvc.h.

Set HistogramPersistencySvc::m_converted [protected]

for the final report: the list of converted histograms

Definition at line 91 of file HistogramPersistencySvc.h.

Set HistogramPersistencySvc::m_excluded [protected]

for the final report: the list of excluded histograms

Definition at line 93 of file HistogramPersistencySvc.h.


The documentation for this class was generated from the following files:
Generated at Fri Jul 18 12:07:47 2008 for Gaudi Framework, version v20r2 by Doxygen version 1.5.1 written by Dimitri van Heesch, © 1997-2004