Loading [MathJax]/extensions/tex2jax.js
The Gaudi Framework  v31r0 (aeb156f0)
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AlgDecorators.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // GaudiKernel
5 // ============================================================================
7 #include "GaudiKernel/IAlgTool.h"
10 #include "GaudiKernel/IProperty.h"
11 #include "GaudiKernel/SmartIF.h"
12 // ============================================================================
13 // GaudiAlg
14 // ============================================================================
16 #include "GaudiAlg/GaudiTool.h"
17 // ============================================================================
18 // GaudiPython
19 // ============================================================================
21 // ============================================================================
22 // Disable warnings on gcc
23 // ============================================================================
24 #if defined( __GNUC__ )
25 # pragma GCC diagnostic ignored "-Wdeprecated-declarations"
26 #endif
27 // ============================================================================
33 // ============================================================================
34 /* get the tool from GaudiAlgorithm
35  * @param alg GaudiAlgorithm
36  * @param type tool type
37  * @param name tool name
38  * @param parent tool parent
39  * @param create flag to create
40  * @return the tool
41  */
42 // ============================================================================
44  const IInterface* parent, const bool create ) {
45  return alg ? alg->tool<IAlgTool>( type, name, parent, create ) : nullptr;
46 }
47 // ============================================================================
48 /* get the tool from GaudiAlgorithm
49  * @param alg GaudiAlgorithm
50  * @param typeAndName tool type/name
51  * @param parent tool parent
52  * @param create flag to create
53  * @return the tool
54  */
55 // ============================================================================
57  const IInterface* parent, const bool create ) {
58  return alg ? alg->tool<IAlgTool>( typeAndName, parent, create ) : nullptr;
59 }
60 // ============================================================================
61 /* get the service from GaudiAlgorithm
62  * @param alg GaudiAlgorithm
63  * @param name service name
64  * @param create flag to create
65  * @return the tool
66  */
67 // ============================================================================
68 IInterface* GaudiPython::AlgDecorator::svc_( const GaudiAlgorithm* alg, const std::string& name, const bool create ) {
69  return alg ? alg->svc<IInterface>( name, create ) : nullptr;
70 }
71 // ============================================================================
72 // get all counters form the algorithm
73 // ============================================================================
76  names.clear();
77  out.clear();
78  if ( !alg ) return 0;
79  alg->forEachCounter( [&]( const std::string& name, auto& counter ) {
80  names.push_back( name );
81  out.push_back( &counter );
82  } );
83  return out.size();
84 }
85 // ============================================================================
86 // get all counters form the tool
87 // ============================================================================
90  names.clear();
91  out.clear();
92  if ( !alg ) return 0;
93  alg->forEachCounter( [&]( const std::string& name, auto& counter ) {
94  names.push_back( name );
95  out.push_back( &counter );
96  } );
97  return out.size();
98 }
99 // ============================================================================
100 // get all counters form the algorithm
101 // ============================================================================
104  names.clear();
105  out.clear();
106  return alg ? _counters_a_( dynamic_cast<const GaudiAlgorithm*>( alg ), names, out ) : 0;
107 }
108 // ============================================================================
109 // get all counters form the tool
110 // ============================================================================
113  names.clear();
114  out.clear();
115  return alg ? _counters_t_( dynamic_cast<const GaudiTool*>( alg ), names, out ) : 0;
116 }
117 // ============================================================================
118 // get the counter by name
119 // ============================================================================
121  return cmp ? &( cmp->counter( name ) ) : nullptr; // RETURN
122 }
123 // ============================================================================
124 // get the counter by name
125 // ============================================================================
127  return cmp ? &( cmp->counter( name ) ) : nullptr; // RETURN
128 }
129 // ============================================================================
130 // get the counter by name
131 // ============================================================================
133  return cmp ? _counter_a_( dynamic_cast<const GaudiAlgorithm*>( cmp ), name ) : nullptr;
134 }
135 // ============================================================================
136 // get the counter by name
137 // ============================================================================
139  return cmp ? _counter_t_( dynamic_cast<const GaudiTool*>( cmp ), name ) : nullptr;
140 }
141 // ============================================================================
142 // get all tools
143 // ============================================================================
145  tools.clear();
146  if ( cmp ) tools = cmp->tools();
147  return tools.size(); // RETURN
148 }
149 // ============================================================================
150 // get all tools
151 // ============================================================================
153  tools.clear();
154  if ( cmp ) tools = cmp->tools();
155  return tools.size(); // RETURN
156 }
157 // ============================================================================
158 // get all tools
159 // ============================================================================
161  tools.clear();
162  return cmp ? _tools_a_( dynamic_cast<const GaudiAlgorithm*>( cmp ), tools ) : 0;
163 }
164 // ============================================================================
165 // get all tools
166 // ============================================================================
168  tools.clear();
169  return cmp ? _tools_t_( dynamic_cast<const GaudiTool*>( cmp ), tools ) : 0;
170 }
171 // ============================================================================
172 /* check the data in Transient Event Store
173  * @param alg GaudiAlgorithm
174  * @param location data location in TES
175  * @param useRoonInTes flag to respect RootInTes
176  * @return the data
177  */
178 // ============================================================================
180  const bool useRootInTes ) {
181  return alg ? alg->exist<DataObject>( alg->evtSvc(), location, useRootInTes ) : false;
182 }
183 // ============================================================================
184 /* get the data from Transient Event Store
185  * @param alg GaudiAlgorithm
186  * @param location data location in TES
187  * @param useRoonInTes flag to respect RootInTes
188  * @return the data
189  */
190 // ============================================================================
192  const bool useRootInTes ) {
193  return alg ? alg->get<DataObject>( alg->evtSvc(), location, useRootInTes ) : nullptr;
194 }
195 // ============================================================================
196 // Re-enable warnings on gcc
197 // ============================================================================
198 #if defined( __GNUC__ )
199 # pragma GCC diagnostic pop
200 #endif
201 
202 // ============================================================================
203 // The END
204 // ============================================================================
static size_t _counters_a_(const GaudiAlgorithm *alg, std::vector< std::string > &names, Counters &out)
SmartIF< IDataProviderSvc > & evtSvc() const
shortcut for method eventSvc
Definition: Algorithm.h:265
Header file for class GaudiAlgorithm.
void forEachCounter(Callable &&f) const
Definition: CounterHolder.h:42
static bool exist(const GaudiAlgorithm *alg, const std::string &location, const bool useRootInTes)
get the data from TES
Header file for class GaudiAlgorithm.
static IInterface * svc_(const GaudiAlgorithm *alg, const std::string &name, const bool create=false)
get the service from GaudiAlgorithm
bool exist(IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Check the existence of a data object or container in the Gaudi Transient Event Store.
Collection of "decorators" for python algorithms.
static size_t _counters_t_(const GaudiTool *alg, std::vector< std::string > &names, Counters &out)
static IAlgTool * tool_(const GaudiAlgorithm *alg, const std::string &type, const std::string &name, const IInterface *parent=0, const bool create=true)
get the tool from GaudiAlgorithm
STL class.
T push_back(T...args)
StatEntity & counter(const std::string &tag) const
accessor to certain counter by name
Definition: GaudiCommon.h:507
Definition of the basic interface.
Definition: IInterface.h:244
static size_t _tools_t_(const GaudiTool *, Tools &tools)
The useful base class for data processing algorithms.
Gaudi::Utils::GetData< TYPE >::return_type get(IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const
Templated access to the data in Gaudi Transient Store.
T clear(T...args)
static size_t _tools_a_(const GaudiAlgorithm *, Tools &tools)
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
T size(T...args)
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
The useful base class for tools.
Definition: GaudiTool.h:101
const std::vector< IAlgTool * > & tools() const
Definition: Algorithm.cpp:767
static StatEntity * _counter_t_(const GaudiTool *alg, const std::string &name)
static DataObject * get_(const GaudiAlgorithm *alg, const std::string &location, const bool useRootInTes)
get the data from TES
backward compatible StatEntity class.
Definition: Counters.h:837
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:30
TOOL * tool(const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const
Useful method for the easy location of tools.
static StatEntity * _counter_a_(const GaudiAlgorithm *alg, const std::string &name)
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.