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
9#include "Identifier/Identifier.h"
10
11// constructor
13(const std::string& type, const std::string& name, const IInterface* parent)
14 : AthAlgTool(type, name, parent),
15 m_applyPatch(false)
16{
17 declareInterface<ITGC_RDO_Decoder>(this);
18}
19
21{
22 ATH_MSG_DEBUG("TgcRDO_Decoder::initialize");
23
24 //try to configure the cabling service
25 ATH_CHECK(m_cabling.retrieve());
26
27 return StatusCode::SUCCESS;
28}
29
31{
32 return StatusCode::SUCCESS;
33}
34
36{
37 m_applyPatch = patch;
38}
39
40TgcDigit* Muon::TgcRDO_Decoder::getDigit(const TgcRawData * rawData, bool orFlag) const
41{
42 // MuonTGC_CablingSvc should be configured at initialise
43 if(!m_cabling){
44 ATH_MSG_ERROR("MuonTGC_CablingSvc is not available in TgcRDO_Decoder::getDigit()");
45 return nullptr;
46 }
47
48 int offset=0, offsetORed=0;
49
50 const uint16_t sswId = rawData->sswId();
51 const uint16_t slbId = rawData->slbId();
52 const uint16_t bitpos = rawData->bitpos();
53
54 if(m_applyPatch) {
55 if(sswId==9) {
56 if((slbId%4==3 && bitpos>=77 && bitpos<=84) ||
57 (slbId%4!=3 && bitpos>=77 && bitpos<=111)) {
58 offset=1;
59 }
60 } else if(sswId>=3 && sswId<=8) {
61 if((slbId==1 && bitpos>=66 && bitpos<=73) ||
62 (slbId==2 && bitpos>=42 && bitpos<=63)) {
63 offset=36;
64 }
65 if((slbId==1 && bitpos>=102 && bitpos<=109) ||
66 (slbId==2 && bitpos>= 78 && bitpos<= 99)) {
67 offset=-36;
68 }
69 if((slbId==1 && bitpos>=74 && bitpos<=75) ||
70 (slbId==2 && bitpos>=40 && bitpos<=41)) {
71 offsetORed=36;
72 }
73 if((slbId==1 && bitpos>=110 && bitpos<=111) ||
74 (slbId==2 && bitpos>= 76 && bitpos<= 77)) {
75 offsetORed=-36;
76 }
77 }
78 }
79 int corr = orFlag ? offsetORed : offset;
80
81 // get official channel ID
82 Identifier chanId;
83 bool c_found = m_cabling->getOfflineIDfromReadoutID
84 (chanId, rawData->subDetectorId(), rawData->rodId(),
85 sswId, slbId, bitpos+corr, orFlag);
86
87 if(!c_found) return nullptr;
88
89 return new TgcDigit(chanId,rawData->bcTag());
90}
91
92Identifier Muon::TgcRDO_Decoder::getOfflineData(const TgcRawData * rawData, bool orFlag, uint16_t& bctag) const
93{
94 Identifier chanId(0);
95
96 // ITGCcablingSvc should be configured at initialise
97 if(!m_cabling){
98 ATH_MSG_ERROR("ITGCcablingSvc is not available in TgcRDO_Decoder::getOfflineData()");
99 return chanId;
100 }
101
102
104
105 const uint16_t sswId = rawData->sswId();
106 const uint16_t slbId = rawData->slbId();
107 const uint16_t bitpos = rawData->bitpos();
108
109 int offset=0, offsetORed=0;
110 if(m_applyPatch) {
111 if(sswId==9) {
112 if((slbId%4==3 && bitpos>=77 && bitpos<= 84) ||
113 (slbId%4!=3 && bitpos>=77 && bitpos<=111)) {
114 offset=1;
115 }
116 } else if(sswId>=3 && sswId<=8) {
117 if((slbId==1 && bitpos>=66 && bitpos<=73) ||
118 (slbId==2 && bitpos>=42 && bitpos<=63)) {
119 offset=36;
120 }
121 if((slbId==1 && bitpos>=102 && bitpos<=109) ||
122 (slbId==2 && bitpos>= 78 && bitpos<= 99)) {
123 offset=-36;
124 }
125 if((slbId==1 && bitpos>=74 && bitpos<=75) ||
126 (slbId==2 && bitpos>=40 && bitpos<=41)) {
127 offsetORed=36;
128 }
129 if((slbId==1 && bitpos>=110 && bitpos<=111) ||
130 (slbId==2 && bitpos>= 76 && bitpos<= 77)) {
131 offsetORed=-36;
132 }
133 }
134 }
135 int corr = orFlag ? offsetORed : offset;
136
137 // get official channel ID
138 bool c_found = m_cabling->getOfflineIDfromReadoutID
139 (chanId, rawData->subDetectorId(), rawData->rodId(),
140 sswId, slbId, bitpos+corr, orFlag);
141
142 if(!c_found) return chanId;
143
144 bctag = rawData->bcTag();
145 return chanId;
146}
147
148
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_DEBUG(x)
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
virtual StatusCode finalize()
ServiceHandle< MuonTGC_CablingSvc > m_cabling
Identifier getOfflineData(const TgcRawData *rawData, bool orFlag, uint16_t &bctag) const
Get offline ID and bcTag from TGC RDO.
TgcRDO_Decoder(const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize()
TgcDigit * getDigit(const TgcRawData *rawData, bool orFlag) const
Get TGC Digit from TGC RDO.
void applyPatch(bool patch)
Set a flag for application of patch.
@ 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