Gaudi Framework, version v22r1

Home   Generated: Mon Feb 28 2011
Public Types | Protected Attributes | Friends

HistogramPersistencySvc Class Reference

HistogramPersistencySvc class implementation definition. More...

#include <HistogramPersistencySvc.h>

Inheritance diagram for HistogramPersistencySvc:
Inheritance graph
[legend]
Collaboration diagram for HistogramPersistencySvc:
Collaboration graph
[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

for report: unconverted histograms

Definition at line 79 of file HistogramPersistencySvc.h.

the actual type for the vector of strings

Definition at line 77 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.

  :  PersistencySvc(name, svc)
  //
  , m_convert   ()
  , m_exclude   ()
  , m_converted ()
  , m_excluded  ()
  //
{
  std::vector<std::string> defServices;
  defServices.push_back("HbookHistSvc");
  defServices.push_back("RootHistSvc");
  m_svcNames.set(defServices);
  declareProperty ("HistogramPersistency", m_histPersName = "");
  declareProperty ("OutputFile", m_outputFile = "");
  //
  declareProperty
    ("ConvertHistos" , m_convert ,
     "The list of patterns to be accepted for conversion" ) ;
  //
  declareProperty
    ("ExcludeHistos" , m_exclude ,
     "The list of patterns to be excluded for conversion" ) ;
  declareProperty("Warnings",m_warnings=true,
                  "Set this property to false to suppress warning messages");
}
HistogramPersistencySvc::~HistogramPersistencySvc (  ) [virtual]

Standard Destructor.

Definition at line 279 of file HistogramPersistencySvc.cpp.

{}

Member Function Documentation

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.

{
  // enable the conversion
  enable ( true ) ;
  // conversion is possible ?
  if ( "NONE" == m_histPersName )
  {
    enable ( false ) ;
    return PersistencySvc::createRep ( pObj , refpAddr ) ;   // RETURN
  }
  // histogram ?
  if ( 0 != dynamic_cast<AIDA::IBaseHistogram*> ( pObj ) )
  {
    bool select = false ;
    // Empty ConvertHistos property means convert all
    if ( m_convert.empty() ) { select = true ; }
    else
    {
      for ( Strings::const_iterator item = m_convert.begin() ;
            m_convert.end() != item ; ++item )
      { if ( match ( pObj , *item ) ) { select = true ; break ; } }
    }
    // exclude ?
    for ( Strings::const_iterator item = m_exclude.begin() ;
          m_exclude.end() != item && select ; ++item )
    { if ( match ( pObj , *item ) ) { select = false ; break ; } }
    //
    enable ( select ) ;
    //
    const std::string& path = oname ( pObj ) ;
    //
    if ( !select ) { m_excluded.insert  ( path ) ; }
    else           { m_converted.insert ( path ) ; }
  }
  //
  return PersistencySvc::createRep ( pObj , refpAddr ) ;     // RETURN
}
StatusCode HistogramPersistencySvc::finalize (  ) [virtual]

Finalize the service.

Reimplemented from PersistencySvc.

Definition at line 53 of file HistogramPersistencySvc.cpp.

{
  //
  MsgStream log ( msgSvc() , name() );
  if ( !(m_convert.empty() && m_exclude.empty()) )
  { // print message if any of the two properties is used
    log << MSG::INFO  << "Histograms Converted/Excluded: "
        << m_converted.size() << "/" << m_excluded.size() << endmsg ;
  }
  //
  if ( !m_excluded.empty() )
  {
    log << MSG::DEBUG << "Excluded  Histos : #" << m_excluded.size() ;
    for ( Set::const_iterator item = m_excluded.begin() ;
          m_excluded.end() != item ; ++item )
    { log << std::endl << "  '" << (*item) << "'" ; }
    log << endmsg ;
  }
  //
  if ( !m_converted.empty() )
  {
    log << MSG::DEBUG << "Converted Histos : #" << m_converted.size() ;
    for ( Set::const_iterator item = m_converted.begin() ;
          m_converted.end() != item ; ++item )
    { log << std::endl << "  '" << (*item) << "'" ; }
    log << endmsg ;
  }
  //
  StatusCode status = PersistencySvc::finalize();
  return status;
}
StatusCode HistogramPersistencySvc::initialize (  ) [virtual]

Initialize the service.

Reimplemented from PersistencySvc.

Definition at line 87 of file HistogramPersistencySvc.cpp.

                                                   {
  StatusCode status = PersistencySvc::initialize();
  if ( status.isSuccess() )   {
    status = reinitialize();
  }
  return status;
}
StatusCode HistogramPersistencySvc::reinitialize (  ) [virtual]

Reinitialize the service.

Reimplemented from Service.

Definition at line 97 of file HistogramPersistencySvc.cpp.

{
  MsgStream log(msgSvc(), name());
  // Obtain the IProperty of the ApplicationMgr
  SmartIF<IProperty> prpMgr(serviceLocator());
  if ( !prpMgr.isValid() )   {
    log << MSG::FATAL << "IProperty interface not found in ApplicationMgr." << endmsg;
    return StatusCode::FAILURE;
  }
  else {
    setProperty(prpMgr->getProperty("HistogramPersistency")).ignore();
  }

  // To keep backward compatibility, we set the property of conversion service
  // into JobOptions catalogue
  if( m_outputFile != "" ) {
    SmartIF<IJobOptionsSvc> joptsvc(serviceLocator()->service("JobOptionsSvc"));
    if( joptsvc.isValid() ) {
      StringProperty p("OutputFile", m_outputFile);
      if ( m_histPersName == "ROOT" ) {
        joptsvc->addPropertyToCatalogue("RootHistSvc", p).ignore();
      } else if (m_histPersName == "HBOOK" ) {
        joptsvc->addPropertyToCatalogue("HbookHistSvc", p).ignore();
      }
    }
  }

  // Load the Histogram persistency service that's required as default
  setConversionSvc(0).ignore();
  if ( m_histPersName == "ROOT" ) {
    setConversionSvc(service("RootHistSvc")).ignore();
    if ( !conversionSvc() ) {
      return StatusCode::FAILURE;
    }
    enable(true);
  }
  else if ( m_histPersName == "HBOOK" ) {
    setConversionSvc(service("HbookHistSvc")).ignore();
    if ( !conversionSvc() ) {
      return StatusCode::FAILURE;
    }
    enable(true);
  }
  else if ( m_histPersName == "NONE" ) {
    enable(false);
    if ( m_warnings ) {
      log << MSG::WARNING << "Histograms saving not required." << endmsg;
    }
  }
  else {
    setConversionSvc(service(m_histPersName)).ignore();
    if ( !conversionSvc() ) {
      return StatusCode::FAILURE;
    }
    enable(true);
    if ( m_warnings ) {
      log << MSG::WARNING << "Unknown Histogram Persistency Mechanism " << m_histPersName << endmsg;
    }
  }
  return StatusCode::SUCCESS;
}

Friends And Related Function Documentation

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

Definition at line 52 of file HistogramPersistencySvc.h.

friend class SvcFactory< HistogramPersistencySvc > [friend]

Definition at line 51 of file HistogramPersistencySvc.h.


Member Data Documentation

the list of patterns to be converted

Definition at line 87 of file HistogramPersistencySvc.h.

for the final report: the list of converted histograms

Definition at line 91 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 excluded histograms

Definition at line 93 of file HistogramPersistencySvc.h.

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.

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:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Mon Feb 28 2011 18:28:07 for Gaudi Framework, version v22r1 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004