ATLAS Offline Software
Loading...
Searching...
No Matches
DecorUtils.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONTRUTHALGS_DECORUTILS_H
5#define MUONTRUTHALGS_DECORUTILS_H
6
10
11namespace Muon{
12 template <typename ContType, typename DataType>
13 using DecorHandlePtr_wt = std::unique_ptr<SG::WriteDecorHandle<ContType, DataType>>;
14 template <typename ContType, typename DataType>
15 using DecorHandlePtrVec_t = std::vector<DecorHandlePtr_wt<ContType, DataType>>;
16
17
19 template <typename DataType, typename ContType>
21 makeHandle(const EventContext& ctx,
23 const DataType defVal = {}) {
24 if (key.empty()) {
25 return nullptr;
26 }
27 auto decorHandle = std::make_unique<SG::WriteDecorHandle<ContType, DataType>>(key, ctx);
28 for (const auto* obj : (**decorHandle)){
29 (*decorHandle)(*obj) = defVal;
30 }
31 return decorHandle;
32 }
33
34 template <typename DataType, typename ContType>
36 makeHandles(const EventContext& ctx,
38 const DataType defVal = {}) {
40 for (const SG::WriteDecorHandleKey<ContType>& key : keys) {
41 handles.emplace_back(makeHandle(ctx, key, defVal));
42 }
43 return handles;
44 }
45}
46#endif
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
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/attr name from which a WriteDecorHandle is made.
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
DecorHandlePtr_wt< ContType, DataType > makeHandle(const EventContext &ctx, const SG::WriteDecorHandleKey< ContType > &key, const DataType defVal={})
Returns a unique_ptr with an initialized WriteDecorHandle.
Definition DecorUtils.h:21
std::vector< DecorHandlePtr_wt< ContType, DataType > > DecorHandlePtrVec_t
Definition DecorUtils.h:15
std::unique_ptr< SG::WriteDecorHandle< ContType, DataType > > DecorHandlePtr_wt
Definition DecorUtils.h:13
DecorHandlePtrVec_t< ContType, DataType > makeHandles(const EventContext &ctx, const SG::WriteDecorHandleKeyArray< ContType > &keys, const DataType defVal={})
Definition DecorUtils.h:36
DecorHandleKeyArray< WriteDecorHandle< T, S >, WriteDecorHandleKey< T >, Gaudi::DataHandle::Writer > WriteDecorHandleKeyArray