ATLAS Offline Software
Loading...
Searching...
No Matches
TgcRDO_Decoder.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "TgcRDO_Decoder.h"
6
7#include "Identifier/Identifier.h"
10
11namespace Muon {
12// constructor
14 ATH_MSG_DEBUG("TgcRDO_Decoder::initialize");
15
16 // try to configure the cabling service
17 ATH_CHECK(m_cablingKey.initialize());
18
19 return StatusCode::SUCCESS;
20}
21
23 m_applyPatch = patch;
24}
25
26std::unique_ptr<TgcDigit> TgcRDO_Decoder::getDigit(const EventContext& ctx,
27 const TgcRawData& rawData,
28 bool orFlag) const {
29 // MuonTGC_CablingSvc should be configured at initialise
30 const TgcCablingMap* cabling{nullptr};
31 if (!SG::get(cabling, m_cablingKey, ctx).isSuccess()) {
33 "Cabling is not available in "
34 "TgcRDO_Decoder::getDigit()");
35 return nullptr;
36 }
37
38 int offset = 0, offsetORed = 0;
39
40 const uint16_t sswId = rawData.sswId();
41 const uint16_t slbId = rawData.slbId();
42 const uint16_t bitpos = rawData.bitpos();
43
44 if (m_applyPatch) {
45 if (sswId == 9) {
46 if ((slbId % 4 == 3 && bitpos >= 77 && bitpos <= 84) ||
47 (slbId % 4 != 3 && bitpos >= 77 && bitpos <= 111)) {
48 offset = 1;
49 }
50 } else if (sswId >= 3 && sswId <= 8) {
51 if ((slbId == 1 && bitpos >= 66 && bitpos <= 73) ||
52 (slbId == 2 && bitpos >= 42 && bitpos <= 63)) {
53 offset = 36;
54 }
55 if ((slbId == 1 && bitpos >= 102 && bitpos <= 109) ||
56 (slbId == 2 && bitpos >= 78 && bitpos <= 99)) {
57 offset = -36;
58 }
59 if ((slbId == 1 && bitpos >= 74 && bitpos <= 75) ||
60 (slbId == 2 && bitpos >= 40 && bitpos <= 41)) {
61 offsetORed = 36;
62 }
63 if ((slbId == 1 && bitpos >= 110 && bitpos <= 111) ||
64 (slbId == 2 && bitpos >= 76 && bitpos <= 77)) {
65 offsetORed = -36;
66 }
67 }
68 }
69 int corr = orFlag ? offsetORed : offset;
70
71 // get official channel ID
72 Identifier chanId;
73 bool c_found = cabling->getOfflineIDfromReadoutID(
74 chanId, rawData.subDetectorId(), rawData.rodId(), sswId, slbId,
75 bitpos + corr, orFlag);
76
77 if (!c_found) {
78 return nullptr;
79 }
80
81 return std::make_unique<TgcDigit>(chanId, rawData.bcTag());
82}
83
85 const TgcRawData& rawData,
86 bool orFlag, uint16_t& bctag) const {
87 Identifier chanId{};
88
89 // ITGCcablingSvc should be configured at initialise
90 const TgcCablingMap* cabling{nullptr};
91 if (!SG::get(cabling, m_cablingKey, ctx).isSuccess()) {
93 "Cabling is not available in "
94 "TgcRDO_Decoder::getOfflineData()");
95 return chanId;
96 }
97
99
100 const uint16_t sswId = rawData.sswId();
101 const uint16_t slbId = rawData.slbId();
102 const uint16_t bitpos = rawData.bitpos();
103
104 int offset = 0, offsetORed = 0;
105 if (m_applyPatch) {
106 if (sswId == 9) {
107 if ((slbId % 4 == 3 && bitpos >= 77 && bitpos <= 84) ||
108 (slbId % 4 != 3 && bitpos >= 77 && bitpos <= 111)) {
109 offset = 1;
110 }
111 } else if (sswId >= 3 && sswId <= 8) {
112 if ((slbId == 1 && bitpos >= 66 && bitpos <= 73) ||
113 (slbId == 2 && bitpos >= 42 && bitpos <= 63)) {
114 offset = 36;
115 }
116 if ((slbId == 1 && bitpos >= 102 && bitpos <= 109) ||
117 (slbId == 2 && bitpos >= 78 && bitpos <= 99)) {
118 offset = -36;
119 }
120 if ((slbId == 1 && bitpos >= 74 && bitpos <= 75) ||
121 (slbId == 2 && bitpos >= 40 && bitpos <= 41)) {
122 offsetORed = 36;
123 }
124 if ((slbId == 1 && bitpos >= 110 && bitpos <= 111) ||
125 (slbId == 2 && bitpos >= 76 && bitpos <= 77)) {
126 offsetORed = -36;
127 }
128 }
129 }
130 int corr = orFlag ? offsetORed : offset;
131
132 // get official channel ID
133 bool c_found = cabling->getOfflineIDfromReadoutID(
134 chanId, rawData.subDetectorId(), rawData.rodId(), sswId, slbId,
135 bitpos + corr, orFlag);
136
137 if (!c_found) {
138 return chanId;
139 }
140
141 bctag = rawData.bcTag();
142 return chanId;
143}
144} // namespace Muon
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
virtual Identifier getOfflineData(const EventContext &ctx, const TgcRawData &rawData, bool orFlag, uint16_t &bctag) const override
Get offline ID and bcTag from TGC RDO.
SG::ReadCondHandleKey< Muon::TgcCablingMap > m_cablingKey
virtual void applyPatch(bool patch) override
Set a flag for application of patch.
virtual StatusCode initialize() override
virtual std::unique_ptr< TgcDigit > getDigit(const EventContext &ctx, const TgcRawData &rawData, bool orFlag) const override
Get TGC Digit from TGC RDO.
@ BC_UNDEFINED
Definition TgcDigit.h:37
An unit object of TGC ROD output.
Definition TgcRawData.h:23
uint16_t sswId() const
Definition TgcRawData.h:272
uint16_t bitpos() const
Definition TgcRawData.h:293
uint16_t bcTag() const
Definition TgcRawData.h:251
uint16_t subDetectorId() const
Definition TgcRawData.h:264
uint16_t slbId() const
Definition TgcRawData.h:276
uint16_t rodId() const
Definition TgcRawData.h:268
NRpcCablingAlg reads raw condition data and writes derived condition data to the condition store.
const T * get(const ReadCondHandleKey< T > &key, const EventContext &ctx)
Convenience function to retrieve an object given a ReadCondHandleKey.