ATLAS Offline Software
PixelReadoutManager.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #include "PixelReadoutManager.h"
6 
11 
12 // #define PIXEL_DEBUG
13 
14 namespace InDetDD
15 {
16 
18  ISvcLocator *svc)
19  : base_class(name, svc)
20 {
21 }
22 
23 
25 {
26  ATH_MSG_DEBUG("PixelReadoutManager::initialize()");
27 
28  ATH_CHECK(m_detStore.retrieve());
29  ATH_CHECK(m_detStore->retrieve(m_detManager, "Pixel"));
30  ATH_CHECK(m_detStore->retrieve(m_idHelper, "PixelID"));
31 
32  return StatusCode::SUCCESS;
33 }
34 
35 
37 {
38  const Identifier wafer_id = m_idHelper->wafer_id(id);
39  const SiDetectorElement *element = m_detManager->getDetectorElement(wafer_id);
40  const PixelModuleDesign *p_design = static_cast<const PixelModuleDesign *>(&element->design());
42  ATH_MSG_ERROR("RD53 readout technologies not supported!");
43  return PixelModuleType::NONE;
44  }
45 
47  if (m_idHelper->is_dbm(id)) {
48  return PixelModuleType::DBM;
49  }
50 
51  if (p_design->numberOfCircuits() == 2) {
53  }
54 
56  }
57 
59  if (std::abs(m_idHelper->barrel_ec(id)) == 0) {
61  }
62  if (std::abs(m_idHelper->barrel_ec(id)) == 2) {
64  }
65  }
66 
67  return PixelModuleType::NONE;
68 }
69 
70 
72 {
73  const Identifier wafer_id = m_idHelper->wafer_id(id);
74  Identifier diodeId = id;
75  Identifier offlineId = m_idHelper->wafer_id(diodeId);
76  int col = getColumn(diodeId, offlineId);
77  int row = getRow(diodeId, offlineId);
78 
79  const SiDetectorElement *element = m_detManager->getDetectorElement(wafer_id);
80  const PixelModuleDesign *p_design = static_cast<const PixelModuleDesign *>(&element->design());
82  ATH_MSG_ERROR("RD53 readout technologies not supported!");
84  }
85 
87  if (p_design->numberOfCircuits() == 2) { // IBL planar
88  if (col == 0 || col == p_design->columnsPerCircuit() - 1) { // column edge =0,79
89  return PixelDiodeType::LONG;
90  }
92  }
94  }
95 
97  if (col > 0 && col < p_design->columnsPerCircuit() - 1) {
98  if (row >= p_design->rowsPerCircuit() / 2 - 1 - 6 - 1 && row <= p_design->rowsPerCircuit() / 2 - 1) {
99  if ((row - (p_design->rowsPerCircuit() / 2 - 1 - 6) + 1) % 2 + 1 == 1) {
100  return PixelDiodeType::LONG;
101  }
102  if ((row - (p_design->rowsPerCircuit() / 2 - 1 - 6) + 1) % 2 + 1 == 2) {
103  return PixelDiodeType::GANGED;
104  }
105  }
106  return PixelDiodeType::NORMAL;
107  }
108 
109  if (col == 0 || col==p_design->columnsPerCircuit() - 1) {
110  if (row >= p_design->rowsPerCircuit() / 2 - 1 - 6 - 1) {
111  return PixelDiodeType::GANGED;
112  }
113  return PixelDiodeType::LONG;
114  }
115 
116  ATH_MSG_WARNING("Pixel Type : the col number should be 0-" << p_design->columnsPerCircuit() << ", not " <<col);
117  return PixelDiodeType::NORMAL;
118  }
119 
120  return PixelDiodeType::NORMAL;
121 }
122 
123 
125  uint32_t FE,
126  uint32_t row,
127  uint32_t column) const
128 {
129  return getPixelId(m_idHelper->wafer_id(offlineIdHash), FE, row, column);
130 }
131 
132 
134  uint32_t FE,
135  uint32_t row,
136  uint32_t column) const
137 {
138  const SiDetectorElement *element = m_detManager->getDetectorElement(offlineId);
139  const PixelModuleDesign *p_design = static_cast<const PixelModuleDesign *>(&element->design());
141  ATH_MSG_ERROR("RD53 readout technologies not supported!");
142  return {};
143  }
144 
145  unsigned int columnsPerFE = p_design->columnsPerCircuit();
146  unsigned int FEsPerHalfModule = p_design->numberOfCircuits();
147  unsigned int rowsPerFE = 0;
148  int column_row_offset = 0;
150  rowsPerFE = p_design->rowsPerCircuit();
151  column_row_offset = -1;
152  }
153  else if (p_design->getReadoutTechnology() == PixelReadoutTechnology::FEI3) {
154  rowsPerFE = p_design->rowsPerCircuit()/2+4; // normal + ganged
155  }
156 
157  // ---------------------
158  // Check input sanity
159  // ---------------------
160  // Identify the module type
161  PixelModuleType moduleType = getModuleType(offlineId);
162 
163  // Correct row, column
164  row = row + column_row_offset;
165  column = column + column_row_offset;
166 
167  if (row>=rowsPerFE || column>=columnsPerFE || FE>=((moduleType == PixelModuleType::IBL_PLANAR || moduleType == PixelModuleType::IBL_3D || moduleType == PixelModuleType::DBM) ? FEsPerHalfModule:2*FEsPerHalfModule)) {
168  ATH_MSG_DEBUG("Illegal pixel requested OfflineID: " << std::hex << offlineId << std::dec << " FE: " << FE << " row: " << row << " column: " << column);
169  ATH_MSG_DEBUG("Limits are: FE < " << ((moduleType == PixelModuleType::IBL_PLANAR || moduleType == PixelModuleType::IBL_3D || moduleType == PixelModuleType::DBM) ? FEsPerHalfModule : 2*FEsPerHalfModule) << ", row < " << rowsPerFE << ", column < " << columnsPerFE);
170  return {}; // illegal Identifier, standardized for PixelRodDecoder
171  }
172 
173  // ---------------------
174  // Convert row/column to eta/phi indices
175  // ---------------------
176  unsigned int phi_index, eta_index;
177  switch (moduleType)
178  {
180  eta_index = rowsPerFE-1-row;
181  if (m_idHelper->barrel_ec(offlineId)>0) { // A side (pos. eta)
182  phi_index = column;
183  }
184  else { // C side
185  phi_index = columnsPerFE-1-column;
186  }
187  break;
188 
190  phi_index = rowsPerFE-1-row;
191  eta_index = FE*columnsPerFE+column;
192  break;
193 
195  phi_index = rowsPerFE-1-row;
196  eta_index = FE*columnsPerFE+column;
197  break;
198 
199  default: // pixels
200  if (FE<FEsPerHalfModule) {
201  phi_index = ((2*rowsPerFE)-1)-row;
202  eta_index = ((columnsPerFE*FEsPerHalfModule)-1)-(column+(FE*columnsPerFE));
203  }
204  else {
205  phi_index = row;
206  eta_index = ((FE-FEsPerHalfModule)*columnsPerFE)+column;
207  }
208  if (moduleType == PixelModuleType::PIX_ENDCAP) {
209  // Swap phi_index for even endcap modules
210  if ((m_idHelper->phi_module(offlineId))%2==0) {
211  phi_index = 2*rowsPerFE-phi_index-1;
212  ATH_MSG_DEBUG("Even disk module found, phi module: " << m_idHelper->phi_module(offlineId) << " swapped phi index to : " << phi_index);
213  }
214  }
215  break;
216  }
217 
218  Identifier diodeId = m_idHelper->pixel_id(offlineId, phi_index, eta_index);
219 
220 #ifdef PIXEL_DEBUG
221  unsigned int eta_index_max = m_idHelper->eta_index_max(offlineId);
222  unsigned int phi_index_max = m_idHelper->phi_index_max(offlineId);
223  if (eta_index>eta_index_max) {
224  ATH_MSG_DEBUG("Error! eta_index: " << eta_index << " > eta_index_max: " << eta_index_max);
225  }
226  if (phi_index>phi_index_max) {
227  ATH_MSG_DEBUG("Error! phi_index: " << phi_index << " > phi_index_max: " << phi_index_max);
228  }
229  //consistency check - to be removed to speed up
230  uint32_t check_FE = getFE(diodeId, offlineId);
231  uint32_t check_row = getRow(diodeId, offlineId) + column_row_offset;
232  uint32_t check_column = getColumn(diodeId, offlineId) + column_row_offset;
233  if (check_FE!=FE || check_row!=row || check_column!=column) {
234  ATH_MSG_WARNING("identify OfflineID: 0x" << std::hex << offlineId << std::dec << " FE: " << FE << " row: " << row << " column: " << column << " unequal to:");
235  ATH_MSG_WARNING("identify PixelID: 0x" << std::hex << diodeId << std::dec << " FE: " << check_FE << " row: " << check_row << " column: " << check_column);
236  }
237 #endif
238 
239  return diodeId;
240 }
241 
242 
244  Identifier offlineId) const
245 {
246  const SiDetectorElement *element = m_detManager->getDetectorElement(offlineId);
247  const PixelModuleDesign *p_design = static_cast<const PixelModuleDesign *>(&element->design());
249  ATH_MSG_ERROR("RD53 readout technologies not supported!");
250  return 0xffffffff;
251  }
252 
253  unsigned int columnsPerFE = p_design->columnsPerCircuit();
254  unsigned int FEsPerHalfModule = p_design->numberOfCircuits();
255  unsigned int rowsPerFE = 0;
257  rowsPerFE = p_design->rowsPerCircuit();
258  }
259  else if (p_design->getReadoutTechnology() == PixelReadoutTechnology::FEI3) {
260  rowsPerFE = p_design->rowsPerCircuit()/2+4; // normal + ganged
261  }
262 
263  // ---------------------
264  // Set module properties
265  // ---------------------
266  PixelModuleType moduleType = getModuleType(offlineId);
267  unsigned int FE;
268  unsigned int phi_index = m_idHelper->phi_index(diodeId);
269  int eta_index = m_idHelper->eta_index(diodeId);
270 
271  switch (moduleType)
272  {
274  FE = 0; // simple as that
275  return FE;
276  break;
277 
279  // Swap phi_index for even endcap modules
280  if ((m_idHelper->phi_module(offlineId))%2==0) {
281  phi_index = 2*rowsPerFE-phi_index-1;
282  }
283  break;
284 
285  default: // PIX_BARREL + IBL
286  break;
287  }
288 
289 
290  // ---------------------
291  // Compute FE number
292  // ---------------------
293  if (phi_index>=rowsPerFE) {
294  FE = (int)((FEsPerHalfModule-1)-(eta_index/columnsPerFE));
295  }
296  else {
297  FE = (int)(eta_index/columnsPerFE)+FEsPerHalfModule;
298  }
299 
300  // For IBL, the above returns FE number in range [2,3] (planar), or [1] (3D sensors).
301  // Change that to be [0,1] (planar) and [0] (3D) for consistency
302  if (moduleType == PixelModuleType::IBL_PLANAR || moduleType == PixelModuleType::IBL_3D) { FE = FE - FEsPerHalfModule; }
303 
304  return FE;
305 }
306 
307 
309  Identifier offlineId) const
310 {
311  const SiDetectorElement *element = m_detManager->getDetectorElement(offlineId);
312  const PixelModuleDesign *p_design = static_cast<const PixelModuleDesign *>(&element->design());
314  ATH_MSG_ERROR("RD53 readout technologies not supported!");
315  return 0xffffffff;
316  }
317 
318  unsigned int columnsPerFE = p_design->columnsPerCircuit();
319  unsigned int rowsPerFE = 0;
320  int column_offset = 0;
322  rowsPerFE = p_design->rowsPerCircuit();
323  column_offset = 1;
324  }
325  else if (p_design->getReadoutTechnology() == PixelReadoutTechnology::FEI3) {
326  rowsPerFE = p_design->rowsPerCircuit()/2+4; // normal + ganged
327  }
328 
329  PixelModuleType moduleType = getModuleType(offlineId);
330 
331  unsigned int phi_index = m_idHelper->phi_index(diodeId);
332  int eta_index = m_idHelper->eta_index(diodeId);
333 
334  // ---------------------
335  // Set module properties
336  // ---------------------
337  switch (moduleType)
338  {
340  break;
341 
343  // Swap phi_index for even endcap modules
344  if ((m_idHelper->phi_module(offlineId))%2==0) {
345  phi_index = 2*rowsPerFE-phi_index-1;
346  }
347  break;
348 
349  default: // PIX_BARREL + IBL
350  break;
351  }
352 
353  // ---------------------
354  // Convert eta index to column number
355  // ---------------------
356  int column{};
357  // DBM (column <-> phi_index)
358  if (moduleType == PixelModuleType::DBM) {
359  if (m_idHelper->barrel_ec(offlineId)>0) {
360  column = m_idHelper->phi_index(diodeId); // A side
361  }
362  else {
363  column = columnsPerFE-m_idHelper->phi_index(diodeId)-1; // C side
364  }
365  }
366  // Pixels, IBL
367  else {
368  if ((phi_index>=rowsPerFE)) {
369  column = (columnsPerFE-1)-(eta_index%columnsPerFE);
370  }
371  else {
372  column = eta_index%columnsPerFE;
373  }
374  }
375 
376  // ---------------------
377  // Check output sanity
378  // ---------------------
379  if (column >= (int)columnsPerFE) {
380  ATH_MSG_ERROR("Computed column number exceeds maximum value: col = " << column + column_offset << " (max = " << columnsPerFE << ")");
381  return 0xffffffff;
382  }
383 
384  return column + column_offset;
385 }
386 
387 
389  Identifier offlineId) const
390 {
391  const SiDetectorElement *element = m_detManager->getDetectorElement(offlineId);
392  const PixelModuleDesign *p_design = static_cast<const PixelModuleDesign *>(&element->design());
394  ATH_MSG_ERROR("RD53 readout technologies not supported!");
395  return 0xffffffff;
396  }
397 
398  unsigned int rowsPerFE = 0;
399  int row_offset = 0;
401  rowsPerFE = p_design->rowsPerCircuit();
402  row_offset = 1;
403  }
404  else if (p_design->getReadoutTechnology() == PixelReadoutTechnology::FEI3) {
405  rowsPerFE = p_design->rowsPerCircuit()/2+4; // normal + ganged
406  }
407 
408  PixelModuleType moduleType = getModuleType(offlineId);
409 
410  unsigned int phi_index = m_idHelper->phi_index(diodeId);
411 
412  // ---------------------
413  // Set module properties
414  // ---------------------
415  switch (moduleType)
416  {
418  break;
419 
421  // Swap phi_index for even endcap modules
422  if ((m_idHelper->phi_module(offlineId))%2==0) {
423  phi_index = 2*rowsPerFE-phi_index-1;
424  }
425  break;
426 
427  default: // PIX_BARREL + IBL
428  break;
429  }
430 
431  // ---------------------
432  // Convert phi index to row number
433  // ---------------------
434  int row{};
435  switch (moduleType)
436  {
438  // Row <-> eta_index
439  row = rowsPerFE-m_idHelper->eta_index(diodeId)-1;
440  break;
441 
443  row = rowsPerFE-1-phi_index;
444  break;
445 
447  row = rowsPerFE-1-phi_index;
448  break;
449 
450  default: // Pixels
451  if (phi_index>=rowsPerFE) {
452  row = ((2*rowsPerFE)-1)-phi_index;
453  }
454  else {
455  row = phi_index;
456  }
457  break;
458  }
459 
460  // ---------------------
461  // Check output sanity
462  // ---------------------
463  if (row >= (int)rowsPerFE) {
464  ATH_MSG_ERROR("Computed row number exceeds maximum value: row = " << row + row_offset << "(max = " << rowsPerFE << ")");
465  return 0xffffffff;
466  }
467  return row + row_offset;
468 }
469 
470 } // namespace InDetDD
PixelID.h
This is an Identifier helper class for the Pixel subdetector. This class is a factory for creating co...
query_example.row
row
Definition: query_example.py:24
PixelID::phi_index
int phi_index(const Identifier &id) const
Definition: PixelID.h:658
InDetDD::PixelReadoutManager::m_detStore
ServiceHandle< StoreGateSvc > m_detStore
Definition: PixelReadoutManager.h:46
InDetDD::PixelModuleDesign
Definition: PixelModuleDesign.h:48
InDetDD::PixelModuleType::DBM
@ DBM
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
InDetDD::PixelReadoutManager::getPixelId
virtual Identifier getPixelId(Identifier offlineId, uint32_t FE, uint32_t row, uint32_t column) const override final
Definition: PixelReadoutManager.cxx:133
PixelID::barrel_ec
int barrel_ec(const Identifier &id) const
Values of different levels (failure returns 0)
Definition: PixelID.h:619
InDetDD::PixelDiodeType
PixelDiodeType
Definition: PixelReadoutDefinitions.h:20
DeMoUpdate.column
dictionary column
Definition: DeMoUpdate.py:1110
InDetDD::PixelReadoutTechnology::FEI3
@ FEI3
InDetDD::PixelDiodeType::GANGED
@ GANGED
PixelID::wafer_id
Identifier wafer_id(int barrel_ec, int layer_disk, int phi_module, int eta_module) const
For a single crystal.
Definition: PixelID.h:364
InDetDD::PixelReadoutTechnology::RD53
@ RD53
PixelReadoutManager.h
InDetDD::PixelModuleType::NONE
@ NONE
PixelDetectorManager.h
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
InDetDD::PixelDiodeType::LONG
@ LONG
PixelID::phi_index_max
int phi_index_max(const Identifier &id) const
Definition: PixelID.cxx:143
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
PixelID::eta_index_max
int eta_index_max(const Identifier &id) const
Definition: PixelID.cxx:162
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
InDetDD::PixelModuleDesign::numberOfCircuits
int numberOfCircuits() const
Total number of circuits:
Definition: PixelModuleDesign.h:297
PixelID::eta_index
int eta_index(const Identifier &id) const
Definition: PixelID.h:664
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
InDetDD::PixelModuleType
PixelModuleType
Definition: PixelReadoutDefinitions.h:11
Handler::svc
AthROOTErrorHandlerSvc * svc
Definition: AthROOTErrorHandlerSvc.cxx:10
createCablingJSON.eta_index
int eta_index
Definition: createCablingJSON.py:9
InDetDD::PixelReadoutManager::PixelReadoutManager
PixelReadoutManager(const std::string &name, ISvcLocator *svc)
Definition: PixelReadoutManager.cxx:17
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:191
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
InDetDD::PixelReadoutManager::getFE
virtual uint32_t getFE(Identifier diodeId, Identifier offlineId) const override final
Definition: PixelReadoutManager.cxx:243
InDetDD::PixelReadoutManager::getRow
virtual uint32_t getRow(Identifier diodeId, Identifier offlineId) const override final
Definition: PixelReadoutManager.cxx:388
InDetDD::SiDetectorElement
Definition: SiDetectorElement.h:109
InDetDD::PixelReadoutTechnology::FEI4
@ FEI4
InDetDD::PixelModuleDesign::getReadoutTechnology
PixelReadoutTechnology getReadoutTechnology() const
Definition: PixelModuleDesign.h:368
query_example.col
col
Definition: query_example.py:7
InDetDD::PixelModuleType::IBL_PLANAR
@ IBL_PLANAR
SiDetectorElement.h
PixelID::is_dbm
bool is_dbm(const Identifier &id) const
Test for dbm - WARNING: id MUST be pixel id, otherwise answer is not accurate. Use SiliconID for gene...
Definition: PixelID.h:612
InDetDD::PixelReadoutManager::getPixelIdfromHash
virtual Identifier getPixelIdfromHash(IdentifierHash offlineIdHash, uint32_t FE, uint32_t row, uint32_t column) const override final
Definition: PixelReadoutManager.cxx:124
InDetDD::PixelModuleType::PIX_ENDCAP
@ PIX_ENDCAP
InDetDD::PixelModuleDesign::rowsPerCircuit
int rowsPerCircuit() const
Number of cell rows per circuit:
Definition: PixelModuleDesign.h:317
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition: AthMsgStreamMacros.h:32
InDetDD
Message Stream Member.
Definition: FakeTrackBuilder.h:8
PixelModuleDesign.h
InDetDD::PixelReadoutManager::getColumn
virtual uint32_t getColumn(Identifier diodeId, Identifier offlineId) const override final
Definition: PixelReadoutManager.cxx:308
InDetDD::PixelReadoutManager::m_detManager
const PixelDetectorManager * m_detManager
Definition: PixelReadoutManager.h:47
InDetDD::PixelReadoutManager::m_idHelper
const PixelID * m_idHelper
Definition: PixelReadoutManager.h:48
PixelID::pixel_id
Identifier pixel_id(int barrel_ec, int layer_disk, int phi_module, int eta_module, int phi_index, int eta_index) const
For an individual pixel.
Definition: PixelID.h:432
InDetDD::PixelReadoutManager::getModuleType
virtual PixelModuleType getModuleType(Identifier id) const override final
Definition: PixelReadoutManager.cxx:36
InDetDD::PixelDiodeType::NORMAL
@ NORMAL
InDetDD::PixelReadoutManager::getDiodeType
virtual PixelDiodeType getDiodeType(Identifier id) const override final
Definition: PixelReadoutManager.cxx:71
IdentifierHash
Definition: IdentifierHash.h:38
InDetDD::PixelModuleType::PIX_BARREL
@ PIX_BARREL
InDetDD::SiDetectorElement::design
virtual const SiDetectorDesign & design() const override final
access to the local description (inline):
PixelID::phi_module
int phi_module(const Identifier &id) const
Definition: PixelID.h:644
InDetDD::PixelModuleType::IBL_3D
@ IBL_3D
InDetDD::PixelModuleDesign::columnsPerCircuit
int columnsPerCircuit() const
Number of cell columns per circuit:
Definition: PixelModuleDesign.h:312
InDetDD::PixelReadoutManager::initialize
virtual StatusCode initialize() override final
Definition: PixelReadoutManager.cxx:24
InDetDD::PixelDetectorManager::getDetectorElement
virtual SiDetectorElement * getDetectorElement(const Identifier &id) const override
access to individual elements : via Identifier
Definition: PixelDetectorManager.cxx:80