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