The Gaudi Framework  v29r0 (ff2e7097)
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 // ============================================================================
27 // ============================================================================
28 /* get the tool from GaudiAlgorithm
29  * @param alg GaudiAlgorithm
30  * @param type tool type
31  * @param name tool name
32  * @param parent tool parent
33  * @param create flag to create
34  * @return the tool
35  */
36 // ============================================================================
38  const IInterface* parent, const bool create )
39 {
40  return alg ? alg->tool<IAlgTool>( type, name, parent, create ) : nullptr;
41 }
42 // ============================================================================
43 /* get the tool from GaudiAlgorithm
44  * @param alg GaudiAlgorithm
45  * @param typeAndName tool type/name
46  * @param parent tool parent
47  * @param create flag to create
48  * @return the tool
49  */
50 // ============================================================================
52  const IInterface* parent, const bool create )
53 {
54  return alg ? alg->tool<IAlgTool>( typeAndName, parent, create ) : nullptr;
55 }
56 // ============================================================================
57 /* get the service from GaudiAlgorithm
58  * @param alg GaudiAlgorithm
59  * @param name service name
60  * @param create flag to create
61  * @return the tool
62  */
63 // ============================================================================
65 {
66  return alg ? alg->svc<IInterface>( name, create ) : nullptr;
67 }
68 // ============================================================================
69 // get all counters form the algorithm
70 // ============================================================================
73 {
74  names.clear();
75  out.clear();
76  if ( !alg ) {
77  return 0;
78  } // RETURN
79  //
80  for ( const auto& cnt : alg->counters() ) {
81  names.push_back( cnt.first );
82  out.push_back( &cnt.second );
83  }
84  return out.size();
85 }
86 // ============================================================================
87 // get all counters form the tool
88 // ============================================================================
91 {
92  names.clear();
93  out.clear();
94  if ( !alg ) {
95  return 0;
96  } // RETURN
97  //
98  for ( const auto& cnt : alg->counters() ) {
99  names.push_back( cnt.first );
100  out.push_back( &cnt.second );
101  }
102  return out.size();
103 }
104 // ============================================================================
105 // get all counters form the algorithm
106 // ============================================================================
109 {
110  names.clear();
111  out.clear();
112  return alg ? _counters_a_( dynamic_cast<const GaudiAlgorithm*>( alg ), names, out ) : 0;
113 }
114 // ============================================================================
115 // get all counters form the tool
116 // ============================================================================
119 {
120  names.clear();
121  out.clear();
122  return alg ? _counters_t_( dynamic_cast<const GaudiTool*>( alg ), names, out ) : 0;
123 }
124 // ============================================================================
125 // get the counter by name
126 // ============================================================================
128 {
129  return cmp ? &( cmp->counter( name ) ) : nullptr; // RETURN
130 }
131 // ============================================================================
132 // get the counter by name
133 // ============================================================================
135 {
136  return cmp ? &( cmp->counter( name ) ) : nullptr; // RETURN
137 }
138 // ============================================================================
139 // get the counter by name
140 // ============================================================================
142 {
143  return cmp ? _counter_a_( dynamic_cast<const GaudiAlgorithm*>( cmp ), name ) : nullptr;
144 }
145 // ============================================================================
146 // get the counter by name
147 // ============================================================================
149 {
150  return cmp ? _counter_t_( dynamic_cast<const GaudiTool*>( cmp ), name ) : nullptr;
151 }
152 // ============================================================================
153 // get all tools
154 // ============================================================================
156 {
157  tools.clear();
158  if ( cmp ) tools = cmp->tools();
159  return tools.size(); // RETURN
160 }
161 // ============================================================================
162 // get all tools
163 // ============================================================================
165 {
166  tools.clear();
167  if ( cmp ) tools = cmp->tools();
168  return tools.size(); // RETURN
169 }
170 // ============================================================================
171 // get all tools
172 // ============================================================================
174 {
175  tools.clear();
176  return cmp ? _tools_a_( dynamic_cast<const GaudiAlgorithm*>( cmp ), tools ) : 0;
177 }
178 // ============================================================================
179 // get all tools
180 // ============================================================================
182 {
183  tools.clear();
184  return cmp ? _tools_t_( dynamic_cast<const GaudiTool*>( cmp ), tools ) : 0;
185 }
186 // ============================================================================
187 /* check the data in Transient Event Store
188  * @param alg GaudiAlgorithm
189  * @param location data location in TES
190  * @param useRoonInTes flag to respect RootInTes
191  * @return the data
192  */
193 // ============================================================================
194 bool GaudiPython::AlgDecorator::exist( const GaudiAlgorithm* alg, const std::string& location, const bool useRootInTes )
195 {
196  return alg ? alg->exist<DataObject>( alg->evtSvc(), location, useRootInTes ) : false;
197 }
198 // ============================================================================
199 /* get the data from Transient Event Store
200  * @param alg GaudiAlgorithm
201  * @param location data location in TES
202  * @param useRoonInTes flag to respect RootInTes
203  * @return the data
204  */
205 // ============================================================================
207  const bool useRootInTes )
208 {
209  return alg ? alg->get<DataObject>( alg->evtSvc(), location, useRootInTes ) : nullptr;
210 }
211 
212 // ============================================================================
213 // The END
214 // ============================================================================
static size_t _counters_a_(const GaudiAlgorithm *alg, std::vector< std::string > &names, Counters &out)
Header file for class GaudiAlgorithm.
static bool exist(const GaudiAlgorithm *alg, const std::string &location, const bool useRootInTes)
get the data from TES
static const StatEntity * _counter_t_(const GaudiTool *alg, const std::string &name)
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.
const Statistics & counters() const
accessor to all counters
Definition: GaudiCommon.h:465
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:484
Definition of the basic interface.
Definition: IInterface.h:277
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)
const std::vector< IAlgTool * > & tools() const
Definition: AlgTool.cpp:471
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
T size(T...args)
SmartIF< IDataProviderSvc > & evtSvc() const
shortcut for method eventSvc
Definition: Algorithm.h:280
static const StatEntity * _counter_a_(const GaudiAlgorithm *alg, const std::string &name)
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
The useful base class for tools.
Definition: GaudiTool.h:101
static DataObject * get_(const GaudiAlgorithm *alg, const std::string &location, const bool useRootInTes)
get the data from TES
const std::vector< IAlgTool * > & tools() const
Definition: Algorithm.cpp:923
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
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.
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.