17 std::shared_ptr<PixelDiodeMatrix> ptr = std::make_shared<Helper>();
39 std::shared_ptr<const PixelDiodeMatrix> lowerCell,
40 std::shared_ptr<const PixelDiodeMatrix> middleCells,
42 std::shared_ptr<const PixelDiodeMatrix> upperCell)
45 std::shared_ptr<PixelDiodeMatrix> ptr = std::make_shared<Helper>();
46 ptr->initialize(direction,
48 std::move(middleCells),
50 std::move(upperCell));
55 std::shared_ptr<const PixelDiodeMatrix> lowerCell,
56 std::shared_ptr<const PixelDiodeMatrix> middleCells,
58 std::shared_ptr<const PixelDiodeMatrix> upperCell)
160 double relPosDir = 0;
163 double pitchInverse = 0;
168 relPosDir = relPosition[
distPhi];
174 if (relPosDir < m_lowerCell->
phiWidth()) {
175 return m_lowerCell->cellIdOfPosition(relPosition, cellId);
183 relPosDir = relPosition[
distEta];
189 if (relPosDir < m_lowerCell->
etaWidth()) {
190 return m_lowerCell->cellIdOfPosition(relPosition, cellId);
199 int index = relPosDir * pitchInverse;
216 relPosDir -=
index * pitch;
217 startIndex +=
index * middleCells;
220 int newPhiIndex = cellId.phiIndex();
221 int newEtaIndex = cellId.etaIndex();
226 newPhiIndex += startIndex;
232 newPhiIndex += startIndex + relId.
phiIndex();
237 newEtaIndex += startIndex;
244 newEtaIndex += startIndex + relId.
etaIndex();
248 cellId =
SiCellId(newPhiIndex, newEtaIndex);
276 -matrix->phiHalfWidth(),
277 -matrix->etaHalfWidth()
280 int rel_phi_index = cellId.
phiIndex();
281 int rel_eta_index = cellId.
etaIndex();
282 for( ;!matrix->m_singleCell; ) {
286 int nMiddleCells = 0;
288 const auto direction = matrix->m_direction;
292 relIndex = rel_phi_index;
296 if (relIndex < lowerCell->
phiCells()) {
307 nMiddleCells = middleCells->
phiCells();
311 relIndex = rel_eta_index;
314 if (relIndex < lowerCell->
etaCells()) {
325 nMiddleCells = middleCells->
etaCells();
329 int index = std::min(relIndex / nMiddleCells,matrix->m_numCells);
330 relIndex -=
index * nMiddleCells;
331 startPos +=
index * pitch;
333 matrix = (matrix->m_upperCell &&
index == matrix->m_numCells ) ? matrix->m_upperCell.get() : matrix->m_middleCells.get();
336 rel_phi_index = relIndex;
339 rel_eta_index = relIndex;
343 position[
distPhi] += matrix->phiHalfWidth();
344 position[
distEta] += matrix->etaHalfWidth();
345 dest_position = position;
352 std::string prefix(level,
' ');
356 std::string cellSize =
"";
357 cellSize += prefix +
"phi: " + std::to_string(
m_phiWidth) +
"\n";
358 cellSize += prefix +
"eta: " + std::to_string(
m_etaWidth) +
"\n";
362 std::string cellContent =
"";
365 cellContent += prefix +
"completly empty (WARNING: there should always be at least one cell!)\n";
369 cellContent += prefix +
"direction: ";
372 else { cellContent +=
"unknown\n"; }
376 cellContent += prefix +
"lowerCell: \n";
377 cellContent +=
m_lowerCell->createDebugStringRepr(level + 1);
380 cellContent += prefix +
"middleCells: " + std::to_string(
m_numCells) +
"x :\n";
381 cellContent +=
m_middleCells->createDebugStringRepr(level + 1);
384 cellContent += prefix +
"upperCell: \n";
385 cellContent +=
m_upperCell->createDebugStringRepr(level + 1);
Class used to describe the segmentation of the pixel and allow for conversion between cell id and pos...
std::shared_ptr< const PixelDiodeMatrix > m_upperCell
const PixelDiodeMatrix * cellIdOfPosition(const Amg::Vector2D &position, SiCellId &cellId) const
Return cell Id corresponding to a relative position within the matrix.
std::shared_ptr< const PixelDiodeMatrix > m_middleCells
std::string createDebugStringRepr() const
Create debug representation.
PixelDiodeMatrix()
Hidden constructor.
bool singleCell() const
Query wether the matrix is just a single cell.
void initialize(double phiWidth, double etaWidth)
Initialize for just a single cell.
static std::shared_ptr< const PixelDiodeMatrix > construct(double phiWidth, double etaWidth)
Construct method for just a single cell.
int phiCells() const
Number of cells in phi (x) direction.
int etaCells() const
Number of cells in eta (y) direction.
const PixelDiodeMatrix * positionOfCell(const SiCellId &cellId, Amg::Vector2D &position) const
Search diode matching the given cell id and compute its position.
double etaWidth() const
Width in eta (y) direction.
double phiWidth() const
Width in phi (x) direction.
std::shared_ptr< const PixelDiodeMatrix > m_lowerCell
Identifier for the strip or pixel cell.
int phiIndex() const
Get phi index. Equivalent to strip().
int etaIndex() const
Get eta index.
Eigen::Matrix< double, 2, 1 > Vector2D
@ distEta
readout for silicon
@ distEta
readout for silicon