ATLAS Offline Software
Loading...
Searching...
No Matches
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
10
11
12
18#include "GaudiKernel/EventContext.h"
19
20#include <iostream>
21#include <utility>
22#include <vector>
23
24#include <cstdlib>
25
26namespace 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
Base class for elements of a container that can have aux data.
Property holding a SG store/key/clid/attr name from which a ReadDecorHandle is made.
Handle class for reading a decoration on an object.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Handle class for adding a decoration to an object.
Property holding a SG store/key/clid from which a ReadHandle is made.
const std::string & key() const
Return the StoreGate ID for the referenced object.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
The AlignStoreProviderAlg loads the rigid alignment corrections and pipes them through the readout ge...
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)
std::vector< SG::WriteDecorHandle< T_Cont, T > > createDecorators(const std::vector< SG::WriteDecorHandleKey< T_Cont > > &keys, const EventContext &ctx)
MsgStream & msg
Definition testRead.cxx:32