From 4b9c31e4ccc56c6cd351d88628a31551676e54dc Mon Sep 17 00:00:00 2001 From: Nicholas Styles <nicholas.styles@desy.de> Date: Thu, 19 Nov 2020 15:44:19 +0100 Subject: [PATCH] take readout classes from base package --- .../ReadoutGeometryBase/PixelDiodeMap.h | 7 +- .../ReadoutGeometryBase/PixelDiodeMatrix.h | 72 ++-- .../PixelMultipleConnection1D.h | 2 +- .../ReadoutGeometryBase/src/PixelDiodeMap.cxx | 10 +- .../src/PixelDiodeMatrix.cxx | 155 ++++---- .../PixelGeoModel/src/DBM_Module.cxx | 2 +- .../PixelGeoModel/src/GeoPixelSiCrystal.cxx | 2 +- .../PixelGeoModel/src/PixelDetectorDC1DC2.cxx | 2 +- .../PixelReadoutGeometry/PixelDiodeMap.h | 196 ---------- .../PixelReadoutGeometry/PixelDiodeMatrix.h | 202 ----------- .../PixelReadoutGeometry/PixelModuleDesign.h | 12 +- .../PixelMultipleConnection1D.h | 128 ------- .../PixelReadoutGeometry/PixelReadoutScheme.h | 157 -------- .../src/PixelDiodeMap.cxx | 297 --------------- .../src/PixelDiodeMatrix.cxx | 338 ------------------ .../src/PixelMultipleConnection1D.cxx | 141 -------- .../src/PixelReadoutScheme.cxx | 104 ------ 17 files changed, 122 insertions(+), 1705 deletions(-) delete mode 100755 InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelDiodeMap.h delete mode 100755 InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelDiodeMatrix.h delete mode 100755 InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelMultipleConnection1D.h delete mode 100755 InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelReadoutScheme.h delete mode 100755 InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelDiodeMap.cxx delete mode 100755 InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelDiodeMatrix.cxx delete mode 100755 InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelMultipleConnection1D.cxx delete mode 100755 InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelReadoutScheme.cxx diff --git a/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelDiodeMap.h b/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelDiodeMap.h index 6b197bc511f..db9eb4d2bfb 100755 --- a/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelDiodeMap.h +++ b/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelDiodeMap.h @@ -12,8 +12,9 @@ #define READOUTGEOMETRYBASE_PIXELDIODEMAP_H // STL classes -#include <vector> #include <list> +#include <memory> +#include <vector> // Data member classes #include "ReadoutGeometryBase/PixelDiodeMatrix.h" @@ -44,7 +45,7 @@ class PixelDiodeMatrix; public: /** Constructor from Diode matrix description */ - PixelDiodeMap(const PixelDiodeMatrix * diodeMatrix); + PixelDiodeMap(std::shared_ptr<const PixelDiodeMatrix> diodeMatrix); /** Copy constructor: */ PixelDiodeMap(const PixelDiodeMap &map); @@ -129,7 +130,7 @@ class PixelDiodeMatrix; // Private data: /////////////////////////////////////////////////////////////////// private: - const PixelDiodeMatrix * m_matrix; //!< diode matrix + std::shared_ptr<const PixelDiodeMatrix> m_matrix; //!< diode matrix bool m_generalLayout; //!< Flag set to allow for dealing wth more general layouts. }; diff --git a/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelDiodeMatrix.h b/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelDiodeMatrix.h index ef7b7d08bf1..ad7c44ae4af 100755 --- a/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelDiodeMatrix.h +++ b/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelDiodeMatrix.h @@ -5,16 +5,16 @@ /////////////////////////////////////////////////////////////////// // PixelDiodeMatrix.h /////////////////////////////////////////////////////////////////// -// (c) ATLAS Detector software -/////////////////////////////////////////////////////////////////// #ifndef READOUTGEOMETRYBASE_PIXELDIODEMATRIX_H #define READOUTGEOMETRYBASE_PIXELDIODEMATRIX_H #include "ReadoutGeometryBase/SiCellId.h" -#include "GeoModelKernel/RCBase.h" +#include "GeoPrimitives/GeoPrimitives.h" #include "TrkDetElementBase/TrkDetElementBase.h" +#include <memory> + namespace InDetDD { /** @class PixelDiodeMatrix @@ -77,6 +77,10 @@ namespace InDetDD { no range check in these methods. The methods are called from PixelDiodeMap where it first checks that is within range of the top level cell (refered to as the top level matrix). + + PixelDiodeMatrix might inherit std::shared_ptr but needs to return std::shared_ptr of this pointer. + To do this, std::enable_shared_from_this and shared_from_this() have to be used. + https://en.cppreference.com/w/cpp/memory/enable_shared_from_this See the description of these methods for more details. @@ -86,41 +90,41 @@ namespace InDetDD { - modified & maintained: Nick Styles, Andreas Salzburger **/ - class PixelDiodeMatrix: public RCBase { + class PixelDiodeMatrix : public std::enable_shared_from_this<PixelDiodeMatrix> { public: enum Direction {phiDir, etaDir}; - /// Constructor for just a single cell. - PixelDiodeMatrix(double phiWidth, double etaWidth); + /// Destructor + ~PixelDiodeMatrix() = default; - /** Constructor with multiple matrices. + /// Construct method for just a single cell. + static std::shared_ptr<const PixelDiodeMatrix> construct(double phiWidth, double etaWidth); + + /** Construct method with multiple matrices. There may be zero or one lower matrix (pointer can be 0). Multiple (numCells) middle matrics (must pass a non zero pointer). There may be zero or one upper matrix (pointer can be 0). These must all have the same width and cells in the non replicating direction. */ - PixelDiodeMatrix(Direction direction, // phi or eta - const PixelDiodeMatrix * lowerCell, - const PixelDiodeMatrix * middleCells, - int numCells, - const PixelDiodeMatrix * upperCells); - - /// Destructor - ~PixelDiodeMatrix(); - + static std::shared_ptr<const PixelDiodeMatrix> construct(Direction direction, // phi or eta + std::shared_ptr<const PixelDiodeMatrix> lowerCell, + std::shared_ptr<const PixelDiodeMatrix> middleCells, + int numCells, + std::shared_ptr<const PixelDiodeMatrix> upperCells); + /** Return cell Id corresponding to a relative position within the matrix. The cellId is modified and returns the id relative to the passed cellId. That is, it adds the relative cellId to the cellId passed to the function. A pointer to the correspond cell is returned. This can be used to get the size of the cell. */ - const PixelDiodeMatrix * cellIdOfPosition(const Amg::Vector2D & position, SiCellId & cellId) const; + std::shared_ptr<const PixelDiodeMatrix> cellIdOfPosition(const Amg::Vector2D & position, SiCellId & cellId) const; /** Return position correspong to cell with relative id withing the matrix. Returns the relative position added to the position passed in. A pointer to the correspond cell is returned. This can be used to get the size of the cell. */ - const PixelDiodeMatrix * positionOfCell(const SiCellId & cellId, Amg::Vector2D & position) const; + std::shared_ptr<const PixelDiodeMatrix> positionOfCell(const SiCellId & cellId, Amg::Vector2D & position) const; /** Width in phi (x) direction.*/ double phiWidth() const; @@ -136,21 +140,34 @@ namespace InDetDD { /** Query wether the matrix is just a single cell. Mainly for internal use. */ bool singleCell() const; - - /** Create a string representation for debugging purposes **/ - std::string createDebugStringRepr() const; private: - std::string createDebugStringRepr(unsigned int level) const; + /** Hidden constructor */ + PixelDiodeMatrix() {}; + + /// Initialize for just a single cell. + void initialize(double phiWidth, double etaWidth); + + /** Initialize for multiple matrices. + There may be zero or one lower matrix (pointer can be 0). + Multiple (numCells) middle matrics (must pass a non zero pointer). + There may be zero or one upper matrix (pointer can be 0). + These must all have the same width and cells in the non replicating direction. */ + void initialize(Direction direction, // phi or eta + std::shared_ptr<const PixelDiodeMatrix> lowerCell, + std::shared_ptr<const PixelDiodeMatrix> middleCells, + int numCells, + std::shared_ptr<const PixelDiodeMatrix> upperCells); + double m_phiWidth; double m_etaWidth; int m_phiCells; int m_etaCells; Direction m_direction; int m_numCells; // number of MiddleCells along m_direction direction. - const PixelDiodeMatrix * m_lowerCell; - const PixelDiodeMatrix * m_middleCells; - const PixelDiodeMatrix * m_upperCell; + std::shared_ptr<const PixelDiodeMatrix> m_lowerCell; + std::shared_ptr<const PixelDiodeMatrix> m_middleCells; + std::shared_ptr<const PixelDiodeMatrix> m_upperCell; bool m_singleCell; }; @@ -180,11 +197,6 @@ namespace InDetDD { return m_singleCell; } - inline std::string PixelDiodeMatrix::createDebugStringRepr() const - { - return this->createDebugStringRepr(0); - } - } // end namespace #endif //READOUTGEOMETRYBASE_PIXELDIODEMATRIX_H diff --git a/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelMultipleConnection1D.h b/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelMultipleConnection1D.h index 17a54c74ddc..16d66c8dd8b 100755 --- a/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelMultipleConnection1D.h +++ b/DetectorDescription/ReadoutGeometryBase/ReadoutGeometryBase/PixelMultipleConnection1D.h @@ -21,7 +21,7 @@ namespace InDetDD { Class used to handle connection of multiple diodes to the same readout cell @author: David Calvet - @modifed: Grant Gorfine, Andreas Salzburger + @note: modifed by Grant Gorfine, Andreas Salzburger */ class PixelMultipleConnection1D { diff --git a/DetectorDescription/ReadoutGeometryBase/src/PixelDiodeMap.cxx b/DetectorDescription/ReadoutGeometryBase/src/PixelDiodeMap.cxx index 0403ce6e927..85b10a1b1c2 100755 --- a/DetectorDescription/ReadoutGeometryBase/src/PixelDiodeMap.cxx +++ b/DetectorDescription/ReadoutGeometryBase/src/PixelDiodeMap.cxx @@ -24,16 +24,14 @@ namespace InDetDD { // Implicit constructor: -PixelDiodeMap::PixelDiodeMap(const PixelDiodeMatrix * matrix) : +PixelDiodeMap::PixelDiodeMap(std::shared_ptr<const PixelDiodeMatrix> matrix) : m_matrix(matrix), m_generalLayout(false) { - m_matrix->ref(); } PixelDiodeMap::~PixelDiodeMap() { - m_matrix->unref(); } @@ -59,10 +57,10 @@ PixelDiodeMap::~PixelDiodeMap() // The cellId returned will be added to this so we must start with 0,0. SiCellId cellId(0,0); - const PixelDiodeMatrix * cell = m_matrix->cellIdOfPosition(relativePos, cellId); + std::shared_ptr<const PixelDiodeMatrix> cell = m_matrix->cellIdOfPosition(relativePos, cellId); // return invalid Id if there was a problem (don't expect this to be the case). - if (!cell) { + if (cell==nullptr) { return SiCellId(); // Invalid id. } @@ -93,7 +91,7 @@ PixelDiodeMap::parameters(const SiCellId & cellId) const // Position is relative to left bottom corner. // Amg::Vector2D position(-halfWidth, -halfLength); - const PixelDiodeMatrix * cell = m_matrix->positionOfCell(cellId, position); + std::shared_ptr<const PixelDiodeMatrix> cell = m_matrix->positionOfCell(cellId, position); if (cell) { diff --git a/DetectorDescription/ReadoutGeometryBase/src/PixelDiodeMatrix.cxx b/DetectorDescription/ReadoutGeometryBase/src/PixelDiodeMatrix.cxx index 43fc3cf6842..fafba5f5ff1 100755 --- a/DetectorDescription/ReadoutGeometryBase/src/PixelDiodeMatrix.cxx +++ b/DetectorDescription/ReadoutGeometryBase/src/PixelDiodeMatrix.cxx @@ -10,43 +10,64 @@ namespace InDetDD { -PixelDiodeMatrix::PixelDiodeMatrix(double phiWidth, double etaWidth) - : m_phiWidth(phiWidth), - m_etaWidth(etaWidth), - m_phiCells(1), - m_etaCells(1), - m_direction(phiDir), // Irrelevant - m_numCells(0), - m_lowerCell(0), - m_middleCells(0), - m_upperCell(0), - m_singleCell(true) -{} - -PixelDiodeMatrix::PixelDiodeMatrix(Direction direction, // phi or eta - const PixelDiodeMatrix * lowerCell, - const PixelDiodeMatrix * middleCells, - int numCells, - const PixelDiodeMatrix * upperCell) - : m_phiWidth(0), - m_etaWidth(0), - m_phiCells(0), - m_etaCells(0), - m_direction(direction), - m_numCells(numCells), - m_lowerCell(lowerCell), - m_middleCells(middleCells), - m_upperCell(upperCell), - m_singleCell(false) +std::shared_ptr<const PixelDiodeMatrix> PixelDiodeMatrix::construct(double phiWidth, double etaWidth) { + class Helper : public PixelDiodeMatrix{}; + std::shared_ptr<PixelDiodeMatrix> ptr = std::make_shared<Helper>(); + ptr->initialize(phiWidth, etaWidth); + return ptr; +} + +void PixelDiodeMatrix::initialize(double phiWidth, double etaWidth) +{ + m_phiWidth = phiWidth; + m_etaWidth = etaWidth; + m_phiCells = 1; + m_etaCells = 1; + m_direction = phiDir; // Irrelevant + m_numCells = 0; + m_lowerCell = nullptr; + m_middleCells = nullptr; + m_upperCell = nullptr; + m_singleCell = true; +} + +std::shared_ptr<const PixelDiodeMatrix> PixelDiodeMatrix::construct(Direction direction, // phi or eta + std::shared_ptr<const PixelDiodeMatrix> lowerCell, + std::shared_ptr<const PixelDiodeMatrix> middleCells, + int numCells, + std::shared_ptr<const PixelDiodeMatrix> upperCell) +{ + class Helper : public PixelDiodeMatrix{}; + std::shared_ptr<PixelDiodeMatrix> ptr = std::make_shared<Helper>(); + ptr->initialize(direction, + lowerCell, + middleCells, + numCells, + upperCell); + return ptr; +} + +void PixelDiodeMatrix::initialize(Direction direction, // phi or eta + std::shared_ptr<const PixelDiodeMatrix> lowerCell, + std::shared_ptr<const PixelDiodeMatrix> middleCells, + int numCells, + std::shared_ptr<const PixelDiodeMatrix> upperCell) +{ + m_phiWidth = 0; + m_etaWidth = 0; + m_phiCells = 0; + m_etaCells = 0; + m_direction = direction; + m_numCells = numCells; + m_lowerCell = lowerCell; + m_middleCells = middleCells; + m_upperCell = upperCell; + m_singleCell = false; + // middleCells must be non zero. assert(m_middleCells); - // Increment ref counts - if (m_lowerCell) m_lowerCell->ref(); - if (m_middleCells) m_middleCells->ref(); - if (m_upperCell) m_upperCell->ref(); - if (m_direction == phiDir) { // In eta direction widths must be all the same. @@ -101,59 +122,7 @@ PixelDiodeMatrix::PixelDiodeMatrix(Direction direction, // phi or eta } -PixelDiodeMatrix:: ~PixelDiodeMatrix() -{ - // unref the point the pointers. - if (m_lowerCell) m_lowerCell->unref(); - if (m_middleCells) m_middleCells->unref(); - if (m_upperCell) m_upperCell->unref(); -} - -std::string -PixelDiodeMatrix::createDebugStringRepr(unsigned int level) const -{ - std::string prefix = ""; - for (unsigned int i=0; i<level; i++) { - prefix += " "; - } - // base case: single cell - if (m_singleCell) { - std::string cellSize = ""; - cellSize += prefix + "phi: " + std::to_string(m_phiWidth) + "\n"; - cellSize += prefix + "eta: " + std::to_string(m_etaWidth) + "\n"; - return cellSize; - } - - std::string cellContent = ""; - - if (!m_lowerCell and !m_middleCells and !m_upperCell) { - cellContent += prefix + "completly empty (WARNING: there should always be at least one cell!)\n"; - return cellContent; - } - - cellContent += prefix + "direction: "; - if (m_direction == phiDir) {cellContent += "phi\n";} - else if (m_direction == etaDir) {cellContent += "eta\n";} - else {cellContent += "unknown\n";} - - // recursive call for nested cells - if (m_lowerCell) { - cellContent += prefix + "lowerCell: \n"; - cellContent += m_lowerCell->createDebugStringRepr(level+1); - } - if (m_middleCells) { - cellContent += prefix + "middleCells: " + std::to_string(m_numCells) + "x :\n"; - cellContent += m_middleCells->createDebugStringRepr(level+1); - } - if (m_upperCell) { - cellContent += prefix + "upperCell: \n"; - cellContent += m_upperCell->createDebugStringRepr(level+1); - } - - return cellContent; -} - -const PixelDiodeMatrix * +std::shared_ptr<const PixelDiodeMatrix> PixelDiodeMatrix::cellIdOfPosition(const Amg::Vector2D & relPosition, SiCellId & cellId) const /// Description. @@ -180,7 +149,7 @@ PixelDiodeMatrix::cellIdOfPosition(const Amg::Vector2D & relPosition, SiCellId & using Trk::distEta; if (m_singleCell) { - return this; + return shared_from_this(); } double relPosDir = 0; // Relative position along m_direction @@ -222,7 +191,7 @@ PixelDiodeMatrix::cellIdOfPosition(const Amg::Vector2D & relPosition, SiCellId & int index = static_cast<int>((relPosDir) / pitch); if (index < 0) index = 0; // Make sure its in range (in case of rounding errors) - const PixelDiodeMatrix * nextCell = 0; + std::shared_ptr<const PixelDiodeMatrix> nextCell = nullptr; if (m_upperCell && (index >= m_numCells)) { // We are in the upper cell. @@ -241,7 +210,7 @@ PixelDiodeMatrix::cellIdOfPosition(const Amg::Vector2D & relPosition, SiCellId & int newPhiIndex = cellId.phiIndex(); int newEtaIndex = cellId.etaIndex(); - const PixelDiodeMatrix * cell = 0; + std::shared_ptr<const PixelDiodeMatrix> cell = nullptr; if (m_direction == phiDir) { if (nextCell->singleCell()) { @@ -273,7 +242,7 @@ PixelDiodeMatrix::cellIdOfPosition(const Amg::Vector2D & relPosition, SiCellId & -const PixelDiodeMatrix * +std::shared_ptr<const PixelDiodeMatrix> PixelDiodeMatrix::positionOfCell(const SiCellId & cellId, Amg::Vector2D & position) const /// Description. @@ -298,7 +267,7 @@ PixelDiodeMatrix::positionOfCell(const SiCellId & cellId, Amg::Vector2D & positi if (m_singleCell) { position[distPhi] += 0.5*m_phiWidth; position[distEta] += 0.5*m_etaWidth; - return this; + return shared_from_this(); } int relIndex = 0; // Relative index along m_direction @@ -342,7 +311,7 @@ PixelDiodeMatrix::positionOfCell(const SiCellId & cellId, Amg::Vector2D & positi relIndex -= index * middleCells; startPos += index * pitch; - const PixelDiodeMatrix * nextCell = 0; + std::shared_ptr<const PixelDiodeMatrix> nextCell = nullptr; if (m_upperCell && (index == m_numCells)) { // We are in the upper cell. @@ -352,7 +321,7 @@ PixelDiodeMatrix::positionOfCell(const SiCellId & cellId, Amg::Vector2D & positi nextCell = m_middleCells; } - const PixelDiodeMatrix * cell = 0; + std::shared_ptr<const PixelDiodeMatrix> cell = nullptr; if (m_direction == phiDir) { SiCellId relId(relIndex,cellId.etaIndex()); position[distPhi] += startPos; diff --git a/InnerDetector/InDetDetDescr/PixelGeoModel/src/DBM_Module.cxx b/InnerDetector/InDetDetDescr/PixelGeoModel/src/DBM_Module.cxx index db84a8c3659..701c5e29b6a 100644 --- a/InnerDetector/InDetDetDescr/PixelGeoModel/src/DBM_Module.cxx +++ b/InnerDetector/InDetDetDescr/PixelGeoModel/src/DBM_Module.cxx @@ -17,7 +17,7 @@ #include "InDetReadoutGeometry/SiDetectorElement.h" #include "PixelReadoutGeometry/PixelModuleDesign.h" -#include "PixelReadoutGeometry/PixelDiodeMatrix.h" +#include "ReadoutGeometryBase/PixelDiodeMatrix.h" using namespace InDetDD; DBM_Module::DBM_Module(InDetDD::PixelDetectorManager* ddmgr, diff --git a/InnerDetector/InDetDetDescr/PixelGeoModel/src/GeoPixelSiCrystal.cxx b/InnerDetector/InDetDetDescr/PixelGeoModel/src/GeoPixelSiCrystal.cxx index efb5515b672..4e314b60dd9 100644 --- a/InnerDetector/InDetDetDescr/PixelGeoModel/src/GeoPixelSiCrystal.cxx +++ b/InnerDetector/InDetDetDescr/PixelGeoModel/src/GeoPixelSiCrystal.cxx @@ -23,7 +23,7 @@ #include "InDetReadoutGeometry/SiDetectorElement.h" #include "PixelReadoutGeometry/PixelModuleDesign.h" -#include "PixelReadoutGeometry/PixelDiodeMatrix.h" +#include "ReadoutGeometryBase/PixelDiodeMatrix.h" #include "ReadoutGeometryBase/SiCommonItems.h" #include "ReadoutGeometryBase/InDetDD_Defs.h" diff --git a/InnerDetector/InDetDetDescr/PixelGeoModel/src/PixelDetectorDC1DC2.cxx b/InnerDetector/InDetDetDescr/PixelGeoModel/src/PixelDetectorDC1DC2.cxx index 5373d17fa3d..fa5e3b08d5e 100644 --- a/InnerDetector/InDetDetDescr/PixelGeoModel/src/PixelDetectorDC1DC2.cxx +++ b/InnerDetector/InDetDetDescr/PixelGeoModel/src/PixelDetectorDC1DC2.cxx @@ -10,7 +10,7 @@ #include "ReadoutGeometryBase/InDetDD_Defs.h" #include "PixelReadoutGeometry/PixelDetectorManager.h" -#include "PixelReadoutGeometry/PixelDiodeMatrix.h" +#include "ReadoutGeometryBase/PixelDiodeMatrix.h" #include "PixelReadoutGeometry/PixelModuleDesign.h" #include "ReadoutGeometryBase/SiCommonItems.h" #include "InDetReadoutGeometry/SiDetectorElement.h" diff --git a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelDiodeMap.h b/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelDiodeMap.h deleted file mode 100755 index 8480048509d..00000000000 --- a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelDiodeMap.h +++ /dev/null @@ -1,196 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelDiodeMap.h -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef INDETREADOUTGEOMETRY_PIXELDIODEMAP_H -#define INDETREADOUTGEOMETRY_PIXELDIODEMAP_H - -// STL classes -#include <list> -#include <memory> -#include <vector> - -// Data member classes -#include "PixelReadoutGeometry/PixelDiodeMatrix.h" - -// Input/output classes -#include "ReadoutGeometryBase/SiCellId.h" -#include "ReadoutGeometryBase/SiDiodesParameters.h" - -namespace InDetDD { - -class SiCellId; -class PixelDiodeMatrix; - - /** @class PixelDiodeMap - - Class used to describe the diode segmentation of a pixel module - - to get the position and size of a PixelDiode object - - to get a PixelDiode object containing a space point - - to get a PixelDiode object from a PixelModulePosition - - @author: David Calvet - - modified Davide Costanzo. Replace PixelModulePosition with SiCellId - - modified: Grant Gorfine, Andreas Salzburger - */ - - class PixelDiodeMap { - - public: - - /** Constructor from Diode matrix description */ - PixelDiodeMap(std::shared_ptr<const PixelDiodeMatrix> diodeMatrix); - - /** Copy constructor: */ - PixelDiodeMap(const PixelDiodeMap &map); - - /** Destructor */ - ~PixelDiodeMap(); - - /** Assignment operator */ - PixelDiodeMap &operator=(const PixelDiodeMap &map); - - /////////////////////////////////////////////////////////////////// - // Const methods: - /////////////////////////////////////////////////////////////////// - - /** Get diodes parameters (position and size): */ - SiDiodesParameters parameters(const SiCellId & diodeId) const; - - /** cell id for a given local position */ - SiCellId cellIdOfPosition(const Amg::Vector2D & localPosition) const; - - /** Check if cellId is within range */ - SiCellId cellIdInRange(const SiCellId & cellId) const; - - /** Get the neighbouring PixelDiodes of a given PixelDiode: - Cell for which the neighbours must be found - List of cells which are neighbours of the given one */ - void neighboursOfCell(const SiCellId & cellId, - std::vector<SiCellId> &neighbours) const; - - /** Compute the intersection length of two diodes: - return: the intersection length when the two diodes are projected on one - of the two axis, or 0 in case of no intersection or problem - nput: the two diodes for which the intersection length is computed */ - double intersectionLength(const SiCellId &diode1, const SiCellId &diode2) const; - - // Global sensor size: - double leftColumn() const; - double rightColumn() const; - double leftRow() const; - double rightRow() const; - - double width() const; - double length() const; - - // Number of cells in each direction. - int phiDiodes() const; - int etaDiodes() const; - - // Total number of diodes: - int diodes() const; - - /////////////////////////////////////////////////////////////////// - // Non-const methods: - /////////////////////////////////////////////////////////////////// - /** Set general layout flag. This can be set to true to allow handling - of more complex layouts where cells are not lined up with each other - such as bricking. Probably never will be needed. */ - void setGeneralLayout() {m_generalLayout = true;} - - /////////////////////////////////////////////////////////////////// - // Private methods: - /////////////////////////////////////////////////////////////////// - private: - - /** Compute the intersection length along one direction: - return 0 if no intersection - x1,x2 are the centers - dx1,dx2 are the full lengths */ - double intersectionLength1D(const double x1,const double dx1, - const double x2,const double dx2) const; - - /** Slower method. Called by neighboursOfCell if m_generalLayout set. */ - void neighboursOfCellGeneral(const SiCellId & cellId, - std::vector<SiCellId> &neighbours) const; - - /** Slower method. Called by intersectionLength if m_generalLayout set. */ - double intersectionLengthGeneral(const SiCellId &diode1, - const SiCellId &diode2) const; - - - /////////////////////////////////////////////////////////////////// - // Private data: - /////////////////////////////////////////////////////////////////// - private: - std::shared_ptr<const PixelDiodeMatrix> m_matrix; //!< diode matrix - bool m_generalLayout; //!< Flag set to allow for dealing wth more general layouts. - }; - - /////////////////////////////////////////////////////////////////// - // Inline methods: - /////////////////////////////////////////////////////////////////// - - inline double PixelDiodeMap::length() const - { - return m_matrix->etaWidth(); - } - - inline double PixelDiodeMap::width() const - { - return m_matrix->phiWidth(); - } - - inline double PixelDiodeMap::leftColumn() const - { - return -0.5*length(); - } - - inline double PixelDiodeMap::rightColumn() const - { - return 0.5*length(); - } - - inline double PixelDiodeMap::leftRow() const - { - return -0.5*width(); - } - - inline double PixelDiodeMap::rightRow() const - { - return 0.5*width(); - } - - inline int PixelDiodeMap::diodes() const - { - return phiDiodes() * etaDiodes(); - } - - inline int PixelDiodeMap::phiDiodes() const - { - return m_matrix->phiCells(); - } - - inline int PixelDiodeMap::etaDiodes() const - { - return m_matrix->etaCells(); - } - - inline SiCellId PixelDiodeMap::cellIdInRange(const SiCellId & cellId) const - { - if (!cellId.isValid() || - cellId.phiIndex() <0 || cellId.phiIndex() >= phiDiodes() || - cellId.etaIndex() <0 || cellId.etaIndex() >= etaDiodes()) return SiCellId(); // Invalid - return cellId; - } - -} // namespace InDetDD - -#endif // INDETREADOUTGEOMETRY_PIXELDIODEMAP_H diff --git a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelDiodeMatrix.h b/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelDiodeMatrix.h deleted file mode 100755 index 5ea18845c10..00000000000 --- a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelDiodeMatrix.h +++ /dev/null @@ -1,202 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelDiodeMatrix.h -/////////////////////////////////////////////////////////////////// - -#ifndef INDETREADOUTGEOMETRY_PIXELDIODEMATRIX_H -#define INDETREADOUTGEOMETRY_PIXELDIODEMATRIX_H - -#include "ReadoutGeometryBase/SiCellId.h" -#include "GeoPrimitives/GeoPrimitives.h" -#include "TrkDetElementBase/TrkDetElementBase.h" - -#include <memory> - -namespace InDetDD { - - /** @class PixelDiodeMatrix - - Class used to describe the segmentation of the pixel and allow for conversion between cell id and position. - - The class PixelDiodeMatrix represents what it calls a cell. In the context - of this class a cell can either be just a simple cell as one would normally - think of a pixel cell (eg a 50x400um or 50x600um cell) or it can be a - container of multiple cells. To allow for different size cells and layout, - it contains a lower cell, an upper cell and multiple middle - cells. The middle cells are all the same (so all have the same size), but - the upper and lower cells can be different and can have different size or be left out - if they are not needed. The direction of replication is also specified (eta - or phi direction). The size of the cells in the direction orthoganal to the - replication direction must all be the same (there is no check for this though). - - To help understand the structure and its use, consider the current pixel - geometry. The pixel module has two cell sizes short and long cells. These - are refered to as normal and big bellow. The long cells are in the region - at the edge of the the FE chips in order to cover the gap between FE chips. - - The assembly of this structure is done when building the sensitive detector - in GeoModel in the class GeoPixelSiCrystal. - - - normalCell (short pixel cell) 50x400um - - bigCell (long pixel cell): 50x600um - - - singleChipRow (represents one row associated to a FE) - - Size: phiWidth = 50um, etaWidth = 600*2+400*16) um = 7.6 CLHEP::mm - - upper cell: bigCell - - middle cells: 16 x normalCell - - lower cell: bigcell - - direction: eta - - - singleRow (represents a row of cells covering the full length of the - module) - - Size: phiWidth = 50um, etaWidth = 8 * (600*2+400*16) um = 60.8 CLHEP::mm - - upper cell: none - - middle cells: 8 x singleChipRow - - lower cell: none - - direction: eta - - - fullMatrix (represents the full module) - - Size: phiWidth = 50 * 328 um = 16.4 CLHEP::mm, etaWidth = 60.8 CLHEP::mm - - upper cell: none - - middle cells: 328 x singleRow - - lower cell: non - - direction: phi - - Each cell knows its total size and total number of child cells in the phi and eta - direction. This is determined by totaling up these quantities - when the object is constructed. - - The structure allows for efficient navigation from cell number to - position and vice-versa. There are two main methods which allow for this navigation: - cellIdOfPosition() (from cell id to position) and positionOfCell() (from position to cell id). - - As it is assumed that child cells fill up completely its parent, there is - no range check in these methods. The methods are called from PixelDiodeMap - where it first checks that is within range of the top level cell (refered to - as the top level matrix). - - PixelDiodeMatrix might inherit std::shared_ptr but needs to return std::shared_ptr of this pointer. - To do this, std::enable_shared_from_this and shared_from_this() have to be used. - https://en.cppreference.com/w/cpp/memory/enable_shared_from_this - - See the description of these methods for more details. - - @image html pixeldiodematrix.gif - - @author Grant Gorfine - - modified & maintained: Nick Styles, Andreas Salzburger - **/ - - class PixelDiodeMatrix : public std::enable_shared_from_this<PixelDiodeMatrix> { - - public: - - enum Direction {phiDir, etaDir}; - - /// Destructor - ~PixelDiodeMatrix() = default; - - /// Construct method for just a single cell. - static std::shared_ptr<const PixelDiodeMatrix> construct(double phiWidth, double etaWidth); - - /** Construct method with multiple matrices. - There may be zero or one lower matrix (pointer can be 0). - Multiple (numCells) middle matrics (must pass a non zero pointer). - There may be zero or one upper matrix (pointer can be 0). - These must all have the same width and cells in the non replicating direction. */ - static std::shared_ptr<const PixelDiodeMatrix> construct(Direction direction, // phi or eta - std::shared_ptr<const PixelDiodeMatrix> lowerCell, - std::shared_ptr<const PixelDiodeMatrix> middleCells, - int numCells, - std::shared_ptr<const PixelDiodeMatrix> upperCells); - - /** Return cell Id corresponding to a relative position within the matrix. - The cellId is modified and returns the id relative to the passed cellId. - That is, it adds the relative cellId to the cellId passed to the function. - A pointer to the correspond cell is returned. This can be used to get the - size of the cell. */ - std::shared_ptr<const PixelDiodeMatrix> cellIdOfPosition(const Amg::Vector2D & position, SiCellId & cellId) const; - - /** Return position correspong to cell with relative id withing the matrix. - Returns the relative position added to the position passed in. - A pointer to the correspond cell is returned. This can be used to get the - size of the cell. */ - std::shared_ptr<const PixelDiodeMatrix> positionOfCell(const SiCellId & cellId, Amg::Vector2D & position) const; - - /** Width in phi (x) direction.*/ - double phiWidth() const; - - /** Width in eta (y) direction. */ - double etaWidth() const; - - /** Number of cells in phi (x) direction. */ - int phiCells() const; - - /** Number of cells in eta (y) direction. */ - int etaCells() const; - - /** Query wether the matrix is just a single cell. Mainly for internal use. */ - bool singleCell() const; - - private: - /** Hidden constructor */ - PixelDiodeMatrix() {}; - - /// Initialize for just a single cell. - void initialize(double phiWidth, double etaWidth); - - /** Initialize for multiple matrices. - There may be zero or one lower matrix (pointer can be 0). - Multiple (numCells) middle matrics (must pass a non zero pointer). - There may be zero or one upper matrix (pointer can be 0). - These must all have the same width and cells in the non replicating direction. */ - void initialize(Direction direction, // phi or eta - std::shared_ptr<const PixelDiodeMatrix> lowerCell, - std::shared_ptr<const PixelDiodeMatrix> middleCells, - int numCells, - std::shared_ptr<const PixelDiodeMatrix> upperCells); - - double m_phiWidth; - double m_etaWidth; - int m_phiCells; - int m_etaCells; - Direction m_direction; - int m_numCells; // number of MiddleCells along m_direction direction. - std::shared_ptr<const PixelDiodeMatrix> m_lowerCell; - std::shared_ptr<const PixelDiodeMatrix> m_middleCells; - std::shared_ptr<const PixelDiodeMatrix> m_upperCell; - bool m_singleCell; - - }; - - inline double PixelDiodeMatrix::phiWidth() const - { - return m_phiWidth; - } - - inline double PixelDiodeMatrix::etaWidth() const - { - return m_etaWidth; - } - - inline int PixelDiodeMatrix::phiCells() const - { - return m_phiCells; - } - - inline int PixelDiodeMatrix::etaCells() const - { - return m_etaCells; - } - - inline bool PixelDiodeMatrix::singleCell() const - { - return m_singleCell; - } - -} // end namespace - -#endif //INDETREADOUTGEOMETRY_PIXELDIODEMATRIX_H diff --git a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelModuleDesign.h b/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelModuleDesign.h index cfb57df01ae..3e12c3bde4e 100755 --- a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelModuleDesign.h +++ b/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelModuleDesign.h @@ -1,5 +1,5 @@ /* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration + Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration */ /////////////////////////////////////////////////////////////////// @@ -9,15 +9,15 @@ /////////////////////////////////////////////////////////////////// -#ifndef INDETREADOUTGEOMETRY_PIXELMODULEDESIGN_H -#define INDETREADOUTGEOMETRY_PIXELMODULEDESIGN_H +#ifndef PIXELREADOUTGEOMETRY_PIXELMODULEDESIGN_H +#define PIXELREADOUTGEOMETRY_PIXELMODULEDESIGN_H // Base class #include "InDetReadoutGeometry/SiDetectorDesign.h" // Data member classes -#include "PixelReadoutGeometry/PixelDiodeMap.h" -#include "PixelReadoutGeometry/PixelReadoutScheme.h" +#include "ReadoutGeometryBase/PixelDiodeMap.h" +#include "ReadoutGeometryBase/PixelReadoutScheme.h" // Other includes #include "CxxUtils/CachedUniquePtr.h" @@ -351,4 +351,4 @@ namespace InDetDD { } // namespace InDetDD -#endif // INDETREADOUTGEOMETRY_PIXELMODULEDESIGN_H +#endif // READOUTGEOMETRYBASE_PIXELMODULEDESIGN_H diff --git a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelMultipleConnection1D.h b/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelMultipleConnection1D.h deleted file mode 100755 index 1e605eaceee..00000000000 --- a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelMultipleConnection1D.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelMultipleConnection1D.h -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// - - -#ifndef INDETREADOUTGEOMETRY_PIXELMULTIPLECONNECTION1D_H -#define INDETREADOUTGEOMETRY_PIXELMULTIPLECONNECTION1D_H - -#include <vector> - -namespace InDetDD { - - /** @class PixelMultipleConnection1D - - Class used to handle connection of multiple diodes to the same readout cell - - @author: David Calvet - @note: modifed by Grant Gorfine, Andreas Salzburger - */ - - class PixelMultipleConnection1D { - - /////////////////////////////////////////////////////////////////// - // Public methods: - /////////////////////////////////////////////////////////////////// - public: - - PixelMultipleConnection1D(); - - /** Constructor with parameters: - lower diode index for which the connection scheme is given - vector containing, for each diode, the readout cell number to which - the corresponding diode is connected */ - PixelMultipleConnection1D(const int lowerIndex, const std::vector<int> &connections); - - - void set(const int lowerIndex, const std::vector<int> &connections); - - - /////////////////////////////////////////////////////////////////// - // Const methods: - /////////////////////////////////////////////////////////////////// - - /** Check if the readout cell is in the range; Also for index of gangedCell. */ - bool outsideReadout(const int index) const; - - /** Check if the diode is in the range: */ - bool outsideDiode(const int cell) const; - - /** Return the number of diodes that are connected to this readout cell, Must check outsideReadout first. */ - int numberOfConnectedCells(const int index) const; - - /** Return the diode index corresponding the this readout. - number 0 will return the primary cell (ie diode index = readout cell index) - Must check outsideReadout first.*/ - int connectedCell(const int index, unsigned int number) const; - - /** Return readout cell id of this diode, Must check outsideDiode first. */ - int readoutOfDiode(const int index) const; - - /** If the diode is gnaged return the other diode. If the diode is not ganged return the same diode. - Must check outsideReadout first. */ - int gangedCell(const int index) const; - - /////////////////////////////////////////////////////////////////// - // Private data: - /////////////////////////////////////////////////////////////////// - private: - int m_lowerDiode; //!< lower diode index to which it applies - int m_upperDiode; //!< upper diode index to which it applies - int m_lowerReadout; //!< lower cell to which it applies - int m_upperReadout; //!< upper cell to which it applies - std::vector< std::vector<int> > m_readoutToDiode; //!< connection table readout -> diodes - std::vector<int> m_diodeToReadout; //!< connection table diode -> readout - std::vector<int> m_diodeGanged; //!< connection table diode -> other diode. - - /////////////////////////////////////////////////////////////////// - // Private methods: - /////////////////////////////////////////////////////////////////// - void debugPrintout(); - -}; - -/////////////////////////////////////////////////////////////////// -// Inline methods: -/////////////////////////////////////////////////////////////////// - -inline bool PixelMultipleConnection1D::outsideReadout(const int readout) const -{ - return (readout<m_lowerReadout || readout>m_upperReadout); -} - - -inline bool PixelMultipleConnection1D::outsideDiode(const int diode) const -{ - return (diode<m_lowerDiode || diode>m_upperDiode); -} - - -inline int PixelMultipleConnection1D::numberOfConnectedCells(const int index) const -{ - return m_readoutToDiode[index - m_lowerReadout].size(); -} - -inline int PixelMultipleConnection1D::connectedCell(const int index, unsigned int number) const -{ - return m_readoutToDiode[index - m_lowerReadout][number]; -} - -inline int PixelMultipleConnection1D::readoutOfDiode(const int index) const -{ - return m_diodeToReadout[index - m_lowerDiode]; -} - -inline int PixelMultipleConnection1D::gangedCell(const int index) const -{ - return m_diodeGanged[index - m_lowerReadout]; -} - -} // namespace InDetDD - -#endif // INDETREADOUTGEOMETRY_PIXELMULTIPLECONNECTION1D_H diff --git a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelReadoutScheme.h b/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelReadoutScheme.h deleted file mode 100755 index ddc397c6d44..00000000000 --- a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/PixelReadoutGeometry/PixelReadoutScheme.h +++ /dev/null @@ -1,157 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelReadoutScheme.h -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// - -#ifndef INDETREADOUTGEOMETRY_PIXELREADOUTSCHEME_H -#define INDETREADOUTGEOMETRY_PIXELREADOUTSCHEME_H - -// Data member classes -#include "PixelReadoutGeometry/PixelMultipleConnection1D.h" - -// Input and output classes -#include "ReadoutGeometryBase/SiReadoutCellId.h" -#include "ReadoutGeometryBase/SiCellId.h" - -namespace InDetDD { - - /** @class PixelReadoutScheme - - Class used to describe the connection scheme of a diode matrix - to a set of readout circuits - - to get the readout cell connected to a diode - - to get the list of diodes connected to a readout cell - - @author David Calvet - - modified on 5/10/04 Davide Costanzo. Replace PixelModulePosition with SiCellId - - modified: Grant Gorfine, Andreas Salzburger - */ - - class PixelReadoutScheme { - - /////////////////////////////////////////////////////////////////// - // Public methods: - /////////////////////////////////////////////////////////////////// - public: - - /////////////////////////////////////////////////////////////////// - // Constructors/destructor: - /////////////////////////////////////////////////////////////////// - - /** Constructor with parameters: - - number of circuits in one circuit column - number of circuits in one circuit row - number of cell columns per circuit - number of cell rows per circuit - number of diode columns connected to one circuit - number of diode rows connected to one circuit */ - PixelReadoutScheme(const int circuitsPerColumn,const int circuitsPerRow, - const int cellColumnsPerCircuit, - const int cellRowsPerCircuit, - const int diodeColumnsPerCircuit, - const int diodeRowsPerCircuit); - - /** Destructor: */ - ~PixelReadoutScheme(); - - /////////////////////////////////////////////////////////////////// - // Const methods: - /////////////////////////////////////////////////////////////////// - - /** total number of circuits: */ - int numberOfCircuits() const; - - /** number of cell columns per circuit: */ - int columnsPerCircuit() const; - - /** number of cell rows per circuit:*/ - int rowsPerCircuit() const; - - /** number of cell columns per module:*/ - int columns() const; - - /** number of cell rows per module:*/ - int rows() const; - - /** number of cells connected to this readout.*/ - int numberOfConnectedCells(const SiReadoutCellId & readoutId) const; - - /** Cell ids of cell connected to this readout.*/ - SiCellId connectedCell(const SiReadoutCellId & readoutId, unsigned int number) const; - - /** Readout id of this diode.*/ - SiReadoutCellId readoutIdOfCell(const SiCellId & cellId) const; - - /** If cell is ganged return the other cell, otherwise return an invalid id.*/ - SiCellId gangedCell(const SiCellId & cellId) const; - - /////////////////////////////////////////////////////////////////// - // Non-const methods: - /////////////////////////////////////////////////////////////////// - - /** Add a new multiple connection for rows: - lower diode row for which the connection scheme is given - vector containing, for each diode, the readout cell row number - to which the corresponding diode is connected */ - void addMultipleRowConnection(const int lowerRow, const std::vector<int> &connections); - - /////////////////////////////////////////////////////////////////// - // Private methods: - /////////////////////////////////////////////////////////////////// - private: - - PixelReadoutScheme(); - - /////////////////////////////////////////////////////////////////// - // Private data: - /////////////////////////////////////////////////////////////////// - private: - PixelMultipleConnection1D m_rowConnections; //!< multiple connections for rows - int m_numberOfCircuits; //!< total number of circuits - int m_columnsPerCircuit; //!< number of cell columns per circuit - int m_rowsPerCircuit; //!< number of cell rows per circuit - int m_columns; //!< Number of columns - int m_rows; //!< Number of rows - -}; - -/////////////////////////////////////////////////////////////////// -// Inline methods: -/////////////////////////////////////////////////////////////////// -inline PixelReadoutScheme::~PixelReadoutScheme() -{} - -inline int PixelReadoutScheme::numberOfCircuits() const -{ - return m_numberOfCircuits; -} - -inline int PixelReadoutScheme::columnsPerCircuit() const -{ - return m_columnsPerCircuit; -} - -inline int PixelReadoutScheme::rowsPerCircuit() const -{ - return m_rowsPerCircuit; -} - -inline int PixelReadoutScheme::columns() const -{ - return m_columns; -} - -inline int PixelReadoutScheme::rows() const -{ - return m_rows; -} - -} // namespace InDetDD - -#endif // INDETREADOUTGEOMETRY_PIXELREADOUTSCHEME_H diff --git a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelDiodeMap.cxx b/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelDiodeMap.cxx deleted file mode 100755 index 2d92ad3f9c2..00000000000 --- a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelDiodeMap.cxx +++ /dev/null @@ -1,297 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelDiodeMap.cxx -// Implementation file for class PixelDiodeMap -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// -// Version 4.2 14/08/2001 David Calvet -// Modified: Grant Gorfine -/////////////////////////////////////////////////////////////////// - -#include "PixelReadoutGeometry/PixelDiodeMap.h" -#include "PixelReadoutGeometry/PixelDiodeMatrix.h" -#include "ReadoutGeometryBase/SiCellId.h" - -#include <cmath> -#include <algorithm> - -namespace InDetDD { - - - -// Implicit constructor: -PixelDiodeMap::PixelDiodeMap(std::shared_ptr<const PixelDiodeMatrix> matrix) : - m_matrix(matrix), - m_generalLayout(false) -{ -} - -PixelDiodeMap::~PixelDiodeMap() -{ -} - - - SiCellId PixelDiodeMap::cellIdOfPosition(const Amg::Vector2D & localPos) const -{ - using std::abs; - using Trk::distPhi; - using Trk::distEta; - - // Check that we are in the bounds of the top level matrix - // NB. edge is included in bounds. - - double halfWidth = 0.5*width(); - double halfLength = 0.5*length(); - if ( (abs(localPos[distPhi]) > halfWidth) || - (abs(localPos[distEta]) > halfLength) ) { - return SiCellId(); // Invalid Id. - } - - // position relative to bottom left corner. - Amg::Vector2D relativePos = localPos + Amg::Vector2D(halfWidth, halfLength); - - // The cellId returned will be added to this so we must start with 0,0. - SiCellId cellId(0,0); - - std::shared_ptr<const PixelDiodeMatrix> cell = m_matrix->cellIdOfPosition(relativePos, cellId); - - // return invalid Id if there was a problem (don't expect this to be the case). - if (cell==nullptr) { - return SiCellId(); // Invalid id. - } - - return cellId; - -} - - -// Get diodes parameters (position and size): -SiDiodesParameters -PixelDiodeMap::parameters(const SiCellId & cellId) const -{ - - // Check we are in range - - if (!cellId.isValid() || - (cellId.phiIndex() < 0) || - (cellId.phiIndex() >= m_matrix->phiCells()) || - (cellId.etaIndex() < 0) || - (cellId.etaIndex() >= m_matrix->etaCells())) { - return SiDiodesParameters(); - } - - double halfWidth = 0.5*width(); - double halfLength = 0.5*length(); - - // - // Position is relative to left bottom corner. - // - Amg::Vector2D position(-halfWidth, -halfLength); - std::shared_ptr<const PixelDiodeMatrix> cell = m_matrix->positionOfCell(cellId, position); - - if (cell) { - - // get size - Amg::Vector2D size(cell->phiWidth(), cell->etaWidth()); - - // return parameters - return SiDiodesParameters(position,size); - } - - // return something in case of failure. - return SiDiodesParameters(); -} - -void PixelDiodeMap::neighboursOfCell(const SiCellId & cellId, - std::vector<SiCellId> &neighbours) const -{ - neighbours.clear(); - - if (!cellId.isValid()) return; - - // If non regular layout revert to slower method - if (m_generalLayout) return neighboursOfCellGeneral(cellId, neighbours); - - neighbours.reserve(8); - // neighbours easily determined from cell number - // normally 8 neighbours 4 edge and 4 corners - - int phiIndex = cellId.phiIndex(); - int etaIndex = cellId.etaIndex(); - - // M = minus - // P = plus - int phiM = phiIndex-1; - int phiP = phiIndex+1; - int etaM = etaIndex-1; - int etaP = etaIndex+1; - - // -,0 - if (phiM >= 0) neighbours.push_back(SiCellId(phiM,etaIndex)); - // -,- - if (phiM >= 0 && etaM >= 0) neighbours.push_back(SiCellId(phiM,etaM)); - // 0,- - if (etaM >= 0) neighbours.push_back(SiCellId(phiIndex,etaM)); - // +,- - if (phiP < phiDiodes() && etaM >= 0) neighbours.push_back(SiCellId(phiP,etaM)); - // +,0 - if (phiP < phiDiodes()) neighbours.push_back(SiCellId(phiP,etaIndex)); - // -,+ - if (phiM >= 0 && etaP < etaDiodes()) neighbours.push_back(SiCellId(phiM,etaP)); - // 0,+ - if (etaP < etaDiodes()) neighbours.push_back(SiCellId(phiIndex,etaP)); - // +,+ - if (phiP < phiDiodes() && etaP < etaDiodes()) neighbours.push_back(SiCellId(phiP,etaP)); -} - -// Get the neighbouring PixelDiodes of a given PixelDiode: -// This will work for more complex layouts such as bricking. Probably never really needed but -// since the code was here I keep it available. -void PixelDiodeMap::neighboursOfCellGeneral(const SiCellId & cellId, - std::vector<SiCellId> &neighbours) const -{ - // extract the diode spatial parameters - const SiDiodesParameters params=parameters(cellId); - const SiLocalPosition diodeCenter=params.centre(); - const SiLocalPosition diodeSize=params.width(); - const double ¢erColumn=diodeCenter.xColumn(); - const double ¢erRow=diodeCenter.xRow(); - const double halfSizeColumn=diodeSize.xColumn()/2; - const double halfSizeRow=diodeSize.xRow()/2; - - // parameter - const double epsilon=0.01; - - // compute the points to check - const double left1=centerColumn-halfSizeColumn*(1+epsilon); - const double right1=centerColumn+halfSizeColumn*(1+epsilon); - const double left2=centerColumn-halfSizeColumn*(1-epsilon); - const double right2=centerColumn+halfSizeColumn*(1-epsilon); - const double top1=centerRow+halfSizeRow*(1+epsilon); - const double bot1=centerRow-halfSizeRow*(1+epsilon); - const double top2=centerRow+halfSizeRow*(1-epsilon); - const double bot2=centerRow-halfSizeRow*(1-epsilon); - - // build the list of positions to check - std::vector<SiLocalPosition> positions; - positions.reserve(12); - SiLocalPosition position; - position.xRow(bot1); position.xColumn(left2); positions.push_back(position); - position.xRow(bot1); position.xColumn(left1); positions.push_back(position); - position.xRow(bot2); position.xColumn(left1); positions.push_back(position); - position.xRow(top2); position.xColumn(left1); positions.push_back(position); - position.xRow(top1); position.xColumn(left1); positions.push_back(position); - position.xRow(top1); position.xColumn(left2); positions.push_back(position); - position.xRow(bot1); position.xColumn(right2); positions.push_back(position); - position.xRow(bot1); position.xColumn(right1); positions.push_back(position); - position.xRow(bot2); position.xColumn(right1); positions.push_back(position); - position.xRow(top2); position.xColumn(right1); positions.push_back(position); - position.xRow(top1); position.xColumn(right1); positions.push_back(position); - position.xRow(top1); position.xColumn(right2); positions.push_back(position); - - // build the list of neighbours - neighbours.reserve(8); - - // loop on all positions to check - for(std::vector<SiLocalPosition>::const_iterator p_position=positions.begin() ; - p_position!=positions.end() ; ++p_position) { - - // get the PixelDiode for this position - SiCellId cellId_neighb = cellIdOfPosition(*p_position); - - if (cellId.isValid()) { - // check if the diode is already in the list - //bool found=false; - std::vector<SiCellId>::const_iterator foundIter - = std::find(neighbours.begin(), neighbours.end(), cellId_neighb ); - - // If not found add this diode to the list - if (foundIter == neighbours.end()) neighbours.push_back(cellId_neighb); - - } - } -} - - -// Compute the intersection length of two diodes: -double PixelDiodeMap::intersectionLength(const SiCellId &diode1, - const SiCellId &diode2) const -{ - if(!diode1.isValid() || !diode2.isValid()) return 0; - // If non regular layout revert to slower method - if (m_generalLayout) return intersectionLengthGeneral(diode1, diode2); - - const SiLocalPosition size = parameters(diode1).width(); - - int phiIndexDelta = std::abs(diode1.phiIndex() - diode2.phiIndex()); - int etaIndexDelta = std::abs(diode1.etaIndex() - diode2.etaIndex()); - - // Intersection length is just the length or width of the diode depending on which neighbour. - if (phiIndexDelta == 1 && etaIndexDelta == 0) return size.xEta(); - if (phiIndexDelta == 0 && etaIndexDelta == 1) return size.xPhi(); - // Will return 0 if it is a corner neighbour or if its not a neighbour or if they are oth the same diode. - return 0; -} - -// Compute the intersection length of two diodes: -// This will work for more complex layouts such as bricking. Probably never really needed but -// since the code was here I keep it available. -double PixelDiodeMap::intersectionLengthGeneral(const SiCellId &diode1, - const SiCellId &diode2) const - -{ - const SiDiodesParameters params1=parameters(diode1); - const SiDiodesParameters params2=parameters(diode2); - const SiLocalPosition center1=params1.centre(); - const SiLocalPosition center2=params2.centre(); - const SiLocalPosition size1=params1.width(); - const SiLocalPosition size2=params2.width(); - - // compute intersection length on column direction - const double intersectionColumn=intersectionLength1D(center1.xColumn(), - size1.xColumn(), - center2.xColumn(), - size2.xColumn()); - // compute intersection length on row direction - const double intersectionRow=intersectionLength1D(center1.xRow(), - size1.xRow(), - center2.xRow(), - size2.xRow()); - - // return the real intersection - // (if both directions intersect, there is a problem) - if (intersectionColumn>0) { - if (intersectionRow>0) return 0; - return intersectionColumn; - } else { - return intersectionRow; - } -} - -// Compute the intersection length along one direction: -double PixelDiodeMap::intersectionLength1D(const double x1,const double dx1, - const double x2,const double dx2) const -{ - // compute distance between the two centers - double distance=std::abs(x1-x2); - - // compute theoretical intersection - double intersection=(dx1+dx2)/2-distance; - - // if intersection if negative, no intersection - if (intersection<-1e-10) return intersection; - else if (intersection<1e-10) return 0; - else { - // intersection cannot exceed size - if (intersection>dx1) intersection=dx1; - if (intersection>dx2) intersection=dx2; - return intersection; - } -} - -} // namespace InDetDD - diff --git a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelDiodeMatrix.cxx b/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelDiodeMatrix.cxx deleted file mode 100755 index 1acd59cdc1a..00000000000 --- a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelDiodeMatrix.cxx +++ /dev/null @@ -1,338 +0,0 @@ -/* - Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration -*/ - -#include "PixelReadoutGeometry/PixelDiodeMatrix.h" -#include "ReadoutGeometryBase/SiCellId.h" -#include "TrkEventPrimitives/ParamDefs.h" - -#include <cassert> - -namespace InDetDD { - -std::shared_ptr<const PixelDiodeMatrix> PixelDiodeMatrix::construct(double phiWidth, double etaWidth) -{ - class Helper : public PixelDiodeMatrix{}; - std::shared_ptr<PixelDiodeMatrix> ptr = std::make_shared<Helper>(); - ptr->initialize(phiWidth, etaWidth); - return ptr; -} - -void PixelDiodeMatrix::initialize(double phiWidth, double etaWidth) -{ - m_phiWidth = phiWidth; - m_etaWidth = etaWidth; - m_phiCells = 1; - m_etaCells = 1; - m_direction = phiDir; // Irrelevant - m_numCells = 0; - m_lowerCell = nullptr; - m_middleCells = nullptr; - m_upperCell = nullptr; - m_singleCell = true; -} - -std::shared_ptr<const PixelDiodeMatrix> PixelDiodeMatrix::construct(Direction direction, // phi or eta - std::shared_ptr<const PixelDiodeMatrix> lowerCell, - std::shared_ptr<const PixelDiodeMatrix> middleCells, - int numCells, - std::shared_ptr<const PixelDiodeMatrix> upperCell) -{ - class Helper : public PixelDiodeMatrix{}; - std::shared_ptr<PixelDiodeMatrix> ptr = std::make_shared<Helper>(); - ptr->initialize(direction, - lowerCell, - middleCells, - numCells, - upperCell); - return ptr; -} - -void PixelDiodeMatrix::initialize(Direction direction, // phi or eta - std::shared_ptr<const PixelDiodeMatrix> lowerCell, - std::shared_ptr<const PixelDiodeMatrix> middleCells, - int numCells, - std::shared_ptr<const PixelDiodeMatrix> upperCell) -{ - m_phiWidth = 0; - m_etaWidth = 0; - m_phiCells = 0; - m_etaCells = 0; - m_direction = direction; - m_numCells = numCells; - m_lowerCell = lowerCell; - m_middleCells = middleCells; - m_upperCell = upperCell; - m_singleCell = false; - - // middleCells must be non zero. - assert(m_middleCells); - - if (m_direction == phiDir) { - - // In eta direction widths must be all the same. - if (m_middleCells){ - m_etaWidth = m_middleCells->etaWidth(); - m_etaCells = m_middleCells->etaCells(); - } - // Check lower and upper are consistent - // TODO. - - if (m_lowerCell) { - m_phiWidth += m_lowerCell->phiWidth(); - m_phiCells += m_lowerCell->phiCells(); - } - - if (m_middleCells){ - m_phiWidth += m_numCells * m_middleCells->phiWidth(); - m_phiCells += m_numCells * m_middleCells->phiCells(); - } - - if (m_upperCell) { - m_phiWidth += m_upperCell->phiWidth(); - m_phiCells += m_upperCell->phiCells(); - } - - } else { // eta Direction - - // In phi direction widths must be all the same. - if (m_middleCells){ - m_phiWidth = m_middleCells->phiWidth(); - m_phiCells = m_middleCells->phiCells(); - } - // Check lower and upper are consistent - // TODO. - - if (m_lowerCell) { - m_etaWidth += m_lowerCell->etaWidth(); - m_etaCells += m_lowerCell->etaCells(); - } - - if (m_middleCells){ - m_etaWidth += m_numCells * m_middleCells->etaWidth(); - m_etaCells += m_numCells * m_middleCells->etaCells(); - } - - if (m_upperCell) { - m_etaWidth += m_upperCell->etaWidth(); - m_etaCells += m_upperCell->etaCells(); - } - - } - -} - -std::shared_ptr<const PixelDiodeMatrix> -PixelDiodeMatrix::cellIdOfPosition(const Amg::Vector2D & relPosition, SiCellId & cellId) const - - /// Description. - /// Overview of algoritm: - /// - /// - Before calling this method on the top level matrix the 2D position is - /// calculated relative to the bottom left corner. - /// - The method cellIdOfPosition is always called with the position relative to - /// bottom left of the cell and the cell id of bottom left child cell. - /// For the top level matrix this is the position (-halfWidth, -halfLength) and a starting - /// cell id of (0,0). - /// - It first checks if it is in the lower cell (if it exists). - /// - If not, it determines which cell by dividing the position relative to - /// the start of the cell array by the pitch in that direction. - /// - If it is beyond the range of the middle cells it is taken as being in - /// the upper cell. - /// - The cell number is added to the cellId that is passed to the method - /// - Once the cell is determined the function is called recursively until it - /// reaches a single cell. - /// - -{ - using Trk::distPhi; - using Trk::distEta; - - if (m_singleCell) { - return shared_from_this(); - } - - double relPosDir = 0; // Relative position along m_direction - int startIndex = 0; - double pitch = 0; - int middleCells = 0; - - if (m_direction == phiDir) { - - relPosDir = relPosition[distPhi]; - pitch = m_middleCells->phiWidth(); - middleCells = m_middleCells->phiCells(); - - if (m_lowerCell) { - if (relPosDir < m_lowerCell->phiWidth()) { - return m_lowerCell->cellIdOfPosition(relPosition, cellId); - } else { - relPosDir -= m_lowerCell->phiWidth(); - startIndex += m_lowerCell->phiCells(); - } - } - } else { // etaDir - - relPosDir = relPosition[distEta]; - pitch = m_middleCells->etaWidth(); - middleCells = m_middleCells->etaCells(); - - if (m_lowerCell) { - if (relPosDir < m_lowerCell->etaWidth()) { - return m_lowerCell->cellIdOfPosition(relPosition, cellId); - } else { - relPosDir -= m_lowerCell->etaWidth(); - startIndex += m_lowerCell->etaCells(); - } - } - } - - - int index = static_cast<int>((relPosDir) / pitch); - - if (index < 0) index = 0; // Make sure its in range (in case of rounding errors) - std::shared_ptr<const PixelDiodeMatrix> nextCell = nullptr; - - if (m_upperCell && (index >= m_numCells)) { - // We are in the upper cell. - index = m_numCells; - nextCell = m_upperCell; - } else { - // We are in the middle cells - // Make sure its in range (in case of rounding errors) - if (index >= m_numCells) index = m_numCells - 1; - nextCell = m_middleCells; - } - - - relPosDir -= index * pitch; - startIndex += index * middleCells; - - int newPhiIndex = cellId.phiIndex(); - int newEtaIndex = cellId.etaIndex(); - std::shared_ptr<const PixelDiodeMatrix> cell = nullptr; - - if (m_direction == phiDir) { - if (nextCell->singleCell()) { - newPhiIndex += startIndex; - cell = nextCell; - } else { - Amg::Vector2D newRelPos(relPosDir, relPosition[distEta]); - SiCellId relId(0,0); - cell = nextCell->cellIdOfPosition(newRelPos, relId); - newPhiIndex += startIndex + relId.phiIndex(); - newEtaIndex += relId.etaIndex(); - } - } else { - if (nextCell->singleCell()) { - newEtaIndex += startIndex; - cell = nextCell; - } else { - Amg::Vector2D newRelPos(relPosition[distPhi], relPosDir); - SiCellId relId(0,0); - cell = nextCell->cellIdOfPosition(newRelPos, relId); - newPhiIndex += relId.phiIndex(); - newEtaIndex += startIndex + relId.etaIndex(); - } - } - - cellId = SiCellId(newPhiIndex, newEtaIndex); - return cell; -} - - - -std::shared_ptr<const PixelDiodeMatrix> -PixelDiodeMatrix::positionOfCell(const SiCellId & cellId, Amg::Vector2D & position) const - - /// Description. - /// Overview of algoritm: - /// - /// - It starts with the position of the bottom left corner of the cell. - /// For the full matrix this is (-halfwidth,-halflength) - /// - It first checks if is in the lower cell (if it exists). - /// - If not it determines the bottom edge of the cell by multiplying the cell - /// number by the pitch. - /// - If it is beyond the range of the middle cells it is taken as being in - /// the upper cell. - /// - This position is then passed recursively to the same method until it - /// reaches a single cell. - /// - At the end the 2D position is then transformed to the position - /// relative to the module center. - -{ - using Trk::distPhi; - using Trk::distEta; - - if (m_singleCell) { - position[distPhi] += 0.5*m_phiWidth; - position[distEta] += 0.5*m_etaWidth; - return shared_from_this(); - } - - int relIndex = 0; // Relative index along m_direction - double pitch = 0; - int middleCells = 0; - double startPos = 0; - - if (m_direction == phiDir) { - - relIndex = cellId.phiIndex(); - pitch = m_middleCells->phiWidth(); - middleCells = m_middleCells->phiCells(); - - if (m_lowerCell) { - if (relIndex < m_lowerCell->phiCells()) { - return m_lowerCell->positionOfCell(cellId, position); - } else { - relIndex -= m_lowerCell->phiCells(); - startPos += m_lowerCell->phiWidth(); - } - } - - } else { // etaDir - - relIndex = cellId.etaIndex(); - pitch = m_middleCells->etaWidth(); - middleCells = m_middleCells->etaCells(); - - if (m_lowerCell) { - if (relIndex < m_lowerCell->etaCells()) { - return m_lowerCell->positionOfCell(cellId, position); - } else { - relIndex -= m_lowerCell->etaCells(); - startPos += m_lowerCell->etaWidth(); - } - } - } - - int index = relIndex / middleCells; - if (index > m_numCells) index = m_numCells; - relIndex -= index * middleCells; - startPos += index * pitch; - - std::shared_ptr<const PixelDiodeMatrix> nextCell = nullptr; - - if (m_upperCell && (index == m_numCells)) { - // We are in the upper cell. - nextCell = m_upperCell; - } else { - // We are in the middle cells - nextCell = m_middleCells; - } - - std::shared_ptr<const PixelDiodeMatrix> cell = nullptr; - if (m_direction == phiDir) { - SiCellId relId(relIndex,cellId.etaIndex()); - position[distPhi] += startPos; - cell = nextCell->positionOfCell(relId, position); - } else { - SiCellId relId(cellId.phiIndex(),relIndex); - position[distEta] += startPos; - cell = nextCell->positionOfCell(relId, position); - } - - return cell; -} - -} // end namespace diff --git a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelMultipleConnection1D.cxx b/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelMultipleConnection1D.cxx deleted file mode 100755 index f01091e5751..00000000000 --- a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelMultipleConnection1D.cxx +++ /dev/null @@ -1,141 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelMultipleConnection1D.cxx -// Implementation file for class PixelMultipleConnection1D -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// -// Version 1.1 05/04/2001 David Calvet -// 06/02/2008 Grant Gorfine -/////////////////////////////////////////////////////////////////// - -#include "PixelReadoutGeometry/PixelMultipleConnection1D.h" -#include <iostream> - -namespace InDetDD { - -// Constructor with parameters: -PixelMultipleConnection1D::PixelMultipleConnection1D(const int lowerIndex, - const std::vector<int> &connections) - : m_lowerDiode(0), - m_upperDiode(-1), - m_lowerReadout(0), - m_upperReadout(-1) -{ - set(lowerIndex, connections); -} - -PixelMultipleConnection1D::PixelMultipleConnection1D() - : m_lowerDiode(0), - m_upperDiode(-1), - m_lowerReadout(0), - m_upperReadout(-1) -{} - -void -PixelMultipleConnection1D::set(const int lowerIndex, - const std::vector<int> &connections) -{ - - // extract lower and upper diode and readout cell numbers from connections vector - bool firstDiode = true; - bool firstReadout = true; - for(unsigned int index = 0; index < connections.size(); ++index) { - int readout = connections[index]; - int diode = lowerIndex + index; - if (firstDiode && readout != diode) { - m_lowerDiode = diode; - m_upperDiode = diode; - firstDiode = false; - } - if (firstReadout) { - m_lowerReadout=readout; - m_upperReadout=readout; - firstReadout = false; - } - if (readout<m_lowerReadout) m_lowerReadout=readout; - if (readout>m_upperReadout) m_upperReadout=readout; - if (readout != diode && diode < m_lowerDiode) m_lowerDiode = diode; - if (readout != diode && diode > m_upperDiode) m_upperDiode = diode; - } - - // Fource readout range to be include diode range (this is generally already the case) - if (m_lowerReadout > m_lowerDiode) m_lowerReadout = m_lowerDiode; - if (m_upperReadout < m_upperDiode) m_upperReadout = m_upperDiode; - - m_diodeToReadout.resize(m_upperDiode - m_lowerDiode + 1); - m_readoutToDiode.resize(m_upperReadout - m_lowerReadout + 1); - - // First fill primary cell. ie diode and readout the same. - for(unsigned int index = 0; index < connections.size(); ++index) { - int readout = connections[index]; - int diode = lowerIndex + index; - if (readout == diode) m_readoutToDiode[readout-m_lowerReadout].push_back(diode); - } - - - // Now the rest of readoutToDiode ie diode and readout not the same. - // Fill also diodeToReadout - for(unsigned int index = 0; index < connections.size(); ++index) { - int readout = connections[index]; - int diode = lowerIndex + index; - if (readout != diode) m_readoutToDiode[readout - m_lowerReadout].push_back(diode); - if (diode >= m_lowerDiode && diode <= m_upperDiode) m_diodeToReadout[diode - m_lowerDiode] = readout; - } - - // Created ganged map. If the diode is ganged it points to the other diode. - m_diodeGanged.resize(m_upperReadout - m_lowerReadout + 1); - for(int iDiode = m_lowerReadout; iDiode <= m_upperReadout; iDiode++) { - // Fill with the same index which indicates its not ganged. - m_diodeGanged[iDiode - m_lowerReadout] = iDiode; - int readout = iDiode; - if (!outsideDiode(iDiode)) readout = readoutOfDiode(iDiode); - if (numberOfConnectedCells(readout) >= 2) { - int cell0 = connectedCell(readout, 0); - int cell1 = connectedCell(readout, 1); - if (iDiode == cell0) { - m_diodeGanged[iDiode - m_lowerReadout] = cell1; - } else { - m_diodeGanged[iDiode - m_lowerReadout] = cell0; - } - } - } - - // For debugging only - //debugPrintout(); -} - -void PixelMultipleConnection1D::debugPrintout() -{ - // Debug printout - std::cout << "m_lowerDiode = " << m_lowerDiode << std::endl; - std::cout << "m_upperDiode = " << m_upperDiode << std::endl; - std::cout << "m_lowerReadout = " << m_lowerReadout << std::endl; - std::cout << "m_upperReadout = " << m_upperReadout << std::endl; - std::cout << "m_readoutToDiode: "; - for (unsigned int i = 0; i < m_readoutToDiode.size(); i++) { - std::cout << "(" << m_lowerReadout + i << ": "; - for (unsigned int j = 0; j < m_readoutToDiode[i].size(); j++) { - std::cout << m_readoutToDiode[i][j] << " "; - } - std::cout << ") "; - } - std::cout << std::endl; - - for (unsigned int i = 0; i < m_diodeToReadout.size(); i++) { - std::cout << "(" << m_lowerDiode + i << ": " << m_diodeToReadout[i] << ") "; - } - std::cout << std::endl; - - for (unsigned int i = 0; i < m_diodeGanged.size(); i++) { - std::cout << "(" << m_lowerReadout + i << ": " << m_diodeGanged[i] << ") "; - } - std::cout << std::endl; -} - - - -} // namespace InDetDD diff --git a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelReadoutScheme.cxx b/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelReadoutScheme.cxx deleted file mode 100755 index e8ffe8e0aca..00000000000 --- a/InnerDetector/InDetDetDescr/PixelReadoutGeometry/src/PixelReadoutScheme.cxx +++ /dev/null @@ -1,104 +0,0 @@ -/* - Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration -*/ - -/////////////////////////////////////////////////////////////////// -// PixelReadoutScheme.cxx -// Implementation file for class PixelReadoutScheme -/////////////////////////////////////////////////////////////////// -// (c) ATLAS Pixel Detector software -/////////////////////////////////////////////////////////////////// -// Version 2.1 08/06/2001 David Calvet -// Modified: Grant Gorfine -/////////////////////////////////////////////////////////////////// - -#include "PixelReadoutGeometry/PixelReadoutScheme.h" -#include "ReadoutGeometryBase/SiCellId.h" -#include "ReadoutGeometryBase/SiReadoutCellId.h" - -namespace InDetDD { - -// Constructor with parameters: -PixelReadoutScheme::PixelReadoutScheme(const int circuitsPerColumn, - const int circuitsPerRow, - const int cellColumnsPerCircuit, - const int cellRowsPerCircuit, - const int diodeColumnsPerCircuit, - const int diodeRowsPerCircuit) : - m_numberOfCircuits(circuitsPerColumn*circuitsPerRow), - m_columnsPerCircuit(cellColumnsPerCircuit), - m_rowsPerCircuit(cellRowsPerCircuit), - m_columns(circuitsPerRow*diodeColumnsPerCircuit), - m_rows(circuitsPerColumn*diodeRowsPerCircuit) -{} - - - -// Number of cells connected to this readout. 2 means its ganged. -int -PixelReadoutScheme::numberOfConnectedCells(const SiReadoutCellId & readoutId) const -{ - if (!readoutId.isValid()) return 0; - - // Do quick check to see if it is outside ganged pixel range. - int phiIndex = readoutId.phiIndex(); - if (m_rowConnections.outsideReadout(phiIndex)) return 1; - - return m_rowConnections.numberOfConnectedCells(phiIndex); - -} - -// Id of diodes connected to this readout. 0 is the primary cell. -SiCellId -PixelReadoutScheme::connectedCell(const SiReadoutCellId & readoutId, unsigned int number) const -{ - if (!readoutId.isValid()) return SiCellId(); - - // Do quick check to see if it is outside ganged pixel range. - int phiIndex = readoutId.phiIndex(); - if (m_rowConnections.outsideReadout(phiIndex)) return readoutId; - - int numConnected = m_rowConnections.numberOfConnectedCells(phiIndex); - if (!numConnected || static_cast<int>(number) >= numConnected) return SiCellId(); - - int newPhiIndex = m_rowConnections.connectedCell(phiIndex, number); - return SiCellId(newPhiIndex, readoutId.etaIndex()); -} - -// Id of the readout cell for this diode. -SiReadoutCellId -PixelReadoutScheme::readoutIdOfCell(const SiCellId & cellId) const -{ - if (!cellId.isValid()) return SiReadoutCellId(); - - int phiIndex = cellId.phiIndex(); - int newPhiIndex = phiIndex; - if (!m_rowConnections.outsideDiode(phiIndex)) { - newPhiIndex = m_rowConnections.readoutOfDiode(phiIndex); - } - - return SiReadoutCellId(newPhiIndex, cellId.etaIndex()); - -} - -SiCellId -PixelReadoutScheme::gangedCell(const SiCellId & cellId) const -{ - if (!cellId.isValid()) return cellId; - int phiIndex = cellId.phiIndex(); - if (m_rowConnections.outsideReadout(phiIndex)) return SiCellId(); // Invalid ID - int newPhiIndex = m_rowConnections.gangedCell(phiIndex); - if (newPhiIndex == phiIndex) return SiCellId(); // Invalid ID - return SiCellId(newPhiIndex, cellId.etaIndex()); -} - - -void PixelReadoutScheme::addMultipleRowConnection(const int lowerIndex, - const std::vector<int> &connections) -{ - - m_rowConnections.set(lowerIndex, connections); -} - - -} // namespace InDetDD -- GitLab