ATLAS Offline Software
Loading...
Searching...
No Matches
ITkStripsRawContByteStreamTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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 FullEventAssembler<SrcIdMap>* fullEventAssembler = nullptr;
49 ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler (fullEventAssembler,"SCTRawCont") );
51 // Set ROD Minor version
52 fullEventAssembler->setRodMinorVersion(m_rodBlockVersion);
53 ATH_MSG_DEBUG(" Setting Minor Version Number to " << m_rodBlockVersion);
54 // Mapping between ROD IDs and the hits in that ROD
55 std::map<uint32_t, std::vector<const SCT_RDORawData*>> rdoMap;
56
57 // The following few lines are to make sure there is an entry in the rdoMap for
58 // every ROD, even if there are no hits in it for a particular event
59 // (as there might be ByteStream errors e.g. TimeOut errors).
60 std::vector<std::uint32_t> listOfAllRODs;
61 m_cabling->getAllRods(listOfAllRODs);
62 for (std::uint32_t rod : listOfAllRODs) {
63 rdoMap[rod].clear();
64 }
65 // Loop over the collections in the ITkStrips RDO container
66 for (const auto* itkStripsRawColl : *itkStripsRDOCont) {
67 if (itkStripsRawColl == nullptr) {
68 ATH_MSG_WARNING("Null pointer to ITkStrips RDO collection.");
69 continue;
70 } else {
71 // Collection ID
72 Identifier idColl{itkStripsRawColl->identify()};
73 IdentifierHash idCollHash{m_itkStripsIDHelper->wafer_hash(idColl)};
74 uint32_t robid{m_cabling->getRobIdFromHash(idCollHash)};
75 if (robid == 0) continue;
76 // Building the ROD ID
77 eformat::helper::SourceIdentifier srcIDROB{robid};
78 eformat::helper::SourceIdentifier srcIDROD{srcIDROB.subdetector_id(), srcIDROB.module_id()};
79 uint32_t rodid{srcIDROD.code()};
80 // Loop over RDOs in the collection
81 for (const auto* rdo : *itkStripsRawColl) {
82 // Fill the ROD/RDO map
83 rdoMap[rodid].push_back(rdo);
84 }
85 }
86 } // End loop over collections
87
88 // Now encode data for each ROD in turn
89 for (const auto& rodToRDOs : rdoMap) {
90 rod = fullEventAssembler->getRodData(rodToRDOs.first); // Get ROD data address
91 m_encoder->fillROD(*rod, rodToRDOs.first, rodToRDOs.second); // Encode ROD data
92 }
93 return StatusCode::SUCCESS;
94}
#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.