20 #define PERSISTENCYSVC_HISTOGRAMPERSISTENCYSVC_CPP
26 #include "GaudiKernel/SmartIF.h"
27 #include "GaudiKernel/MsgStream.h"
28 #include "GaudiKernel/ISvcLocator.h"
29 #include "GaudiKernel/IJobOptionsSvc.h"
30 #include "GaudiKernel/DataObject.h"
31 #include "GaudiKernel/IRegistry.h"
32 #include "GaudiKernel/IDataProviderSvc.h"
41 #define class class GAUDI_API
42 #include "AIDA/IBaseHistogram.h"
55 if ( !(m_convert.empty() && m_exclude.empty()) )
57 log <<
MSG::INFO <<
"Histograms Converted/Excluded: "
58 << m_converted.size() <<
"/" << m_excluded.size() <<
endmsg ;
61 if ( !m_excluded.empty() )
63 log <<
MSG::DEBUG <<
"Excluded Histos : #" << m_excluded.size() ;
64 for (
const auto&
item : m_excluded )
65 { log << std::endl <<
" '" <<
item <<
"'" ; }
69 if ( !m_converted.empty() )
71 log <<
MSG::DEBUG <<
"Converted Histos : #" << m_converted.size() ;
72 for (
const auto&
item : m_converted )
73 { log << std::endl <<
" '" <<
item <<
"'" ; }
96 auto prpMgr = serviceLocator()->as<
IProperty>();
98 log <<
MSG::FATAL <<
"IProperty interface not found in ApplicationMgr." <<
endmsg;
102 setProperty(prpMgr->getProperty(
"HistogramPersistency")).ignore();
108 auto joptsvc = serviceLocator()->service<
IJobOptionsSvc> (
"JobOptionsSvc");
112 joptsvc->addPropertyToCatalogue(
"RootHistSvc", p).ignore();
114 joptsvc->addPropertyToCatalogue(
"HbookHistSvc", p).ignore();
158 const std::string s_NULL =
"<NULL>" ;
167 (
const std::string&
name ,
168 const std::string& pat )
171 return std::string::npos != name.find ( pat );
178 inline const std::string& oname (
const DataObject* obj )
180 if ( !obj ) {
return s_NULL ; }
182 return reg ? reg -> identifier() : obj -> name () ;
191 const std::string& pat )
193 return obj && match ( oname ( obj ) , pat ) ;
207 if (
"NONE" == m_histPersName )
213 if ( dynamic_cast<AIDA::IBaseHistogram*> ( pObj ) )
216 auto match_pObj = [&](
const std::string&
s) {
return match( pObj ,
s ); };
218 bool select = ( m_convert.empty()
219 || std::any_of( m_convert.begin(), m_convert.end(), match_pObj )
220 ) && std::none_of( m_exclude.begin(), m_exclude.end(), match_pObj );
224 const auto&
path = oname ( pObj ) ;
226 if ( !select ) { m_excluded.insert (
path ) ; }
227 else { m_converted.insert (
path ) ; }
236 (
const std::string& name ,
240 std::vector<std::string> defServices;
241 defServices.push_back(
"RootHistSvc");
242 m_svcNames.set(defServices);
243 declareProperty (
"HistogramPersistency", m_histPersName =
"");
244 declareProperty (
"OutputFile", m_outputFile =
"");
247 (
"ConvertHistos" , m_convert ,
248 "The list of patterns to be accepted for conversion" ) ;
251 (
"ExcludeHistos" , m_exclude ,
252 "The list of patterns to be excluded for conversion" ) ;
253 declareProperty(
"Warnings",m_warnings=
true,
254 "Set this property to false to suppress warning messages");
SmartIF< IConversionSvc > & service(const std::string &nam)
Retrieve conversion service by name.
Definition of the MsgStream class used to transmit messages.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
StatusCode initialize() override
Initialize the service.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
bool isSuccess() const
Test for a status code of SUCCESS.
StatusCode setConversionSvc(IConversionSvc *svc) override
Set conversion service the converter is connected to.
StatusCode reinitialize() override
Reinitialize the service.
IRegistry * registry() const
Get pointer to Registry.
bool m_warnings
Flag to disable warning messages when using external input.
bool enable(bool value)
Set enabled flag.
Main interface for the JobOptions service.
StatusCode initialize() override
Initialize the service.
#define DECLARE_COMPONENT(type)
This class is used for returning status codes from appropriate routines.
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.
StatusCode finalize() override
stop the service.
bool PyHelper() setProperty(IInterface *p, char *name, char *value)
PersistencySvc class implementation definition.
HistogramPersistencySvc class implementation definition.
StatusCode createRep(DataObject *pObject, IOpaqueAddress *&refpAddress) override
Implementation of IConverter: Convert the transient object to the requested representation.
HistogramPersistencySvc(const std::string &name, ISvcLocator *svc)
Standard Constructor.
SmartIF< IConversionSvc > & conversionSvc() const override
Get conversion service the converter is connected to.
Opaque address interface definition.
The IProperty is the basic interface for all components which have properties that can be set or get...
A DataObject is the base class of any identifiable object on any data store.
std::string m_outputFile
Name of the outputFile.
std::string m_histPersName
Name of the Hist Pers type.