Gaudi Framework, version v20r3

Generated: 24 Nov 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::string > Strings
 the actual type for the vector of strings
typedef std::set< std::string > Set
 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.
: Object implementation
 HistogramPersistencySvc (const std::string &name, ISvcLocator *svc)
 Standard Constructor.
virtual ~HistogramPersistencySvc ()
 Standard Destructor.

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
bool m_warnings
 Flag to disable warning messages when using external input.

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 246 of file HistogramPersistencySvc.cpp.

00248   :  PersistencySvc(name, svc)
00249   //
00250   , m_convert   () 
00251   , m_exclude   () 
00252   , m_converted () 
00253   , m_excluded  ()
00254   //
00255 {
00256   std::vector<std::string> defServices;
00257   defServices.push_back("HbookHistSvc");
00258   defServices.push_back("RootHistSvc");
00259   m_svcNames.set(defServices);
00260   declareProperty ("HistogramPersistency", m_histPersName = "");
00261   declareProperty ("OutputFile", m_outputFile = "");
00262   //
00263   declareProperty 
00264     ("ConvertHistos" , m_convert , 
00265      "The list of patterns to be accepted for conversion" ) ;
00266   //
00267   declareProperty 
00268     ("ExcludeHistos" , m_exclude , 
00269      "The list of patterns to be excluded for conversion" ) ;
00270   declareProperty("Warnings",m_warnings=true,
00271                   "Set this property to false to suppress warning messages");
00272 }

HistogramPersistencySvc::~HistogramPersistencySvc (  )  [virtual]

Standard Destructor.

Definition at line 276 of file HistogramPersistencySvc.cpp.

00276 {}


Member Function Documentation

StatusCode HistogramPersistencySvc::initialize (  )  [virtual]

Initialize the service.

Reimplemented from PersistencySvc.

Definition at line 83 of file HistogramPersistencySvc.cpp.

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

StatusCode HistogramPersistencySvc::reinitialize (  )  [virtual]

Reinitialize the service.

Reimplemented from Service.

Definition at line 93 of file HistogramPersistencySvc.cpp.

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

StatusCode HistogramPersistencySvc::finalize ( void   )  [virtual]

Finalize the service.

Reimplemented from PersistencySvc.

Definition at line 49 of file HistogramPersistencySvc.cpp.

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

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 204 of file HistogramPersistencySvc.cpp.

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


Friends And Related Function Documentation

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.

std::string HistogramPersistencySvc::m_outputFile [protected]

Name of the outputFile.

Definition at line 85 of file HistogramPersistencySvc.h.

the list of patterns to be converted

Definition at line 87 of file HistogramPersistencySvc.h.

the list of patterns to be excludes

Definition at line 89 of file HistogramPersistencySvc.h.

for the final report: the list of converted histograms

Definition at line 91 of file HistogramPersistencySvc.h.

for the final report: the list of excluded histograms

Definition at line 93 of file HistogramPersistencySvc.h.

Flag to disable warning messages when using external input.

Definition at line 95 of file HistogramPersistencySvc.h.


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

Generated at Mon Nov 24 14:45:29 2008 for Gaudi Framework, version v20r3 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004