ATLAS Offline Software
Loading...
Searching...
No Matches
MuonDigitizationTool.icc
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4#ifndef MUONDIGITIZATION_MUONDIGITIZATIONTOOL_ICC
5#define MUONDIGITIZATION_MUONDIGITIZATIONTOOL_ICC
6
7#include <StoreGate/ReadHandle.h>
8#include <StoreGate/WriteHandle.h>
9#include <StoreGate/ReadCondHandle.h>
10
11namespace MuonR4{
12 template <class DigitColl>
13 DigitColl* MuonDigitizationTool::fetchCollection(const Identifier& hitId,
14 OutDigitCache_t<DigitColl>& digitCache) const {
15 const IdentifierHash hash{m_idHelperSvc->moduleHash(hitId)};
16
17 if (static_cast<unsigned>(hash) >= digitCache.size()) {
18 digitCache.resize(static_cast<unsigned>(hash) + 1);
19 }
20 std::unique_ptr<DigitColl>& coll = digitCache[static_cast<unsigned>(hash)];
21 if (!coll) {
22 coll = std::make_unique<DigitColl>(m_idHelperSvc->chamberId(hitId), hash);
23 }
24 return coll.get();
25 }
26 template <class DigitCont, class DigitColl>
27 StatusCode MuonDigitizationTool:: writeDigitContainer(const EventContext& ctx,
28 const SG::WriteHandleKey<DigitCont>& key,
29 OutDigitCache_t<DigitColl>&& digitCache,
30 unsigned int hashMax) const {
31 SG::WriteHandle<DigitCont> writeHandle{key, ctx};
32 ATH_CHECK(writeHandle.record(std::make_unique<DigitCont>(hashMax)));
33 for (size_t coll_hash = 0; coll_hash < digitCache.size(); ++coll_hash) {
34 if (digitCache[coll_hash] && digitCache[coll_hash]->size()) {
35 ATH_CHECK(writeHandle->addCollection(digitCache[coll_hash].release(), coll_hash));
36 }
37 }
38 return StatusCode::SUCCESS;
39 }
40}
41#endif