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;
166 if (m_direction == phiDir) {
168 relPosDir = relPosition[
distPhi];
169 pitch = m_middleCells->phiWidth();
170 pitchInverse = m_middleCells->phiWidthInverse();
171 middleCells = m_middleCells->phiCells();
174 if (relPosDir < m_lowerCell->
phiWidth()) {
175 return m_lowerCell->cellIdOfPosition(relPosition, cellId);
177 relPosDir -= m_lowerCell->phiWidth();
178 startIndex += m_lowerCell->phiCells();
183 relPosDir = relPosition[
distEta];
184 pitch = m_middleCells->etaWidth();
185 pitchInverse = m_middleCells->etaWidthInverse();
186 middleCells = m_middleCells->etaCells();
189 if (relPosDir < m_lowerCell->etaWidth()) {
190 return m_lowerCell->cellIdOfPosition(relPosition, cellId);
192 relPosDir -= m_lowerCell->etaWidth();
193 startIndex += m_lowerCell->etaCells();
199 int index = relPosDir * pitchInverse;
203 bool outOfBounds =
index >= m_numCells;
204 if (m_upperCell !=
nullptr && outOfBounds) {
207 nextCell = m_upperCell.get();
211 if (outOfBounds)
index = m_numCells - 1;
212 nextCell = m_middleCells.get();
216 relPosDir -=
index * pitch;
217 startIndex +=
index * middleCells;
220 int newPhiIndex = cellId.phiIndex();
221 int newEtaIndex = cellId.etaIndex();
224 if (m_direction == phiDir) {
225 if (nextCell->singleCell()) {
226 newPhiIndex += startIndex;
231 cell = nextCell->cellIdOfPosition(newRelPos, relId);
232 newPhiIndex += startIndex + relId.
phiIndex();
236 if (nextCell->singleCell()) {
237 newEtaIndex += startIndex;
242 cell = nextCell->cellIdOfPosition(newRelPos, relId);
244 newEtaIndex += startIndex + relId.
etaIndex();
248 cellId =
SiCellId(newPhiIndex, newEtaIndex);
277 position[
distPhi] += 0.5*m_phiWidth;
278 position[
distEta] += 0.5*m_etaWidth;
287 if (m_direction == phiDir) {
289 relIndex = cellId.phiIndex();
290 pitch = m_middleCells->phiWidth();
291 middleCells = m_middleCells->phiCells();
294 if (relIndex < m_lowerCell->phiCells()) {
295 return m_lowerCell->positionOfCell(cellId, position);
297 relIndex -= m_lowerCell->phiCells();
298 startPos += m_lowerCell->phiWidth();
304 relIndex = cellId.etaIndex();
305 pitch = m_middleCells->etaWidth();
306 middleCells = m_middleCells->etaCells();
309 if (relIndex < m_lowerCell->etaCells()) {
310 return m_lowerCell->positionOfCell(cellId, position);
312 relIndex -= m_lowerCell->etaCells();
313 startPos += m_lowerCell->etaWidth();
318 int index = relIndex / middleCells;
320 relIndex -=
index * middleCells;
321 startPos +=
index * pitch;
324 if (m_upperCell && (
index == m_numCells)) {
326 nextCell = m_upperCell.get();
329 nextCell = m_middleCells.get();
333 if (m_direction == phiDir) {
334 SiCellId relId(relIndex,cellId.etaIndex());
336 cell = nextCell->positionOfCell(relId, position);
338 SiCellId relId(cellId.phiIndex(),relIndex);
340 cell = nextCell->positionOfCell(relId, position);
353 std::string cellSize =
"";
359 std::string cellContent =
"";
362 cellContent +=
prefix +
"completly empty (WARNING: there should always be at least one cell!)\n";
366 cellContent +=
prefix +
"direction: ";
369 else { cellContent +=
"unknown\n"; }
373 cellContent +=
prefix +
"lowerCell: \n";
381 cellContent +=
prefix +
"upperCell: \n";