Gaudi Framework, version v21r11

Home   Generated: 30 Sep 2010

HistogramPersistencySvc Class Reference

HistogramPersistencySvc class implementation definition. More...

#include <HistogramPersistencySvc.h>

Inheritance diagram for HistogramPersistencySvc:
[legend]
Collaboration diagram for HistogramPersistencySvc:
[legend]

List of all members.

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.
: 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 *)>


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.


Member Typedef Documentation

the actual type for the vector of strings

Definition at line 77 of file HistogramPersistencySvc.h.

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

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

HistogramPersistencySvc::~HistogramPersistencySvc (  )  [virtual]

Standard Destructor.

Definition at line 279 of file HistogramPersistencySvc.cpp.

00279 {}


Member Function Documentation

StatusCode HistogramPersistencySvc::initialize (  )  [virtual]

Initialize the service.

Reimplemented from PersistencySvc.

Definition at line 87 of file HistogramPersistencySvc.cpp.

00087                                                    {
00088   StatusCode status = PersistencySvc::initialize();
00089   if ( status.isSuccess() )   {
00090     status = reinitialize();
00091   }
00092   return status;
00093 }

StatusCode HistogramPersistencySvc::reinitialize (  )  [virtual]

Reinitialize the service.

Reimplemented from Service.

Definition at line 97 of file HistogramPersistencySvc.cpp.

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

StatusCode HistogramPersistencySvc::finalize (  )  [virtual]

Finalize the service.

Reimplemented from PersistencySvc.

Definition at line 53 of file HistogramPersistencySvc.cpp.

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

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

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


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

Name of the Hist Pers type.

Definition at line 83 of file HistogramPersistencySvc.h.

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 Thu Sep 30 09:58:31 2010 for Gaudi Framework, version v21r11 by Doxygen version 1.5.6 written by Dimitri van Heesch, © 1997-2004