ATLAS Offline Software
MdtRDO_Decoder.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MUONBYTESTREAMMDTRDODECODER_H
6 #define MUONBYTESTREAMMDTRDODECODER_H
7 
8 #include <string>
9 #include <vector>
10 
12 #include "GaudiKernel/ServiceHandle.h"
17 #include "MuonRDO/MdtAmtHit.h"
19 
20 namespace Muon {
21  // Decoder class for conversion from MDT RDOs to MDT digits
22  // Stefano Rosati
23  // CERN Jan 2004
24 
25  class MdtRDO_Decoder : public AthAlgTool, virtual public IMDT_RDO_Decoder {
26  public:
27  MdtRDO_Decoder(const std::string& type, const std::string& name, const IInterface* parent);
28 
29  virtual StatusCode initialize();
30 
31  MdtDigit* getDigit(const MdtAmtHit* amtHit, uint16_t& subdetId, uint16_t& mrodId, uint16_t& csmId) const;
32 
33  Identifier getOfflineData(const MdtAmtHit* amtHit, uint16_t& subdetId, uint16_t& mrodId, uint16_t& csmId, int& tdc,
34  int& width) const;
35 
36  private:
37  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
38  SG::ReadCondHandleKey<MuonMDT_CablingMap> m_readKey{this, "ReadKey", "MuonMDT_CablingMap", "Key of MuonMDT_CablingMap"};
39  };
40 
41 } // namespace Muon
42 
43 inline MdtDigit* Muon::MdtRDO_Decoder::getDigit(const MdtAmtHit* amtHit, uint16_t& subdetId, uint16_t& mrodId, uint16_t& csmId) const {
45  const MuonMDT_CablingMap* readCdo{*readHandle};
46  if (!readCdo) {
47  ATH_MSG_ERROR("Null pointer to the read conditions object");
48  return nullptr;
49  }
51  cabling_data.tdcId = amtHit->tdcId();
52  cabling_data.channelId = amtHit->channelId();
53  cabling_data.subdetectorId = subdetId;
54  cabling_data.mrod = mrodId;
55  cabling_data.csm = csmId;
56 
57  uint16_t coarse = amtHit->coarse();
58  uint16_t fine = amtHit->fine();
59  int width = (int)amtHit->width();
60 
61  MsgStream& msg(msgStream());
62  bool cab = readCdo->getOfflineId(cabling_data, msg);
63  if (!cab) return nullptr;
64  Identifier chanId;
65  if (!readCdo->convert(cabling_data, chanId, false)) return nullptr;
66  int tdcCounts = coarse * 32 + fine;
67  MdtDigit* mdtDigit = new MdtDigit(chanId, tdcCounts, width, amtHit->isMasked());
68  return mdtDigit;
69 }
70 
71 inline Identifier Muon::MdtRDO_Decoder::getOfflineData(const MdtAmtHit* amtHit, uint16_t& subdetId, uint16_t& mrodId, uint16_t& csmId,
72  int& tdcCounts, int& width) const {
73  uint16_t tdc = amtHit->tdcId();
74  uint16_t chan = amtHit->channelId();
75  uint16_t coarse = amtHit->coarse();
76  uint16_t fine = amtHit->fine();
77  width = amtHit->width();
78  tdcCounts = coarse * 32 + fine;
79 
80  Identifier chanIdDefault;
81  SG::ReadCondHandle<MuonMDT_CablingMap> readHandle{m_readKey};
82  const MuonMDT_CablingMap* readCdo{*readHandle};
83  if (!readCdo) {
84  ATH_MSG_ERROR("Null pointer to the read conditions object");
85  return chanIdDefault;
86  }
88  cabling_data.subdetectorId = subdetId;
89  cabling_data.csm = csmId;
90  cabling_data.tdcId = tdc;
91  cabling_data.channelId = chan;
92  cabling_data.mrod = mrodId;
93 
94  bool cab = readCdo->getOfflineId(cabling_data, msgStream());
95 
96  if (!cab) { return chanIdDefault; }
97 
98  Identifier chanId;
99  readCdo->convert(cabling_data, chanId);
100 
101  return chanId;
102 }
103 
104 #endif
MdtAmtHit::isMasked
bool isMasked() const
Definition: MdtAmtHit.h:76
Muon::IMDT_RDO_Decoder
Definition: IMDT_RDO_Decoder.h:18
MdtAmtHit
MDT RDO's : data from a single channel of an AMT Atlas Muon TDC.
Definition: MdtAmtHit.h:20
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
Muon::MdtRDO_Decoder::initialize
virtual StatusCode initialize()
Definition: MdtRDO_Decoder.cxx:14
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MdtDigit
Definition: MdtDigit.h:19
Muon::MdtRDO_Decoder::getDigit
MdtDigit * getDigit(const MdtAmtHit *amtHit, uint16_t &subdetId, uint16_t &mrodId, uint16_t &csmId) const
Definition: MdtRDO_Decoder.h:43
MdtAmtHit::tdcId
uint16_t tdcId() const
Definition: MdtAmtHit.h:70
createCablingJSON.cabling_data
dictionary cabling_data
Definition: createCablingJSON.py:18
MdtDigit.h
Muon::MdtRDO_Decoder
Definition: MdtRDO_Decoder.h:25
Muon::MdtRDO_Decoder::getOfflineData
Identifier getOfflineData(const MdtAmtHit *amtHit, uint16_t &subdetId, uint16_t &mrodId, uint16_t &csmId, int &tdc, int &width) const
Definition: MdtRDO_Decoder.h:71
Muon
This class provides conversion from CSC RDO data to CSC Digits.
Definition: TrackSystemController.h:49
Muon::MdtRDO_Decoder::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MdtRDO_Decoder.h:37
MuonMDT_CablingMap
Definition: MuonMDT_CablingMap.h:24
IMDT_RDO_Decoder.h
MdtAmtHit::width
uint16_t width() const
Definition: MdtAmtHit.h:74
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
ReadCellNoiseFromCool.chan
chan
Definition: ReadCellNoiseFromCool.py:52
MuonMDT_CablingMap.h
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MdtAmtHit::fine
uint16_t fine() const
Definition: MdtAmtHit.h:73
AthAlgTool.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
MdtCablingData
Definition: MdtCablingData.h:82
Muon::MdtRDO_Decoder::m_readKey
SG::ReadCondHandleKey< MuonMDT_CablingMap > m_readKey
Definition: MdtRDO_Decoder.h:38
ReadCondHandleKey.h
MdtAmtHit.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
Muon::MdtRDO_Decoder::MdtRDO_Decoder
MdtRDO_Decoder(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MdtRDO_Decoder.cxx:9
SG::ReadCondHandleKey< MuonMDT_CablingMap >
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
AthAlgTool
Definition: AthAlgTool.h:26
IMuonIdHelperSvc.h
MdtAmtHit::channelId
uint16_t channelId() const
Definition: MdtAmtHit.h:71
ServiceHandle< Muon::IMuonIdHelperSvc >
MdtAmtHit::coarse
uint16_t coarse() const
Definition: MdtAmtHit.h:72