41#include <boost/algorithm/string/predicate.hpp> 
   42namespace ba = boost::algorithm;
 
   49#define ON_DEBUG if ( msgLevel( MSG::DEBUG ) ) 
   50#define ON_VERBOSE if ( msgLevel( MSG::VERBOSE ) ) 
   62  template <
typename MAP, 
typename SET>
 
   63  inline void map_to_set( 
const MAP& m, 
SET& s ) {
 
   64    std::transform( std::begin( m ), std::end( m ), std::inserter( s, s.begin() ),
 
   65                    std::mem_fn( &MAP::value_type::second ) );
 
   77      return ( 
id < rhs.
id );
 
 
 
   96  constexpr struct clear_t {
 
   97    template <
typename T1, 
typename T2>
 
   98    void operator()( std::pair<const T1* const, T2*>& p ) {
 
   99      const_cast<T1*
>( p.first )->release();
 
  103  template <
typename M>
 
  105    std::for_each( std::begin( m ), std::end( m ), clear_ );
 
  125    debug() << 
"Failed to initialize the base class (Service)" << 
endmsg;
 
  135    error() << 
"unable to get the AlgContextSvc" << 
endmsg;
 
  140  if ( !incidentSvc ) {
 
  141    error() << 
"unable to get the IncidentSvc" << 
endmsg;
 
  149    error() << 
"could not retrieve the ToolSvc handle !" << 
endmsg;
 
  155  const bool rethrow = 
false;
 
  156  const bool oneShot = 
true; 
 
  157  incidentSvc->addListener( 
this, IncidentType::BeginEvent, std::numeric_limits<long>::min(), rethrow, oneShot );
 
 
  173    bool foundAppMgr( 
false );
 
  174    for ( 
const auto& item : 
serviceLocator()->getOptsSvc().items() ) {
 
  175      m_jobHistory->addProperty( get<0>( item ), get<1>( item ) );
 
  176      foundAppMgr |= get<0>( item ).compare( 0, 15, 
"ApplicationMgr." ) == 0;
 
  179    if ( !foundAppMgr ) {
 
  182        error() << 
"could not get the ApplicationMgr" << 
endmsg;
 
  184        for ( 
auto prop : ap->getProperties() ) {
 
  185          m_jobHistory->addProperty( 
"ApplicationMgr." + prop->name(), prop->toString() );
 
  200  for ( 
auto ialg : algMgr->getAlgorithms() ) {
 
  203      warning() << 
"Algorithm " << ialg->name() << 
" does not inherit from Gaudi::Algorithm. Not registering it." 
  211  info() << 
"Registered " << count << 
" Algorithms" << 
endmsg;
 
  217    ( 
const_cast<IAlgTool*
>( algtool ) )->addRef();
 
 
  246      error() << 
"Unable to open output file \"m_outputFile\"" << 
endmsg;
 
 
  283    warning() << 
"Algorithm " << alg.name() << 
" already registered with HistorySvc" << 
endmsg;
 
  293    log << 
"Registering algorithm: ";
 
  295    log << alg.name() << 
endmsg;
 
 
  305  info() << 
"Dumping properties for " << alg.name() << endl;
 
  311  info() << alg.name() << 
" --> " << endl << *hist << 
endmsg;
 
 
  321  if ( !hist ) { 
return; }
 
  323  for ( 
auto prop : hist->
properties() ) { ofs << alg.name() << 
"  " << 
dumpProp( prop ) << std::endl; }
 
 
  331    warning() << 
"Algorithm " << alg.name() << 
" not registered" << 
endmsg;
 
 
  349  log << 
"Dumping properties for all Algorithms (" << 
m_algmap.size() << 
")" << 
endmsg;
 
  355  log << 
"Dumping properties for all AlgTools (" << 
m_algtoolmap.size() << 
")" << 
endmsg;
 
  359    debug() << 
" --> " << algtool.second->algtool_name() << 
endmsg;
 
  365  log << 
"Dumping properties for all Services (" << 
m_svcmap.size() << 
")" << 
endmsg;
 
  371  log << 
"Dumping properties for Job";
 
 
  382  ofs << 
"GLOBAL" << std::endl;
 
  383  for ( 
const auto& prop : 
m_jobHistory->propertyPairs() ) {
 
  384    ofs << prop.first << 
"  " << 
dumpProp( prop.second.get() ) << std::endl;
 
  387  ofs << std::endl << 
"SERVICES" << std::endl;
 
  390  ofs << std::endl << 
"ALGORITHMS" << std::endl;
 
  393  ofs << std::endl << 
"ALGTOOLS" << std::endl;
 
 
  403  warning() << 
"trying to create DataHistoryObj before " 
  404            << 
"HistorySvc has been initialized" << 
endmsg;
 
 
  411                                               const std::string&  ) {
 
  420    debug() << 
"Could not discover current Algorithm:" << endl
 
  421            << 
"          object CLID: " << 
id << 
"  key: \"" << key << 
"\"" << 
endmsg;
 
  428      warning() << 
"Could not extract concrete Algorithm:" << endl
 
  429                << 
"          object CLID: " << 
id << 
"  key: \"" << key << 
"\"" << 
endmsg;
 
 
  441  auto boundaries = 
m_datMap.equal_range( dhh );
 
  442  auto match      = boundaries.second;
 
  444  if ( boundaries.first != boundaries.second ) {
 
  450      algName = ialg->name();
 
  455    match = std::find_if( boundaries.first, boundaries.second,
 
  456                          [&algName]( 
decltype( boundaries )::first_type::reference p ) -> 
bool {
 
  457                            return p.second->algorithmHistory()->algorithm_name() == algName;
 
  461  if ( match == boundaries.second ) { 
 
  463    m_datMap.insert( pair<DHH, DataHistory*>( dhh, dh ) );
 
 
  471                                         const std::string&  )
 const {
 
  475  auto mitr = 
m_datMap.equal_range( dhh );
 
  476  return ( mitr.first != mitr.second ) ? mitr.first->second : 
nullptr;
 
 
  482                                std::list<DataHistory*>& dhlist )
 const {
 
  488  auto mitr = 
m_datMap.equal_range( dhh );
 
  489  for ( 
auto itr = mitr.first; itr != mitr.second; ++itr ) {
 
  490    dhlist.push_back( itr->second );
 
 
  509      log << 
"Registering Service: ";
 
  511      log << svc.name() << 
endmsg;
 
  517    ( 
const_cast<IService*
>( psvc ) )->addRef();
 
 
  529  if ( itr != 
m_svcmap.end() ) 
return itr->second;
 
  531  warning() << 
"Service " << svc.name() << 
" not registered" << 
endmsg;
 
 
  542  info() << 
"Dumping properties for " << svc.name() << endl;
 
  548  info() << svc.name() << 
" --> " << endl << *hist << 
endmsg;
 
 
  561  for ( 
auto& prop : hist->
properties() ) { ofs << svc.name() << 
"  " << 
dumpProp( prop ) << std::endl; }
 
 
  571        error() << 
"unable to get the AlgContextSvc" << 
endmsg;
 
  581    error() << 
"Could not dcast IAlgTool \"" << ialg.
name() << 
"\" to an AlgTool" << 
endmsg;
 
  586    warning() << 
"AlgTool " << ialg.
name() << 
" already registered in HistorySvc" << 
endmsg;
 
  595    log << 
"Registering algtool: ";
 
  597    log << alg->name() << 
endmsg;
 
 
  608  info() << 
"Dumping properties for " << alg.name() << endl;
 
  614  info() << alg.name() << 
" --> " << endl << *hist << 
endmsg;
 
 
  626  for ( 
auto& prop : hist->
properties() ) { ofs << alg.name() << 
"  " << 
dumpProp( prop ) << std::endl; }
 
 
  636    warning() << 
"AlgTool " << alg.name() << 
" not registered" << 
endmsg;
 
 
  650  if ( incident.
type() == IncidentType::BeginEvent ) {
 
  652      warning() << 
"Error capturing state." << endl << 
"Will try again at next BeginEvent incident" << 
endmsg;
 
 
  660  std::ostringstream ost;
 
 
  680    ofs << 
"<?xml version=\"1.0\" ?> " << std::endl;
 
  681    ofs << 
"<!--Test-xml-->" << std::endl;
 
  682    ofs << 
"<SETUP>" << std::endl;
 
  683    ofs << 
"  <GLOBAL>" << std::endl;
 
  685    ofs << 
"GLOBAL" << std::endl;
 
  688  std::string client_currently_open = 
"start";
 
  691    const auto& client = item.first;
 
  692    const auto& prp    = item.second;
 
  696      if ( client != client_currently_open ) {
 
  697        if ( client_currently_open != 
"start" ) ofs << 
"    </COMPONENT>" << endl;
 
  698        ofs << 
"    <COMPONENT name=\"" << client << 
"\" class=\"undefined\">" << std::endl;
 
  701      ofs << client << 
"  ";
 
  706    client_currently_open = client;
 
  712    ofs << 
"</GLOBAL>" << endl << 
"<SERVICES>" << endl;
 
  714    ofs << 
"SERVICES" << std::endl;
 
  718  auto sortedDump = [&ofs, 
this]( 
const auto& map ) {
 
  719    std::map<std::string, const INamedInterface*> sorted;
 
  720    for ( 
const auto& item : map ) sorted[item.first->name()] = item.first;
 
  721    for ( 
const auto& item : sorted ) 
dumpState( item.second, ofs );
 
  727    ofs << 
"</SERVICES>" << endl << 
"<ALGORITHMS> " << endl;
 
  729    ofs << 
"ALGORITHMS" << std::endl;
 
  735    ofs << 
"</ALGORITHMS>" << endl << 
"<ALGTOOLS> " << endl;
 
  737    ofs << 
"ALGTOOLS" << std::endl;
 
 
  755  if ( ( is = 
dynamic_cast<const IService*
>( in ) ) != 
nullptr ) {
 
  761  } 
else if ( ( ia = 
dynamic_cast<const Gaudi::Algorithm*
>( in ) ) != 
nullptr ) {
 
  767  } 
else if ( ( it = 
dynamic_cast<const IAlgTool*
>( in ) ) != 
nullptr ) {
 
  774    error() << 
"Could not dcast interface to accepted History Obj type for " << in->
name() << 
endmsg;
 
  778  if ( !hist || !vhist ) {
 
  779    error() << 
"Could not dcast recognized object to HistoryObj or IVersHistoryObj. This should never happen." 
  785    hist->
dump( ofs, 
true );
 
  787    ofs << 
">> " << vhist->
name() << endl << *hist << endl;
 
 
unsigned int CLID
Class ID definition.
 
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
 
#define DECLARE_COMPONENT(type)
 
AlgToolHistory class definition.
 
const PropertyList & properties() const override
 
AlgorithmHistory class definition.
 
const PropertyList & properties() const override
 
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
 
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
 
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
 
MsgStream & debug() const
shortcut for the method msgStream(MSG::DEBUG)
 
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
 
DataHistory class definition.
 
Base class from which all concrete algorithm classes should be derived.
 
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
 
std::string documentation() const
property documentation
 
virtual std::string toString() const =0
value -> string
 
virtual std::ostream & fillStream(std::ostream &) const
the printout of the property value
 
const std::string name() const
property name
 
Base class for History Objects.
 
virtual std::ostream & dump(std::ostream &, bool isXML=false, int indent=0) const =0
 
static std::string convert_string(const std::string &)
 
HistorySvc class definition.
 
Gaudi::Property< bool > m_activate
 
virtual StatusCode registerDataHistory(const CLID &id, const std::string &key, const std::string &store)
 
StatusCode listProperties() const override
 
StatusCode registerAlgTool(const IAlgTool &) override
 
Gaudi::Property< std::string > m_outputFile
 
ServiceHandle< IAlgContextSvc > p_algCtxSvc
 
virtual StatusCode captureState()
 
void dumpState(std::ofstream &) const
 
StatusCode registerJob() override
 
std::map< const Gaudi::Algorithm *, AlgorithmHistory * > m_algmap
 
Gaudi::Property< bool > m_dump
 
std::set< const IAlgTool * > m_ialgtools
 
StatusCode initialize() override
 
DataHistory * getDataHistory(const CLID &id, const std::string &key, const std::string &store) const override
 
IAlgorithm * getCurrentIAlg() const
 
StatusCode registerSvc(const IService &) override
 
std::multimap< DHH, DataHistory * > m_datMap
 
ServiceHistory * getServiceHistory(const IService &) const override
 
JobHistory * getJobHistory() const override
 
StatusCode registerAlg(const Gaudi::Algorithm &) override
 
std::unique_ptr< JobHistory > m_jobHistory
 
std::map< const IService *, ServiceHistory * > m_svcmap
 
DataHistory * createDataHistoryObj(const CLID &id, const std::string &key, const std::string &store) override
 
StatusCode stop() override
 
StatusCode reinitialize() override
 
void dumpProperties(std::ofstream &) const
 
std::string dumpProp(const Gaudi::Details::PropertyBase *, const bool isXML=false, int indent=0) const
 
std::map< const AlgTool *, AlgToolHistory * > m_algtoolmap
 
AlgorithmHistory * getAlgHistory(const Gaudi::Algorithm &) const override
 
AlgToolHistory * getAlgToolHistory(const IAlgTool &) const override
 
StatusCode finalize() override
 
SmartIF< IToolSvc > m_toolSvc
 
void handle(const Incident &inc) override
 
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
 
The IAlgorithm is the interface implemented by the Algorithm base class.
 
IInterface compliant class extending IInterface with the name() method.
 
virtual const std::string & name() const =0
Retrieve the name of the instance.
 
General service interface definition.
 
virtual const std::list< IService * > & getServices() const =0
Return the list of Services.
 
virtual SmartIF< IService > & service(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
 
Interface for Versioned History Objects.
 
virtual const std::string & name() const =0
 
Base class for all Incidents (computing events).
 
const std::string & type() const
Access to the incident type.
 
JobHistory class definition.
 
ServiceHistory class definition.
 
const PropertyList & properties() const override
 
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
 
StatusCode finalize() override
 
Gaudi::StateMachine::State m_state
Service state.
 
SmartIF< IFace > service(const std::string &name, bool createIf=true) const
 
StatusCode initialize() override
 
This class is used for returning status codes from appropriate routines.
 
const StatusCode & ignore() const
Allow discarding a StatusCode without warning.
 
constexpr static const auto SUCCESS
 
constexpr static const auto FAILURE
 
GAUDI_API ISvcLocator * svcLocator()
 
bool operator<(DHH const &rhs) const
 
DHH(const CLID &i, std::string k)