| The Gaudi Framework v29r1 (5cd95fa2)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- File List
- File Members

AlgDecorators.cpp
Go to the documentation of this file.
1 // ============================================================================
2 // Include files
3 // ============================================================================
4 // GaudiKernel
5 // ============================================================================
6 #include "GaudiKernel/DataObject.h"
7 #include "GaudiKernel/IAlgTool.h"
8 #include "GaudiKernel/IAlgorithm.h"
9 #include "GaudiKernel/IInterface.h"
10 #include "GaudiKernel/IProperty.h"
11 #include "GaudiKernel/SmartIF.h"
12 // ============================================================================
13 // GaudiAlg
14 // ============================================================================
15 #include "GaudiAlg/GaudiAlgorithm.h"
16 #include "GaudiAlg/GaudiTool.h"
17 // ============================================================================
18 // GaudiPython
19 // ============================================================================
20 #include "GaudiPython/AlgDecorators.h"
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 // ============================================================================
37 IAlgTool* GaudiPython::AlgDecorator::tool_( const GaudiAlgorithm* alg, const std::string& type, const std::string& name,
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 // ============================================================================
51 IAlgTool* GaudiPython::AlgDecorator::tool_( const GaudiAlgorithm* alg, const std::string& typeAndName,
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 // ============================================================================
64 IInterface* GaudiPython::AlgDecorator::svc_( const GaudiAlgorithm* alg, const std::string& name, const bool create )
65 {
66 return alg ? alg->svc<IInterface>( name, create ) : nullptr;
67 }
68 // ============================================================================
69 // get all counters form the algorithm
70 // ============================================================================
71 size_t GaudiPython::AlgDecorator::_counters_a_( const GaudiAlgorithm* alg, std::vector<std::string>& names,
72 GaudiPython::AlgDecorator::Counters& out )
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 // ============================================================================
89 size_t GaudiPython::AlgDecorator::_counters_t_( const GaudiTool* alg, std::vector<std::string>& names,
90 GaudiPython::AlgDecorator::Counters& out )
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 // ============================================================================
107 size_t GaudiPython::AlgDecorator::_counters_a_( const IAlgorithm* alg, std::vector<std::string>& names,
108 GaudiPython::AlgDecorator::Counters& out )
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 // ============================================================================
117 size_t GaudiPython::AlgDecorator::_counters_t_( const IAlgTool* alg, std::vector<std::string>& names,
118 GaudiPython::AlgDecorator::Counters& out )
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 // ============================================================================
127 const StatEntity* GaudiPython::AlgDecorator::_counter_a_( const GaudiAlgorithm* cmp, const std::string& name )
128 {
129 return cmp ? &( cmp->counter( name ) ) : nullptr; // RETURN
130 }
131 // ============================================================================
132 // get the counter by name
133 // ============================================================================
134 const StatEntity* GaudiPython::AlgDecorator::_counter_t_( const GaudiTool* cmp, const std::string& name )
135 {
136 return cmp ? &( cmp->counter( name ) ) : nullptr; // RETURN
137 }
138 // ============================================================================
139 // get the counter by name
140 // ============================================================================
141 const StatEntity* GaudiPython::AlgDecorator::_counter_a_( const IAlgorithm* cmp, const std::string& name )
142 {
143 return cmp ? _counter_a_( dynamic_cast<const GaudiAlgorithm*>( cmp ), name ) : nullptr;
144 }
145 // ============================================================================
146 // get the counter by name
147 // ============================================================================
148 const StatEntity* GaudiPython::AlgDecorator::_counter_t_( const IAlgTool* cmp, const std::string& name )
149 {
150 return cmp ? _counter_t_( dynamic_cast<const GaudiTool*>( cmp ), name ) : nullptr;
151 }
152 // ============================================================================
153 // get all tools
154 // ============================================================================
155 size_t GaudiPython::AlgDecorator::_tools_a_( const GaudiAlgorithm* cmp, GaudiPython::AlgDecorator::Tools& tools )
156 {
157 tools.clear();
158 if ( cmp ) tools = cmp->tools();
159 return tools.size(); // RETURN
160 }
161 // ============================================================================
162 // get all tools
163 // ============================================================================
164 size_t GaudiPython::AlgDecorator::_tools_t_( const GaudiTool* cmp, GaudiPython::AlgDecorator::Tools& tools )
165 {
166 tools.clear();
167 if ( cmp ) tools = cmp->tools();
168 return tools.size(); // RETURN
169 }
170 // ============================================================================
171 // get all tools
172 // ============================================================================
173 size_t GaudiPython::AlgDecorator::_tools_a_( const IAlgorithm* cmp, GaudiPython::AlgDecorator::Tools& tools )
174 {
175 tools.clear();
176 return cmp ? _tools_a_( dynamic_cast<const GaudiAlgorithm*>( cmp ), tools ) : 0;
177 }
178 // ============================================================================
179 // get all tools
180 // ============================================================================
181 size_t GaudiPython::AlgDecorator::_tools_t_( const IAlgTool* cmp, GaudiPython::AlgDecorator::Tools& tools )
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 // ============================================================================
206 DataObject* GaudiPython::AlgDecorator::get_( const GaudiAlgorithm* alg, const std::string& location,
207 const bool useRootInTes )
208 {
209 return alg ? alg->get<DataObject>( alg->evtSvc(), location, useRootInTes ) : nullptr;
210 }
211
212 // ============================================================================
213 // The END
214 // ============================================================================
GaudiPython::AlgDecorator::_counters_a_
static size_t _counters_a_(const GaudiAlgorithm *alg, std::vector< std::string > &names, Counters &out)
Definition: AlgDecorators.cpp:71
GaudiTool.h
Header file for class GaudiAlgorithm.
gaudiComponentHelp.name
name
Definition: gaudiComponentHelp.py:32
GaudiPython::AlgDecorator::exist
static bool exist(const GaudiAlgorithm *alg, const std::string &location, const bool useRootInTes)
get the data from TES
Definition: AlgDecorators.cpp:194
IAlgorithm.h
GaudiPython::AlgDecorator::_counter_t_
static const StatEntity * _counter_t_(const GaudiTool *alg, const std::string &name)
Definition: AlgDecorators.cpp:134
GaudiAlgorithm.h
Header file for class GaudiAlgorithm.
GaudiPython.HistoUtils.location
location
Definition: HistoUtils.py:899
GaudiPython::AlgDecorator::svc_
static IInterface * svc_(const GaudiAlgorithm *alg, const std::string &name, const bool create=false)
get the service from GaudiAlgorithm
Definition: AlgDecorators.cpp:64
GaudiAlgorithm::exist
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.
Definition: GaudiAlgorithm.h:488
AlgDecorators.h
Collection of "decorators" for python algorithms.
GaudiCommon::counters
const Statistics & counters() const
accessor to all counters
Definition: GaudiCommon.h:465
GaudiPython::AlgDecorator::_counters_t_
static size_t _counters_t_(const GaudiTool *alg, std::vector< std::string > &names, Counters &out)
Definition: AlgDecorators.cpp:89
GaudiPython::AlgDecorator::tool_
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
Definition: AlgDecorators.cpp:37
std::string
STL class.
std::vector::push_back
T push_back(T...args)
GaudiCommon::counter
StatEntity & counter(const std::string &tag) const
accessor to certain counter by name
Definition: GaudiCommon.h:484
IInterface
Definition of the basic interface.
Definition: IInterface.h:277
gaudirun.type
type
Definition: gaudirun.py:133
SmartIF.h
GaudiPython::AlgDecorator::_tools_t_
static size_t _tools_t_(const GaudiTool *, Tools &tools)
Definition: AlgDecorators.cpp:164
GaudiAlgorithm
The useful base class for data processing algorithms.
Definition: GaudiAlgorithm.h:94
GaudiAlgorithm::get
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.
Definition: GaudiAlgorithm.h:240
IAlgTool.h
std::vector::clear
T clear(T...args)
GaudiPython::AlgDecorator::_tools_a_
static size_t _tools_a_(const GaudiAlgorithm *, Tools &tools)
Definition: AlgDecorators.cpp:155
AlgTool::tools
const std::vector< IAlgTool * > & tools() const
Definition: AlgTool.cpp:473
IAlgorithm
The IAlgorithm is the interface implemented by the Algorithm base class.
Definition: IAlgorithm.h:28
std::vector::size
T size(T...args)
IProperty.h
Algorithm::evtSvc
SmartIF< IDataProviderSvc > & evtSvc() const
shortcut for method eventSvc
Definition: Algorithm.h:282
std::vector< std::string >
GaudiPython::AlgDecorator::_counter_a_
static const StatEntity * _counter_a_(const GaudiAlgorithm *alg, const std::string &name)
Definition: AlgDecorators.cpp:127
IAlgTool
The interface implemented by the AlgTool base class.
Definition: IAlgTool.h:23
GaudiTool
The useful base class for tools.
Definition: GaudiTool.h:101
GaudiPython::AlgDecorator::get_
static DataObject * get_(const GaudiAlgorithm *alg, const std::string &location, const bool useRootInTes)
get the data from TES
Definition: AlgDecorators.cpp:206
Algorithm::tools
const std::vector< IAlgTool * > & tools() const
Definition: Algorithm.cpp:922
StatEntity
The basic counter used for Monitoring purposes.
Definition: StatEntity.h:65
DataObject
A DataObject is the base class of any identifiable object on any data store.
Definition: DataObject.h:29
IInterface.h
GaudiCommon::tool
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.
Definition: GaudiCommonImp.h:108
GaudiCommon::svc
SmartIF< SERVICE > svc(const std::string &name, const bool create=true) const
A useful method for the easy location of services.
Definition: GaudiCommonImp.h:158
DataObject.h