|
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 >
113 std::vector< OptionalDecoration< T_Cont,T > >
115 const T_Cont& container,
117 const EventContext& ctx,
120 std::vector< OptionalDecoration< T_Cont, T > >
out;
121 bool all_available =
true;
122 if( !container.empty() ) {
126 decorate.push_back( !a_key.second.isAvailable( *container[0] ) );
129 std::cout <<
"WARNING IDTPM::createDecoratorsIfNeeded: Decoration "
130 << a_key.first.key() <<
" already exists; reject update."
135 if( !all_available ) {
144 if( not
out.back().first.isPresent() ) {
145 std::stringstream
msg;
146 msg <<
"Container " << a_key.first.key()
147 <<
" to be decorated does not exist.";
148 throw std::runtime_error(
msg.str() );
157 template<
class T_Cont,
class T >
158 std::vector< SG::WriteDecorHandle< T_Cont, T > >
161 const EventContext& ctx )
163 std::vector< SG::WriteDecorHandle< T_Cont, T > >
out;
166 out.emplace_back( a_key, ctx );
167 if( not
out.back().isValid() ) {
168 std::stringstream
msg;
169 msg <<
"Failed to create decorator handle " << a_key.key();
170 throw std::runtime_error(
msg.str() );
177 template<
class T_Cont,
class T_Cont_Elm,
class T >
183 if( !decorator.second.isAvailable(
particle ) ) {
184 const T existing = decorator.second(
particle );
186 std::cout <<
"WARNING IDTPM::safeDecorator: " << decorator.first.decorKey()
187 <<
" Already exists on this object with a different value."
196 template<
class T_Cont,
class T_Cont_Elm,
class T >
202 if( decorator.second ) {
208 template<
class T_Cont,
class T_Cont_Elm,
class T >
219 #endif // > !INDETTRACKPERFMON_SAFEDECORATOR_H
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
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)
Like above - FIXME: maybe not needed.
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
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.