Loading [MathJax]/extensions/tex2jax.js
 |
ATLAS Offline Software
|
Go to the documentation of this file.
5 #ifndef INDETTRACKPERFMON_SAFEDECORATOR_H
6 #define INDETTRACKPERFMON_SAFEDECORATOR_H
23 #include "GaudiKernel/EventContext.h"
35 template<
class ContainerType,
class VariableType >
37 std::pair< SG::WriteDecorHandleKey<ContainerType>,
40 template<
class ContainerType,
class VariableType >
42 std::pair< SG::WriteDecorHandle<ContainerType, VariableType>,
45 template<
class ContainerType,
class VariableType >
47 std::pair< SG::WriteDecorHandle<ContainerType, VariableType>,
bool >;
51 template<
class T_Parent,
class T_Cont,
class T >
56 const std::vector< std::string >& decor_names,
60 decor_out.reserve( decor_names.size() );
61 for(
const std::string& a_decor_name: decor_names ) {
62 decor_out.emplace_back(
66 parent.declare( decor_out.back().first );
67 decor_out.back().first.setOwner( &
parent );
68 decor_out.back().first.initialize().ignore();
74 template<
class T_Parent,
class T_Cont >
79 const std::vector< std::string >& decor_names,
83 decor_out.reserve( decor_names.size() );
84 for (
const std::string &a_decor_name : decor_names) {
85 assert( !a_decor_name.empty() );
86 decor_out.emplace_back( container_key.
key()+
"."+
prefix+a_decor_name );
89 parent.declare( decor_out.back() );
90 decor_out.back().setOwner(&
parent);
91 decor_out.back().initialize().ignore();
112 template<
class T_Cont,
class T >
114 const T_Cont& container,
118 bool all_available =
true;
119 if( !container.empty() ) {
123 decorate.push_back( !a_key.second.isAvailable( *container[0] ) );
126 std::cout <<
"WARNING IDTPM::decorationsAllExist: Decoration "
127 << a_key.first.key() <<
" already exists; reject update."
132 return all_available;
136 template<
class T_Cont,
class T >
137 std::vector< OptionalDecoration< T_Cont,T > >
139 const T_Cont& container,
141 const EventContext& ctx,
144 std::vector< OptionalDecoration< T_Cont, T > >
out;
145 bool all_available =
true;
146 if( !container.empty() ) {
150 decorate.push_back( !a_key.second.isAvailable( *container[0] ) );
153 std::cout <<
"WARNING IDTPM::createDecoratorsIfNeeded: Decoration "
154 << a_key.first.key() <<
" already exists; reject update."
159 if( !all_available ) {
168 if( not
out.back().first.isPresent() ) {
169 std::stringstream
msg;
170 msg <<
"Container " << a_key.first.key()
171 <<
" to be decorated does not exist.";
172 throw std::runtime_error(
msg.str() );
181 template<
class T_Cont,
class T >
182 std::vector< SG::WriteDecorHandle< T_Cont, T > >
185 const EventContext& ctx )
187 std::vector< SG::WriteDecorHandle< T_Cont, T > >
out;
190 out.emplace_back( a_key, ctx );
191 if( not
out.back().isValid() ) {
192 std::stringstream
msg;
193 msg <<
"Failed to create decorator handle " << a_key.key();
194 throw std::runtime_error(
msg.str() );
201 template<
class T_Cont,
class T_Cont_Elm,
class T >
203 const T_Cont_Elm& particle,
207 if( !decorator.second.isAvailable( particle ) ) {
208 const T existing = decorator.second( particle );
210 std::cout <<
"WARNING IDTPM::safeDecorator: " << decorator.first.decorKey()
211 <<
" Already exists on this object with a different value."
215 decorator.first( particle ) =
value;
220 template<
class T_Cont,
class T_Cont_Elm,
class T >
222 const T_Cont_Elm& particle,
226 if( decorator.second ) {
227 decorator.first( particle ) =
value;
232 template<
class T_Cont,
class T_Cont_Elm,
class T >
234 const T_Cont_Elm& particle,
238 decorator.first( particle ) =
value;
243 #endif // > !INDETTRACKPERFMON_SAFEDECORATOR_H
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
void decorate(const T_Cont_Elm &particle, OptionalDecoration< T_Cont, T > &decorator, const T &value)
unsafe fill decoration method for convenience
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
similar to createDecoratorsIfNeeded, but without the checking if decorations already exist
void decorateOrRejectQuietly(const T_Cont_Elm &particle, OptionalDecoration< T_Cont, T > &decorator, const T &value)
Safe method to fill the decoration if decor flag is true.
std::vector< OptionalDecoration< T_Cont, T > > createDecoratorsIfNeeded(const T_Cont &container, const std::vector< WriteKeyAccessorPair< T_Cont, T > > &keys, const EventContext &ctx, bool verbose=false)
create/book the decorations if they do not exist already
Helper class to provide constant type-safe access to aux data.
const std::string & key() const
Return the StoreGate ID for the referenced object.
bool equal(double a, double b)
Compare two FP numbers, working around x87 precision issues.
void createDecoratorKeys(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::WriteDecorHandleKey< T_Cont > > &decor_out)
like createDecoratorKeysAndAccessor but without the accessor to check the availablilty of a decoratio...
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
void decorateOrWarnIfUnequal(const T_Cont_Elm &particle, WriteAccessorRefPair< T_Cont, T > &decorator, const T &value)
Fill the decoration if it deas not exist or it has a different value.
std::pair< SG::WriteDecorHandle< ContainerType, VariableType >, SG::AuxElement::ConstAccessor< VariableType > & > WriteAccessorRefPair
bool decorationsAllExist(const T_Cont &container, const std::vector< WriteKeyAccessorPair< T_Cont, T > > &keys, bool verbose=false)
Like above - FIXME: maybe not needed.
Handle class for adding a decoration to an object.
Workaround x86 precision issues for FP inequality comparisons.
Handle class for adding a decoration to an object.
void createDecoratorKeysAndAccessor(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< WriteKeyAccessorPair< T_Cont, T > > &decor_out)
create a pair composed of a WriteDecorHandleKey to create a decorator handle and an accessor to check...
std::pair< SG::WriteDecorHandleKey< ContainerType >, SG::AuxElement::ConstAccessor< VariableType > > WriteKeyAccessorPair
Useful declarations.
Handle class for reading a decoration on an object.
std::pair< SG::WriteDecorHandle< ContainerType, VariableType >, bool > OptionalDecoration
Base class for elements of a container that can have aux data.