Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
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 
11 namespace 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>
35  DecorHandlePtrVec_t<ContType, DataType>
36  makeHandles(const EventContext& ctx,
38  const DataType defVal = {}) {
39  DecorHandlePtrVec_t<ContType, DataType> handles{};
41  handles.emplace_back(makeHandle(ctx, key, defVal));
42  }
43  return handles;
44  }
45 }
46 #endif
SG::WriteDecorHandleKey
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Definition: StoreGate/StoreGate/WriteDecorHandleKey.h:89
WriteCalibToCool.defVal
defVal
Definition: WriteCalibToCool.py:442
DataType
OFFLINE_FRAGMENTS_NAMESPACE::PointerType DataType
Definition: RoIBResultByteStreamTool.cxx:25
SG::HandleKeyArray
Definition: StoreGate/StoreGate/HandleKeyArray.h:38
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition: TrackSystemController.h:45
WriteDecorHandleKey.h
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Muon::makeHandles
DecorHandlePtrVec_t< ContType, DataType > makeHandles(const EventContext &ctx, const SG::WriteDecorHandleKeyArray< ContType > &keys, const DataType defVal={})
Definition: DecorUtils.h:36
Muon::DecorHandlePtr_wt
std::unique_ptr< SG::WriteDecorHandle< ContType, DataType > > DecorHandlePtr_wt
Definition: DecorUtils.h:13
Muon::makeHandle
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
WriteDecorHandle.h
Handle class for adding a decoration to an object.
WriteDecorHandleKeyArray.h
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:798
python.PyAthena.obj
obj
Definition: PyAthena.py:132
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
Muon::DecorHandlePtrVec_t
std::vector< DecorHandlePtr_wt< ContType, DataType > > DecorHandlePtrVec_t
Definition: DecorUtils.h:15