ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCnv
MuonByteStreamCnvTest
src
MM_RdoToDigit.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MM_RdoToDigit.h
"
6
7
8
StatusCode
MM_RdoToDigit::initialize
() {
9
ATH_CHECK
(
m_idHelperSvc
.retrieve());
10
ATH_CHECK
(
m_mmRdoDecoderTool
.retrieve());
11
ATH_CHECK
(
m_mmRdoKey
.initialize());
12
ATH_CHECK
(
m_mmDigitKey
.initialize());
13
return
StatusCode::SUCCESS;
14
}
15
16
StatusCode
MM_RdoToDigit::execute
(
const
EventContext& ctx)
const
{
17
ATH_MSG_DEBUG
(
"in execute()"
);
18
SG::ReadHandle<Muon::MM_RawDataContainer>
rdoContainer(
m_mmRdoKey
, ctx);
19
if
(!rdoContainer.
isPresent
()) {
20
ATH_MSG_ERROR
(
"No MM RDO container found!"
);
21
return
StatusCode::FAILURE;
22
}
23
SG::WriteHandle<MmDigitContainer>
wh_mmDigit(
m_mmDigitKey
, ctx);
24
ATH_CHECK
(wh_mmDigit.
record
(std::make_unique<MmDigitContainer>(
m_idHelperSvc
->mmIdHelper().module_hash_max())));
25
ATH_MSG_DEBUG
(
"Decoding MM RDO into MM Digit"
);
26
DigitCollection
digitMap{};
27
for
(
const
Muon::MM_RawDataCollection
* coll : *rdoContainer) {
28
ATH_CHECK
(
decodeMM
(ctx, *coll, digitMap));
29
}
30
31
for
(
auto
& [hash, collection]: digitMap) {
32
ATH_CHECK
(wh_mmDigit->addCollection(collection.release(), hash));
33
}
34
35
return
StatusCode::SUCCESS;
36
}
37
38
StatusCode
MM_RdoToDigit::decodeMM
(
const
EventContext& ctx,
39
const
Muon::MM_RawDataCollection
& rdoColl,
40
DigitCollection
& digitContainer)
const
{
41
if
(rdoColl.
empty
()) {
42
return
StatusCode::SUCCESS;
43
}
44
45
ATH_MSG_DEBUG
(
" Number of RawData in this rdo "
<< rdoColl.
size
());
46
47
// for each RDO, loop over RawData, converter RawData to digit
48
// retrieve/create digit collection, and insert digit into collection
49
for
(
const
Muon::MM_RawData
* data : rdoColl) {
50
std::unique_ptr<MmDigit> newDigit{
m_mmRdoDecoderTool
->getDigit(ctx, data)};
51
if
(!newDigit) {
52
ATH_MSG_WARNING
(
"Error in MM RDO decoder"
);
53
continue
;
54
}
55
56
// find here the Proper Digit Collection identifier, using the rdo-hit id
57
// (since RDO collections are not in a 1-to-1 relation with digit collections)
58
const
Identifier
elementId =
m_idHelperSvc
->mmIdHelper().elementID(newDigit->identify());
59
IdentifierHash
coll_hash =
m_idHelperSvc
->moduleHash(elementId);
60
std::unique_ptr<MmDigitCollection>& outCollection = digitContainer[coll_hash];
61
if
(!outCollection) {
62
outCollection = std::make_unique<MmDigitCollection>(elementId, coll_hash);
63
}
64
outCollection->push_back(std::move(newDigit));
65
}
66
67
return
StatusCode::SUCCESS;
68
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition
AthMsgStreamMacros.h:29
MM_RdoToDigit.h
DataVector::size
size_type size() const noexcept
Returns the number of elements in the collection.
DataVector::empty
bool empty() const noexcept
Returns true if the collection is empty.
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
MM_RdoToDigit::initialize
virtual StatusCode initialize() override final
Definition
MM_RdoToDigit.cxx:8
MM_RdoToDigit::m_mmDigitKey
SG::WriteHandleKey< MmDigitContainer > m_mmDigitKey
Definition
MM_RdoToDigit.h:33
MM_RdoToDigit::m_mmRdoDecoderTool
ToolHandle< Muon::IMM_RDO_Decoder > m_mmRdoDecoderTool
Definition
MM_RdoToDigit.h:30
MM_RdoToDigit::m_mmRdoKey
SG::ReadHandleKey< Muon::MM_RawDataContainer > m_mmRdoKey
Definition
MM_RdoToDigit.h:32
MM_RdoToDigit::decodeMM
StatusCode decodeMM(const EventContext &ctx, const Muon::MM_RawDataCollection &rdoCollection, DigitCollection &digitContainer) const
Definition
MM_RdoToDigit.cxx:38
MM_RdoToDigit::DigitCollection
std::unordered_map< IdentifierHash, std::unique_ptr< MmDigitCollection > > DigitCollection
Definition
MM_RdoToDigit.h:24
MM_RdoToDigit::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition
MM_RdoToDigit.h:31
MM_RdoToDigit::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
MM_RdoToDigit.cxx:16
Muon::MM_RawDataCollection
Definition
MM_RawDataCollection.h:15
Muon::MM_RawData
Temporary class to hold the MM RDO.
Definition
MM_RawData.h:20
SG::ReadHandle
Definition
StoreGate/StoreGate/ReadHandle.h:67
SG::VarHandleBase::isPresent
bool isPresent() const
Is the referenced object present in SG?
Definition
StoreGate/src/VarHandleBase.cxx:400
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Identifier
Definition
IdentifierFieldParser.cxx:14
Generated on
for ATLAS Offline Software by
1.17.0