Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
TrapezoidSegmentation.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // TrapezoidSegmentation.cxx, ATLAS Detector software
8 
9 // Trk includes
10 #include <memory>
11 
12 
13 
18 // Amg includes
20 
21 Trk::TrapezoidSegmentation::TrapezoidSegmentation(std::shared_ptr<const Trk::TrapezoidBounds> mBounds,
22  size_t numCellsX, size_t numCellsY) :
23  m_activeBounds(std::move(mBounds)),
24  m_binUtility(nullptr),
25  m_binsX(numCellsX),
26  m_binsY(numCellsY)
27 {
28  // first the x dimension if needed
29  if (numCellsX > 1) {
30  m_binUtility = new Trk::BinUtility(numCellsX, -0.5*(m_activeBounds->minHalflengthX()+m_activeBounds->maxHalflengthX()), 0.5*(m_activeBounds->minHalflengthX()+m_activeBounds->maxHalflengthX()), Trk::open, Trk::binX);
31  }
32  // use y dimension if needed
33  if (numCellsY > 1){
34  Trk::BinUtility yBinUtility(numCellsY, -m_activeBounds->halflengthY(), m_activeBounds->halflengthY(), Trk::open, Trk::binY);
35  if (m_binUtility)
36  (*m_binUtility) += yBinUtility;
37  else
38  m_binUtility = new Trk::BinUtility(yBinUtility);
39  }
40 }
41 
43 {
44  delete m_binUtility;
45 }
46 
47 void Trk::TrapezoidSegmentation::createSegmenationSurfaces(std::vector< std::shared_ptr< const Trk::Surface> >& boundarySurfaces,
48  std::vector< std::shared_ptr< const Trk::Surface> >& segmentationSurfacesX,
49  std::vector< std::shared_ptr< const Trk::Surface> >& segmentationSurfacesY,
50  double halfThickness,
51  int readoutDirection,
52  double) const
53 {
54  // The Lorentz angle is not taken into account for trapezoidal segmentation
55  // (A) --- top/bottom surfaces -----------------------------------------------------------
56  // let's create the top/botten surfaces first - we call them readout / counter readout
57  // there are some things to consider
58  // - they share only the readout surface, then the segmentation surfaces are tilted and cannot be shared on the same module
59  std::unique_ptr<Trk::TrapezoidBounds> moduleTrapBounds(new Trk::TrapezoidBounds(m_activeBounds->minHalflengthX(),m_activeBounds->maxHalflengthX(),m_activeBounds->halflengthY()));
60  std::shared_ptr<const Trk::SurfaceBounds> moduleBounds(&*moduleTrapBounds);
61  // - they are separated by half a thickness in z
62  Amg::Transform3D readoutPlaneTransform(Amg::Transform3D::Identity());
63  Amg::Transform3D counterPlaneTransform(Amg::Transform3D::Identity());
64  // readout and counter readout bounds, the bounds of the readout plane are like the active ones
65  const std::shared_ptr<const Trk::SurfaceBounds>& readoutPlaneBounds = moduleBounds;
66  std::shared_ptr<const Trk::SurfaceBounds> counterPlaneBounds(nullptr);
67  // the transform of the readout plane is always centric
68  readoutPlaneTransform.translation() = Amg::Vector3D(0.,0.,readoutDirection*halfThickness);
69  // no lorentz angle and everything is straight-forward
70  counterPlaneBounds = moduleBounds;
71  counterPlaneTransform.translation() = Amg::Vector3D(0.,0.,-readoutDirection*halfThickness);
72 
73  // - build the readout & counter readout surfaces
74  boundarySurfaces.push_back(std::make_shared<const Trk::PlaneSurface>(readoutPlaneTransform,readoutPlaneBounds));
75  boundarySurfaces.push_back(std::make_shared<const Trk::PlaneSurface>(counterPlaneTransform,counterPlaneBounds));
76 
77  // (B) - bin X -----------------------------------------------------------
78  // easy stuff first, constant pitch size and
79  double pitchX = 2.*(m_activeBounds->maxHalflengthX()+m_activeBounds->minHalflengthX())*0.5/m_binsX;
80 
81  // now the rotation matrix for the xBins
82  Amg::RotationMatrix3D xBinRotationMatrix;
83  xBinRotationMatrix.col(0) = Amg::Vector3D::UnitY();
84  xBinRotationMatrix.col(1) = Amg::Vector3D::UnitZ();
85  xBinRotationMatrix.col(2) = Amg::Vector3D::UnitX();
86 
87  // reserve, it's always (number of bins-1) as the boundaries are within the boundarySurfaces
88  segmentationSurfacesX.reserve(m_binsX);
89  for (size_t ibinx = 0; ibinx <= m_binsX; ++ibinx){
90  // the current step x position
91  double cPosX = -(m_activeBounds->minHalflengthX()+m_activeBounds->maxHalflengthX())*0.5+ibinx*pitchX;
92 
93  // set position & rotation for all (boundaries and segmentations) --> Then you separate between them
94  Amg::Vector3D xPosition = Amg::Vector3D(cPosX, 0.,0.);
95  double stereoLocal = asin(sinStereoLocal(Amg::Vector2D(cPosX, 0.)));
96  const Amg::RotationMatrix3D xRotation = xBinRotationMatrix*Amg::AngleAxis3D(stereoLocal, Amg::Vector3D::UnitY());
97  // build the rotation from it
98  Amg::Transform3D binTransform(Amg::getTransformFromRotTransl(xRotation, xPosition));
99  // the correct bounds for this
100  auto xBinBounds = std::make_unique<Trk::RectangleBounds>(m_activeBounds->halflengthY()/cos(stereoLocal),halfThickness);
101  // these are the boundaries
102  if (ibinx==0 || ibinx == m_binsX) // (i) this is the low/high boundary --- ( ibin == 0/m_binsX )
103  boundarySurfaces.push_back(std::make_shared<const Trk::PlaneSurface>(binTransform,&*xBinBounds));
104  else // these are the bin boundaries
105  segmentationSurfacesX.push_back(std::make_shared<const Trk::PlaneSurface>(binTransform,&*xBinBounds));
106  }
107 
108  // (C) - bin Y surfaces - everything is defined -----------------------------------------------------------
109  // now the rotation matrix for the yBins - anticyclic
110  Amg::RotationMatrix3D yBinRotationMatrix;
111  yBinRotationMatrix.col(0) = Amg::Vector3D::UnitX();
112  yBinRotationMatrix.col(1) = Amg::Vector3D::UnitZ();
113  yBinRotationMatrix.col(2) = Amg::Vector3D(0.,-1.,0.);
114  // easy stuff first, constant pitch in Y
115  double pitchY = 2.*m_activeBounds->halflengthY()/m_binsY;
116  // reserve, it's always (number of bins-1) as the boundaries are within the boundarySurfaces
117  segmentationSurfacesY.reserve(m_binsY);
118  for (size_t ibiny = 0; ibiny <= m_binsY; ++ibiny){
119  // the position of the bin surface
120  double binPosY = -m_activeBounds->halflengthY()+ibiny*pitchY;
121  Amg::Vector3D binSurfaceCenter(0.,binPosY,0.);
122  double localPitchX = PitchX(Amg::Vector2D(0., binPosY));
123  auto yBinBounds = std::make_unique<Trk::RectangleBounds>(localPitchX*m_binsX*0.5,halfThickness);
124  Amg::Transform3D binTransform(Amg::getTransformFromRotTransl(yBinRotationMatrix,binSurfaceCenter));
125  // these are the boundaries
126  if (ibiny == 0 || ibiny == m_binsY)
127  boundarySurfaces.push_back(std::make_shared<Trk::PlaneSurface>(binTransform,&*yBinBounds));
128  else // these are the bin boundaries
129  segmentationSurfacesY.push_back(std::make_shared<Trk::PlaneSurface>(binTransform,&*yBinBounds));
130  }
131 }
132 
133 
135 {
136  // use the bin utility for this job
137  double bX = (m_binsX>1) ? m_binUtility->binPosition(projectLocX(Amg::Vector2D(dCell.first, dCell.second)),0.,0) : 0.;
138  double bY = (m_binsY>1) ? m_binUtility->binPosition(dCell.second,0.,1) : 0.;
139  return Amg::Vector2D(bX,bY);
140 }
141 
142 
145  const Amg::Vector3D& endStep,
146  double halfThickness,
147  int readoutDirection,
148  double lorentzAngle) const
149 {
150 
151  Amg::Vector3D stepCenter = 0.5*(startStep+endStep);
152  // project to parameter surface
153  double lorentzDeltaX = -readoutDirection*stepCenter.z()*std::tan(lorentzAngle);
154  // take the full drift length
155  double driftInZ = (halfThickness-readoutDirection*stepCenter.z());
156  double driftLength = std::abs(driftInZ/std::cos(lorentzAngle));
157  // the projected center
158  Amg::Vector2D stepCenterProjected(stepCenter.x()+lorentzDeltaX,stepCenter.y());
159  // the cell & its center
160  Trk::DigitizationCell dCell = cell(stepCenterProjected);
161  Amg::Vector2D cellCenter = cellPosition(dCell);
162  // we are ready to return what we have
163  return Trk::DigitizationStep((endStep-startStep).mag(),driftLength,dCell,startStep,endStep,stepCenterProjected,cellCenter);
164 }
165 
166 
167 
168 
169 
Trk::TrapezoidSegmentation::numCellsY
size_t numCellsY() const
Return the simple binning parameters.
Definition: TrapezoidSegmentation.h:113
TrapezoidBounds.h
Trk::TrapezoidSegmentation::m_activeBounds
std::shared_ptr< const TrapezoidBounds > m_activeBounds
Definition: TrapezoidSegmentation.h:102
ReadCellNoiseFromCool.cell
cell
Definition: ReadCellNoiseFromCool.py:53
RectangleBounds.h
Trk::TrapezoidSegmentation::~TrapezoidSegmentation
virtual ~TrapezoidSegmentation()
Virtual Destructor.
Definition: TrapezoidSegmentation.cxx:42
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::TrapezoidSegmentation::numCellsX
size_t numCellsX() const
Return the simple binning parameters.
Definition: TrapezoidSegmentation.h:111
Trk::TrapezoidSegmentation::cellPosition
const Amg::Vector2D cellPosition(const DigitizationCell &cId) const override
calculate the cell Position from the Id
Definition: TrapezoidSegmentation.cxx:134
Trk::TrapezoidSegmentation::m_binUtility
BinUtility * m_binUtility
Definition: TrapezoidSegmentation.h:103
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
TrapezoidSegmentation.h
Trk::DigitizationCell
std::pair< size_t, size_t > DigitizationCell
Definition: DigitizationCell.h:18
Amg::getTransformFromRotTransl
Amg::Transform3D getTransformFromRotTransl(Amg::RotationMatrix3D rot, Amg::Vector3D transl_vec)
Definition: GeoPrimitivesHelpers.h:172
Trk::binY
@ binY
Definition: BinningType.h:48
Trk::TrapezoidSegmentation::TrapezoidSegmentation
TrapezoidSegmentation(std::shared_ptr< const Trk::TrapezoidBounds >, size_t numCellsX, size_t numCellsY=1)
Constructor for all same-size pixels or strips (in case numCellsY is set to 1)
Definition: TrapezoidSegmentation.cxx:21
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
drawFromPickle.tan
tan
Definition: drawFromPickle.py:36
Trk::binX
@ binX
Definition: BinningType.h:47
Trk::DigitizationStep
Definition: DigitizationCell.h:21
Trk::BinUtility
Definition: BinUtility.h:39
Trk::TrapezoidSegmentation::createSegmenationSurfaces
void createSegmenationSurfaces(std::vector< std::shared_ptr< const Surface > > &boundarySurfaces, std::vector< std::shared_ptr< const Surface > > &segmentationSurfacesX, std::vector< std::shared_ptr< const Surface > > &segmentationSurfacesY, double halfThickness, int readoutDirection=1., double lorentzAngle=0.) const override
Create the segmentation surfaces in X.
Definition: TrapezoidSegmentation.cxx:47
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::TrapezoidBounds
Definition: TrapezoidBounds.h:43
Trk::open
@ open
Definition: BinningType.h:40
Trk::TrapezoidSegmentation::digitizationStep
const DigitizationStep digitizationStep(const Amg::Vector3D &start, const Amg::Vector3D &end, double halfThickness, int readoutDirection=1, double lorentzAngle=0.) const override
Fill the associated digitisation cell from this start and end position, correct for lorentz effect if...
Definition: TrapezoidSegmentation.cxx:144
Amg::RotationMatrix3D
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Definition: GeoPrimitives.h:49
PlaneSurface.h
GeoPrimitivesHelpers.h
Amg::AngleAxis3D
Eigen::AngleAxisd AngleAxis3D
Definition: GeoPrimitives.h:45
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:26