ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawDataReadingAlg.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// Tile includes
12
13// Athena includes
17
18#include <functional>
19
21
24
27
30
33
36
39
42
45
46 m_doL2 = !m_l2ContainerKey.empty();
48
49
50 ATH_MSG_DEBUG("Initialize Tile raw data reading: "
51 << ((m_doDigits) ? m_digitsContainerKey.key() + " " : "")
52 << ((m_doMuRcvDigits) ? m_muRcvDigitsContainerKey.key() + " " : "")
53 << ((m_doFlxDigits) ? m_flxDigitsContainerKey.key() + " " : "")
54 << ((m_doRawChannels) ? m_rawChannelContainerKey.key() + " " : "")
56 << ((m_doBeamElements) ? m_beamElemContainerKey.key() + " " : "")
57 << ((m_doLaserObject) ? m_laserObjectKey.key() + " " : "")
58 << ((m_doMuonReceiver) ? m_muonReceiverContainerKey.key() + " " : "")
59 << ((m_doL2) ? m_l2ContainerKey.key() + " " : ""));
60
61 ATH_CHECK(m_hid2RESrcIDKey.initialize());
62
63 ATH_CHECK(m_robSvc.retrieve());
64 ATH_CHECK(m_cablingSvc.retrieve());
65 ATH_CHECK(m_decoder.retrieve());
66
67 return StatusCode::SUCCESS;
68}
69
70StatusCode TileRawDataReadingAlg::execute(const EventContext& ctx) const {
71
73 ATH_CHECK(hid2re.isValid());
74
75 if (m_doDigits) {
78 [] (const TileROD_Decoder* decoder, const ROBDataProviderSvc::ROBF* rob, TileDigitsCollection& digitsCollection) {
79 decoder->fillCollection(rob, digitsCollection);
80 }));
81 }
82
83 if (m_doRawChannels) {
86 [] (const TileROD_Decoder* decoder, const ROBDataProviderSvc::ROBF* rob,
88 decoder->fillCollection(rob, rawChannelCollection, container);
89 }));
90 }
91
92 if (m_doMuonReceiver) {
94 }
95
96 if (m_doMuRcvDigits) {
100 }
101
105 [] (const TileROD_Decoder* decoder, const ROBDataProviderSvc::ROBF* rob,
106 TileRawChannelCollection& rawChannelCollection, TileRawChannelContainer*) {
107 decoder->fillCollection_TileMuRcv_RawChannel(rob, rawChannelCollection);
108 }, TileFragHash::MF));
109 }
110
111 if (m_doBeamElements) {
113 }
114
115 if (m_doLaserObject) {
117 }
118
119 if (m_doFlxDigits) {
124 }
125
126 if (m_doL2) {
128 }
129
130 return StatusCode::SUCCESS;
131}
132
133
134template <class GetRobOperation, class FillCollOperation>
136 const EventContext& ctx, const TileHid2RESrcID* hid2re,
137 GetRobOperation getRobFromFragID, FillCollOperation fillCollection,
138 unsigned int offsetID) const {
139
140 uint32_t newrob = 0x0;
141 std::vector<uint32_t> robid{0};
142 std::vector<const ROBDataProviderSvc::ROBF*> robf;
143 auto digitsContainer = std::make_unique<TileMutableDigitsContainer>(true, TileFragHash::Digitizer);
144 ATH_CHECK( digitsContainer->status() );
145
146 // Iterate over all collections in a container and fill them
147 for (IdentifierHash hash : digitsContainer->GetAllCurrentHashes()) {
148 TileDigitsCollection* digitsCollection = digitsContainer->indexFindPtr (hash);
149 TileDigitsCollection::ID collID = digitsCollection->identify();
150
151 // Find ROB
152 newrob = getRobFromFragID(hid2re, collID + offsetID);
153 if (newrob != robid[0]) {
154 robid[0] = newrob;
155 robf.clear();
156 m_robSvc->getROBData(ctx, robid, robf);
157 }
158
159 if (robf.size() > 0 ) {
160 fillCollection(&*m_decoder, robf[0], *digitsCollection);
161 } else {
162 uint32_t status = TileROD_Decoder::NO_ROB;
163 digitsCollection->setFragBCID(0xDEAD | (status << 16));
164 ATH_MSG_DEBUG( "Status [" << digitsKey.key() << "] for " << "drawer 0x" << MSG::hex
165 << collID << " in Digi frag is 0x" << status << MSG::dec);
166 }
167 }
168
169 ATH_MSG_DEBUG( "Creating digits container: " << digitsKey.key() );
170
171 SG::WriteHandle<TileDigitsContainer> digitsCnt(digitsKey, ctx);
172 ATH_CHECK( digitsCnt.record(std::move(digitsContainer)) );
173
174 return StatusCode::SUCCESS;
175}
176
177template <class GetRobOperation, class FillCollOperation>
179 const EventContext& ctx, const TileHid2RESrcID* hid2re,
180 GetRobOperation getRobFromFragID, FillCollOperation fillCollection,
181 TileFragHash::TYPE type) const {
182
183
184 uint32_t newrob = 0x0;
185 std::vector<uint32_t> robid{0};
186 std::vector<const ROBDataProviderSvc::ROBF*> robf;
187 std::unordered_map<uint32_t, int> bsflags;
188 uint32_t flags;
189
190 auto rawChannelContainer = std::make_unique<TileMutableRawChannelContainer>(true, type);
191 ATH_CHECK( rawChannelContainer->status() );
192
193 // Iterate over all collections in a container and fill them
194 for (IdentifierHash hash : rawChannelContainer->GetAllCurrentHashes()) {
195 TileRawChannelCollection* rawChannelCollection = rawChannelContainer->indexFindPtr (hash);
196 TileRawChannelCollection::ID collID = rawChannelCollection->identify();
197
198 // Find ROB
199 newrob = getRobFromFragID(hid2re, collID);
200 if (newrob != robid[0]) {
201 robid[0] = newrob;
202 robf.clear();
203 m_robSvc->getROBData(ctx, robid, robf);
204 }
205
206 // Unpack ROB data
207 if (robf.size() > 0 ) {
208 fillCollection(&*m_decoder, robf[0], *rawChannelCollection, &*rawChannelContainer);
209
210 flags = rawChannelContainer->get_bsflags();
211 auto result = bsflags.insert(std::pair<uint32_t, int>(flags, 1));
212 if (result.second == false) {
213 result.first->second++;
214 }
215 } else {
216 ATH_MSG_DEBUG( "ROB [" << rawChannelsKey.key() << "] for " << "drawer 0x" << MSG::hex << collID << MSG::dec << " not found in BS" );
218 rawChannelCollection->setFragGlobalCRC(status);
219 ATH_MSG_DEBUG( "Status [" << rawChannelsKey.key() << "] for " << "drawer 0x" << MSG::hex << collID << " is 0x" << status << MSG::dec);
220 }
221 }
222
223 if (bsflags.size() > 1) {
224 int n = 0;
225 for (const auto & elem : bsflags) {
226 if (elem.second > n) {
227 n = elem.second;
228 flags = elem.first;
229 }
230 }
231
232 if (flags != rawChannelContainer->get_bsflags()) {
233
234 uint32_t unit = ((flags & 0xC0000000) >> 30);
235 if ((flags & 0x30000000) < 0x30000000) {
236 unit += TileRawChannelUnit::OnlineOffset; // Online units in real data
237 }
238
239 ATH_MSG_DEBUG( "Changing units [" << rawChannelsKey.key() << "] for " << "RawChannelContainer from "
240 << rawChannelContainer->get_unit() << " to " << unit << MSG::hex
241 << " and BS flags from 0x" << rawChannelContainer->get_bsflags() << " to 0x" << flags << MSG::dec);
242
243 rawChannelContainer->set_unit((TileRawChannelUnit::UNIT)unit);
244 rawChannelContainer->set_bsflags(flags);
245 }
246 }
247
248 ATH_MSG_DEBUG( "Creating raw channel container: " << rawChannelsKey );
249
250 SG::WriteHandle<TileRawChannelContainer> rawChannelsCnt(rawChannelsKey, ctx);
251 ATH_CHECK( rawChannelsCnt.record(std::move(rawChannelContainer)) );
252
253 return StatusCode::SUCCESS;
254}
255
256
258 const EventContext& ctx, const TileHid2RESrcID* hid2re) const {
259
260 std::vector<uint32_t> robid{0};
261 std::vector<const ROBDataProviderSvc::ROBF*> robf;
262
263 auto beamElementsContainer = std::make_unique<TileMutableBeamElemContainer>(true);
264 ATH_CHECK( beamElementsContainer->status() );
265
266 // Iterate over all collections in a container and fill them
267 for (IdentifierHash hash : beamElementsContainer->GetAllCurrentHashes()) {
268 TileBeamElemCollection* beamElementsCollection = beamElementsContainer->indexFindPtr(hash);
269 TileBeamElemCollection::ID collID = beamElementsCollection->identify();
270
271 // Find ROB
272 uint32_t newrob = hid2re->getRobFromFragID(collID);
273 if (newrob != robid[0]) {
274 robid[0] = newrob;
275 robf.clear();
276 m_robSvc->getROBData(ctx, robid, robf);
277 }
278
279 // Unpack ROB data
280 if (robf.size() > 0 ) {
281 m_decoder->fillCollection(robf[0], *beamElementsCollection);
282 }
283 }
284
285 ATH_MSG_DEBUG( "Creating beam elements container: " << beamElementsKey );
286
287 SG::WriteHandle<TileBeamElemContainer> beamElementsCnt(beamElementsKey, ctx);
288 ATH_CHECK( beamElementsCnt.record(std::move(beamElementsContainer)) );
289
290 return StatusCode::SUCCESS;
291}
292
293
295 const EventContext& ctx, const TileHid2RESrcID* hid2re) const {
296
297 std::vector<uint32_t> robid{0};
298 std::vector<const ROBDataProviderSvc::ROBF*> robf;
299
300 auto laserObject = std::make_unique<TileLaserObject>() ;
301 m_decoder->setLaserVersion(*laserObject);
302
303 robid[0] = hid2re->getRobFromFragID(LASER_OBJ_FRAG);
304 m_robSvc->getROBData(ctx, robid, robf);
305
306 if (robf.size() > 0 ) {
307 m_decoder->fillTileLaserObj(robf[0], *laserObject);
308 } else {
309 ATH_MSG_DEBUG( " No LASTROD fragment in BS, TileLaserObject will be empty." );
310 }
311
312 ATH_MSG_DEBUG( "Creating laser object: " << laserObjectKey );
313
314 SG::WriteHandle<TileLaserObject> laserObj(laserObjectKey, ctx);
315 ATH_CHECK( laserObj.record(std::move(laserObject)) );
316
317 return StatusCode::SUCCESS;
318}
319
320
322 const EventContext& ctx) const {
323
324 const RawEvent* re = m_robSvc->getEvent(ctx);
325 if (!re) {
326 ATH_MSG_ERROR( "Could not get raw event from ByteStreamInputSvc" );
327 return StatusCode::FAILURE;
328 }
329
330 auto muonReceiverContainer = std::make_unique<TileMuonReceiverContainer>();
331
332 if (!m_decoder->convertTMDBDecision(re, muonReceiverContainer.get()).isSuccess()) {
333 ATH_MSG_WARNING( "Conversion tool returned an error. TileMuonReceiverContainer might be empty." );
334 }
335
336 SG::WriteHandle<TileMuonReceiverContainer> muRcvCnt(muRcvKey, ctx);
337 ATH_CHECK( muRcvCnt.record(std::move(muonReceiverContainer)) );
338
339 return StatusCode::SUCCESS;
340}
341
342
344 const EventContext& ctx) const {
345
346 const RawEvent* re = m_robSvc->getEvent(ctx);
347 if (!re) {
348 ATH_MSG_ERROR( "Could not get raw event from ByteStreamInputSvc" );
349 return StatusCode::FAILURE;
350 }
351
352 auto l2Container = std::make_unique<TileL2Container>();
353 l2Container->reserve(256);
354 for(int i = 0; i < 256; ++i) {
355 int collId = m_decoder->hashFunc()->identifier(i);
356 l2Container->push_back (std::make_unique<TileL2>(collId));
357 }
358
359 if (!m_decoder->convert(re, l2Container.get()).isSuccess()) {
360 ATH_MSG_WARNING( "Conversion tool returned an error. TileL2Container might be empty." );
361 }
362
363 SG::WriteHandle<TileL2Container> l2Cnt(l2Key, ctx);
364 ATH_CHECK( l2Cnt.record(std::move(l2Container)) );
365
366 return StatusCode::SUCCESS;
367}
const boost::regex re(r_e)
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
OFFLINE_FRAGMENTS_NAMESPACE::FullEventFragment RawEvent
data type for reading raw event
Definition RawEvent.h:37
Handle class for recording to StoreGate.
Helper for holding non-const raw data prior to recording in SG.
Helper for holding non-const raw data prior to recording in SG.
Helper for holding non-const raw data prior to recording in SG.
#define LASER_OBJ_FRAG
Definition TileTBFrag.h:49
This is a "hash" representation of an Identifier.
OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment ROBF
ROB Fragment class.
const std::string & key() const
Return the StoreGate ID for the referenced object.
Property holding a SG store/key/clid from which a WriteHandle is made.
StatusCode record(std::unique_ptr< T > data)
Record a const object to the store.
static const unsigned int FELIX_FRAGID_OFFSET
Offset for frag ID used for FELIX in frag ID to ROB ID map.
void setFragBCID(uint32_t bcid)
Set BCID.
TYPE
initialize
This class provides conversion between fragment ID and RESrcID.
uint32_t getRobFromFragID(int frag_id) const
make a ROB SrcID for a fragment ID
uint32_t getRobFromTileMuRcvFragID(int frag_id) const
Decodes the different TileCal ROD subfragment types in bytestream data and fills TileDigitsContainer,...
void fillCollection_TileMuRcv_Digi(const ROBData *rob, TileDigitsCollection &v) const
void fillCollection_FELIX_Digi(const ROBData *rob, TileDigitsCollection &v) const
void setFragGlobalCRC(uint32_t globalcrc)
Various set methods.
StatusCode execute(const EventContext &ctx) const override
SG::WriteHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
SG::WriteHandleKey< TileLaserObject > m_laserObjectKey
SG::ReadCondHandleKey< TileHid2RESrcID > m_hid2RESrcIDKey
StatusCode readL2(const SG::WriteHandleKey< TileL2Container > &l2Key, const EventContext &ctx) const
SG::WriteHandleKey< TileL2Container > m_l2ContainerKey
SG::WriteHandleKey< TileDigitsContainer > m_muRcvDigitsContainerKey
StatusCode initialize() override
SG::WriteHandleKey< TileDigitsContainer > m_digitsContainerKey
StatusCode readMuonReceiver(const SG::WriteHandleKey< TileMuonReceiverContainer > &muRcvKey, const EventContext &ctx) const
StatusCode readRawChannels(const SG::WriteHandleKey< TileRawChannelContainer > &rawChannelsKey, const EventContext &ctx, const TileHid2RESrcID *hid2re, GetRobOperation getRobFromFragID, FillCollOperation fillCollection, TileFragHash::TYPE type=TileFragHash::OptFilterDsp) const
ToolHandle< TileROD_Decoder > m_decoder
StatusCode readBeamElements(const SG::WriteHandleKey< TileBeamElemContainer > &beamElementsKey, const EventContext &ctx, const TileHid2RESrcID *hid2re) const
StatusCode readLaserObject(const SG::WriteHandleKey< TileLaserObject > &laserObjectKey, const EventContext &ctx, const TileHid2RESrcID *hid2re) const
SG::WriteHandleKey< TileRawChannelContainer > m_muRcvRawChannelContainerKey
SG::WriteHandleKey< TileMuonReceiverContainer > m_muonReceiverContainerKey
SG::WriteHandleKey< TileDigitsContainer > m_flxDigitsContainerKey
ServiceHandle< TileCablingSvc > m_cablingSvc
SG::WriteHandleKey< TileBeamElemContainer > m_beamElemContainerKey
ServiceHandle< IROBDataProviderSvc > m_robSvc
Name of ROB data provider service.
StatusCode readDigits(const SG::WriteHandleKey< TileDigitsContainer > &digitsKey, const EventContext &ctx, const TileHid2RESrcID *hid2re, GetRobOperation getRobFromFragID, FillCollOperation fillCollection, unsigned int offsetID=0) const