ATLAS Offline Software
Loading...
Searching...
No Matches
SCTRawContByteStreamTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9#include "eformat/SourceIdentifier.h"
15
16// Constructor
17
18SCTRawContByteStreamTool::SCTRawContByteStreamTool(const std::string& type, const std::string& name,
19 const IInterface* parent) :
20 base_class(type, name, parent)
21{
22}
23
24// Initialize
25
27{
28 ATH_CHECK( m_byteStreamCnvSvc.retrieve() );
29
30 // Retrieve ID mapping
31 ATH_CHECK(m_cabling.retrieve());
32 ATH_MSG_INFO("Retrieved service " << m_cabling);
33
34 // Get the SCT Helper
35 ATH_CHECK(detStore()->retrieve(m_sctIDHelper, "SCT_ID"));
36
37 return StatusCode::SUCCESS;
38}
39
40// Finalize
41
43{
44 return StatusCode::SUCCESS;
45}
46
47// Convert method
48
49StatusCode SCTRawContByteStreamTool::convert(const SCT_RDO_Container* sctRDOCont) const
50{
51 FullEventAssembler<SrcIdMap>* fullEventAssembler = nullptr;
52 ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler (fullEventAssembler,
53 "SCTRawCont") );
55
56 // Set ROD Minor version
57 fullEventAssembler->setRodMinorVersion(m_rodBlockVersion);
58 ATH_MSG_DEBUG(" Setting Minor Version Number to " << m_rodBlockVersion);
59
60 // Mapping between ROD IDs and the hits in that ROD
61 std::map<uint32_t, std::vector<const SCT_RDORawData*>> rdoMap;
62
63 // The following few lines are to make sure there is an entry in the rdoMap for
64 // every ROD, even if there are no hits in it for a particular event
65 // (as there might be ByteStream errors e.g. TimeOut errors).
66 std::vector<std::uint32_t> listOfAllRODs;
67 m_cabling->getAllRods(listOfAllRODs);
68 for (std::uint32_t rod : listOfAllRODs) {
69 rdoMap[rod].clear();
70 }
71
72 // Loop over the collections in the SCT RDO container
73 for (const InDetRawDataCollection<SCT_RDORawData>* sctRawColl : *sctRDOCont) {
74 if (sctRawColl == nullptr) {
75 ATH_MSG_WARNING("Null pointer to SCT RDO collection.");
76 continue;
77 }
78 else {
79 // Collection ID
80 Identifier idColl{sctRawColl->identify()};
81 IdentifierHash idCollHash{m_sctIDHelper->wafer_hash(idColl)};
82 uint32_t robid{m_cabling->getRobIdFromHash(idCollHash)};
83
84 if (robid == 0) continue;
85
86 // Building the ROD ID
87 eformat::helper::SourceIdentifier srcIDROB{robid};
88 eformat::helper::SourceIdentifier srcIDROD{srcIDROB.subdetector_id(), srcIDROB.module_id()};
89 uint32_t rodid{srcIDROD.code()};
90
91 // Loop over RDOs in the collection
92 for (const SCT_RDORawData* rdo : *sctRawColl) {
93 // Fill the ROD/RDO map
94 rdoMap[rodid].push_back(rdo);
95 }
96 }
97 } // End loop over collections
98
99 // Now encode data for each ROD in turn
100 for (const auto& rodToRDOs : rdoMap) {
101 rod = fullEventAssembler->getRodData(rodToRDOs.first); // Get ROD data address
102 m_encoder->fillROD(*rod, rodToRDOs.first, rodToRDOs.second); // Encode ROD data
103 }
104
105 return StatusCode::SUCCESS;
106}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Header file for abstract interface to SCT cabling tool.
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
This is a "hash" representation of an Identifier.
ToolHandle< ISCT_RodEncoder > m_encoder
Algorithm Tool to decode ROB bytestream data into RDO.
virtual StatusCode initialize() override
Initialize.
virtual StatusCode convert(const SCT_RDO_Container *sctRDOCont) const override
Main Convert method.
UnsignedShortProperty m_rodBlockVersion
SCTRawContByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
ToolHandle< ISCT_CablingTool > m_cabling
Providing mappings of online and offline identifiers and also serial numbers.
virtual StatusCode finalize() override
Finalize.
const SCT_ID * m_sctIDHelper
Identifier helper class for the SCT subdetector that creates compact Identifier objects and Identifie...
ServiceHandle< IByteStreamCnvSvc > m_byteStreamCnvSvc