ATLAS Offline Software
Loading...
Searching...
No Matches
ITkStripsRawContByteStreamTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9#include "eformat/SourceIdentifier.h"
13
15
16
17// Constructor
18
19ITkStripsRawContByteStreamTool::ITkStripsRawContByteStreamTool(const std::string& type, const std::string& name,
20 const IInterface* parent) :
21 base_class(type, name, parent){
22 //nop
23}
24
25// Initialize
26StatusCode
28 ATH_CHECK( m_byteStreamCnvSvc.retrieve() );
29 // Retrieve ID mapping
30 ATH_CHECK(m_cabling.retrieve());
31 ATH_MSG_DEBUG("Retrieved service " << m_cabling);
32 // Get the SCT Helper, valid also for ITk strips
33 ATH_CHECK(detStore()->retrieve(m_itkStripsIDHelper, "SCT_ID"));
34 return StatusCode::SUCCESS;
35}
36
37// Finalize
38
39StatusCode
41 return StatusCode::SUCCESS;
42}
43
44// Convert method
45
46StatusCode
48
49 const EventContext& ctx = Gaudi::Hive::currentContext(); // FIXME: should be taken by convert
50
51 FullEventAssembler<SrcIdMap>* fullEventAssembler = nullptr;
52 ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler (fullEventAssembler,"SCTRawCont") );
54 // Set ROD Minor version
55 fullEventAssembler->setRodMinorVersion(m_rodBlockVersion);
56 ATH_MSG_DEBUG(" Setting Minor Version Number to " << m_rodBlockVersion);
57 // Mapping between ROD IDs and the hits in that ROD
58 std::map<uint32_t, std::vector<const SCT_RDORawData*>> rdoMap;
59
60 // The following few lines are to make sure there is an entry in the rdoMap for
61 // every ROD, even if there are no hits in it for a particular event
62 // (as there might be ByteStream errors e.g. TimeOut errors).
63 std::vector<std::uint32_t> listOfAllRODs;
64 m_cabling->getAllRods(listOfAllRODs, ctx);
65 for (std::uint32_t rod : listOfAllRODs) {
66 rdoMap[rod].clear();
67 }
68 // Loop over the collections in the ITkStrips RDO container
69 for (const auto* itkStripsRawColl : *itkStripsRDOCont) {
70 if (itkStripsRawColl == nullptr) {
71 ATH_MSG_WARNING("Null pointer to ITkStrips RDO collection.");
72 continue;
73 } else {
74 // Collection ID
75 Identifier idColl{itkStripsRawColl->identify()};
76 IdentifierHash idCollHash{m_itkStripsIDHelper->wafer_hash(idColl)};
77 uint32_t robid{m_cabling->getRobIdFromHash(idCollHash, ctx)};
78 if (robid == 0) continue;
79 // Building the ROD ID
80 eformat::helper::SourceIdentifier srcIDROB{robid};
81 eformat::helper::SourceIdentifier srcIDROD{srcIDROB.subdetector_id(), srcIDROB.module_id()};
82 uint32_t rodid{srcIDROD.code()};
83 // Loop over RDOs in the collection
84 for (const auto* rdo : *itkStripsRawColl) {
85 // Fill the ROD/RDO map
86 rdoMap[rodid].push_back(rdo);
87 }
88 }
89 } // End loop over collections
90
91 // Now encode data for each ROD in turn
92 for (const auto& rodToRDOs : rdoMap) {
93 rod = fullEventAssembler->getRodData(rodToRDOs.first); // Get ROD data address
94 m_encoder->fillROD(*rod, rodToRDOs.first, rodToRDOs.second); // Encode ROD data
95 }
96 return StatusCode::SUCCESS;
97}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
This is an Identifier helper class for the SCT subdetector.
InDetRawDataContainer< InDetRawDataCollection< SCT_RDORawData > > SCT_RDO_Container
Template class for assembling a full atlas raw event from subfragments.
void setRodMinorVersion(uint16_t m)
change the ROD minor version
std::vector< uint32_t > RODDATA
ROD data as a vector of unsigned int.
RODDATA * getRodData(uint32_t id)
get a block of ROD data
ToolHandle< IITkStripsRodEncoder > m_encoder
Algorithm Tool to decode ROB bytestream data into RDO.
ToolHandle< IITkStripCablingTool > m_cabling
Providing mappings of online and offline identifiers and also serial numbers.
virtual StatusCode convert(const SCT_RDO_Container *itkRDOCont) const override
Main Convert method.
virtual StatusCode finalize() override
Finalize.
virtual StatusCode initialize() override
Initialize.
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc
const SCT_ID * m_itkStripsIDHelper
Identifier helper class for the SCT subdetector that creates compact Identifier objects and Identifie...
ITkStripsRawContByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
This is a "hash" representation of an Identifier.