ATLAS Offline Software
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"
10 #include "InDetIdentifier/SCT_ID.h"
15 
16 // Constructor
17 
18 SCTRawContByteStreamTool::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
36 
37  return StatusCode::SUCCESS;
38 }
39 
40 // Finalize
41 
43 {
44  return StatusCode::SUCCESS;
45 }
46 
47 // Convert method
48 
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 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCTRawContByteStreamTool::m_byteStreamCnvSvc
ServiceHandle< ByteStreamCnvSvc > m_byteStreamCnvSvc
Definition: SCTRawContByteStreamTool.h:65
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
ISCT_RodEncoder.h
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
FullEventAssembler< SrcIdMap >
SCTRawContByteStreamTool::m_rodBlockVersion
UnsignedShortProperty m_rodBlockVersion
Definition: SCTRawContByteStreamTool.h:77
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
SCT_RDORawData
Definition: SCT_RDORawData.h:24
InDetRawDataContainer
Definition: InDetRawDataContainer.h:27
ReadCondHandle.h
SCTRawContByteStreamTool::SCTRawContByteStreamTool
SCTRawContByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
Definition: SCTRawContByteStreamTool.cxx:18
SrcIdMap.h
SCTRawContByteStreamTool.h
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
RawEvent.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
InDetRawDataCollection
Definition: InDetRawDataCollection.h:31
SCTRawContByteStreamTool::m_sctIDHelper
const SCT_ID * m_sctIDHelper
Identifier helper class for the SCT subdetector that creates compact Identifier objects and Identifie...
Definition: SCTRawContByteStreamTool.h:75
test_pyathena.parent
parent
Definition: test_pyathena.py:15
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
SCT_ID::wafer_hash
IdentifierHash wafer_hash(const Identifier &wafer_id) const
wafer hash from id - optimized
Definition: SCT_ID.h:492
RunTileMonitoring.rod
rod
Definition: RunTileMonitoring.py:134
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SiDetectorElement.h
FullEventAssembler::setRodMinorVersion
void setRodMinorVersion(uint16_t m)
change the ROD minor version
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
SCTRawContByteStreamTool::initialize
virtual StatusCode initialize() override
Initialize.
Definition: SCTRawContByteStreamTool.cxx:26
ISCT_CablingTool.h
SCTRawContByteStreamTool::m_cabling
ToolHandle< ISCT_CablingTool > m_cabling
Providing mappings of online and offline identifiers and also serial numbers.
Definition: SCTRawContByteStreamTool.h:71
IdentifierHash
Definition: IdentifierHash.h:38
SCTRawContByteStreamTool::finalize
virtual StatusCode finalize() override
Finalize.
Definition: SCTRawContByteStreamTool.cxx:42
SCTRawContByteStreamTool::m_encoder
ToolHandle< ISCT_RodEncoder > m_encoder
Algorithm Tool to decode ROB bytestream data into RDO.
Definition: SCTRawContByteStreamTool.h:68
SCTRawContByteStreamTool::convert
virtual StatusCode convert(const SCT_RDO_Container *sctRDOCont) const override
Main Convert method.
Definition: SCTRawContByteStreamTool.cxx:49
FullEventAssembler::getRodData
RODDATA * getRodData(uint32_t id)
get a block of ROD data