DataOnDemandSvc Class Reference

The DataOnDemandSvc listens to incidents typically triggered by the data service of the configurable name "IncidentName". More...

#include <src/IncidentSvc/DataOnDemandSvc.h>

Inheritance diagram for DataOnDemandSvc:
Collaboration diagram for DataOnDemandSvc:

Classes

struct  Leaf
 
struct  Node
 Helper class of the DataOnDemandSvc. More...
 
struct  Protection
 Helper class of the DataOnDemandSvc. More...
 

Public Types

typedef std::vector< std::stringSetup
 
typedef TClass * ClassH
 
typedef GaudiUtils::HashMap< Gaudi::StringKey, NodeNodeMap
 
typedef GaudiUtils::HashMap< Gaudi::StringKey, LeafAlgMap
 
- Public Types inherited from extends< Service, IIncidentListener >
using base_class = extends
 Typedef to this class. More...
 
using extend_interfaces_base = extend_interfaces< Interfaces...>
 Typedef to the base of this class. More...
 
- Public Types inherited from Service
typedef Gaudi::PluginService::Factory< IService *, const std::string &, ISvcLocator * > Factory
 
- Public Types inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
using base_class = CommonMessaging
 
- Public Types inherited from extend_interfaces< Interfaces...>
using ext_iids = typename Gaudi::interface_list_cat< typename Interfaces::ext_iids...>::type
 take union of the ext_iids of all Interfaces... More...
 

Public Member Functions

StatusCode initialize () override
 Inherited Service overrides: Service initialization. More...
 
StatusCode finalize () override
 Inherited Service overrides: Service finalization. More...
 
StatusCode reinitialize () override
 Inherited Service overrides: Service reinitialization. More...
 
void handle (const Incident &incident) override
 IIncidentListener interfaces overrides: incident handling. More...
 
 DataOnDemandSvc (const std::string &name, ISvcLocator *svc)
 Standard initializing service constructor. More...
 
 ~DataOnDemandSvc () override=default
 Standard destructor. More...
 
void update_1 (Property &p)
 
void update_2 (Property &p)
 
void update_3 (Property &p)
 
void update_dump (Property &)
 update handler for 'Dump' property More...
 
- Public Member Functions inherited from extends< Service, IIncidentListener >
void * i_cast (const InterfaceID &tid) const override
 Implementation of IInterface::i_cast. More...
 
StatusCode queryInterface (const InterfaceID &ti, void **pp) override
 Implementation of IInterface::queryInterface. More...
 
std::vector< std::stringgetInterfaceNames () const override
 Implementation of IInterface::getInterfaceNames. More...
 
 ~extends () override=default
 Virtual destructor. More...
 
- Public Member Functions inherited from Service
const std::stringname () const override
 Retrieve name of the service. More...
 
StatusCode configure () override
 
StatusCode initialize () override
 
StatusCode start () override
 
StatusCode stop () override
 
StatusCode finalize () override
 
StatusCode terminate () override
 
Gaudi::StateMachine::State FSMState () const override
 
Gaudi::StateMachine::State targetFSMState () const override
 
StatusCode reinitialize () override
 
StatusCode restart () override
 
StatusCode sysInitialize () override
 Initialize Service. More...
 
StatusCode sysStart () override
 Initialize Service. More...
 
StatusCode sysStop () override
 Initialize Service. More...
 
StatusCode sysFinalize () override
 Finalize Service. More...
 
StatusCode sysReinitialize () override
 Re-initialize the Service. More...
 
StatusCode sysRestart () override
 Re-initialize the Service. More...
 
StatusCode setProperty (const Property &p) override
 
StatusCode setProperty (const std::string &s) override
 
StatusCode setProperty (const std::string &n, const std::string &v) override
 
StatusCode getProperty (Property *p) const override
 
const PropertygetProperty (const std::string &name) const override
 
StatusCode getProperty (const std::string &n, std::string &v) const override
 
const std::vector< Property * > & getProperties () const override
 
bool hasProperty (const std::string &name) const override
 
template<class TYPE >
StatusCode setProperty (const std::string &name, const TYPE &value)
 set the property form the value More...
 
 Service (std::string name, ISvcLocator *svcloc)
 Standard Constructor. More...
 
SmartIF< ISvcLocator > & serviceLocator () const override
 Retrieve pointer to service locator. More...
 
StatusCode setProperties ()
 Method for setting declared properties to the values specified for the job. More...
 
template<class T >
StatusCode service (const std::string &name, const T *&psvc, bool createIf=true) const
 Access a service by name, creating it if it doesn't already exist. More...
 
template<class T >
StatusCode service (const std::string &name, T *&psvc, bool createIf=true) const
 
template<typename IFace = IService>
SmartIF< IFace > service (const std::string &name, bool createIf=true) const
 
template<class T >
StatusCode service (const std::string &svcType, const std::string &svcName, T *&psvc) const
 Access a service by name and type, creating it if it doesn't already exist. More...
 
template<class T >
PropertydeclareProperty (const std::string &name, T &property, const std::string &doc="none") const
 Declare the named property. More...
 
PropertydeclareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const
 Declare remote named properties. More...
 
template<class T >
StatusCode declarePrivateTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Private tool. More...
 
template<class T >
StatusCode declarePublicTool (ToolHandle< T > &handle, std::string toolTypeAndName="", bool createIf=true)
 Declare used Public tool. More...
 
SmartIF< IAuditorSvc > & auditorSvc () const
 The standard auditor service.May not be invoked before sysInitialize() has been invoked. More...
 
- Public Member Functions inherited from CommonMessagingBase
virtual ~CommonMessagingBase ()=default
 Virtual destructor. More...
 
SmartIF< IMessageSvc > & msgSvc () const
 The standard message service. More...
 
MsgStreammsgStream () const
 Return an uninitialized MsgStream. More...
 
MsgStreammsgStream (const MSG::Level level) const
 Predefined configurable message stream for the efficient printouts. More...
 
MsgStreamalways () const
 shortcut for the method msgStream(MSG::ALWAYS) More...
 
MsgStreamfatal () const
 shortcut for the method msgStream(MSG::FATAL) More...
 
MsgStreamerr () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamerror () const
 shortcut for the method msgStream(MSG::ERROR) More...
 
MsgStreamwarning () const
 shortcut for the method msgStream(MSG::WARNING) More...
 
MsgStreaminfo () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MsgStreamdebug () const
 shortcut for the method msgStream(MSG::DEBUG) More...
 
MsgStreamverbose () const
 shortcut for the method msgStream(MSG::VERBOSE) More...
 
MsgStreammsg () const
 shortcut for the method msgStream(MSG::INFO) More...
 
MSG::Level msgLevel () const
 get the output level from the embedded MsgStream More...
 
MSG::Level outputLevel () const __attribute__((deprecated))
 Backward compatibility function for getting the output level. More...
 
bool msgLevel (MSG::Level lvl) const
 get the output level from the embedded MsgStream More...
 
- Public Member Functions inherited from extend_interfaces< Interfaces...>
 ~extend_interfaces () override=default
 Virtual destructor. More...
 

Protected Member Functions

StatusCode configureHandler (Leaf &leaf)
 Configure handler for leaf. More...
 
StatusCode execHandler (const std::string &tag, Leaf &leaf)
 Execute leaf handler (algorithm) More...
 
StatusCode execHandler (const std::string &tag, Node &node)
 Execute node handler (simple object creation using seal reflection) More...
 
StatusCode setupNodeHandlers ()
 Initialize node handlers. More...
 
StatusCode setupAlgHandlers ()
 Initialize leaf handlers. More...
 
StatusCode setup ()
 Setup routine (called by (re-) initialize. More...
 
void i_setNodeHandler (const std::string &name, const std::string &type)
 Internal method to initialize a node handler. More...
 
StatusCode i_setAlgHandler (const std::string &name, const Gaudi::Utils::TypeNameString &alg)
 Internal method to initialize an algorithm handler. More...
 
StatusCode update ()
 update the handlers More...
 
void dump (const MSG::Level level, const bool mode=true) const
 dump the content of DataOnDemand service More...
 
- Protected Member Functions inherited from Service
 ~Service () override
 Standard Destructor. More...
 
int outputLevel () const
 get the Service's output level More...
 
- Protected Member Functions inherited from CommonMessaging< implements< IService, IProperty, IStateful > >
void updateMsgStreamOutputLevel (int level)
 Update the output level of the cached MsgStream. More...
 

Private Types

typedef std::map< std::string, std::stringMap
 

Private Attributes

SmartIF< IIncidentSvcm_incSvc = nullptr
 Incident service. More...
 
SmartIF< IAlgManagerm_algMgr = nullptr
 Algorithm manager. More...
 
SmartIF< IDataProviderSvcm_dataSvc = nullptr
 Data provider reference. More...
 
SmartIF< IToolSvcm_toolSvc
 Data provider reference. More...
 
std::string m_trapType = "DataFault"
 Trap name. More...
 
std::string m_dataSvcName = "EventDataSvc"
 Data service name. More...
 
bool m_partialPath = true
 Flag to allow for the creation of partial leaves. More...
 
bool m_dump = false
 flag to force the printout More...
 
bool m_init = false
 flag to warm up the configuration More...
 
bool m_allowInitFailure = false
 flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithms fails (m_init). More...
 
Setup m_algMapping
 Mapping to algorithms. More...
 
Setup m_nodeMapping
 Mapping to nodes. More...
 
AlgMap m_algs
 Map of algorithms to handle incidents. More...
 
NodeMap m_nodes
 Map of "empty" objects to be placed as intermediate nodes. More...
 
Map m_algMap
 the major configuration property { 'data' : 'algorithm' } More...
 
Map m_nodeMap
 the major configuration property { 'data' : 'type' } More...
 
bool m_updateRequired = true
 
std::string m_prefix = "/Event/"
 
ChronoEntity m_total
 
ulonglong m_statAlg = 0
 
ulonglong m_statNode = 0
 
ulonglong m_stat = 0
 
ChronoEntity m_timer_nodes
 
ChronoEntity m_timer_algs
 
ChronoEntity m_timer_all
 
bool m_locked_nodes = false
 
bool m_locked_algs = false
 
bool m_locked_all = false
 
std::vector< std::stringm_nodeMapTools
 
std::vector< IDODNodeMapper * > m_nodeMappers
 
std::vector< std::stringm_algMapTools
 
std::vector< IDODAlgMapper * > m_algMappers
 

Additional Inherited Members

- Protected Attributes inherited from Service
IntegerProperty m_outputLevel = MSG::NIL
 Service output level. More...
 
Gaudi::StateMachine::State m_state = Gaudi::StateMachine::OFFLINE
 Service state. More...
 
Gaudi::StateMachine::State m_targetState = Gaudi::StateMachine::OFFLINE
 Service state. More...
 

Detailed Description

The DataOnDemandSvc listens to incidents typically triggered by the data service of the configurable name "IncidentName".

In the job options handlers can be declared, which allow to configure this service. Such handlers are either:

  • Node handlers, if objects other than the default object type have to be instantiated. DataOnDemandSvc.Nodes = { "DATA='/Event/Rec' TYPE='DataObject'", "DATA='/Event/Rec/Muon' TYPE='DataObject'" };
  • Leaf handlers (Algorithms), which get instantiated and executed on demand. DataOnDemandSvc.Algorithms = { "DATA='/Event/Rec/Muon/Digits' TYPE='MuonDigitAlg/MyMuonDigits'" }; If the algorithm name is omitted the class name will be the instance name.

The handlers only get called if the exact path matches. In the event already the partial path to any handler is missing a leaf handler may be triggered, which includes the partial paths ( DataOnDemandSvc.UsePreceedingPath = true )

2006-10-15: New options (using map-like semantics:)

{ "Phys/StdLoosePions/Particles" : "PreLoadParticles/StdLoosePions" ,
"Phys/StdLoosePions/Vertioces" : "PreLoadParticles/StdLoosePions" } ;
{ "Phys" : "DataObject" ,
"MC" : "DataObject" } ;

New treatment of preceding paths. for each registered leaf or node the all parent nodes are added into the node-map with default directory type 'DataObject'

The major properties are equipped with handlers (more or less mandatory for interactive work in python)

From now the default prefix ( "/Event/" ) could be omitted from any data-item. It will be added automatically.

Author
M.Frank
Version
1.0

Definition at line 90 of file DataOnDemandSvc.h.

Member Typedef Documentation

typedef TClass* DataOnDemandSvc::ClassH

Definition at line 97 of file DataOnDemandSvc.h.

Definition at line 269 of file DataOnDemandSvc.h.

Definition at line 96 of file DataOnDemandSvc.h.

Constructor & Destructor Documentation

DataOnDemandSvc::DataOnDemandSvc ( const std::string name,
ISvcLocator svc 
)

Standard initializing service constructor.

Parameters
name[IN] Service instance name
svc[IN] Pointer to service locator
Returns
Reference to DataOnDemandSvc object.

Definition at line 41 of file DataOnDemandSvc.cpp.

42  : base_class( name, svc )
43 {
44  // ==========================================================================
46  ( "IncidentName" ,
47  m_trapType ,
48  "The type of handled Incident" ) ;
49  //
50  declareProperty ( "DataSvc" , m_dataSvcName ) ;
51  //
52  declareProperty ( "UsePreceedingPath" , m_partialPath ) ;
54  ( "Dump" ,
55  m_dump ,
56  "Dump the configuration and stastics" ) ->
57  declareUpdateHandler ( &DataOnDemandSvc::update_dump , this ) ;
58  //
60  ( "PreInitialize" ,
61  m_init ,
62  "Flag to (pre)initialize all algorithms" ) ;
64  ( "AllowPreInitializeFailure" ,
66  "Allow (pre)initialization of algorithms to fail without stopping the application" ) ;
67  //
68  declareProperty ( "Algorithms" , m_algMapping ) ->
69  declareUpdateHandler ( &DataOnDemandSvc::update_2 , this ) ;
70  declareProperty ( "Nodes" , m_nodeMapping ) ->
71  declareUpdateHandler ( &DataOnDemandSvc::update_3 , this ) ;
72  //
73  declareProperty ( "AlgMap" , m_algMap ) ->
74  declareUpdateHandler ( &DataOnDemandSvc::update_1 , this ) ;
75  declareProperty ( "NodeMap" , m_nodeMap ) ->
76  declareUpdateHandler ( &DataOnDemandSvc::update_1 , this ) ;
77 
78  declareProperty ( "Prefix" , m_prefix ) ;
79 
80  declareProperty("NodeMappingTools", m_nodeMapTools,
81  "List of tools of type IDODNodeMapper");
82  declareProperty("AlgMappingTools", m_algMapTools,
83  "List of tools of type IDODAlgMapper");
84  // ==========================================================================
85 }
std::vector< std::string > m_algMapTools
std::string m_trapType
Trap name.
std::string m_dataSvcName
Data service name.
Setup m_nodeMapping
Mapping to nodes.
extends base_class
Typedef to this class.
Definition: extends.h:14
Map m_algMap
the major configuration property { 'data' : 'algorithm' }
Setup m_algMapping
Mapping to algorithms.
bool m_allowInitFailure
flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithm...
void update_dump(Property &)
update handler for 'Dump' property
std::vector< std::string > m_nodeMapTools
std::string m_prefix
bool m_partialPath
Flag to allow for the creation of partial leaves.
bool m_dump
flag to force the printout
bool m_init
flag to warm up the configuration
Map m_nodeMap
the major configuration property { 'data' : 'type' }
Property * declareProperty(const std::string &name, T &property, const std::string &doc="none") const
Declare the named property.
Definition: Service.h:215
void update_2(Property &p)
void update_3(Property &p)
void update_1(Property &p)
DataOnDemandSvc::~DataOnDemandSvc ( )
overridedefault

Standard destructor.

Member Function Documentation

StatusCode DataOnDemandSvc::configureHandler ( Leaf leaf)
protected

Configure handler for leaf.

Parameters
leaf[IN] Reference to leaf handler
Returns
StatusCode indicating success or failure

Definition at line 520 of file DataOnDemandSvc.cpp.

521 {
522  if ( l.algorithm ) { return StatusCode::SUCCESS ; }
523  if ( ! m_algMgr ) { return StatusCode::FAILURE ; }
524  l.algorithm = m_algMgr->algorithm(l.name, false);
525  if ( l.algorithm ) { return StatusCode::SUCCESS ; }
526  // create it!
527  StatusCode sc = m_algMgr->createAlgorithm ( l.type , l.name , l.algorithm , true ) ;
528  if ( sc.isFailure() )
529  {
530  error()
531  << "Failed to create algorithm "
532  << l.type << "('" << l.name<< "')" << endmsg;
533  l.algorithm = nullptr ;
534  return sc ; // RETURN
535  }
536  if ( l.algorithm->isInitialized() ) { return StatusCode:: SUCCESS ;}
537  // initialize it!
538  sc = l.algorithm -> sysInitialize () ;
539  if ( sc.isFailure() )
540  {
541  error()
542  << "Failed to initialize algorithm "
543  << l.type << "('" << l.name<< "')" << endmsg;
544  l.algorithm = nullptr ;
545  return sc ; // RETURN
546  }
547  if ( Gaudi::StateMachine::RUNNING == l.algorithm->FSMState() )
548  { return StatusCode::SUCCESS ; }
549  // run it!
550  sc = l.algorithm->sysStart() ;
551  if ( sc.isFailure() )
552  {
553  error()
554  << "Failed to 'run' algorithm "
555  << l.type << "('" << l.name<< "')" << endmsg;
556  l.algorithm = nullptr ;
557  return sc ; // RETURN
558  }
559  return StatusCode::SUCCESS ;
560 }
virtual SmartIF< IAlgorithm > & algorithm(const Gaudi::Utils::TypeNameString &typeName, const bool createIf=true)=0
Returns a smart pointer to a service.
virtual StatusCode createAlgorithm(const std::string &algtype, const std::string &algname, IAlgorithm *&alg, bool managed=false, bool checkIfExists=true)=0
Create an instance of a algorithm type that has been declared beforehand and assigns to it a name...
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
dictionary l
Definition: gaudirun.py:421
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode sysInitialize() override
Initialize Service.
Definition: Service.cpp:26
void DataOnDemandSvc::dump ( const MSG::Level  level,
const bool  mode = true 
) const
protected

dump the content of DataOnDemand service

Parameters
levelthe printout level
modethe printout mode

Definition at line 789 of file DataOnDemandSvc.cpp.

791 {
792  if ( m_algs.empty() && m_nodes.empty() ) { return ; }
793 
796  for ( auto& alg : m_algs )
797  {
798  auto check = _m.find(alg.first) ;
799  if ( _m.end() != check )
800  {
801  warning() << " The data item is activated for '"
802  << check->first << "' as '" << check->second.first << "'" << endmsg ;
803  }
804  const Leaf& l = alg.second ;
805  std::string nam = ( l.name == l.type ? l.type : (l.type+"/"+l.name) ) ;
806  //
807  if ( !mode && 0 == l.num ) { continue ; }
808  //
809  std::string val ;
810  if ( mode ) { val = ( ! l.algorithm ) ? "F" : "T" ; }
811  else { val = std::to_string( l.num ) ; }
812  //
813  _m[ no_prefix ( alg.first , m_prefix ) ] = { nam , val } ;
814  }
815  // nodes:
816  for ( const auto& node : m_nodes )
817  {
818  auto check = _m.find(node.first) ;
819  if ( _m.end() != check )
820  {
821  warning() << " The data item is already activated for '"
822  << check->first << "' as '" << check->second.first << "'" << endmsg ;
823  }
824  const Node& n = node.second ;
825  std::string nam = "'" + n.name + "'" ;
826  //
827  std::string val ;
828 
829  if ( !mode && 0 == n.num ) { continue ; }
830 
831  if ( mode ) { val = ( 0 == n.clazz ) ? "F" : "T" ; }
832  else { val = std::to_string( n.num ) ; }
833  //
834  _m[ no_prefix ( node.first , m_prefix ) ] = { nam , val } ;
835  }
836  //
837  if ( _m.empty() ) { return ; }
838 
839  // find the correct formats
840  size_t n1 = 0 ;
841  size_t n2 = 0 ;
842  size_t n3 = 0 ;
843  for ( const auto& i : _m )
844  {
845  n1 = std::max ( n1 , i.first.size() ) ;
846  n2 = std::max ( n2 , i.second.first.size() ) ;
847  n3 = std::max ( n3 , i.second.second.size() ) ;
848  }
849  if ( 10 > n1 ) { n1 = 10 ; }
850  if ( 10 > n2 ) { n2 = 10 ; }
851  if ( 60 < n1 ) { n1 = 60 ; }
852  if ( 60 < n2 ) { n2 = 60 ; }
853  //
854 
855  const std::string _f = " | %%1$-%1%.%1%s | %%2$-%2%.%2%s | %%3$%3%.%3%s |" ;
856  boost::format _ff ( _f ) ;
857  _ff % n1 % n2 % n3 ;
858 
859  const std::string _format = _ff.str() ;
860 
861  auto& msg = msgStream(level);
862 
863  if ( mode ) { msg << "Data-On-Demand Actions enabled for:" ; }
864  else { msg << "Data-On-Demand Actions has been used for:" ; }
865 
866  boost::format fmt1( _format) ;
867  fmt1 % "Address" % "Creator" % ( mode ? "S" : "#" ) ;
868  //
869  const std::string header = fmt1.str() ;
870  std::string line = std::string( header.size() , '-' ) ;
871  line[0] = ' ' ;
872 
873  msg << '\n' << line
874  << '\n' << header
875  << '\n' << line ;
876 
877  // make the actual printout:
878  for ( const auto& item : _m )
879  {
880  boost::format fmt( _format) ;
881  msg << '\n' <<
882  ( fmt % item.first % item.second.first % item.second.second ) ;
883  }
884 
885  msg << '\n' << line << endmsg ;
886 
887 }
MsgStream & msg() const
shortcut for the method msgStream(MSG::INFO)
T empty(T...args)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
Definition: MsgStream.cpp:119
T to_string(T...args)
T end(T...args)
STL class.
STL class.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
bool empty() const
Definition: Map.h:184
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
std::string m_prefix
T max(T...args)
dictionary l
Definition: gaudirun.py:421
T find(T...args)
T size(T...args)
AlgMap m_algs
Map of algorithms to handle incidents.
MsgStream & msgStream() const
Return an uninitialized MsgStream.
tuple item
print s1,s2
Definition: ana.py:146
list header
Definition: Test.py:33
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode DataOnDemandSvc::execHandler ( const std::string tag,
Leaf leaf 
)
protected

Execute leaf handler (algorithm)

Parameters
tag[IN] Path to requested leaf
leaf[IN] Reference to leaf handler
Returns
StatusCode indicating success or failure

Definition at line 750 of file DataOnDemandSvc.cpp.

751 {
753  //
754  if ( l.executing ) { return StatusCode::FAILURE ; } // RETURN
755  //
756  if ( ! l.algorithm )
757  {
759  if ( sc.isFailure() )
760  {
761  error()
762  << "Failed to configure handler for: "
763  << l.name << "[" << l.type << "] " << tag << endmsg;
764  return sc ; // RETURN
765  }
766  }
767  //
768  Chrono atimer ( m_total ) ;
769  //
770  Protection p(l.executing);
771  StatusCode sc = l.algorithm->sysExecute();
772  if ( sc.isFailure() )
773  {
774  error() << "Failed to execute the algorithm:"
775  << l.algorithm->name() << " for location:" << tag << endmsg;
776  return sc ; // RETURN
777  }
778  ++l.num ;
779  //
780  return StatusCode::SUCCESS ;
781 }
ChronoEntity m_timer_algs
A small utility class for chronometry of user codes.
Definition: Chrono.h:25
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
dictionary l
Definition: gaudirun.py:421
Helper object, useful for measurement of CPU-performance of highly-recursive structures, e.g.
Definition: LockedChrono.h:52
ChronoEntity m_total
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode DataOnDemandSvc::execHandler ( const std::string tag,
Node node 
)
protected

Execute node handler (simple object creation using seal reflection)

Parameters
tag[IN] Path to requested leaf
node[IN] Reference to node handler
Returns
StatusCode indicating success or failure

Definition at line 697 of file DataOnDemandSvc.cpp.

698 {
699 
701 
702  if ( n.executing ) { return StatusCode::FAILURE ; } // RETURN
703 
704  Protection p(n.executing);
705 
707 
708  if ( n.dataObject ) { object.reset( new DataObject() ) ; }
709  else
710  {
711  // try to recover the handler
712  if ( !n.clazz ) { n.clazz = TClass::GetClass(n.name.c_str()) ; }
713  if ( !n.clazz )
714  {
715  error()
716  << "Failed to get dictionary for class '"
717  << n.name
718  << "' for location:" << tag << endmsg;
719  return StatusCode::FAILURE ; // RETURN
720  }
721 
722  object.reset( reinterpret_cast<DataObject*>(n.clazz->New()) );
723 
724  if ( !object )
725  {
726  error()
727  << "Failed to create an object of type:"
728  << n.clazz->GetName() << " for location:" << tag
729  << endmsg;
730  return StatusCode::FAILURE ; // RETURN
731  }
732  }
733  //
734  StatusCode sc = m_dataSvc->registerObject(tag, object.release() );
735  if ( sc.isFailure() )
736  {
737  error() << "Failed to register an object of type:"
738  << n.name << " at location:" << tag
739  << endmsg;
740  return sc ; // RETURN
741  }
742  ++n.num ;
743  //
744  return StatusCode::SUCCESS ;
745 }
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
T reset(T...args)
STL class.
Helper object, useful for measurement of CPU-performance of highly-recursive structures, e.g.
Definition: LockedChrono.h:52
ChronoEntity m_timer_nodes
virtual StatusCode registerObject(const std::string &fullPath, DataObject *pObject)=0
Register object with the data store.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode DataOnDemandSvc::finalize ( )
override

Inherited Service overrides: Service finalization.

Definition at line 316 of file DataOnDemandSvc.cpp.

317 {
318  //
319  info()
320  << "Handled \"" << m_trapType << "\" incidents: "
321  << m_statAlg << "/" << m_statNode << "/" << m_stat << "(Alg/Node/Total)."
322  << endmsg ;
323  if ( m_dump || msgLevel(MSG::DEBUG) )
324  {
325  info()
327  ( "Algorithm timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
328  << m_total.outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
329  info()
331  ( "Nodes timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
332  << m_timer_nodes.outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
333  info()
335  ( "Algs timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
336  << m_timer_algs .outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
337  info()
339  ( "All timing: Mean(+-rms)/Min/Max:%3%(+-%4%)/%6%/%7%[ms] " , System::milliSec )
340  << m_timer_all .outputUserTime ( "Total:%2%[s]" , System::Sec ) << endmsg ;
341  }
342  // dump it!
343  if ( m_dump ) { dump ( MSG::INFO , false ) ; }
344  else if ( msgLevel(MSG::DEBUG) ) { dump ( MSG::DEBUG , false ) ; }
345  //
346  if ( m_incSvc )
347  {
349  m_incSvc.reset();
350  }
351  m_algMgr.reset();
352  m_dataSvc.reset();
353  if (m_toolSvc) { // we may not have retrieved the ToolSvc
354  // Do not call releaseTool if the ToolSvc was already finalized.
356  for(const auto& i : m_nodeMappers ) m_toolSvc->releaseTool(i).ignore();
357  for(const auto& i : m_algMappers ) m_toolSvc->releaseTool(i).ignore();
358  } else {
359  warning() << "ToolSvc already finalized: cannot release tools. Check options." << endmsg;
360  }
361  m_nodeMappers.clear();
362  m_algMappers.clear();
363  m_toolSvc.reset();
364  }
365  return Service::finalize();
366 }
ChronoEntity m_timer_all
StatusCode finalize() override
Definition: Service.cpp:193
ChronoEntity m_timer_algs
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:57
MsgStream & info() const
shortcut for the method msgStream(MSG::INFO)
std::vector< IDODNodeMapper * > m_nodeMappers
SmartIF< IIncidentSvc > m_incSvc
Incident service.
std::string m_trapType
Trap name.
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
ulonglong m_statNode
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
void clear(STATE_TYPE _i=std::ios_base::failbit)
Definition: MsgStream.h:222
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
std::string outputUserTime() const
print the chrono ;
std::vector< IDODAlgMapper * > m_algMappers
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
bool m_dump
flag to force the printout
ChronoEntity m_timer_nodes
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
ChronoEntity m_total
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
virtual void removeListener(IIncidentListener *lis, const std::string &type="")=0
Remove listener.
void ignore() const
Definition: StatusCode.h:108
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void DataOnDemandSvc::handle ( const Incident incident)
override

IIncidentListener interfaces overrides: incident handling.

Definition at line 625 of file DataOnDemandSvc.cpp.

626 {
627 
629 
630  ++m_stat ;
631  // proper incident type?
632  if ( incident.type() != m_trapType ) { return ; } // RETURN
633  const DataIncident* inc = dynamic_cast<const DataIncident*>(&incident);
634  if ( ! inc ) { return ; } // RETURN
635  // update if needed!
636  if ( m_updateRequired ) { update() ; }
637 
638  if ( msgLevel(MSG::VERBOSE) )
639  {
640  verbose()
641  << "Incident: [" << incident.type () << "] "
642  << " = " << incident.source ()
643  << " Location:" << inc->tag() << endmsg;
644  }
645  // ==========================================================================
646  Gaudi::StringKey tag ( inc->tag() ) ;
647  // ==========================================================================
648  auto icl = m_nodes.find ( tag ) ;
649  if ( icl != m_nodes.end() )
650  {
651  StatusCode sc = execHandler ( tag , icl->second ) ;
652  if ( sc.isSuccess() ) { ++m_statNode ; }
653  return ; // RETURN
654  }
655  // ==========================================================================
656  auto ialg = m_algs.find ( tag ) ;
657  if ( ialg != m_algs.end() )
658  {
659  StatusCode sc = execHandler ( tag , ialg->second ) ;
660  if ( sc.isSuccess() ) { ++m_statAlg ; }
661  return ; // RETURN
662  }
663  // ==========================================================================
664  // Fall back on the tools
665  if (m_toolSvc) {
666  if ( msgLevel(MSG::VERBOSE))
667  verbose() << "Try to find mapping with mapping tools" << endmsg;
668  Finder finder(no_prefix(inc->tag(), m_prefix), m_nodeMappers, m_algMappers);
669  // - try the node mappers
670  std::string node = finder.node();
671  if (isGood(node)) {
672  // if one is found update the internal node mapping and try again.
673  if (msgLevel(MSG::VERBOSE))
674  verbose() << "Found Node handler: " << node << endmsg;
675  i_setNodeHandler(inc->tag(), node);
676  handle(incident);
677  --m_stat; // avoid double counting because of recursion
678  return;
679  }
680  // - try alg mappings
681  Gaudi::Utils::TypeNameString alg = finder.alg();
682  if (isGood(alg)) {
683  // we got an algorithm, update alg map and try to handle again
684  if (msgLevel(MSG::VERBOSE))
685  verbose() << "Found Algorithm handler: " << alg << endmsg;
686  i_setAlgHandler(inc->tag(), alg).ignore();
687  handle(incident);
688  --m_stat; // avoid double counting because of recursion
689  return;
690  }
691  }
692 }
void i_setNodeHandler(const std::string &name, const std::string &type)
Internal method to initialize a node handler.
ChronoEntity m_timer_all
const std::string & type() const
Access to the incident type.
Definition: Incident.h:41
const std::string & source() const
Access to the source of the incident.
Definition: Incident.h:47
std::vector< IDODNodeMapper * > m_nodeMappers
bool isSuccess() const
Test for a status code of SUCCESS.
Definition: StatusCode.h:76
void handle(const Incident &incident) override
IIncidentListener interfaces overrides: incident handling.
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
std::string m_trapType
Trap name.
The helper class to represent the efficient "key" for access.
Definition: StringKey.h:35
STL class.
ulonglong m_statNode
iterator end()
Definition: Map.h:132
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
StatusCode execHandler(const std::string &tag, Leaf &leaf)
Execute leaf handler (algorithm)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
iterator find(const key_type &key)
Definition: Map.h:149
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
std::string m_prefix
std::vector< IDODAlgMapper * > m_algMappers
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
Helper object, useful for measurement of CPU-performance of highly-recursive structures, e.g.
Definition: LockedChrono.h:52
AlgMap m_algs
Map of algorithms to handle incidents.
Data service incident class.
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg)
Internal method to initialize an algorithm handler.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode update()
update the handlers
StatusCode DataOnDemandSvc::i_setAlgHandler ( const std::string name,
const Gaudi::Utils::TypeNameString alg 
)
protected

Internal method to initialize an algorithm handler.

Definition at line 217 of file DataOnDemandSvc.cpp.

217  {
218  Leaf leaf(alg.type(), alg.name());
219  if (m_init)
220  {
222  if (sc.isFailure()) {
223  if (m_allowInitFailure) {
224  // re-store the content of the leaf object to try again to initialize
225  // the algorithm later (on demand)
226  leaf = Leaf(alg.type(), alg.name());
227  }
228  else
229  return sc;
230  }
231  }
232  m_algs[name] = leaf;
233  return StatusCode::SUCCESS;
234 }
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
bool m_allowInitFailure
flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithm...
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
AlgMap m_algs
Map of algorithms to handle incidents.
bool m_init
flag to warm up the configuration
const std::string & type() const
const std::string & name() const
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
void DataOnDemandSvc::i_setNodeHandler ( const std::string name,
const std::string type 
)
protected

Internal method to initialize a node handler.

Definition at line 207 of file DataOnDemandSvc.cpp.

207  {
208  ClassH cl = TClass::GetClass(type.c_str()) ;
209  if (!cl) {
210  warning()
211  << "Failed to access dictionary class for "
212  << name << " of type:" << type << endmsg;
213  }
214  m_nodes[name] = Node(cl, false, type);
215 }
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:319
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
T c_str(T...args)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode DataOnDemandSvc::initialize ( )
override

Inherited Service overrides: Service initialization.

Definition at line 298 of file DataOnDemandSvc.cpp.

299 {
300  // initialize the Service Base class
302  if ( sc.isFailure() ) { return sc; }
303  sc = setup();
304  if ( sc.isFailure() ) { return sc; }
305  //
306  if ( m_dump ) { dump ( MSG::INFO ) ; }
307  else if ( msgLevel(MSG::DEBUG) ) { dump ( MSG::DEBUG ) ; }
308  //
309  if ( m_init ) { return update () ; }
310  //
311  return StatusCode::SUCCESS ;
312 }
StatusCode initialize() override
Definition: Service.cpp:68
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
StatusCode setup()
Setup routine (called by (re-) initialize.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
bool m_dump
flag to force the printout
bool m_init
flag to warm up the configuration
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
StatusCode update()
update the handlers
StatusCode DataOnDemandSvc::reinitialize ( )
override

Inherited Service overrides: Service reinitialization.

re-initialization of the service

Definition at line 370 of file DataOnDemandSvc.cpp.

371 {
372  // reinitialize the Service Base class
373  if ( m_incSvc )
374  {
375  m_incSvc -> removeListener ( this , m_trapType );
376  m_incSvc.reset();
377  }
378  m_algMgr.reset();
379  m_dataSvc.reset();
380  for(const auto& i : m_nodeMappers ) m_toolSvc->releaseTool(i).ignore();
381  m_nodeMappers.clear();
382  for(const auto& i : m_algMappers ) m_toolSvc->releaseTool(i).ignore();
383  m_algMappers.clear();
384  m_toolSvc.reset();
385  //
387  if ( sc.isFailure() ) { return sc; }
388  //
389  sc = setup() ;
390  if ( sc.isFailure() ) { return sc; }
391  //
392  if ( m_dump ) { dump ( MSG::INFO ) ; }
393  else if ( msgLevel(MSG::DEBUG) ) { dump ( MSG::DEBUG ) ; }
394  //
395  return StatusCode::SUCCESS ;
396 }
std::vector< IDODNodeMapper * > m_nodeMappers
SmartIF< IIncidentSvc > m_incSvc
Incident service.
std::string m_trapType
Trap name.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
StatusCode setup()
Setup routine (called by (re-) initialize.
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode reinitialize() override
Definition: Service.cpp:282
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
std::vector< IDODAlgMapper * > m_algMappers
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
bool m_dump
flag to force the printout
virtual StatusCode releaseTool(IAlgTool *tool)=0
Release the tool.
void reset(TYPE *ptr=nullptr)
Set the internal pointer to the passed one disposing of the old one.
Definition: SmartIF.h:88
void ignore() const
Definition: StatusCode.h:108
MSG::Level msgLevel() const
get the output level from the embedded MsgStream
list i
Definition: ana.py:128
StatusCode DataOnDemandSvc::setup ( )
protected

Setup routine (called by (re-) initialize.

Definition at line 400 of file DataOnDemandSvc.cpp.

401 {
402  if ( !(m_algMgr = serviceLocator()) ) // assignment meant
403  {
404  error() << "Failed to retrieve the IAlgManager interface." << endmsg;
405  return StatusCode::FAILURE;
406  }
407 
408  if ( !(m_incSvc = serviceLocator()->service("IncidentSvc")) ) // assignment meant
409  {
410  error() << "Failed to retrieve Incident service." << endmsg;
411  return StatusCode::FAILURE;
412  }
414 
415  if ( !(m_dataSvc = serviceLocator()->service(m_dataSvcName)) ) // assignment meant
416  {
417  error()
418  << "Failed to retrieve the data provider interface of "
419  << m_dataSvcName << endmsg;
420  return StatusCode::FAILURE;
421  }
422 
423  // No need to get the ToolSvc if we are not using tools
424  if (!(m_nodeMapTools.empty() && m_algMapTools.empty())) {
425  if ( !(m_toolSvc = serviceLocator()->service("ToolSvc")) ) // assignment meant
426  {
427  error() << "Failed to retrieve ToolSvc" << endmsg;
428  return StatusCode::FAILURE;
429  }
430 
431  // load the node mapping tools
432  IDODNodeMapper *nodetool = nullptr;
433  for(const auto& i : m_nodeMapTools) {
434  const StatusCode sc = m_toolSvc->retrieveTool(i, nodetool);
435  if (sc.isFailure()) return sc;
436  m_nodeMappers.push_back(nodetool);
437  }
438  IDODAlgMapper *algtool = nullptr;
439  for(const auto& i : m_algMapTools) {
440  const StatusCode sc = m_toolSvc->retrieveTool(i, algtool);
441  if (sc.isFailure()) return sc;
442  m_algMappers.push_back(algtool);
443  }
444  }
445  return update();
446 }
SmartIF< ISvcLocator > & serviceLocator() const override
Retrieve pointer to service locator.
Definition: Service.cpp:324
T empty(T...args)
std::vector< IDODNodeMapper * > m_nodeMappers
SmartIF< IIncidentSvc > m_incSvc
Incident service.
std::vector< std::string > m_algMapTools
std::string m_trapType
Trap name.
std::string m_dataSvcName
Data service name.
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
StatusCode retrieveTool(const std::string &type, T *&tool, const IInterface *parent=nullptr, bool createIf=true)
Retrieve specified tool sub-type with tool dependent part of the name automatically assigned...
Definition: IToolSvc.h:145
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
StatusCode service(const Gaudi::Utils::TypeNameString &name, T *&svc, bool createIf=true)
Templated method to access a service by name.
Definition: ISvcLocator.h:78
T push_back(T...args)
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
Interface of tools used by the DataOnDemandSvc to choose the type of node to be created at a path...
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
std::vector< std::string > m_nodeMapTools
std::vector< IDODAlgMapper * > m_algMappers
Interface of tools used by the DataOnDemandSvc to choose the algorithm to be run to produce the data ...
Definition: IDODAlgMapper.h:17
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
virtual void addListener(IIncidentListener *lis, const std::string &type="", long priority=0, bool rethrow=false, bool singleShot=false)=0
Add listener.
StatusCode service(const std::string &name, const T *&psvc, bool createIf=true) const
Access a service by name, creating it if it doesn't already exist.
Definition: Service.h:144
list i
Definition: ana.py:128
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode update()
update the handlers
StatusCode DataOnDemandSvc::setupAlgHandlers ( )
protected

Initialize leaf handlers.

Definition at line 486 of file DataOnDemandSvc.cpp.

487 {
488  std::string typ, tag;
489 
490  for (auto alg: m_algMapping)
491  {
492  using Parser = Gaudi::Utils::AttribStringParser;
493  for (auto attrib: Parser(alg)) {
494  switch( ::toupper(attrib.tag[0]) ) {
495  case 'D':
496  tag = std::move(attrib.value);
497  break;
498  case 'T':
499  typ = std::move(attrib.value);
500  break;
501  }
502  }
504  if ( m_algMap .end () != m_algMap .find ( tag ) ||
505  m_nodeMap .end () != m_nodeMap .find ( tag ) )
506  {
507  warning()
508  << "The obsolete property 'Algorithms' redefines the action for '"
509  + tag + "' to be '" +item.type() +"/"+item.name()+"'"
510  << endmsg ;
511  }
512  m_algMap[tag] = item.type() + "/" + item.name() ;
513  }
514  m_updateRequired = true ;
515  return StatusCode::SUCCESS;
516 }
Parse attribute strings allowing iteration over the various attributes.
Map m_algMap
the major configuration property { 'data' : 'algorithm' }
STL class.
Setup m_algMapping
Mapping to algorithms.
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:9
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
T move(T...args)
tuple item
print s1,s2
Definition: ana.py:146
Map m_nodeMap
the major configuration property { 'data' : 'type' }
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode DataOnDemandSvc::setupNodeHandlers ( )
protected

Initialize node handlers.

Definition at line 450 of file DataOnDemandSvc.cpp.

451 {
452  std::string nam, typ, tag;
454  // Setup for node leafs, where simply a constructor is called...
455  for (auto node: m_nodeMapping)
456  {
457  using Parser = Gaudi::Utils::AttribStringParser;
458  for (auto attrib: Parser(node)) {
459  switch( ::toupper(attrib.tag[0]) ) {
460  case 'D':
461  tag = std::move(attrib.value);
462  break;
463  case 'T':
464  nam = std::move(attrib.value);
465  break;
466  }
467  }
468  if ( m_algMap .end () != m_algMap .find ( tag ) ||
469  m_nodeMap .end () != m_nodeMap .find ( tag ) )
470  {
471  warning()
472  << "The obsolete property 'Nodes' redefines the action for '"
473  + tag + "' to be '" +nam+"'"
474  << endmsg ;
475  }
476  m_nodeMap[tag] = nam ;
477  }
478  //
479  m_updateRequired = true ;
480  //
481  return sc;
482 }
Parse attribute strings allowing iteration over the various attributes.
Setup m_nodeMapping
Mapping to nodes.
Map m_algMap
the major configuration property { 'data' : 'algorithm' }
STL class.
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
T move(T...args)
Map m_nodeMap
the major configuration property { 'data' : 'type' }
void toupper(std::string &s)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
StatusCode DataOnDemandSvc::update ( )
protected

update the handlers

convert obsolete "Nodes" into new "NodeMap"

convert obsolete "Algorithms" into new "AlgMap"

add the default prefix

add the default prefix

get all directories

setup algorithms

setup nodes

Definition at line 239 of file DataOnDemandSvc.cpp.

240 {
241  if ( !m_updateRequired ) { return StatusCode::SUCCESS ; }
242 
244  StatusCode sc = setupNodeHandlers() ; // convert "Nodes" new "NodeMap"
245  if ( sc.isFailure() )
246  {
247  error() << "Failed to setup old \"Nodes\"" << endmsg ;
248  return sc ;
249  }
251  sc = setupAlgHandlers() ; // convert "Algorithms" into "AlgMap"
252  if ( sc.isFailure() )
253  {
254  error() << "Failed to setup old \"Algorithms\"" << endmsg ;
255  return sc ;
256  }
258  add_prefix ( m_algMap , m_prefix ) ;
260  add_prefix ( m_nodeMap , m_prefix ) ;
262  std::set<std::string> dirs ;
263  if ( m_partialPath ){ get_dirs ( m_algMap , dirs ) ; }
264  if ( m_partialPath ){ get_dirs ( m_nodeMap , dirs ) ; }
265  //
266  auto _e = dirs.find("/Event") ;
267  if ( dirs.end() != _e ) { dirs.erase( _e ) ; }
268  // add all directories as nodes
269  for ( const auto& dir : dirs )
270  {
271  if ( m_algMap .end () == m_algMap .find ( dir ) &&
272  m_nodeMap .end () == m_nodeMap .find ( dir ) )
273  m_nodeMap [dir] = "DataObject" ;
274  }
275  //
276  m_algs .clear () ;
277  m_nodes .clear () ;
278  //
280  for ( const auto& alg : m_algMap )
281  {
282  if (i_setAlgHandler(alg.first, alg.second).isFailure())
283  return StatusCode::FAILURE;
284  }
286  for ( const auto& node : m_nodeMap )
287  {
288  i_setNodeHandler(node.first, node.second);
289  }
291  m_updateRequired = false ;
292  //
293  return StatusCode::SUCCESS ;
294 }
void i_setNodeHandler(const std::string &name, const std::string &type)
Internal method to initialize a node handler.
T end(T...args)
Map m_algMap
the major configuration property { 'data' : 'algorithm' }
bool isFailure() const
Test for a status code of FAILURE.
Definition: StatusCode.h:86
MsgStream & error() const
shortcut for the method msgStream(MSG::ERROR)
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:26
StatusCode setupNodeHandlers()
Initialize node handlers.
T erase(T...args)
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
auto end(reverse_wrapper< T > &w)
Definition: reverse.h:47
std::string m_prefix
bool m_partialPath
Flag to allow for the creation of partial leaves.
T find(T...args)
AlgMap m_algs
Map of algorithms to handle incidents.
void clear()
Definition: Map.h:178
Map m_nodeMap
the major configuration property { 'data' : 'type' }
StatusCode setupAlgHandlers()
Initialize leaf handlers.
StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg)
Internal method to initialize an algorithm handler.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void DataOnDemandSvc::update_1 ( Property p)

Definition at line 89 of file DataOnDemandSvc.cpp.

90 {
91  verbose() << " I am update handler for property " << p << endmsg ;
92  // force update
93  m_updateRequired = true ;
94 }
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void DataOnDemandSvc::update_2 ( Property p)

Definition at line 110 of file DataOnDemandSvc.cpp.

111 {
112  warning()
113  << "The property 'Algorithms' is obsolete, switch to map-like 'AlgMap' "
114  << " = { 'data' : 'algorithm' } "
115  << endmsg ;
116  // force update
117  m_updateRequired = true ;
118 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void DataOnDemandSvc::update_3 ( Property p)

Definition at line 98 of file DataOnDemandSvc.cpp.

99 {
100  warning()
101  << "The property 'Nodes' is obsolete, switch to map-like 'NodeMap' "
102  << " = { 'data' : 'type' } "
103  << endmsg ;
104  // force update
105  m_updateRequired = true ;
106 }
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:244
void DataOnDemandSvc::update_dump ( Property )

update handler for 'Dump' property

Definition at line 122 of file DataOnDemandSvc.cpp.

123 {
124  // no action if not yet initialized
125  if ( FSMState() < Gaudi::StateMachine::INITIALIZED ) { return ; }
126  // dump the configuration:
127  if ( m_dump ) { dump ( MSG::ALWAYS ) ; }
128 }
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:57
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
bool m_dump
flag to force the printout

Member Data Documentation

Map DataOnDemandSvc::m_algMap
private

the major configuration property { 'data' : 'algorithm' }

Definition at line 271 of file DataOnDemandSvc.h.

std::vector<IDODAlgMapper *> DataOnDemandSvc::m_algMappers
private

Definition at line 292 of file DataOnDemandSvc.h.

Setup DataOnDemandSvc::m_algMapping
private

Mapping to algorithms.

Definition at line 261 of file DataOnDemandSvc.h.

std::vector<std::string> DataOnDemandSvc::m_algMapTools
private

Definition at line 291 of file DataOnDemandSvc.h.

SmartIF<IAlgManager> DataOnDemandSvc::m_algMgr = nullptr
private

Algorithm manager.

Definition at line 242 of file DataOnDemandSvc.h.

AlgMap DataOnDemandSvc::m_algs
private

Map of algorithms to handle incidents.

Definition at line 265 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_allowInitFailure = false
private

flag to allow DataOnDemand initialization to succeed even if the (pre)initialization of the algorithms fails (m_init).

Definition at line 259 of file DataOnDemandSvc.h.

SmartIF<IDataProviderSvc> DataOnDemandSvc::m_dataSvc = nullptr
private

Data provider reference.

Definition at line 244 of file DataOnDemandSvc.h.

std::string DataOnDemandSvc::m_dataSvcName = "EventDataSvc"
private

Data service name.

Definition at line 250 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_dump = false
private

flag to force the printout

Definition at line 254 of file DataOnDemandSvc.h.

SmartIF<IIncidentSvc> DataOnDemandSvc::m_incSvc = nullptr
private

Incident service.

Definition at line 240 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_init = false
private

flag to warm up the configuration

Definition at line 256 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_locked_algs = false
private

Definition at line 286 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_locked_all = false
private

Definition at line 287 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_locked_nodes = false
private

Definition at line 285 of file DataOnDemandSvc.h.

Map DataOnDemandSvc::m_nodeMap
private

the major configuration property { 'data' : 'type' }

Definition at line 273 of file DataOnDemandSvc.h.

std::vector<IDODNodeMapper *> DataOnDemandSvc::m_nodeMappers
private

Definition at line 290 of file DataOnDemandSvc.h.

Setup DataOnDemandSvc::m_nodeMapping
private

Mapping to nodes.

Definition at line 263 of file DataOnDemandSvc.h.

std::vector<std::string> DataOnDemandSvc::m_nodeMapTools
private

Definition at line 289 of file DataOnDemandSvc.h.

NodeMap DataOnDemandSvc::m_nodes
private

Map of "empty" objects to be placed as intermediate nodes.

Definition at line 267 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_partialPath = true
private

Flag to allow for the creation of partial leaves.

Definition at line 252 of file DataOnDemandSvc.h.

std::string DataOnDemandSvc::m_prefix = "/Event/"
private

Definition at line 275 of file DataOnDemandSvc.h.

ulonglong DataOnDemandSvc::m_stat = 0
private

Definition at line 280 of file DataOnDemandSvc.h.

ulonglong DataOnDemandSvc::m_statAlg = 0
private

Definition at line 278 of file DataOnDemandSvc.h.

ulonglong DataOnDemandSvc::m_statNode = 0
private

Definition at line 279 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_timer_algs
private

Definition at line 283 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_timer_all
private

Definition at line 284 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_timer_nodes
private

Definition at line 282 of file DataOnDemandSvc.h.

SmartIF<IToolSvc> DataOnDemandSvc::m_toolSvc
private

Data provider reference.

Definition at line 246 of file DataOnDemandSvc.h.

ChronoEntity DataOnDemandSvc::m_total
private

Definition at line 277 of file DataOnDemandSvc.h.

std::string DataOnDemandSvc::m_trapType = "DataFault"
private

Trap name.

Definition at line 248 of file DataOnDemandSvc.h.

bool DataOnDemandSvc::m_updateRequired = true
private

Definition at line 274 of file DataOnDemandSvc.h.


The documentation for this class was generated from the following files: