| The Gaudi Framework v32r1 (f65d50dc)

DataOnDemandSvc.h
Go to the documentation of this file.
1 #ifndef GAUDISVC_DATAONDEMANDSVC_H
2 #define GAUDISVC_DATAONDEMANDSVC_H
3 // ============================================================================
4 // Include Files
5 // ============================================================================
6 // STD & STL
7 // ============================================================================
8 #include <map>
9 #include <vector>
10 // ============================================================================
11 // GaudiKernel
12 // ============================================================================
13 #include "GaudiKernel/ChronoEntity.h"
14 #include "GaudiKernel/IDODAlgMapper.h"
15 #include "GaudiKernel/IDODNodeMapper.h"
16 #include "GaudiKernel/IIncidentListener.h"
17 #include "GaudiKernel/Service.h"
18 #include "GaudiKernel/StatEntity.h"
19 #include "GaudiKernel/StringKey.h"
20 // ============================================================================
21 // ROOT TClass
22 // ============================================================================
23 #include "TClass.h"
24 // ============================================================================
25 // Forward declarations
26 // ============================================================================
27 class IAlgTool;
28 class IAlgorithm;
29 class IAlgManager;
30 class IIncidentSvc;
31 class IDataProviderSvc;
32 class IToolSvc;
33 // ============================================================================
90 class DataOnDemandSvc : public extends<Service, IIncidentListener> {
91 public:
92 // ==========================================================================
93 // Typedefs
94 typedef std::vector<std::string> Setup;
95 typedef TClass* ClassH;
96 // ==========================================================================
101 struct Protection {
102 bool& m_bool;
103 Protection( bool& b ) : m_bool( b ) { m_bool = true; }
104 ~Protection() { m_bool = false; }
105 };
106 // ==========================================================================
112 struct Node {
113 // ========================================================================
115 ClassH clazz; // the actual class
116 std::string name;
117 unsigned long num = 0;
118 bool executing = false;
120 bool dataObject = false; // trivial object? DataObject?
121 // =======================================================================
122 Node() = default;
123 // ========================================================================
124 Node( ClassH c, bool e, std::string n )
125 : clazz( c ), name( std::move( n ) ), executing( e ), dataObject( "DataObject" == name ) {}
126 //
127 Node( const Node& c )
128 : clazz( c.clazz ), name( c.name ), num( c.num ), executing( c.executing ), dataObject( c.dataObject ) {}
129 // ========================================================================
130 };
131 // ==========================================================================
133 struct Leaf {
134 IAlgorithm* algorithm = nullptr;
135 std::string name;
136 std::string type;
137 unsigned long num = 0;
138 bool executing = false;
139 Leaf() = default;
140 Leaf( const Leaf& l ) = default;
141 Leaf( std::string t, std::string n ) : name( std::move( n ) ), type( std::move( t ) ) {}
142 };
143 // ==========================================================================
144 public:
145 // ==========================================================================
146 typedef GaudiUtils::HashMap<Gaudi::StringKey, Node> NodeMap;
147 typedef GaudiUtils::HashMap<Gaudi::StringKey, Leaf> AlgMap;
149 StatusCode initialize() override;
151 StatusCode finalize() override;
153 StatusCode reinitialize() override;
155 void handle( const Incident& incident ) override;
157 using extends::extends;
158 // ==========================================================================
159 protected:
160 // ==========================================================================
165 StatusCode configureHandler( Leaf& leaf );
166 // ==========================================================================
172 StatusCode execHandler( const std::string& tag, Leaf& leaf );
173 // ==========================================================================
179 StatusCode execHandler( const std::string& tag, Node& node );
180 // ==========================================================================
182 StatusCode setupNodeHandlers();
183 // ==========================================================================
185 StatusCode setupAlgHandlers();
186 // ==========================================================================
188 StatusCode setup();
190 void i_setNodeHandler( const std::string& name, const std::string& type );
192 StatusCode i_setAlgHandler( const std::string& name, const Gaudi::Utils::TypeNameString& alg );
193 // ==========================================================================
194 protected:
195 // ==========================================================================
197 StatusCode update();
202 void dump( const MSG::Level level, const bool mode = true ) const;
203 // ==========================================================================
204 private:
205 // ==========================================================================
206 void force_update( Gaudi::Details::PropertyBase& p ) {
207 verbose() << "updated property " << p.name() << ", forcing update" << endmsg;
208 m_updateRequired = true;
209 };
210 void deprecated_property( Gaudi::Details::PropertyBase& p ) {
211 warning() << p.name() << " " << p.documentation() << endmsg;
212 force_update( p );
213 };
214
215 // ==========================================================================
217 SmartIF<IIncidentSvc> m_incSvc = nullptr;
219 SmartIF<IAlgManager> m_algMgr = nullptr;
221 SmartIF<IDataProviderSvc> m_dataSvc = nullptr;
223 SmartIF<IToolSvc> m_toolSvc;
225 AlgMap m_algs;
227 NodeMap m_nodes;
228
229 bool m_updateRequired = true;
230 // ==========================================================================
231 ChronoEntity m_total;
232 unsigned long long m_statAlg = 0;
233 unsigned long long m_statNode = 0;
234 unsigned long long m_stat = 0;
235 // ==========================================================================
236 ChronoEntity m_timer_nodes;
237 ChronoEntity m_timer_algs;
238 ChronoEntity m_timer_all;
239 bool m_locked_nodes = false;
240 bool m_locked_algs = false;
241 bool m_locked_all = false;
242 // ==========================================================================
243 std::vector<IDODNodeMapper*> m_nodeMappers;
244 std::vector<IDODAlgMapper*> m_algMappers;
245 // ==========================================================================
246 // Properties
247 Gaudi::Property<std::string> m_trapType{this, "IncidentName", "DataFault", "the type of handled Incident"};
248 Gaudi::Property<std::string> m_dataSvcName{this, "DataSvc", "EventDataSvc", "DataSvc name"};
249
250 Gaudi::Property<bool> m_partialPath{this, "UsePreceedingPath", true, "allow creation of partial leaves"};
251 Gaudi::Property<bool> m_dump{
252 this, "Dump", false,
253 [this]( auto& ) {
254 if ( m_dump && FSMState() >= Gaudi::StateMachine::INITIALIZED ) { dump( MSG::ALWAYS ); }
255 },
256 "dump configuration and stastics, if set to True after initialize it triggers a dump immediately"};
257 Gaudi::Property<bool> m_init{this, "PreInitialize", false, "(pre)initialize all algorithms"};
258 Gaudi::Property<bool> m_allowInitFailure{
259 this, "AllowPreInitializeFailure", false,
260 "allow (pre)initialization of algorithms to fail without stopping the application"};
261
262 Gaudi::Property<Setup> m_algMapping{
263 this, "Algorithms", {}, &DataOnDemandSvc::deprecated_property, "[[deprecated]] use AlgMap"};
264 Gaudi::Property<Setup> m_nodeMapping{
265 this, "Nodes", {}, &DataOnDemandSvc::deprecated_property, "[[deprecated]] use NodeMap"};
266
267 typedef std::map<std::string, std::string> Map;
268 Gaudi::Property<Map> m_algMap{this, "AlgMap", {}, &DataOnDemandSvc::force_update, "mapping {'data': 'algorithm'}"};
269 Gaudi::Property<Map> m_nodeMap{this, "NodeMap", {}, &DataOnDemandSvc::force_update, "mapping {'data': 'type'}"};
270
271 Gaudi::Property<std::string> m_prefix{this, "Prefix", "/Event/"};
272
273 Gaudi::Property<std::vector<std::string>> m_nodeMapTools{
274 this, "NodeMappingTools", {}, "list of tools of type IDODNodeMapper"};
275 Gaudi::Property<std::vector<std::string>> m_algMapTools{
276 this, "AlgMappingTools", {}, "list of tools of type IDODAlgMapper"};
277 };
278 // ============================================================================
279
280 // ============================================================================
281 // The END
282 // ============================================================================
283 #endif // GAUDISVC_DATAONDEMANDSVC_H
DataOnDemandSvc::i_setNodeHandler
void i_setNodeHandler(const std::string &name, const std::string &type)
Internal method to initialize a node handler.
Definition: DataOnDemandSvc.cpp:106
IToolSvc
The interface implemented by the IToolSvc base class.
Definition: IToolSvc.h:19
DataOnDemandSvc::m_timer_all
ChronoEntity m_timer_all
Definition: DataOnDemandSvc.h:238
Gaudi::StateMachine::INITIALIZED
Definition: StateMachine.h:15
SmartIF< IIncidentSvc >
DataOnDemandSvc::Node::name
std::string name
Definition: DataOnDemandSvc.h:116
ManySmallAlgs.alg
alg
Definition: ManySmallAlgs.py:69
gaudirun.c
c
Definition: gaudirun.py:487
DataOnDemandSvc::Node::num
unsigned long num
Definition: DataOnDemandSvc.h:117
DataOnDemandSvc::ClassH
TClass * ClassH
Definition: DataOnDemandSvc.h:95
DataOnDemandSvc
The DataOnDemandSvc listens to incidents typically triggered by the data service of the configurable ...
Definition: DataOnDemandSvc.h:90
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:352
DataOnDemandSvc::m_timer_algs
ChronoEntity m_timer_algs
Definition: DataOnDemandSvc.h:237
Service::FSMState
Gaudi::StateMachine::State FSMState() const override
Definition: Service.h:52
CommonMessagingBase::warning
MsgStream & warning() const
shortcut for the method msgStream(MSG::WARNING)
Definition: CommonMessaging.h:101
ChronoEntity
a small helper class for implementation of ChronoStatSvc service, It also could be used as some local...
Definition: ChronoEntity.h:21
DataOnDemandSvc::Leaf::type
std::string type
Definition: DataOnDemandSvc.h:136
DataOnDemandSvc::m_incSvc
SmartIF< IIncidentSvc > m_incSvc
Incident service.
Definition: DataOnDemandSvc.h:217
DataOnDemandSvc::handle
void handle(const Incident &incident) override
IIncidentListener interfaces overrides: incident handling.
Definition: DataOnDemandSvc.cpp:467
DataOnDemandSvc::Leaf::algorithm
IAlgorithm * algorithm
Definition: DataOnDemandSvc.h:134
DataOnDemandSvc::Setup
std::vector< std::string > Setup
Definition: DataOnDemandSvc.h:94
IAlgManager
The IAlgManager is the interface implemented by the Algorithm Factory in the Application Manager to s...
Definition: IAlgManager.h:27
DataOnDemandSvc::m_trapType
Gaudi::Property< std::string > m_trapType
Definition: DataOnDemandSvc.h:247
std
STL namespace.
DataOnDemandSvc::m_locked_nodes
bool m_locked_nodes
Definition: DataOnDemandSvc.h:239
DataOnDemandSvc::Leaf
Definition: DataOnDemandSvc.h:133
DataOnDemandSvc::m_nodeMap
Gaudi::Property< Map > m_nodeMap
Definition: DataOnDemandSvc.h:269
DataOnDemandSvc::Leaf::executing
bool executing
Definition: DataOnDemandSvc.h:138
DataOnDemandSvc::Protection::m_bool
bool & m_bool
Definition: DataOnDemandSvc.h:102
DataOnDemandSvc::m_init
Gaudi::Property< bool > m_init
Definition: DataOnDemandSvc.h:257
Gaudi::Details::PropertyBase::name
const std::string name() const
property name
Definition: Property.h:36
IDataProviderSvc
Data provider interface definition.
Definition: IDataProviderSvc.h:43
DataOnDemandSvc::initialize
StatusCode initialize() override
Inherited Service overrides: Service initialization.
Definition: DataOnDemandSvc.cpp:181
std::map< std::string, std::string >
DataOnDemandSvc::dump
void dump(const MSG::Level level, const bool mode=true) const
dump the content of DataOnDemand service
Definition: DataOnDemandSvc.cpp:605
DataOnDemandSvc::force_update
void force_update(Gaudi::Details::PropertyBase &p)
Definition: DataOnDemandSvc.h:206
DataOnDemandSvc::deprecated_property
void deprecated_property(Gaudi::Details::PropertyBase &p)
Definition: DataOnDemandSvc.h:210
DataOnDemandSvc::Node::Node
Node()=default
std::string
STL class.
DataOnDemandSvc::m_dataSvc
SmartIF< IDataProviderSvc > m_dataSvc
Data provider reference.
Definition: DataOnDemandSvc.h:221
Service.h
GaudiPluginService.cpluginsvc.n
n
Definition: cpluginsvc.py:210
DataOnDemandSvc::m_algMapping
Gaudi::Property< Setup > m_algMapping
Definition: DataOnDemandSvc.h:262
DataOnDemandSvc::m_algMapTools
Gaudi::Property< std::vector< std::string > > m_algMapTools
Definition: DataOnDemandSvc.h:275
Service::name
const std::string & name() const override
Retrieve name of the service.
Definition: Service.cpp:274
DataOnDemandSvc::Node::clazz
ClassH clazz
the actual class
Definition: DataOnDemandSvc.h:115
MSG::Level
Level
Definition: IMessageSvc.h:15
DataOnDemandSvc::m_prefix
Gaudi::Property< std::string > m_prefix
Definition: DataOnDemandSvc.h:271
DataOnDemandSvc::m_stat
unsigned long long m_stat
Definition: DataOnDemandSvc.h:234
DataOnDemandSvc::m_nodeMapTools
Gaudi::Property< std::vector< std::string > > m_nodeMapTools
Definition: DataOnDemandSvc.h:273
Gaudi::Utils::TypeNameString
Helper class to parse a string of format "type/name".
Definition: TypeNameString.h:10
DataOnDemandSvc::m_algMap
Gaudi::Property< Map > m_algMap
Definition: DataOnDemandSvc.h:268
DataOnDemandSvc::setup
StatusCode setup()
Setup routine (called by (re-) initialize.
Definition: DataOnDemandSvc.cpp:280
DataOnDemandSvc::Leaf::num
unsigned long num
Definition: DataOnDemandSvc.h:137
DataOnDemandSvc::Node::Node
Node(const Node &c)
Definition: DataOnDemandSvc.h:127
DataOnDemandSvc::execHandler
StatusCode execHandler(const std::string &tag, Leaf &leaf)
Execute leaf handler (algorithm)
Definition: DataOnDemandSvc.cpp:569
StatusCode
This class is used for returning status codes from appropriate routines.
Definition: StatusCode.h:50
DataOnDemandSvc::setupNodeHandlers
StatusCode setupNodeHandlers()
Initialize node handlers.
Definition: DataOnDemandSvc.cpp:327
gaudirun.type
type
Definition: gaudirun.py:142
DataOnDemandSvc::Protection
Helper class of the DataOnDemandSvc.
Definition: DataOnDemandSvc.h:101
CommonMessagingBase::verbose
MsgStream & verbose() const
shortcut for the method msgStream(MSG::VERBOSE)
Definition: CommonMessaging.h:110
StringKey.h
DataOnDemandSvc::m_nodes
NodeMap m_nodes
Map of "empty" objects to be placed as intermediate nodes.
Definition: DataOnDemandSvc.h:227
DataOnDemandSvc::Protection::~Protection
~Protection()
Definition: DataOnDemandSvc.h:104
Gaudi::Details::PropertyBase
PropertyBase base class allowing PropertyBase* collections to be "homogeneous".
Definition: Property.h:32
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
gaudirun.l
dictionary l
Definition: gaudirun.py:521
DataOnDemandSvc::m_partialPath
Gaudi::Property< bool > m_partialPath
Definition: DataOnDemandSvc.h:250
DataOnDemandSvc::m_nodeMappers
std::vector< IDODNodeMapper * > m_nodeMappers
Definition: DataOnDemandSvc.h:243
DataOnDemandSvc::Leaf::name
std::string name
Definition: DataOnDemandSvc.h:135
DataOnDemandSvc::Protection::Protection
Protection(bool &b)
Definition: DataOnDemandSvc.h:103
std::vector< std::string >
DataOnDemandSvc::m_algMgr
SmartIF< IAlgManager > m_algMgr
Algorithm manager.
Definition: DataOnDemandSvc.h:219
DataOnDemandSvc::Node::Node
Node(ClassH c, bool e, std::string n)
Definition: DataOnDemandSvc.h:124
DataOnDemandSvc::m_toolSvc
SmartIF< IToolSvc > m_toolSvc
Data provider reference.
Definition: DataOnDemandSvc.h:223
DataOnDemandSvc::Node::executing
bool executing
Definition: DataOnDemandSvc.h:118
DataOnDemandSvc::m_algs
AlgMap m_algs
Map of algorithms to handle incidents.
Definition: DataOnDemandSvc.h:225
extends
Base class used to extend a class implementing other interfaces.
Definition: extends.h:10
DataOnDemandSvc::m_nodeMapping
Gaudi::Property< Setup > m_nodeMapping
Definition: DataOnDemandSvc.h:264
DataOnDemandSvc::Leaf::Leaf
Leaf(std::string t, std::string n)
Definition: DataOnDemandSvc.h:141
DataOnDemandSvc::m_timer_nodes
ChronoEntity m_timer_nodes
Definition: DataOnDemandSvc.h:236
DataOnDemandSvc::m_dataSvcName
Gaudi::Property< std::string > m_dataSvcName
Definition: DataOnDemandSvc.h:248
Incident
Base class for all Incidents (computing events).
Definition: Incident.h:17
DataOnDemandSvc::m_updateRequired
bool m_updateRequired
Definition: DataOnDemandSvc.h:229
StatEntity.h
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
DataOnDemandSvc::Node::dataObject
bool dataObject
trivial object? DataObject?
Definition: DataOnDemandSvc.h:120
DataOnDemandSvc::finalize
StatusCode finalize() override
Inherited Service overrides: Service finalization.
Definition: DataOnDemandSvc.cpp:201
GaudiUtils::HashMap< Gaudi::StringKey, Node >
IIncidentListener.h
gaudirun.level
level
Definition: gaudirun.py:334
DataOnDemandSvc::NodeMap
GaudiUtils::HashMap< Gaudi::StringKey, Node > NodeMap
Definition: DataOnDemandSvc.h:146
DataOnDemandSvc::m_total
ChronoEntity m_total
Definition: DataOnDemandSvc.h:231
DataOnDemandSvc::Leaf::Leaf
Leaf()=default
DataOnDemandSvc::setupAlgHandlers
StatusCode setupAlgHandlers()
Initialize leaf handlers.
Definition: DataOnDemandSvc.cpp:356
DataOnDemandSvc::Node
Helper class of the DataOnDemandSvc.
Definition: DataOnDemandSvc.h:112
ChronoEntity.h
DataOnDemandSvc::i_setAlgHandler
StatusCode i_setAlgHandler(const std::string &name, const Gaudi::Utils::TypeNameString &alg)
Internal method to initialize an algorithm handler.
Definition: DataOnDemandSvc.cpp:112
DataOnDemandSvc::m_dump
Gaudi::Property< bool > m_dump
Definition: DataOnDemandSvc.h:251
DataOnDemandSvc::configureHandler
StatusCode configureHandler(Leaf &leaf)
Configure handler for leaf.
Definition: DataOnDemandSvc.cpp:385
DataOnDemandSvc::m_allowInitFailure
Gaudi::Property< bool > m_allowInitFailure
Definition: DataOnDemandSvc.h:258
DataOnDemandSvc::m_algMappers
std::vector< IDODAlgMapper * > m_algMappers
Definition: DataOnDemandSvc.h:244
DataOnDemandSvc::Map
std::map< std::string, std::string > Map
Definition: DataOnDemandSvc.h:267
MSG::ALWAYS
Definition: IMessageSvc.h:15
DataOnDemandSvc::m_locked_algs
bool m_locked_algs
Definition: DataOnDemandSvc.h:240
endmsg
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition: MsgStream.h:192
DataOnDemandSvc::m_statNode
unsigned long long m_statNode
Definition: DataOnDemandSvc.h:233
Gaudi::Details::PropertyBase::documentation
std::string documentation() const
property documentation
Definition: Property.h:38
IIncidentSvc
The interface implemented by the IncidentSvc service.
Definition: IIncidentSvc.h:23
DataOnDemandSvc::m_statAlg
unsigned long long m_statAlg
Definition: DataOnDemandSvc.h:232
IDODNodeMapper.h
DataOnDemandSvc::reinitialize
StatusCode reinitialize() override
Inherited Service overrides: Service reinitialization.
Definition: DataOnDemandSvc.cpp:249
DataOnDemandSvc::update
StatusCode update()
update the handlers
Definition: DataOnDemandSvc.cpp:132
DataOnDemandSvc::AlgMap
GaudiUtils::HashMap< Gaudi::StringKey, Leaf > AlgMap
Definition: DataOnDemandSvc.h:147
IDODAlgMapper.h
DataOnDemandSvc::m_locked_all
bool m_locked_all
Definition: DataOnDemandSvc.h:241