ATLAS Offline Software
Loading...
Searching...
No Matches
ITkPixelHitSortingTool.cxx
Go to the documentation of this file.
1/*
2Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
12#include "ITkPixel1RawData.h"
16
17
18#include <map>
19
20ITkPixelHitSortingTool::ITkPixelHitSortingTool(const std::string& type,const std::string& name,const IInterface* parent) :
21 AthAlgTool(type,name,parent)
22{
23 //not much to construct as of now
24}
25
26
28 ATH_CHECK(m_pixelReadout.retrieve());
29 ATH_CHECK(detStore()->retrieve(m_pixIdHelper, "PixelID"));
30 ATH_CHECK(detStore()->retrieve(m_detManager, "ITkPixel"));
31 return StatusCode::SUCCESS;
32}
33
34template<class ContainerType>
35std::map<ITkPixelOnlineId, ITkPixLayout<uint16_t>> ITkPixelHitSortingTool::sortRDOHits(const ContainerType* rdoContainer, const ITkPixelCablingData* cabling) const {
36
37 std::map<ITkPixelOnlineId, ITkPixLayout<uint16_t>> EventHitMaps;
38
39 for(const auto& RDO_Collection : *rdoContainer){
40
41 for(const auto *const rdo : *RDO_Collection) {
42
43 const Identifier rdoID = rdo->identify();
44 const Identifier waferID = m_pixIdHelper->wafer_id(rdoID);
45
46 const uint16_t tot = rdo->getToT();
47
48 uint16_t col = (uint16_t) m_pixIdHelper->eta_index(rdoID);
49 uint16_t row = (uint16_t) m_pixIdHelper->phi_index(rdoID);
50 const uint32_t chip = (const uint32_t) ITkPixelCablingData::chipID( cabling->transformType(waferID.get_identifier32().get_compact()), col, row);
51
52 ATH_MSG_DEBUG("Before Inverse transform");
53 ITkPixelCabling::chipToModuleInverseTransform(cabling->transformType(waferID.get_identifier32().get_compact()), chip, col, row);
54 ATH_MSG_DEBUG("After Inverse transform");
55 //find out if we're dealing with 25x100 sensors
56 const InDetDD::SiDetectorElement *element = m_detManager->getDetectorElement(waferID);
57 const InDetDD::PixelModuleDesign *p_design = static_cast<const InDetDD::PixelModuleDesign *>(&element->design());
58 const uint nChips = p_design->numberOfCircuits();
59 const uint rowsPerFE = p_design->rowsPerCircuit();
60 const uint colsPerFE = p_design->columnsPerCircuit();
61
62 ATH_MSG_DEBUG("Module specs: nChips = " << nChips << ", rows per FE = " << rowsPerFE << " cols per FE = " << colsPerFE);
63 //<----------
64
65 //Store ToT+1, reserve 0 for no hit.
66 //HitMap and encoder labels rows/cols from 0
67
68 //Data from a FE are identified by "DetectorResourceID", which is part
69 //of the header delimiting individual FE payloads within a ROD fragment
70 //payload. The DetectorResourceID is detector-defined. For pixels, it
71 //has an 'online part', containing chipID and information useful for decoding
72 //(chipID on/off). Then there's an offline-specific part
73 //composed - for convenience - of (offline) module ID. We can mask out
74 //the auxiliary online info to get the mapping from FE -> online ID
75 // offlineDetectorResourceID = chipID [2 MSB] | module ID [24 LSB]
76 //Furthermore, we need to know which ROB fragment the data will go to,
77 //hence we need the 'sourceID' (in eformat vocabulary), which identifies
78 //the DMA buffer on the FELIX machine that received the data. This is
79 //all provided by the cabling package, which gives
80 // offlineDetectorResourceID -> {DetectorResourceID, sourceID}
81 //mapping.
82
83 //ITkPixelCabling::ModuleInfo mi = cabling->onlineModuleInfo(waferID);
84 uint32_t offlineDetectorResourceID = (waferID.get_identifier32().get_compact() >> 8) | (chip << 30);
85
86 ITkPixelOnlineId onlineID = cabling->onlineId(offlineDetectorResourceID);
87
88 //Found a valid ID?
89 if (onlineID.sourceID() == 0xFFFFFFFF){
90 ATH_MSG_WARNING("Cabling not found for module bec " << std::dec << m_pixIdHelper->barrel_ec(waferID) << " ld " << m_pixIdHelper->layer_disk(waferID) << " eta " << m_pixIdHelper->eta_module(waferID) << " phi " << m_pixIdHelper->phi_module(waferID) << ", proceeding with a dummy value");
91 onlineID = ITkPixelOnlineId(0x00170000 | (offlineDetectorResourceID & 0x0000FFFF), offlineDetectorResourceID | 0xF0000000);
92 }
93
94 ATH_MSG_DEBUG(" Chip: " << std::hex << onlineID << std::dec << " ID: " << chip << " col: " << col << " row: " << row << " ToT: " << tot << " eta_index = " << m_pixIdHelper->eta_index(rdoID) << " phi index = " << m_pixIdHelper->phi_index(rdoID) << " rowsPerFE = " << rowsPerFE << " colsPerFE = " << colsPerFE << "\n");
95
96 EventHitMaps[onlineID](col, row) = tot + 1;
97
98 };
99 };
100
101 return EventHitMaps;
102
103}
104
105template std::map<ITkPixelOnlineId, ITkPixLayout<uint16_t>> ITkPixelHitSortingTool::sortRDOHits<ITkPixelRDO_Container>(const ITkPixelRDO_Container* rdoContainer, const ITkPixelCablingData* cabling) const;
106template std::map<ITkPixelOnlineId, ITkPixLayout<uint16_t>> ITkPixelHitSortingTool::sortRDOHits<PixelRDO_Container>(const PixelRDO_Container* rdoContainer, const ITkPixelCablingData* cabling) const;
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_WARNING(x,...)
InDetRawDataContainer< InDetRawDataCollection< ITkPixelRDORawData > > ITkPixelRDO_Container
unsigned int uint
This is an Identifier helper class for the Pixel subdetector.
InDetRawDataContainer< InDetRawDataCollection< PixelRDORawData > > PixelRDO_Container
AthAlgTool(const std::string &type, const std::string &name, const IInterface *parent)
Constructor with parameters:
const ServiceHandle< StoreGateSvc > & detStore() const
static uint8_t chipID(const ITkPixelCabling::TransformType &t, const uint16_t &col, const uint16_t &row)
ServiceHandle< InDetDD::IPixelReadoutManager > m_pixelReadout
std::map< ITkPixelOnlineId, HitMap > sortRDOHits(const ContainerType *rdoContainer, const ITkPixelCablingData *cabling) const
ITkPixelHitSortingTool(const std::string &type, const std::string &name, const IInterface *parent)
const InDetDD::PixelDetectorManager * m_detManager
std::uint32_t sourceID() const
Return the rod/rob Id.
value_type get_compact() const
Get the compact id.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Class used to describe the design of a module (diode segmentation and readout scheme).
int rowsPerCircuit() const
Number of cell rows per circuit:
int numberOfCircuits() const
Total number of circuits:
int columnsPerCircuit() const
Number of cell columns per circuit:
Class to hold geometrical description of a silicon detector element.
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
static void chipToModuleInverseTransform(const TransformType &transform, const uint8_t &chipID, uint16_t &col, uint16_t &row)