ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCnv
MuonByteStreamCnvTest
src
MM_DigitToRDO.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MM_DigitToRDO.h
"
6
9
10
MM_DigitToRDO::MM_DigitToRDO
(
const
std::string& name, ISvcLocator* pSvcLocator) :
AthReentrantAlgorithm
(name, pSvcLocator) {}
11
12
StatusCode
MM_DigitToRDO::initialize
() {
13
ATH_MSG_DEBUG
(
" in initialize()"
);
14
ATH_CHECK
(
m_idHelperSvc
.retrieve());
15
ATH_CHECK
(
m_rdoContainer
.initialize());
16
ATH_CHECK
(
m_digitContainer
.initialize());
17
ATH_CHECK
(
m_calibTool
.retrieve());
18
ATH_CHECK
(
m_cablingKey
.initialize(!
m_cablingKey
.empty()));
19
return
StatusCode::SUCCESS;
20
}
21
22
StatusCode
MM_DigitToRDO::execute
(
const
EventContext& ctx)
const
{
23
using namespace
Muon
;
24
ATH_MSG_DEBUG
(
"in execute()"
);
25
SG::ReadHandle<MmDigitContainer>
digits(
m_digitContainer
, ctx);
26
ATH_CHECK
(digits.
isPresent
());
27
std::unique_ptr<MM_RawDataContainer> rdos = std::make_unique<MM_RawDataContainer>(
m_idHelperSvc
->mmIdHelper().module_hash_max());
28
29
const
Nsw_CablingMap
* mmCablingMap{
nullptr
};
30
if
(!
m_cablingKey
.empty()) {
31
SG::ReadCondHandle<Nsw_CablingMap>
readCondHandle{
m_cablingKey
, ctx};
32
if
(!readCondHandle.
isValid
()){
33
ATH_MSG_ERROR
(
"Cannot find Micromegas cabling map!"
);
34
return
StatusCode::FAILURE;
35
}
36
mmCablingMap = readCondHandle.
cptr
();
37
}
38
39
for
(
const
MmDigitCollection
* digitColl : *digits) {
40
// the identifier of the digit collection is the detector element Id ( multilayer granularity )
41
Identifier
digitId = digitColl->identify();
42
43
// get the hash of the RDO collection
44
IdentifierHash
hash;
45
int
getRdoCollHash =
m_idHelperSvc
->mmIdHelper().get_module_hash(digitId, hash);
46
if
(getRdoCollHash != 0) {
47
ATH_MSG_ERROR
(
"Could not get the module hash Id"
);
48
return
StatusCode::FAILURE;
49
}
50
51
MM_RawDataCollection
* coll =
new
MM_RawDataCollection
(hash);
52
if
(rdos->addCollection(coll, hash).isFailure()) {
53
ATH_MSG_WARNING
(
"Failed to add collection with hash "
<< (
int
)hash);
54
delete
coll;
55
continue
;
56
}
57
58
for
(
const
MmDigit
* digit : *digitColl) {
59
Identifier
newId = digit->identify();
60
// RDO has time and charge in counts
61
int
tdo{0}, relBcid{0}, pdo{0};
62
m_calibTool
->timeToTdo(ctx, digit->stripResponseTime(), newId, tdo, relBcid);
63
m_calibTool
->chargeToPdo(ctx, digit->stripResponseCharge(), newId, pdo);
64
65
// the cabling map is introduced here for studies of the MM strip misalignment. It does not run in standart jobs (read key is empty)
66
if
(mmCablingMap) {
67
std::optional<Identifier> correctedChannelId = mmCablingMap->
correctChannel
(newId, msgStream());
68
if
(!correctedChannelId) {
69
ATH_MSG_DEBUG
(
"Channel was shifted outside its connector and is therefore not decoded into and RDO"
);
70
continue
;
71
}
72
newId = (*correctedChannelId);
73
}
74
// Fill object
75
std::unique_ptr<MM_RawData> rdo = std::make_unique<MM_RawData>(newId,
m_idHelperSvc
->mmIdHelper().channel(newId),
76
tdo, pdo, relBcid,
true
);
77
coll->
push_back
(std::move(rdo));
78
}
79
}
80
81
SG::WriteHandle<MM_RawDataContainer>
writeHanlde(
m_rdoContainer
, ctx);
82
ATH_CHECK
(writeHanlde.
record
(std::move(rdos)));
83
84
ATH_MSG_DEBUG
(
"done execute()"
);
85
return
StatusCode::SUCCESS;
86
}
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_DigitToRDO.h
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition
AthReentrantAlgorithm.h:74
DataVector::push_back
value_type push_back(value_type pElem)
Add an element to the end of the collection.
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
MM_DigitToRDO::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition
MM_DigitToRDO.h:27
MM_DigitToRDO::m_cablingKey
SG::ReadCondHandleKey< Nsw_CablingMap > m_cablingKey
Definition
MM_DigitToRDO.h:33
MM_DigitToRDO::initialize
virtual StatusCode initialize() override final
Definition
MM_DigitToRDO.cxx:12
MM_DigitToRDO::m_calibTool
ToolHandle< Muon::INSWCalibTool > m_calibTool
Definition
MM_DigitToRDO.h:31
MM_DigitToRDO::m_rdoContainer
SG::WriteHandleKey< Muon::MM_RawDataContainer > m_rdoContainer
Definition
MM_DigitToRDO.h:28
MM_DigitToRDO::MM_DigitToRDO
MM_DigitToRDO(const std::string &name, ISvcLocator *pSvcLocator)
Definition
MM_DigitToRDO.cxx:10
MM_DigitToRDO::m_digitContainer
SG::ReadHandleKey< MmDigitContainer > m_digitContainer
Definition
MM_DigitToRDO.h:30
MM_DigitToRDO::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
MM_DigitToRDO.cxx:22
MmDigitCollection
Definition
MmDigitCollection.h:18
MmDigit
Definition
MmDigit.h:20
Muon::MM_RawDataCollection
Definition
MM_RawDataCollection.h:15
Nsw_CablingMap
Definition
Nsw_CablingMap.h:18
Nsw_CablingMap::correctChannel
std::optional< Identifier > correctChannel(const Identifier &id, MsgStream &msg) const
Definition
Nsw_CablingMap.cxx:19
SG::ReadCondHandle
Definition
ReadCondHandle.h:40
SG::ReadCondHandle::isValid
bool isValid()
Definition
ReadCondHandle.h:205
SG::ReadCondHandle::cptr
const_pointer_type cptr()
Definition
ReadCondHandle.h:67
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
Muon
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
Definition
TrackSystemController.h:46
Generated on
for ATLAS Offline Software by
1.17.0