ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
MuonSpectrometer
MuonCnv
MuonByteStreamCnvTest
src
STGC_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 "
STGC_DigitToRDO.h
"
6
7
class
NswCalibDbTimeChargeData
;
8
11
12
STGC_DigitToRDO::STGC_DigitToRDO
(
const
std::string& name, ISvcLocator* pSvcLocator) :
AthReentrantAlgorithm
(name, pSvcLocator) {}
13
14
StatusCode
STGC_DigitToRDO::initialize
() {
15
ATH_MSG_DEBUG
(
" in initialize()"
);
16
ATH_CHECK
(
m_idHelperSvc
.retrieve());
17
ATH_CHECK
(
m_rdoContainer
.initialize());
18
ATH_CHECK
(
m_digitContainer
.initialize());
19
ATH_CHECK
(
m_calibTool
.retrieve());
20
ATH_CHECK
(
m_cablingKey
.initialize(!
m_cablingKey
.empty()));
21
22
return
StatusCode::SUCCESS;
23
}
24
25
StatusCode
STGC_DigitToRDO::execute
(
const
EventContext& ctx)
const
{
26
using namespace
Muon
;
27
ATH_MSG_DEBUG
(
"in execute()"
);
28
SG::ReadHandle<sTgcDigitContainer>
digits(
m_digitContainer
, ctx);
29
ATH_CHECK
(digits.
isPresent
());
30
std::unique_ptr<STGC_RawDataContainer> rdos = std::make_unique<STGC_RawDataContainer>(
m_idHelperSvc
->stgcIdHelper().module_hash_max());
31
32
const
Nsw_CablingMap
* sTgcCablingMap{
nullptr
};
33
if
(!
m_cablingKey
.empty()) {
34
SG::ReadCondHandle<Nsw_CablingMap>
readCondHandle{
m_cablingKey
, ctx};
35
if
(!readCondHandle.
isValid
()){
36
ATH_MSG_ERROR
(
"Cannot find Micromegas cabling map!"
);
37
return
StatusCode::FAILURE;
38
}
39
sTgcCablingMap = readCondHandle.
cptr
();
40
}
41
42
for
(
const
sTgcDigitCollection
* digitColl : *digits) {
43
// Transform the hash id ( digit collection use detector element ID hash, RDO's use
44
// module Id hash
45
Identifier
digitId = digitColl->identify();
46
IdentifierHash
hash =
m_idHelperSvc
->moduleHash(digitId);
47
48
STGC_RawDataCollection
* coll =
new
STGC_RawDataCollection
(hash);
49
if
(rdos->addCollection(coll, hash).isFailure()) {
50
ATH_MSG_WARNING
(
"Failed to add collection with hash "
<< (
int
)hash);
51
delete
coll;
52
continue
;
53
}
54
55
constexpr
double
lowerTimeBound =
Muon::STGC_RawData::s_lowerTimeBound
;
56
constexpr
int
BCWindow =
Muon::STGC_RawData::s_BCWindow
;
57
for
(
const
sTgcDigit
* digit : *digitColl) {
58
// Set proper data time window in simulated sTGC RDOs
59
// BC0 has t = [-12.5, +12.5]
60
// and data will use BC = [-3,+4]
61
// totaling digits within t = [-87.5, 112.5]
62
float
digitTime = digit->time();
63
if
(digitTime < lowerTimeBound || digitTime >= lowerTimeBound + BCWindow * 25)
continue
;
64
Identifier
id
= digit->identify();
65
if
(sTgcCablingMap) {
66
std::optional<Identifier> correctedChannelId = sTgcCablingMap->
correctChannel
(
id
, msgStream());
67
if
(!correctedChannelId) {
68
ATH_MSG_DEBUG
(
"Channel was shifted outside its connector and is therefore not decoded into and RDO"
);
69
continue
;
70
}
71
id
= (*correctedChannelId);
72
}
73
bool
isDead = digit->isDead();
74
int
tdo{0}, pdo{0}, relBCID{0};
75
m_calibTool
->timeToTdo(ctx, digitTime,
id
, tdo, relBCID);
76
m_calibTool
->chargeToPdo(ctx, digit->charge(),
id
, pdo);
77
STGC_RawData
* rdo =
new
STGC_RawData
(
id
,
static_cast<
unsigned
int
>
(relBCID),
static_cast<
float
>
(tdo),
78
static_cast<
unsigned
int
>
(tdo),
static_cast<
unsigned
int
>
(pdo), isDead,
true
);
79
coll->
push_back
(rdo);
80
}
81
}
82
83
SG::WriteHandle<STGC_RawDataContainer>
writeHandle(
m_rdoContainer
, ctx);
84
ATH_CHECK
(writeHandle.
record
(std::move(rdos)));
85
86
ATH_MSG_DEBUG
(
"done execute()"
);
87
return
StatusCode::SUCCESS;
88
}
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
STGC_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
Muon::STGC_RawDataCollection
Definition
STGC_RawDataCollection.h:18
Muon::STGC_RawData
Definition
STGC_RawData.h:15
Muon::STGC_RawData::s_BCWindow
static constexpr int s_BCWindow
Definition
STGC_RawData.h:71
Muon::STGC_RawData::s_lowerTimeBound
static constexpr double s_lowerTimeBound
Definition
STGC_RawData.h:68
NswCalibDbTimeChargeData
Definition
NswCalibDbTimeChargeData.h:25
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.
STGC_DigitToRDO::m_calibTool
ToolHandle< Muon::INSWCalibTool > m_calibTool
Definition
STGC_DigitToRDO.h:33
STGC_DigitToRDO::initialize
virtual StatusCode initialize() override final
Definition
STGC_DigitToRDO.cxx:14
STGC_DigitToRDO::STGC_DigitToRDO
STGC_DigitToRDO(const std::string &name, ISvcLocator *pSvcLocator)
Definition
STGC_DigitToRDO.cxx:12
STGC_DigitToRDO::m_cablingKey
SG::ReadCondHandleKey< Nsw_CablingMap > m_cablingKey
Definition
STGC_DigitToRDO.h:36
STGC_DigitToRDO::m_rdoContainer
SG::WriteHandleKey< Muon::STGC_RawDataContainer > m_rdoContainer
Definition
STGC_DigitToRDO.h:29
STGC_DigitToRDO::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition
STGC_DigitToRDO.h:28
STGC_DigitToRDO::execute
virtual StatusCode execute(const EventContext &ctx) const override final
Definition
STGC_DigitToRDO.cxx:25
STGC_DigitToRDO::m_digitContainer
SG::ReadHandleKey< sTgcDigitContainer > m_digitContainer
Definition
STGC_DigitToRDO.h:31
sTgcDigitCollection
Definition
sTgcDigitCollection.h:18
sTgcDigit
Definition
sTgcDigit.h:20
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