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 //This part will see changes. The PixelReadoutManager will be
49 //retired, and the chip <-> module translation will happen likely
50 //in PixelModuleDesign. Also, figuring out whether we're dealing
51 //with 25x100 or R0 modules can be greatly simplified.
52 //---------->
53 const uint32_t chip = m_pixelReadout->getFE( rdoID, waferID);
54 uint32_t col = m_pixelReadout->getColumn( rdoID, waferID);
55 uint32_t row = m_pixelReadout->getRow( rdoID, waferID);
56
57 //find out if we're dealing with 25x100 sensors
58 const InDetDD::SiDetectorElement *element = m_detManager->getDetectorElement(waferID);
59 const InDetDD::PixelModuleDesign *p_design = static_cast<const InDetDD::PixelModuleDesign *>(&element->design());
60 const uint nChips = p_design->numberOfCircuits();
61 const uint rowsPerFE = p_design->rowsPerCircuit();
62 const uint colsPerFE = p_design->columnsPerCircuit();
63 bool is25x100 = rowsPerFE == 768 && colsPerFE == 200;
64 ATH_MSG_DEBUG("Module specs: nChips = " << nChips << ", rows per FE = " << rowsPerFE << " cols per FE = " << colsPerFE);
65 //<----------
66
67 if (is25x100){
68 //The bonding pattern as understood at the time of writing this code is
69 //that odd sensor rows (with even indices if numbered from 0) are bonded to the left and even (= odd indices) to the right.
70 col = 2 * col + (row + 1)% 2;
71 row = row / 2;
72 ATH_MSG_DEBUG("Adding hit from 25x100 pixel");
73 }
74 else if (colsPerFE == 384 && rowsPerFE == 400){
75 //R0 EC modules are 90 degrees rotated, the readout manager doesn't know about it
76 std::swap(col, row);
77 ATH_MSG_DEBUG("Rotated chip - swapping col and row");
78 }
79
80 //Store ToT+1, reserve 0 for no hit.
81 //HitMap and encoder labels rows/cols from 0
82
83 //Data from a FE are identified by "DetectorResourceID", which is part
84 //of the header delimiting individual FE payloads within a ROD fragment
85 //payload. The DetectorResourceID is detector-defined. For pixels, it
86 //has an 'online part', containing chipID and information useful for decoding
87 //(chipID on/off). Then there's an offline-specific part
88 //composed - for convenience - of (offline) module ID. We can mask out
89 //the auxiliary online info to get the mapping from FE -> online ID
90 // offlineDetectorResourceID = chipID [2 MSB] | module ID [24 LSB]
91 //Furthermore, we need to know which ROB fragment the data will go to,
92 //hence we need the 'sourceID' (in eformat vocabulary), which identifies
93 //the DMA buffer on the FELIX machine that received the data. This is
94 //all provided by the cabling package, which gives
95 // offlineDetectorResourceID -> {DetectorResourceID, sourceID}
96 //mapping.
97
98 //ITkPixelCabling::ModuleInfo mi = cabling->onlineModuleInfo(waferID);
99 uint32_t offlineDetectorResourceID = (waferID.get_identifier32().get_compact() >> 8) | (chip << 30);
100
101 ITkPixelOnlineId onlineID = cabling->onlineId(offlineDetectorResourceID);
102
103 //Found a valid ID?
104 if (onlineID.sourceID() == 0xFFFFFFFF){
105 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");
106 onlineID = ITkPixelOnlineId(0x00170000 | (offlineDetectorResourceID & 0x0000FFFF), offlineDetectorResourceID | 0xF0000000);
107 }
108
109 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");
110
111 EventHitMaps[onlineID](col, row) = tot + 1;
112
113 };
114 };
115
116 return EventHitMaps;
117
118}
119
120template std::map<ITkPixelOnlineId, ITkPixLayout<uint16_t>> ITkPixelHitSortingTool::sortRDOHits<ITkPixelRDO_Container>(const ITkPixelRDO_Container* rdoContainer, const ITkPixelCablingData* cabling) const;
121template 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
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.
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):
void swap(ElementLinkVector< DOBJ > &lhs, ElementLinkVector< DOBJ > &rhs)