ATLAS Offline Software
TgcRDO_Decoder.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 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"
12 
13 // constructor
15 (const std::string& type, const std::string& name, const IInterface* parent)
16  : AthAlgTool(type, name, parent),
17  m_cabling(nullptr),
18  m_applyPatch(false)
19 {
20  declareInterface<ITGC_RDO_Decoder>(this);
21 }
22 
24 {
25  ATH_MSG_DEBUG("TgcRDO_Decoder::initialize");
26 
27  //try to configure the cabling service
28  StatusCode sc = getCabling();
29  if(sc.isFailure()) {
30  ATH_MSG_INFO( "TGCCablingServer not yet configured; postone TGCcabling initialization at first event. " );
31  }
32 
33  return StatusCode::SUCCESS;
34 }
35 
37 {
38  return StatusCode::SUCCESS;
39 }
40 
42 {
43  m_applyPatch = patch;
44 }
45 
46 TgcDigit* Muon::TgcRDO_Decoder::getDigit(const TgcRawData * rawData, bool orFlag) const
47 {
48  // ITGCcablingSvc should be configured at initialise
49  if(!m_cabling){
50  ATH_MSG_ERROR("ITGCcablingSvc is not available in TgcRDO_Decoder::getDigit()");
51  return nullptr;
52  }
53 
54  int offset=0, offsetORed=0;
55 
56  const uint16_t sswId = rawData->sswId();
57  const uint16_t slbId = rawData->slbId();
58  const uint16_t bitpos = rawData->bitpos();
59 
60  if(m_applyPatch) {
61  if(sswId==9) {
62  if((slbId%4==3 && bitpos>=77 && bitpos<=84) ||
63  (slbId%4!=3 && bitpos>=77 && bitpos<=111)) {
64  offset=1;
65  }
66  } else if(sswId>=3 && sswId<=8) {
67  if((slbId==1 && bitpos>=66 && bitpos<=73) ||
68  (slbId==2 && bitpos>=42 && bitpos<=63)) {
69  offset=36;
70  }
71  if((slbId==1 && bitpos>=102 && bitpos<=109) ||
72  (slbId==2 && bitpos>= 78 && bitpos<= 99)) {
73  offset=-36;
74  }
75  if((slbId==1 && bitpos>=74 && bitpos<=75) ||
76  (slbId==2 && bitpos>=40 && bitpos<=41)) {
77  offsetORed=36;
78  }
79  if((slbId==1 && bitpos>=110 && bitpos<=111) ||
80  (slbId==2 && bitpos>= 76 && bitpos<= 77)) {
81  offsetORed=-36;
82  }
83  }
84  }
85  int corr = orFlag ? offsetORed : offset;
86 
87  // get official channel ID
88  Identifier chanId;
89  bool c_found = m_cabling->getOfflineIDfromReadoutID
90  (chanId, rawData->subDetectorId(), rawData->rodId(),
91  sswId, slbId, bitpos+corr, orFlag);
92 
93  if(!c_found) return nullptr;
94 
95  return new TgcDigit(chanId,rawData->bcTag());
96 }
97 
98 Identifier Muon::TgcRDO_Decoder::getOfflineData(const TgcRawData * rawData, bool orFlag, uint16_t& bctag) const
99 {
100  Identifier chanId(0);
101 
102  // ITGCcablingSvc should be configured at initialise
103  if(!m_cabling){
104  ATH_MSG_ERROR("ITGCcablingSvc is not available in TgcRDO_Decoder::getOfflineData()");
105  return chanId;
106  }
107 
108 
110 
111  const uint16_t sswId = rawData->sswId();
112  const uint16_t slbId = rawData->slbId();
113  const uint16_t bitpos = rawData->bitpos();
114 
115  int offset=0, offsetORed=0;
116  if(m_applyPatch) {
117  if(sswId==9) {
118  if((slbId%4==3 && bitpos>=77 && bitpos<= 84) ||
119  (slbId%4!=3 && bitpos>=77 && bitpos<=111)) {
120  offset=1;
121  }
122  } else if(sswId>=3 && sswId<=8) {
123  if((slbId==1 && bitpos>=66 && bitpos<=73) ||
124  (slbId==2 && bitpos>=42 && bitpos<=63)) {
125  offset=36;
126  }
127  if((slbId==1 && bitpos>=102 && bitpos<=109) ||
128  (slbId==2 && bitpos>= 78 && bitpos<= 99)) {
129  offset=-36;
130  }
131  if((slbId==1 && bitpos>=74 && bitpos<=75) ||
132  (slbId==2 && bitpos>=40 && bitpos<=41)) {
133  offsetORed=36;
134  }
135  if((slbId==1 && bitpos>=110 && bitpos<=111) ||
136  (slbId==2 && bitpos>= 76 && bitpos<= 77)) {
137  offsetORed=-36;
138  }
139  }
140  }
141  int corr = orFlag ? offsetORed : offset;
142 
143  // get official channel ID
144  bool c_found = m_cabling->getOfflineIDfromReadoutID
145  (chanId, rawData->subDetectorId(), rawData->rodId(),
146  sswId, slbId, bitpos+corr, orFlag);
147 
148  if(!c_found) return chanId;
149 
150  bctag = rawData->bcTag();
151  return chanId;
152 }
153 
155  // get TGC cablingSvc
156 
157  const ITGCcablingServerSvc* TgcCabGet = nullptr;
158  StatusCode sc = service("Muon::TGCCablingServerSvc", TgcCabGet);
159  if(!sc.isSuccess()) {
160  msg(sc.isFailure() ? MSG::FATAL : MSG::ERROR) << "Could not get TGCCablingServerSvc !" << endmsg;
161  return sc;
162  }
163 
164  sc = TgcCabGet->giveCabling(m_cabling);
165  if(!sc.isSuccess()) {
166  msg(sc.isFailure() ? MSG::FATAL : MSG::ERROR) << "Could not get ITGCcablingSvc from Server!" << endmsg;
167  return sc;
168  } else {
169  ATH_MSG_DEBUG("Found the ITGCcablingSvc.");
170  }
171 
172  return sc;
173 }
174 
TgcRDO_Decoder.h
Muon::TgcRDO_Decoder::TgcRDO_Decoder
TgcRDO_Decoder(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
Definition: TgcRDO_Decoder.cxx:15
TgcRawData::bitpos
uint16_t bitpos() const
Definition: TgcRawData.h:293
TgcDigit::BC_UNDEFINED
@ BC_UNDEFINED
Definition: TgcDigit.h:37
Muon::TgcRDO_Decoder::finalize
virtual StatusCode finalize()
Finalizer.
Definition: TgcRDO_Decoder.cxx:36
python.Constants.FATAL
int FATAL
Definition: Control/AthenaCommon/python/Constants.py:19
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
Muon::TgcRDO_Decoder::getCabling
StatusCode getCabling()
Definition: TgcRDO_Decoder.cxx:154
TgcRawData.h
TgcRawData::subDetectorId
uint16_t subDetectorId() const
Definition: TgcRawData.h:264
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
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:98
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ITGCcablingSvc.h
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
endmsg
#define endmsg
Definition: AnalysisConfig_Ntuple.cxx:63
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:41
TgcDigit.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
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:192
ITGCcablingServerSvc.h
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()
Initializer.
Definition: TgcRDO_Decoder.cxx:23
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
ITGCcablingServerSvc::giveCabling
virtual StatusCode giveCabling(const ITGCcablingSvc *&) const =0
Muon::TgcRDO_Decoder::getDigit
TgcDigit * getDigit(const TgcRawData *rawData, bool orFlag) const
Get TGC Digit from TGC RDO.
Definition: TgcRDO_Decoder.cxx:46
ITGCcablingServerSvc
Definition: ITGCcablingServerSvc.h:16
AthAlgTool
Definition: AthAlgTool.h:26
python.AutoConfigFlags.msg
msg
Definition: AutoConfigFlags.py:7