ATLAS Offline Software
Public Member Functions | Private Member Functions | Static Private Member Functions | Private Attributes | List of all members
InDetDD::PixelDiodeMap Class Reference

#include <PixelDiodeMap.h>

Collaboration diagram for InDetDD::PixelDiodeMap:

Public Member Functions

 PixelDiodeMap (std::shared_ptr< const PixelDiodeMatrix > diodeMatrix)
 Constructor from Diode matrix description. More...
 
 PixelDiodeMap (const PixelDiodeMap &map)
 Copy constructor: More...
 
 ~PixelDiodeMap ()
 Destructor. More...
 
PixelDiodeMapoperator= (const PixelDiodeMap &map)
 Assignment operator. More...
 
SiDiodesParameters parameters (const SiCellId &diodeId) const
 Get diodes parameters (position and size): More...
 
SiCellId cellIdOfPosition (const Amg::Vector2D &localPosition) const
 cell id for a given local position More...
 
SiCellId cellIdInRange (const SiCellId &cellId) const
 Check if cellId is within range. More...
 
void neighboursOfCell (const SiCellId &cellId, std::vector< SiCellId > &neighbours) 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. More...
 
double intersectionLength (const SiCellId &diode1, const SiCellId &diode2) 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. More...
 
double leftColumn () const
 
double rightColumn () const
 
double leftRow () const
 
double rightRow () const
 
double width () const
 
double length () const
 
int phiDiodes () const
 
int etaDiodes () const
 
int diodes () const
 
void setGeneralLayout ()
 Set general layout flag. More...
 
std::string debugStringRepr () const
 Debug representation. More...
 
PixelDiodeParametersProxy parametersProxy (const SiCellId &cellId) const
 Search diode for the given cell and return proxy to access its parameters. More...
 

Private Member Functions

void neighboursOfCellGeneral (const SiCellId &cellId, std::vector< SiCellId > &neighbours) const
 Slower method. More...
 
double intersectionLengthGeneral (const SiCellId &diode1, const SiCellId &diode2) const
 Slower method. More...
 

Static Private Member Functions

static double intersectionLength1D (const double x1, const double dx1, const double x2, const double dx2)
 Compute the intersection length along one direction: return 0 if no intersection x1,x2 are the centers dx1,dx2 are the full lengths. More...
 

Private Attributes

std::shared_ptr< const PixelDiodeMatrixm_matrix
 diode matrix More...
 
bool m_generalLayout
 Flag set to allow for dealing wth more general layouts. More...
 

Detailed Description

Class used to describe the diode segmentation of a pixel module

Author
: David Calvet
  • modified Davide Costanzo. Replace PixelModulePosition with SiCellId
  • modified: Grant Gorfine, Andreas Salzburger

Definition at line 44 of file PixelDiodeMap.h.

Constructor & Destructor Documentation

◆ PixelDiodeMap() [1/2]

InDetDD::PixelDiodeMap::PixelDiodeMap ( std::shared_ptr< const PixelDiodeMatrix diodeMatrix)

Constructor from Diode matrix description.

Definition at line 28 of file PixelDiodeMap.cxx.

28  :
29  m_matrix(std::move(matrix)),
30  m_generalLayout(false)
31 {
32 }

◆ PixelDiodeMap() [2/2]

InDetDD::PixelDiodeMap::PixelDiodeMap ( const PixelDiodeMap map)

Copy constructor:

◆ ~PixelDiodeMap()

InDetDD::PixelDiodeMap::~PixelDiodeMap ( )
default

Destructor.

Member Function Documentation

◆ cellIdInRange()

SiCellId InDetDD::PixelDiodeMap::cellIdInRange ( const SiCellId cellId) const
inline

Check if cellId is within range.

Definition at line 197 of file PixelDiodeMap.h.

198  {
199  if (!cellId.isValid() ||
200  cellId.phiIndex() <0 || cellId.phiIndex() >= phiDiodes() ||
201  cellId.etaIndex() <0 || cellId.etaIndex() >= etaDiodes()) return SiCellId(); // Invalid
202  return cellId;
203  }

◆ cellIdOfPosition()

SiCellId InDetDD::PixelDiodeMap::cellIdOfPosition ( const Amg::Vector2D localPosition) const

cell id for a given local position

Definition at line 38 of file PixelDiodeMap.cxx.

39 {
40  using std::abs;
41  using Trk::distPhi;
42  using Trk::distEta;
43 
44  // Check that we are in the bounds of the top level matrix
45  // NB. edge is included in bounds.
46 
47  double halfWidth = 0.5*width();
48  double halfLength = 0.5*length();
49  if ( (abs(localPos[distPhi]) > halfWidth) ||
50  (abs(localPos[distEta]) > halfLength) ) {
51  return {}; // Invalid Id.
52  }
53 
54  // position relative to bottom left corner.
55  Amg::Vector2D relativePos = localPos + Amg::Vector2D(halfWidth, halfLength);
56 
57  // The cellId returned will be added to this so we must start with 0,0.
58  SiCellId cellId(0,0);
59 
60  const PixelDiodeMatrix *cell = m_matrix->cellIdOfPosition(relativePos, cellId);
61  // return invalid Id if there was a problem (don't expect this to be the case).
62  if (cell==nullptr) {
63  return {}; // Invalid id.
64  }
65 
66  return cellId;
67 
68 }

◆ debugStringRepr()

std::string InDetDD::PixelDiodeMap::debugStringRepr ( ) const
inline

Debug representation.

Definition at line 205 of file PixelDiodeMap.h.

206  {
207  return m_matrix->createDebugStringRepr();
208  }

◆ diodes()

int InDetDD::PixelDiodeMap::diodes ( ) const
inline

Definition at line 182 of file PixelDiodeMap.h.

183  {
184  return phiDiodes() * etaDiodes();
185  }

◆ etaDiodes()

int InDetDD::PixelDiodeMap::etaDiodes ( ) const
inline

Definition at line 192 of file PixelDiodeMap.h.

193  {
194  return m_matrix->etaCells();
195  }

◆ intersectionLength()

double InDetDD::PixelDiodeMap::intersectionLength ( const SiCellId diode1,
const SiCellId diode2 
) 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.

Definition at line 215 of file PixelDiodeMap.cxx.

217 {
218  if(!diode1.isValid() || !diode2.isValid()) return 0;
219  // If non regular layout revert to slower method
220  if (m_generalLayout) return intersectionLengthGeneral(diode1, diode2);
221 
222  const SiLocalPosition size = parameters(diode1).width();
223 
224  int phiIndexDelta = std::abs(diode1.phiIndex() - diode2.phiIndex());
225  int etaIndexDelta = std::abs(diode1.etaIndex() - diode2.etaIndex());
226 
227  // Intersection length is just the length or width of the diode depending on which neighbour.
228  if (phiIndexDelta == 1 && etaIndexDelta == 0) return size.xEta();
229  if (phiIndexDelta == 0 && etaIndexDelta == 1) return size.xPhi();
230  // Will return 0 if it is a corner neighbour or if its not a neighbour or if they are oth the same diode.
231  return 0;
232 }

◆ intersectionLength1D()

double InDetDD::PixelDiodeMap::intersectionLength1D ( const double  x1,
const double  dx1,
const double  x2,
const double  dx2 
)
staticprivate

Compute the intersection length along one direction: return 0 if no intersection x1,x2 are the centers dx1,dx2 are the full lengths.

Definition at line 270 of file PixelDiodeMap.cxx.

272 {
273  // compute distance between the two centers
274  double distance=std::abs(x1-x2);
275 
276  // compute theoretical intersection
277  double intersection=(dx1+dx2)/2-distance;
278 
279  // if intersection if negative, no intersection
280  if (intersection<-1e-10) return intersection;
281  else if (intersection<1e-10) return 0;
282  else {
283  // intersection cannot exceed size
284  if (intersection>dx1) intersection=dx1;
285  if (intersection>dx2) intersection=dx2;
286  return intersection;
287  }
288 }

◆ intersectionLengthGeneral()

double InDetDD::PixelDiodeMap::intersectionLengthGeneral ( const SiCellId diode1,
const SiCellId diode2 
) const
private

Slower method.

Called by intersectionLength if m_generalLayout set.

Definition at line 237 of file PixelDiodeMap.cxx.

240 {
241  const SiDiodesParameters params1=parameters(diode1);
242  const SiDiodesParameters params2=parameters(diode2);
243  const SiLocalPosition center1=params1.centre();
244  const SiLocalPosition center2=params2.centre();
245  const SiLocalPosition size1=params1.width();
246  const SiLocalPosition size2=params2.width();
247 
248  // compute intersection length on column direction
249  const double intersectionColumn=intersectionLength1D(center1.xColumn(),
250  size1.xColumn(),
251  center2.xColumn(),
252  size2.xColumn());
253  // compute intersection length on row direction
254  const double intersectionRow=intersectionLength1D(center1.xRow(),
255  size1.xRow(),
256  center2.xRow(),
257  size2.xRow());
258 
259  // return the real intersection
260  // (if both directions intersect, there is a problem)
261  if (intersectionColumn>0) {
262  if (intersectionRow>0) return 0;
263  return intersectionColumn;
264  } else {
265  return intersectionRow;
266  }
267 }

◆ leftColumn()

double InDetDD::PixelDiodeMap::leftColumn ( ) const
inline

Definition at line 162 of file PixelDiodeMap.h.

163  {
164  return -0.5*length();
165  }

◆ leftRow()

double InDetDD::PixelDiodeMap::leftRow ( ) const
inline

Definition at line 172 of file PixelDiodeMap.h.

173  {
174  return -0.5*width();
175  }

◆ length()

double InDetDD::PixelDiodeMap::length ( ) const
inline

Definition at line 152 of file PixelDiodeMap.h.

153  {
154  return m_matrix->etaWidth();
155  }

◆ neighboursOfCell()

void InDetDD::PixelDiodeMap::neighboursOfCell ( const SiCellId cellId,
std::vector< SiCellId > &  neighbours 
) 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.

Definition at line 104 of file PixelDiodeMap.cxx.

106 {
107  neighbours.clear();
108 
109  if (!cellId.isValid()) return;
110 
111  // If non regular layout revert to slower method
112  if (m_generalLayout) return neighboursOfCellGeneral(cellId, neighbours);
113 
114  neighbours.reserve(8);
115  // neighbours easily determined from cell number
116  // normally 8 neighbours 4 edge and 4 corners
117 
118  int phiIndex = cellId.phiIndex();
119  int etaIndex = cellId.etaIndex();
120 
121  // M = minus
122  // P = plus
123  int phiM = phiIndex-1;
124  int phiP = phiIndex+1;
125  int etaM = etaIndex-1;
126  int etaP = etaIndex+1;
127 
128  // -,0
129  if (phiM >= 0) neighbours.emplace_back(phiM,etaIndex);
130  // -,-
131  if (phiM >= 0 && etaM >= 0) neighbours.emplace_back(phiM,etaM);
132  // 0,-
133  if (etaM >= 0) neighbours.emplace_back(phiIndex,etaM);
134  // +,-
135  if (phiP < phiDiodes() && etaM >= 0) neighbours.emplace_back(phiP,etaM);
136  // +,0
137  if (phiP < phiDiodes()) neighbours.emplace_back(phiP,etaIndex);
138  // -,+
139  if (phiM >= 0 && etaP < etaDiodes()) neighbours.emplace_back(phiM,etaP);
140  // 0,+
141  if (etaP < etaDiodes()) neighbours.emplace_back(phiIndex,etaP);
142  // +,+
143  if (phiP < phiDiodes() && etaP < etaDiodes()) neighbours.emplace_back(phiP,etaP);
144 }

◆ neighboursOfCellGeneral()

void InDetDD::PixelDiodeMap::neighboursOfCellGeneral ( const SiCellId cellId,
std::vector< SiCellId > &  neighbours 
) const
private

Slower method.

Called by neighboursOfCell if m_generalLayout set.

Definition at line 149 of file PixelDiodeMap.cxx.

151 {
152  // extract the diode spatial parameters
153  const SiDiodesParameters params=parameters(cellId);
154  const SiLocalPosition diodeCenter=params.centre();
155  const SiLocalPosition diodeSize=params.width();
156  const double &centerColumn=diodeCenter.xColumn();
157  const double &centerRow=diodeCenter.xRow();
158  const double halfSizeColumn=diodeSize.xColumn()/2;
159  const double halfSizeRow=diodeSize.xRow()/2;
160 
161  // parameter
162  const double epsilon=0.01;
163 
164  // compute the points to check
165  const double left1=centerColumn-halfSizeColumn*(1+epsilon);
166  const double right1=centerColumn+halfSizeColumn*(1+epsilon);
167  const double left2=centerColumn-halfSizeColumn*(1-epsilon);
168  const double right2=centerColumn+halfSizeColumn*(1-epsilon);
169  const double top1=centerRow+halfSizeRow*(1+epsilon);
170  const double bot1=centerRow-halfSizeRow*(1+epsilon);
171  const double top2=centerRow+halfSizeRow*(1-epsilon);
172  const double bot2=centerRow-halfSizeRow*(1-epsilon);
173 
174  // build the list of positions to check
175  std::vector<SiLocalPosition> positions;
176  positions.reserve(12);
177  SiLocalPosition position;
178  position.xRow(bot1); position.xColumn(left2); positions.push_back(position);
179  position.xRow(bot1); position.xColumn(left1); positions.push_back(position);
180  position.xRow(bot2); position.xColumn(left1); positions.push_back(position);
181  position.xRow(top2); position.xColumn(left1); positions.push_back(position);
182  position.xRow(top1); position.xColumn(left1); positions.push_back(position);
183  position.xRow(top1); position.xColumn(left2); positions.push_back(position);
184  position.xRow(bot1); position.xColumn(right2); positions.push_back(position);
185  position.xRow(bot1); position.xColumn(right1); positions.push_back(position);
186  position.xRow(bot2); position.xColumn(right1); positions.push_back(position);
187  position.xRow(top2); position.xColumn(right1); positions.push_back(position);
188  position.xRow(top1); position.xColumn(right1); positions.push_back(position);
189  position.xRow(top1); position.xColumn(right2); positions.push_back(position);
190 
191  // build the list of neighbours
192  neighbours.reserve(8);
193 
194  // loop on all positions to check
195  for(const auto & position : positions) {
196 
197  // get the PixelDiode for this position
198  SiCellId cellId_neighb = cellIdOfPosition(position);
199 
200  if (cellId.isValid()) {
201  // check if the diode is already in the list
202  //bool found=false;
203  std::vector<SiCellId>::const_iterator foundIter
204  = std::find(neighbours.begin(), neighbours.end(), cellId_neighb );
205 
206  // If not found add this diode to the list
207  if (foundIter == neighbours.end()) neighbours.push_back(cellId_neighb);
208 
209  }
210  }
211 }

◆ operator=()

PixelDiodeMap& InDetDD::PixelDiodeMap::operator= ( const PixelDiodeMap map)

Assignment operator.

◆ parameters()

SiDiodesParameters InDetDD::PixelDiodeMap::parameters ( const SiCellId diodeId) const

Get diodes parameters (position and size):

Definition at line 73 of file PixelDiodeMap.cxx.

74 {
75 
76  // Check we are in range
77 
78  if (!cellId.isValid() ||
79  (cellId.phiIndex() < 0) ||
80  (cellId.phiIndex() >= m_matrix->phiCells()) ||
81  (cellId.etaIndex() < 0) ||
82  (cellId.etaIndex() >= m_matrix->etaCells())) {
83  return {};
84  }
85 
86  //
87  // Position is relative to left bottom corner.
88  //
89  Amg::Vector2D position;
90  const PixelDiodeMatrix *cell = m_matrix->positionOfCell(cellId, position);
91  if (cell != nullptr) {
92 
93  // get size
94  Amg::Vector2D size(cell->phiWidth(), cell->etaWidth());
95 
96  // return parameters
97  return SiDiodesParameters(position,size);
98  }
99 
100  // return something in case of failure.
101  return {};
102 }

◆ parametersProxy()

PixelDiodeParametersProxy InDetDD::PixelDiodeMap::parametersProxy ( const SiCellId cellId) const
inline

Search diode for the given cell and return proxy to access its parameters.

Will search through the diode matrix, and compute the diode position at the same time. The position will be cached in the proxy. The proxy will provide access to parameters associated to the diode.

Definition at line 210 of file PixelDiodeMap.h.

210  {
211  PixelDiodeParametersProxy ret;
212  ret.cell_ptr() = m_matrix->positionOfCell(cellId, ret.position());
213  return ret;
214  }

◆ phiDiodes()

int InDetDD::PixelDiodeMap::phiDiodes ( ) const
inline

Definition at line 187 of file PixelDiodeMap.h.

188  {
189  return m_matrix->phiCells();
190  }

◆ rightColumn()

double InDetDD::PixelDiodeMap::rightColumn ( ) const
inline

Definition at line 167 of file PixelDiodeMap.h.

168  {
169  return 0.5*length();
170  }

◆ rightRow()

double InDetDD::PixelDiodeMap::rightRow ( ) const
inline

Definition at line 177 of file PixelDiodeMap.h.

178  {
179  return 0.5*width();
180  }

◆ setGeneralLayout()

void InDetDD::PixelDiodeMap::setGeneralLayout ( )
inline

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.

Definition at line 107 of file PixelDiodeMap.h.

107 {m_generalLayout = true;}

◆ width()

double InDetDD::PixelDiodeMap::width ( ) const
inline

Definition at line 157 of file PixelDiodeMap.h.

158  {
159  return m_matrix->phiWidth();
160  }

Member Data Documentation

◆ m_generalLayout

bool InDetDD::PixelDiodeMap::m_generalLayout
private

Flag set to allow for dealing wth more general layouts.

Definition at line 145 of file PixelDiodeMap.h.

◆ m_matrix

std::shared_ptr<const PixelDiodeMatrix> InDetDD::PixelDiodeMap::m_matrix
private

diode matrix

Definition at line 144 of file PixelDiodeMap.h.


The documentation for this class was generated from the following files:
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
plotBeamSpotCompare.x1
x1
Definition: plotBeamSpotCompare.py:215
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
InDetDD::PixelDiodeMap::parameters
SiDiodesParameters parameters(const SiCellId &diodeId) const
Get diodes parameters (position and size):
Definition: PixelDiodeMap.cxx:73
InDetDD::PixelDiodeMap::m_matrix
std::shared_ptr< const PixelDiodeMatrix > m_matrix
diode matrix
Definition: PixelDiodeMap.h:144
InDetDD::PixelDiodeMap::width
double width() const
Definition: PixelDiodeMap.h:157
plotBeamSpotCompare.x2
x2
Definition: plotBeamSpotCompare.py:217
InDetDD::PixelDiodeMap::intersectionLength1D
static double intersectionLength1D(const double x1, const double dx1, const double x2, const double dx2)
Compute the intersection length along one direction: return 0 if no intersection x1,...
Definition: PixelDiodeMap.cxx:270
InDetDD::PixelDiodeMap::m_generalLayout
bool m_generalLayout
Flag set to allow for dealing wth more general layouts.
Definition: PixelDiodeMap.h:145
intersection
std::vector< std::string > intersection(std::vector< std::string > &v1, std::vector< std::string > &v2)
Definition: compareFlatTrees.cxx:25
InDetDD::PixelDiodeMap::etaDiodes
int etaDiodes() const
Definition: PixelDiodeMap.h:192
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
Trk::distEta
@ distEta
readout for silicon
Definition: ParamDefs.h:51
InDetDD::PixelDiodeMap::phiDiodes
int phiDiodes() const
Definition: PixelDiodeMap.h:187
Trk::distPhi
@ distPhi
Definition: ParamDefs.h:50
InDetDD::PixelDiodeMap::neighboursOfCellGeneral
void neighboursOfCellGeneral(const SiCellId &cellId, std::vector< SiCellId > &neighbours) const
Slower method.
Definition: PixelDiodeMap.cxx:149
eflowRec::phiIndex
unsigned int phiIndex(float phi, float binsize)
calculate phi index for a given phi
Definition: EtaPhiLUT.cxx:23
InDetDD::PixelDiodeMap::length
double length() const
Definition: PixelDiodeMap.h:152
python.testIfMatch.matrix
matrix
Definition: testIfMatch.py:63
InDetDD::SiDiodesParameters::width
const SiLocalPosition & width() const
width of the diodes:
Definition: SiDiodesParameters.h:96
InDetDD::PixelDiodeMap::intersectionLengthGeneral
double intersectionLengthGeneral(const SiCellId &diode1, const SiCellId &diode2) const
Slower method.
Definition: PixelDiodeMap.cxx:237
PowhegControl_ttFCNC_NLO.params
params
Definition: PowhegControl_ttFCNC_NLO.py:226
InDetDD::PixelDiodeMap::cellIdOfPosition
SiCellId cellIdOfPosition(const Amg::Vector2D &localPosition) const
cell id for a given local position
Definition: PixelDiodeMap.cxx:38
Amg::distance
float distance(const Amg::Vector3D &p1, const Amg::Vector3D &p2)
calculates the distance between two point in 3D space
Definition: GeoPrimitivesHelpers.h:54