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