ATLAS Offline Software
decoratorUtils.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef ACTSTRACK_SAFEDECORATOR_H
6 #define ACTSTRACK_SAFEDECORATOR_H
7 
18 #include "GaudiKernel/EventContext.h"
19 
20 #include <iostream>
21 #include <utility>
22 #include <vector>
23 
24 #include <cstdlib>
25 
26 namespace ActsTrk {
27 
28  // convenience method to create several decorator handles from keys
29  template <class T_Cont, class T>
30  std::vector<SG::WriteDecorHandle<T_Cont,T> >
32  const EventContext &ctx) {
33  std::vector<SG::WriteDecorHandle<T_Cont,T> > out;
34  out.reserve(keys.size());
35  for( const SG::WriteDecorHandleKey<T_Cont> &a_key : keys) {
36  out.emplace_back(a_key,ctx);
37  if (not out.back().isValid()) {
38  std::stringstream msg;
39  msg << "Failed to create decorator handdle " << a_key.key();
40  throw std::runtime_error( msg.str() );
41  }
42  }
43  return out;
44  }
45 
46 
47  // convenience method to create several decorator handle keys.
48  template<class T_Parent, class T_Cont>
49  void createDecoratorKeys(T_Parent &parent,
50  const SG::ReadHandleKey<T_Cont> &container_key,
51  const std::string &prefix,
52  const std::vector<std::string> &decor_names,
53  std::vector<SG::WriteDecorHandleKey<T_Cont> > &decor_out) {
54  decor_out.clear();
55  decor_out.reserve(decor_names.size());
56  for (const std::string &a_decor_name : decor_names) {
57  assert( !a_decor_name.empty() );
58  decor_out.emplace_back(container_key.key()+"."+prefix+a_decor_name);
59  // need to declare handles, otherwise the scheduler would not pick up the data dependencies
60  // introduced by the decorations
61  parent.declare(decor_out.back());
62  decor_out.back().setOwner(&parent);
63  decor_out.back().initialize().ignore();
64  }
65  }
66 }
67 #endif
SG::WriteDecorHandleKey
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Definition: StoreGate/StoreGate/WriteDecorHandleKey.h:89
ReadDecorHandleKey.h
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
python.AthDsoLogger.out
out
Definition: AthDsoLogger.py:71
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
SG::ReadHandleKey< T_Cont >
ActsTrk::createDecorators
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
Definition: decoratorUtils.h:31
WriteDecorHandleKey.h
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
WriteDecorHandle.h
Handle class for adding a decoration to an object.
checkCorrelInHIST.prefix
dictionary prefix
Definition: checkCorrelInHIST.py:391
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ActsTrk::createDecoratorKeys
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)
Definition: decoratorUtils.h:49
ReadDecorHandle.h
Handle class for reading a decoration on an object.
ActsTrk
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
Definition: MuonDetectorBuilderTool.cxx:49
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7
AuxElement.h
Base class for elements of a container that can have aux data.