ATLAS Offline Software
STGC_RawDataProviderToolMT.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // STGC_RawDataProviderToolMT.cxx, (c) ATLAS Detector software
8 
11 #include "eformat/SourceIdentifier.h"
12 using eformat::helper::SourceIdentifier;
13 
14 //==============================================================================
15 Muon::STGC_RawDataProviderToolMT::STGC_RawDataProviderToolMT(const std::string& t, const std::string& n, const IInterface* p)
17 {
18  declareInterface<IMuonRawDataProviderTool>(this);
19 }
20 
21 
22 //==============================================================================
24 {
25  // generate all the Source Identifiers to request the fragments.
26  // assume 16 RODs per side (one per sector) and that ROB ID = ROD ID.
27  for (uint32_t detID : {eformat::MUON_STGC_ENDCAP_A_SIDE, eformat::MUON_STGC_ENDCAP_C_SIDE}) { //0x6D, 0x6E
28  for (uint8_t sectorID(0); sectorID < 16; ++sectorID) {
29  // for now lets build all the possible ROB ids of all possible readout configurations
30  // maybe later we can come up with a smart way to detect which readout sheme is running and only request the relevant ROB ids from the ROBDataProviderSvc
31  // reference: slide 6 of https://indico.cern.ch/event/1260377/contributions/5294286/attachments/2603399/4495810/NSW-SwRod-Felix-v3.pdf
32 
33  uint16_t moduleID = (0x0 << 8) | sectorID; // combined/single ROB
34  SourceIdentifier sid(static_cast<eformat::SubDetector>(detID), moduleID);
35  m_allRobIds.push_back(sid.simple_code());
36 
37  moduleID = (0x1 << 8) | sectorID; // full device ROB (split configuration)
38  sid = SourceIdentifier(static_cast<eformat::SubDetector>(detID), moduleID);
39  m_allRobIds.push_back(sid.simple_code());
40 
41  moduleID = (0x2 << 8) | sectorID; // shared device ROB (split configuration)
42  sid = SourceIdentifier(static_cast<eformat::SubDetector>(detID), moduleID);
43  m_allRobIds.push_back(sid.simple_code());
44 
45  moduleID = (0x3 << 8) | sectorID; // spare device ROB (split configuration)
46  sid = SourceIdentifier(static_cast<eformat::SubDetector>(detID), moduleID);
47  m_allRobIds.push_back(sid.simple_code());
48  }
49  }
50 
51  ATH_CHECK(m_rdoContainerCacheKey.initialize(!m_rdoContainerCacheKey.key().empty()));
53  return StatusCode::SUCCESS;
54 }
55 
56 
57 //==============================================================================
59 {
60  // Create the identifiable RdoContainer in StoreGate to be filled with decoded fragment contents.
61  SG::WriteHandle<STGC_RawDataContainer> rdoContainerHandle(m_rdoContainerKey, ctx);
62 
63  const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
64  if(!externalCacheRDO){
65  ATH_CHECK(rdoContainerHandle.record(std::make_unique<STGC_RawDataContainer>(m_maxhashtoUse)));
66  ATH_MSG_DEBUG("Created STGC RDO container");
67  } else {
68  SG::UpdateHandle<STGC_RawDataCollection_Cache> update(m_rdoContainerCacheKey, ctx);
69  ATH_CHECK(update.isValid());
70  ATH_CHECK(rdoContainerHandle.record(std::make_unique<STGC_RawDataContainer>(update.ptr())));
71  ATH_MSG_DEBUG("Created STGC RDO container using cache for " << m_rdoContainerCacheKey.key());
72  }
73 
74  // this should never happen, but since we dereference the pointer, we should check
75  if (!(rdoContainer = rdoContainerHandle.ptr())) {
76  ATH_MSG_ERROR("The STGC RDO container is null, cannot decode STGC data");
77  return StatusCode::FAILURE;
78  }
79 
80  return StatusCode::SUCCESS;
81 }
82 
83 
84 //==============================================================================
85 StatusCode Muon::STGC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& rdoIdhVect, const EventContext& ctx) const
86 {
87  // method for RoI-seeded mode. we don't let empty hash containers reach the decoder,
88  // since an empty container means unseeded mode (decode everything).
89 
90  STGC_RawDataContainer* rdoContainer{nullptr};
91  ATH_CHECK(initRdoContainer(ctx, rdoContainer));
92 
93  if (rdoIdhVect.empty() || m_skipDecoding) return StatusCode::SUCCESS;
94 
95  std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecRobf;
96  m_robDataProvider->getROBData(ctx, m_allRobIds, vecRobf);
97 
98  return convertIntoContainer(ctx, vecRobf, rdoIdhVect, *rdoContainer);
99 }
100 
101 
102 //==============================================================================
104 {
105  // method for unseeded mode. just decode everything.
106 
107  STGC_RawDataContainer* rdoContainer{nullptr};
108  ATH_CHECK(initRdoContainer(ctx, rdoContainer));
109  if(m_skipDecoding) return StatusCode::SUCCESS;
110 
111  std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecRobf;
112  m_robDataProvider->getROBData(ctx, m_allRobIds, vecRobf);
113 
114  // dummy hashID vector for the decoder (empty = unseeded mode)
115  const std::vector<IdentifierHash> rdoIdhVect;
116 
117  return convertIntoContainer(ctx, vecRobf, rdoIdhVect, *rdoContainer);
118 }
119 
120 StatusCode Muon::STGC_RawDataProviderToolMT::convert(const std::vector<uint32_t>& robIds, const EventContext& ctx) const
121 {
122  STGC_RawDataContainer* rdoContainer{nullptr};
123  ATH_CHECK(initRdoContainer(ctx, rdoContainer));
124 
125  if (robIds.empty() || m_skipDecoding) return StatusCode::SUCCESS;
126 
127  std::vector<const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment*> vecRobf;
128 
129  m_robDataProvider->getROBData(ctx, robIds, vecRobf);
130 
131  // pass empty list of ID hashes, every ROB ID in list will be decoded
132  const std::vector<IdentifierHash> hashIDList;
133 
134  return convertIntoContainer(ctx, vecRobf, hashIDList, *rdoContainer);
135 
136 }
137 
138 //===============================================================================
140 {
141  ATH_MSG_ERROR("STGC_RawDataProviderToolMT::convert() Not implemented.");
142  return StatusCode::FAILURE;
143 }
144 
146 {
147  ATH_MSG_ERROR("STGC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs) Not implemented.");
148  return StatusCode::FAILURE;
149 }
150 
151 StatusCode Muon::STGC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& ) const
152 {
153  ATH_MSG_ERROR("STGC_RawDataProviderToolMT::convert(const std::vector<IdentifierHash>& rdoIdhVect) Not implemented.");
154  return StatusCode::FAILURE;
155 }
156 
157 StatusCode Muon::STGC_RawDataProviderToolMT::convert(const ROBFragmentList&, const std::vector<IdentifierHash>&) const
158 {
159  ATH_MSG_ERROR("STGC_RawDataProviderToolMT::convert(const ROBFragmentList& vecRobs, const std::vector<IdentifierHash>&) Not implemented.");
160  return StatusCode::FAILURE;
161 }
STGC_RawDataProviderToolMT.h
xAOD::uint8_t
uint8_t
Definition: Muon_v1.cxx:557
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
Muon::STGC_RawDataContainer
Definition: STGC_RawDataContainer.h:18
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
Muon::STGC_RawDataProviderToolMT::initRdoContainer
StatusCode initRdoContainer(const EventContext &, STGC_RawDataContainer *&) const
Definition: STGC_RawDataProviderToolMT.cxx:58
STGC_RawDataContainer.h
Muon::STGC_RawDataProviderToolMT::STGC_RawDataProviderToolMT
STGC_RawDataProviderToolMT(const std::string &t, const std::string &n, const IInterface *p)
Default constructor.
Definition: STGC_RawDataProviderToolMT.cxx:15
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
beamspotman.n
n
Definition: beamspotman.py:731
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
SG::WriteHandle::ptr
pointer_type ptr()
Dereference the pointer.
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
Muon::STGC_RawDataProviderToolMT::convert
virtual StatusCode convert() const override
the new ones
Definition: STGC_RawDataProviderToolMT.cxx:139
SG::UpdateHandle
Definition: UpdateHandle.h:94
Muon::STGC_RawDataProviderToolCore::initialize
virtual StatusCode initialize() override
Standard AlgTool method.
Definition: STGC_RawDataProviderToolCore.cxx:16
SG::WriteHandle
Definition: StoreGate/StoreGate/WriteHandle.h:76
Muon::STGC_RawDataProviderToolCore
Definition: STGC_RawDataProviderToolCore.h:25
SG::WriteHandle::record
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
Muon::STGC_RawDataProviderToolMT::initialize
virtual StatusCode initialize() override
Standard AlgTool method.
Definition: STGC_RawDataProviderToolMT.cxx:23
Muon::IMuonRawDataProviderTool::ROBFragmentList
std::vector< const OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment * > ROBFragmentList
Decoding method.
Definition: IMuonRawDataProviderTool.h:27
WriteBchToCool.update
update
Definition: WriteBchToCool.py:67