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"
42 #pragma clang diagnostic push
43 #pragma clang diagnostic ignored "-Wkeyword-macro"
45 #define class class GAUDI_API
47 #pragma clang diagnostic pop
49 #include "AIDA/IBaseHistogram.h"
62 if ( !(m_convert.empty() && m_exclude.empty()) )
64 log <<
MSG::INFO <<
"Histograms Converted/Excluded: "
65 << m_converted.size() <<
"/" << m_excluded.size() <<
endmsg ;
68 if ( !m_excluded.empty() )
70 log <<
MSG::DEBUG <<
"Excluded Histos : #" << m_excluded.size() ;
71 for (
const auto&
item : m_excluded )
72 { log << std::endl <<
" '" <<
item <<
"'" ; }
76 if ( !m_converted.empty() )
78 log <<
MSG::DEBUG <<
"Converted Histos : #" << m_converted.size() ;
79 for (
const auto&
item : m_converted )
80 { log << std::endl <<
" '" <<
item <<
"'" ; }
103 auto prpMgr = serviceLocator()->as<
IProperty>();
105 log <<
MSG::FATAL <<
"IProperty interface not found in ApplicationMgr." <<
endmsg;
109 setProperty(prpMgr->getProperty(
"HistogramPersistency")).ignore();
115 auto joptsvc = serviceLocator()->service<
IJobOptionsSvc> (
"JobOptionsSvc");
119 joptsvc->addPropertyToCatalogue(
"RootHistSvc", p).ignore();
121 joptsvc->addPropertyToCatalogue(
"HbookHistSvc", p).ignore();
165 const std::string s_NULL =
"<NULL>" ;
174 (
const std::string&
name ,
175 const std::string& pat )
178 return std::string::npos != name.find ( pat );
185 inline const std::string& oname (
const DataObject* obj )
187 if ( !obj ) {
return s_NULL ; }
189 return reg ? reg -> identifier() : obj -> name () ;
198 const std::string& pat )
200 return obj && match ( oname ( obj ) , pat ) ;
214 if (
"NONE" == m_histPersName )
220 if ( dynamic_cast<AIDA::IBaseHistogram*> ( pObj ) )
223 auto match_pObj = [&](
const std::string&
s) {
return match( pObj ,
s ); };
225 bool select = ( m_convert.empty()
226 || std::any_of( m_convert.begin(), m_convert.end(), match_pObj )
227 ) && std::none_of( m_exclude.begin(), m_exclude.end(), match_pObj );
231 const auto&
path = oname ( pObj ) ;
233 if ( !select ) { m_excluded.insert (
path ) ; }
234 else { m_converted.insert (
path ) ; }
243 (
const std::string& name ,
247 std::vector<std::string> defServices;
248 defServices.push_back(
"RootHistSvc");
249 m_svcNames.set(defServices);
250 declareProperty (
"HistogramPersistency", m_histPersName =
"");
251 declareProperty (
"OutputFile", m_outputFile =
"");
254 (
"ConvertHistos" , m_convert ,
255 "The list of patterns to be accepted for conversion" ) ;
258 (
"ExcludeHistos" , m_exclude ,
259 "The list of patterns to be excluded for conversion" ) ;
260 declareProperty(
"Warnings",m_warnings=
true,
261 "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...
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
StatusCode initialize() override
Initialize the service.
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.
This class is used for returning status codes from appropriate routines.
#define DECLARE_COMPONENT(type)
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.