ATLAS Offline Software
ITkStripsRawContByteStreamTool.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
9 #include "eformat/SourceIdentifier.h"
10 #include "InDetIdentifier/SCT_ID.h"
13 #include "SCT_Cabling/ISCT_CablingTool.h" //same cabling tool for ITk strips
14 
15 // Constructor
16 
18  const IInterface* parent) :
19  base_class(type, name, parent){
20  //nop
21 }
22 
23 // Initialize
26  ATH_CHECK( m_byteStreamCnvSvc.retrieve() );
27  // Retrieve ID mapping
28  ATH_CHECK(m_cabling.retrieve());
29  ATH_MSG_DEBUG("Retrieved service " << m_cabling);
30  // Get the SCT Helper, valid also for ITk strips
32  return StatusCode::SUCCESS;
33 }
34 
35 // Finalize
36 
39  return StatusCode::SUCCESS;
40 }
41 
42 // Convert method
43 
46  FullEventAssembler<SrcIdMap>* fullEventAssembler = nullptr;
47  ATH_CHECK( m_byteStreamCnvSvc->getFullEventAssembler (fullEventAssembler,"SCTRawCont") );
49  // Set ROD Minor version
50  fullEventAssembler->setRodMinorVersion(m_rodBlockVersion);
51  ATH_MSG_DEBUG(" Setting Minor Version Number to " << m_rodBlockVersion);
52  // Mapping between ROD IDs and the hits in that ROD
53  std::map<uint32_t, std::vector<const SCT_RDORawData*>> rdoMap;
54 
55  // The following few lines are to make sure there is an entry in the rdoMap for
56  // every ROD, even if there are no hits in it for a particular event
57  // (as there might be ByteStream errors e.g. TimeOut errors).
58  std::vector<std::uint32_t> listOfAllRODs;
59  m_cabling->getAllRods(listOfAllRODs);
60  for (std::uint32_t rod : listOfAllRODs) {
61  rdoMap[rod].clear();
62  }
63  // Loop over the collections in the ITkStrips RDO container
64  for (const auto* itkStripsRawColl : *itkStripsRDOCont) {
65  if (itkStripsRawColl == nullptr) {
66  ATH_MSG_WARNING("Null pointer to ITkStrips RDO collection.");
67  continue;
68  } else {
69  // Collection ID
70  Identifier idColl{itkStripsRawColl->identify()};
71  IdentifierHash idCollHash{m_itkStripsIDHelper->wafer_hash(idColl)};
72  uint32_t robid{m_cabling->getRobIdFromHash(idCollHash)};
73  if (robid == 0) continue;
74  // Building the ROD ID
75  eformat::helper::SourceIdentifier srcIDROB{robid};
76  eformat::helper::SourceIdentifier srcIDROD{srcIDROB.subdetector_id(), srcIDROB.module_id()};
77  uint32_t rodid{srcIDROD.code()};
78  // Loop over RDOs in the collection
79  for (const auto* rdo : *itkStripsRawColl) {
80  // Fill the ROD/RDO map
81  rdoMap[rodid].push_back(rdo);
82  }
83  }
84  } // End loop over collections
85 
86  // Now encode data for each ROD in turn
87  for (const auto& rodToRDOs : rdoMap) {
88  rod = fullEventAssembler->getRodData(rodToRDOs.first); // Get ROD data address
89  m_encoder->fillROD(*rod, rodToRDOs.first, rodToRDOs.second); // Encode ROD data
90  }
91  return StatusCode::SUCCESS;
92 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
SCT_ID.h
This is an Identifier helper class for the SCT subdetector. This class is a factory for creating comp...
FullEventAssembler< SrcIdMap >
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
ITkStripsRawContByteStreamTool::m_itkStripsIDHelper
const SCT_ID * m_itkStripsIDHelper
Identifier helper class for the SCT subdetector that creates compact Identifier objects and Identifie...
Definition: ITkStripsRawContByteStreamTool.h:70
ITkStripsRawContByteStreamTool::m_cabling
ToolHandle< ISCT_CablingTool > m_cabling
Providing mappings of online and offline identifiers and also serial numbers.
Definition: ITkStripsRawContByteStreamTool.h:66
InDetRawDataContainer
Definition: InDetRawDataContainer.h:27
ITkStripsRawContByteStreamTool::initialize
virtual StatusCode initialize() override
Initialize.
Definition: ITkStripsRawContByteStreamTool.cxx:25
IITkStripsRodEncoder.h
ITkStripsRawContByteStreamTool.h
SrcIdMap.h
ITkStripsRawContByteStreamTool::m_encoder
ToolHandle< IITkStripsRodEncoder > m_encoder
Algorithm Tool to decode ROB bytestream data into RDO.
Definition: ITkStripsRawContByteStreamTool.h:63
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
ITkStripsRawContByteStreamTool::ITkStripsRawContByteStreamTool
ITkStripsRawContByteStreamTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
Definition: ITkStripsRawContByteStreamTool.cxx:17
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
ITkStripsRawContByteStreamTool::m_rodBlockVersion
UnsignedShortProperty m_rodBlockVersion
Definition: ITkStripsRawContByteStreamTool.h:72
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SiDetectorElement.h
ITkStripsRawContByteStreamTool::finalize
virtual StatusCode finalize() override
Finalize.
Definition: ITkStripsRawContByteStreamTool.cxx:38
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
ISCT_CablingTool.h
ITkStripsRawContByteStreamTool::convert
virtual StatusCode convert(const SCT_RDO_Container *itkRDOCont) const override
Main Convert method.
Definition: ITkStripsRawContByteStreamTool.cxx:45
ITkStripsRawContByteStreamTool::m_byteStreamCnvSvc
ServiceHandle< ByteStreamCnvSvc > m_byteStreamCnvSvc
Definition: ITkStripsRawContByteStreamTool.h:60
IdentifierHash
Definition: IdentifierHash.h:38
FullEventAssembler::getRodData
RODDATA * getRodData(uint32_t id)
get a block of ROD data