|
ATLAS Offline Software
|
Go to the documentation of this file.
5 #ifndef IDPVM_safeDecorator_h
6 #define IDPVM_safeDecorator_h
21 #include "GaudiKernel/EventContext.h"
33 bool roughlyEqual(
const unsigned int i,
const unsigned int j);
41 template<
class ContainerType,
class VariableType>
44 template<
class ContainerType,
class VariableType>
47 template<
class ContainerType,
class VariableType>
51 template <
class T_Parent,
class T_Cont,
class T>
55 const std::vector<std::string> &decor_names,
58 decor_out.reserve(decor_names.size());
59 for (
const std::string &a_decor_name: decor_names) {
62 parent.declare(decor_out.back().first);
63 decor_out.back().first.setOwner(&
parent);
64 decor_out.back().first.initialize().ignore();
68 template <
class T_Cont,
class T>
69 std::vector<OptionalDecoration<T_Cont,T> >
72 const EventContext &ctx,
74 std::vector<OptionalDecoration<T_Cont, T> >
out;
75 bool all_available=
true;
76 if (!container.empty()) {
80 decorate.push_back(!a_key.second.isAvailable(*container[0]) );
83 std::cout <<
"WARNING IDPVM::createDecoratorsIfNeeded: Decoration " << a_key.first.key() <<
84 " already exists; reject update.\n";
93 if (not
out.back().first.isPresent()) {
94 std::stringstream
msg;
95 msg <<
"Container " << a_key.first.key() <<
" to be decorated does not exist.";
96 throw std::runtime_error(
msg.str() );
105 template <
class T_Cont,
class T>
106 std::vector<SG::WriteDecorHandle<T_Cont,T> >
108 const EventContext &ctx) {
109 std::vector<SG::WriteDecorHandle<T_Cont,T> >
out;
112 out.emplace_back(a_key,ctx);
113 if (not
out.back().isValid()) {
114 std::stringstream
msg;
115 msg <<
"Failed to create decorator handdle " << a_key.key();
116 throw std::runtime_error(
msg.str() );
124 template<
class T_Parent,
class T_Cont>
127 const std::string &
prefix,
128 const std::vector<std::string> &decor_names,
131 decor_out.reserve(decor_names.size());
132 for (
const std::string &a_decor_name : decor_names) {
133 assert( !a_decor_name.empty() );
134 decor_out.emplace_back(container_key.
key()+
"."+
prefix+a_decor_name);
137 parent.declare(decor_out.back());
138 decor_out.back().setOwner(&
parent);
139 decor_out.back().initialize().ignore();
144 template<
class T_Parent,
class T_Cont>
147 const std::string &
prefix,
148 const std::vector<std::string> &decor_names,
150 decor_out.reserve(decor_out.size() + decor_names.size());
151 for (
const std::string &a_decor_name : decor_names) {
152 decor_out.emplace_back( container_key.
key()+
"."+
prefix+a_decor_name);
153 parent.declare(decor_out.back());
154 decor_out.back().setOwner(&
parent);
155 decor_out.back().initialize().ignore();
160 template <
class T_Cont,
class T_Cont_Elm,
class T>
163 if (!decorator.second.isAvailable(
particle)) {
164 const T existing = decorator.second(
particle);
166 std::cout <<
"WARNING IDPVM::safeDecorator: " << decorator.first.decorKey() <<
167 " Already exists on this object with a different value.\n";
174 template <
class T_Cont,
class T_Cont_Elm,
class T>
177 if (decorator.second) {
183 template <
class T_Cont,
class T_Cont_Elm,
class T>
Class to retrieve associated truth from a track, implementing a cached response.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
void decorate(const T_Cont_Elm &particle, OptionalDecoration< T_Cont, T > &decorator, const T &value)
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
DuplicateBehaviour
Behaviour in case of trying to add a decoration which previously exists.
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)
std::pair< SG::WriteDecorHandle< ContainerType, VariableType >, SG::AuxElement::ConstAccessor< VariableType > & > WriteAccessorRefPair
Helper class to provide constant type-safe access to aux data.
const std::string & key() const
Return the StoreGate ID for the referenced object.
void addReadDecoratorHandleKeys(T_Parent &parent, const SG::ReadHandleKey< T_Cont > &container_key, const std::string &prefix, const std::vector< std::string > &decor_names, std::vector< SG::ReadDecorHandleKey< T_Cont > > &decor_out)
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
std::pair< SG::WriteDecorHandle< ContainerType, VariableType >, bool > OptionalDecoration
void decorateOrRejectQuietly(const T_Cont_Elm &particle, OptionalDecoration< T_Cont, T > &decorator, const T &value)
Handle class for adding a decoration to an object.
Handle class for adding a decoration to an object.
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)
void decorateOrWarnIfUnequal(const T_Cont_Elm &particle, WriteAccessorRefPair< T_Cont, T > &decorator, const T &value)
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)
bool roughlyEqual(const int i, const int j)
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
Handle class for reading a decoration on an object.
Base class for elements of a container that can have aux data.
std::pair< SG::WriteDecorHandleKey< ContainerType >, SG::AuxElement::ConstAccessor< VariableType > > WriteKeyAccessorPair