ATLAS Offline Software
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 
8 #include "MuonRDO/TgcRawData.h"
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 
40 TgcDigit* 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 
92 Identifier 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 
TgcRDO_Decoder.h
Muon::TgcRDO_Decoder::TgcRDO_Decoder
TgcRDO_Decoder(const std::string &type, const std::string &name, const IInterface *parent)
Definition: TgcRDO_Decoder.cxx:13
TgcRawData::bitpos
uint16_t bitpos() const
Definition: TgcRawData.h:293
Muon::TgcRDO_Decoder::finalize
virtual StatusCode finalize()
Definition: TgcRDO_Decoder.cxx:30
TgcRawData.h
TgcRawData::subDetectorId
uint16_t subDetectorId() const
Definition: TgcRawData.h:264
TgcRawData::rodId
uint16_t rodId() const
Definition: TgcRawData.h:268
Muon::TgcRDO_Decoder::getOfflineData
Identifier getOfflineData(const TgcRawData *rawData, bool orFlag, uint16_t &bctag) const
Get offline ID and bcTag from TGC RDO.
Definition: TgcRDO_Decoder.cxx:92
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
Muon::TgcRDO_Decoder::applyPatch
void applyPatch(bool patch)
Set a flag for application of patch.
Definition: TgcRDO_Decoder.cxx:35
TgcDigit.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
TgcRawData::sswId
uint16_t sswId() const
Definition: TgcRawData.h:272
TgcDigit
Definition: TgcDigit.h:21
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
TgcRawData::bcTag
uint16_t bcTag() const
Definition: TgcRawData.h:251
TgcRawData::slbId
uint16_t slbId() const
Definition: TgcRawData.h:276
Muon::TgcRDO_Decoder::initialize
virtual StatusCode initialize()
Definition: TgcRDO_Decoder.cxx:20
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TgcRawData
An unit object of TGC ROD output.
Definition: TgcRawData.h:23
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
Muon::TgcRDO_Decoder::getDigit
TgcDigit * getDigit(const TgcRawData *rawData, bool orFlag) const
Get TGC Digit from TGC RDO.
Definition: TgcRDO_Decoder.cxx:40
TgcDigit::BC_UNDEFINED
@ BC_UNDEFINED
Definition: TgcDigit.h:37
AthAlgTool
Definition: AthAlgTool.h:26
Identifier
Definition: IdentifierFieldParser.cxx:14