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
20
21ITkPixelHitSortingTool::ITkPixelHitSortingTool(const std::string& type,const std::string& name,const IInterface* parent) :
22 AthAlgTool(type,name,parent)
23{
24 //not much to construct as of now
25}
26
27
29 ATH_CHECK(m_pixelReadout.retrieve());
30 ATH_CHECK(detStore()->retrieve(m_pixIdHelper, "PixelID"));
31 ATH_CHECK(detStore()->retrieve(m_detManager, "ITkPixel"));
32 return StatusCode::SUCCESS;
33}
34
35template<class ContainerType>
36std::map<ITkPixelOnlineId, ITkPixLayout<uint16_t>> ITkPixelHitSortingTool::sortRDOHits(const ContainerType* rdoContainer, const ITkPixelCablingData* cabling) const {
37
38 std::map<ITkPixelOnlineId, ITkPixLayout<uint16_t>> EventHitMaps;
39
40 for(const auto& RDO_Collection : *rdoContainer){
41
42 for(const auto *const rdo : *RDO_Collection) {
43
44 const Identifier rdoID = rdo->identify();
45 const Identifier waferID = m_pixIdHelper->wafer_id(rdoID);
46
47 const uint16_t tot = rdo->getToT();
48 const uint32_t chip = m_pixelReadout->getFE( rdoID, waferID);
49 uint32_t col = m_pixelReadout->getColumn( rdoID, waferID);
50 uint32_t row = m_pixelReadout->getRow( rdoID, waferID);
51
52 //find out if we're dealing with 25x100 sensors
53 const InDetDD::SiDetectorElement *element = m_detManager->getDetectorElement(waferID);
54 const InDetDD::PixelModuleDesign *p_design = static_cast<const InDetDD::PixelModuleDesign *>(&element->design());
55 const uint nChips = p_design->numberOfCircuits();
56 const uint rowsPerFE = p_design->rowsPerCircuit();
57 const uint colsPerFE = p_design->columnsPerCircuit();
58 bool is25x100 = rowsPerFE == 768 && colsPerFE == 200;
59 ATH_MSG_DEBUG("Module specs: nChips = " << nChips << ", rows per FE = " << rowsPerFE << " cols per FE = " << colsPerFE);
60
61 if (is25x100){
62 //The bonding pattern as understood at the time of writing this code is
63 //that odd sensor rows (with even indices if numbered from 0) are bonded to the left and even (= odd indices) to the right.
64 col = 2 * col + (row + 1)% 2;
65 row = row / 2;
66 ATH_MSG_DEBUG("Adding hit from 25x100 pixel");
67 }
68 else if (colsPerFE == 384 && rowsPerFE == 400){
69 //R0 EC modules are 90 degrees rotated, the readout manager doesn't know about it
70 std::swap(col, row);
71 ATH_MSG_DEBUG("Rotated chip - swapping col and row");
72 }
73
74 // Store ToT+1, reserve 0 for no hit.
75 // ITkPixelOnlineId onlineID = m_cablingHelper.onlineId(rdoID); To be used when cabling helper is implemented
76 // HitMap and encoder labels rows/cols from 0
77
78 //Extract the online 'base' from cabling. Last two bits are reserved
79 //for chip ID.
80 ITkPixelCabling::ModuleInfo mi = cabling->onlineModuleInfo(waferID);
81 //auto onlineID = (waferID.get_identifier32().get_compact() << 2 ) | chip;
82 auto onlineID = (uint32_t)mi.id | chip;
83
84 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");
85
86 EventHitMaps[onlineID](col, row) = tot + 1;
87
88 };
89 };
90
91 return EventHitMaps;
92
93}
94
95template std::map<ITkPixelOnlineId, ITkPixLayout<uint16_t>> ITkPixelHitSortingTool::sortRDOHits<ITkPixelRDO_Container>(const ITkPixelRDO_Container* rdoContainer, const ITkPixelCablingData* cabling) const;
96template std::map<ITkPixelOnlineId, ITkPixLayout<uint16_t>> ITkPixelHitSortingTool::sortRDOHits<PixelRDO_Container>(const PixelRDO_Container* rdoContainer, const ITkPixelCablingData* cabling) const;
97/*
98template<class ContainerType, class RDOType>
99StatusCode ITkPixelHitSortingTool::createRDO(std::map<ITkPixelOnlineId, HitMap> &EventHitMaps, ContainerType *rdoContainer) const {
100 //this is VERY preliminary/experimental.
101 //Testing purposes only at this point, will certainly change.
102 //Using current ID inspiration, adapted so that no compilation
103 //warnings arise. All values are dummy and no functionality is expected
104 //at this point.
105
106 typedef InDetRawDataCollection< InDetRawData > PixelRawCollection;
107
108 for (const auto& entry : EventHitMaps) {
109
110 // Will have to conver onlineId to offlineIdHash, for now keeping it the same
111 // since we don't have cabling
112 const uint offlineIdHash = (uint)entry.first; // temp
113 PixelRawCollection* coll = new PixelRawCollection (offlineIdHash);
114
115 ATH_CHECK( rdoContainer->fetchOrCreate(offlineIdHash) );//Returns null if not present -- this was used in PixelRODDecoder but compiler says it's not thread safe
116
117 // get identifier from the hash, this is not nice
118 Identifier ident = m_pixIdHelper->wafer_id(offlineIdHash);
119 // set the Identifier to be nice to downstream clients
120 coll->setIdentifier(ident);
121
122 StatusCode sc = rdoContainer->addCollection(coll, offlineIdHash);
123 ATH_MSG_DEBUG("Adding " << offlineIdHash);
124 if (sc.isFailure()){
125 ATH_MSG_ERROR("failed to add Pixel RDO collection to container" );
126
127
128
129 const Identifier pixelId;
130 const unsigned int mToT = 0xFFFF;
131 const unsigned int mBCID = 0xFFFF;
132 const unsigned int mLVL1ID = 0xFFFF;
133 const unsigned int mLVL1A = 0xFFFF;
134
135 coll->push_back(new RDOType(pixelId, mToT, mBCID, mLVL1ID, mLVL1A));
136 }
137 }
138 return StatusCode::SUCCESS;
139}
140
141template StatusCode ITkPixelHitSortingTool::createRDO<ITkPixelRDO_Container, ITkPixel1RawData>(std::map<ITkPixelOnlineId, HitMap> &EventHitMaps, ITkPixelRDO_Container *rdoContainer) const;
142template StatusCode ITkPixelHitSortingTool::createRDO<PixelRDO_Container, Pixel1RawData>(std::map<ITkPixelOnlineId, HitMap> &EventHitMaps, PixelRDO_Container *rdoContainer) const;
143*/
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(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
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)