ATLAS Offline Software
Public Member Functions | Private Member Functions | Private Attributes | List of all members
Trk::TrapezoidSegmentation Class Reference

#include <TrapezoidSegmentation.h>

Inheritance diagram for Trk::TrapezoidSegmentation:
Collaboration diagram for Trk::TrapezoidSegmentation:

Public Member Functions

 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) More...
 
 TrapezoidSegmentation (const TrapezoidSegmentation &)=delete
 TODO contructor from BinUtilities for more complex readouts. More...
 
TrapezoidSegmentationoperator= (const TrapezoidSegmentation &)=delete
 
virtual ~TrapezoidSegmentation ()
 Virtual Destructor. More...
 
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. More...
 
const DigitizationCell cell (const Amg::Vector3D &position) const override
 Get the digitization cell from a 3D position - ignores the shift. More...
 
const DigitizationCell cell (const Amg::Vector2D &position) const override
 Get the digitization cell from a position. More...
 
const Amg::Vector2D cellPosition (const DigitizationCell &cId) const override
 calculate the cell Position from the Id More...
 
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 needed. More...
 
const SurfaceBoundsmoduleBounds () const override
 return the surface bounds by reference More...
 
size_t numCellsX () const
 Return the simple binning parameters. More...
 
size_t numCellsY () const
 Return the simple binning parameters. More...
 

Private Member Functions

template<class T >
const DigitizationCell cellT (const T &position) const
 
double PitchX (const Amg::Vector2D &localPos) const
 Return the local pitch X
More...
 
double sinStereoLocal (const Amg::Vector2D &localPos) const
 Return the local sinStereo
More...
 
double projectLocX (const Amg::Vector2D &localPos) const
 Return the projected x value on the y=0. More...
 
double radius () const
 Return the radius correponding to the given module. More...
 

Private Attributes

std::shared_ptr< const TrapezoidBoundsm_activeBounds
 
BinUtilitym_binUtility
 
size_t m_binsX
 
size_t m_binsY
 

Detailed Description

Definition at line 36 of file TrapezoidSegmentation.h.

Constructor & Destructor Documentation

◆ TrapezoidSegmentation() [1/2]

Trk::TrapezoidSegmentation::TrapezoidSegmentation ( std::shared_ptr< const Trk::TrapezoidBounds mBounds,
size_t  numCellsX,
size_t  numCellsY = 1 
)

Constructor for all same-size pixels or strips (in case numCellsY is set to 1)

Definition at line 22 of file TrapezoidSegmentation.cxx.

23  :
24  m_activeBounds(std::move(mBounds)),
25  m_binUtility(nullptr),
28 {
29  // first the x dimension if needed
30  if (numCellsX > 1) {
31  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);
32  }
33  // use y dimension if needed
34  if (numCellsY > 1){
35  Trk::BinUtility yBinUtility(numCellsY, -m_activeBounds->halflengthY(), m_activeBounds->halflengthY(), Trk::open, Trk::binY);
36  if (m_binUtility)
37  (*m_binUtility) += yBinUtility;
38  else
39  m_binUtility = new Trk::BinUtility(yBinUtility);
40  }
41 }

◆ TrapezoidSegmentation() [2/2]

Trk::TrapezoidSegmentation::TrapezoidSegmentation ( const TrapezoidSegmentation )
delete

TODO contructor from BinUtilities for more complex readouts.

◆ ~TrapezoidSegmentation()

Trk::TrapezoidSegmentation::~TrapezoidSegmentation ( )
virtual

Virtual Destructor.

Definition at line 43 of file TrapezoidSegmentation.cxx.

44 {
45  delete m_binUtility;
46 }

Member Function Documentation

◆ cell() [1/2]

const DigitizationCell Trk::TrapezoidSegmentation::cell ( const Amg::Vector2D position) const
inlineoverridevirtual

Get the digitization cell from a position.

Implements Trk::Segmentation.

Definition at line 130 of file TrapezoidSegmentation.h.

130  {
131  using Trk::locX;
132  using Trk::locY;
133  Amg::Vector2D CorrPosition = position;
134  CorrPosition[Trk::locX] = projectLocX(Amg::Vector2D(CorrPosition[Trk::locX], CorrPosition[Trk::locY]));
135  return cellT<Amg::Vector2D>(CorrPosition);
136  }

◆ cell() [2/2]

const DigitizationCell Trk::TrapezoidSegmentation::cell ( const Amg::Vector3D position) const
inlineoverridevirtual

Get the digitization cell from a 3D position - ignores the shift.

Implements Trk::Segmentation.

Definition at line 124 of file TrapezoidSegmentation.h.

124  {
125  Amg::Vector3D CorrPosition = position;
126  CorrPosition.x() = projectLocX(Amg::Vector2D(CorrPosition.x(), CorrPosition.y()));
127  return cellT<Amg::Vector3D>(CorrPosition);
128  }

◆ cellPosition()

const Amg::Vector2D Trk::TrapezoidSegmentation::cellPosition ( const DigitizationCell cId) const
overridevirtual

calculate the cell Position from the Id

Implements Trk::Segmentation.

Definition at line 135 of file TrapezoidSegmentation.cxx.

136 {
137  // use the bin utility for this job
138  double bX = (m_binsX>1) ? m_binUtility->binPosition(projectLocX(Amg::Vector2D(dCell.first, dCell.second)),0.,0) : 0.;
139  double bY = (m_binsY>1) ? m_binUtility->binPosition(dCell.second,0.,1) : 0.;
140  return Amg::Vector2D(bX,bY);
141 }

◆ cellT()

template<class T >
const DigitizationCell Trk::TrapezoidSegmentation::cellT ( const T &  position) const
private

Definition at line 115 of file TrapezoidSegmentation.h.

116  {
117  if (m_binsX == 1)
118  return DigitizationCell(0, m_binUtility->bin(position,0));
119  else if (m_binsY == 1 )
120  return DigitizationCell(m_binUtility->bin(position,0), 0);
121  return DigitizationCell(m_binUtility->bin(position,0), m_binUtility->bin(position,1));
122  }

◆ createSegmenationSurfaces()

void Trk::TrapezoidSegmentation::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
overridevirtual

Create the segmentation surfaces in X.

Implements Trk::Segmentation.

Definition at line 48 of file TrapezoidSegmentation.cxx.

54 {
55  // The Lorentz angle is not taken into account for trapezoidal segmentation
56  // (A) --- top/bottom surfaces -----------------------------------------------------------
57  // let's create the top/botten surfaces first - we call them readout / counter readout
58  // there are some things to consider
59  // - they share only the readout surface, then the segmentation surfaces are tilted and cannot be shared on the same module
60  std::unique_ptr<Trk::TrapezoidBounds> moduleTrapBounds(new Trk::TrapezoidBounds(m_activeBounds->minHalflengthX(),m_activeBounds->maxHalflengthX(),m_activeBounds->halflengthY()));
62  // - they are separated by half a thickness in z
63  Amg::Transform3D readoutPlaneTransform(Amg::Transform3D::Identity());
64  Amg::Transform3D counterPlaneTransform(Amg::Transform3D::Identity());
65  // readout and counter readout bounds, the bounds of the readout plane are like the active ones
67  Trk::SharedObject<const Trk::SurfaceBounds> counterPlaneBounds(nullptr);
68  // the transform of the readout plane is always centric
69  readoutPlaneTransform.translation() = Amg::Vector3D(0.,0.,readoutDirection*halfThickness);
70  // no lorentz angle and everything is straight-forward
71  counterPlaneBounds = moduleBounds;
72  counterPlaneTransform.translation() = Amg::Vector3D(0.,0.,-readoutDirection*halfThickness);
73 
74  // - build the readout & counter readout surfaces
75  boundarySurfaces.push_back(std::shared_ptr<const Trk::PlaneSurface>(new Trk::PlaneSurface(readoutPlaneTransform,readoutPlaneBounds)));
76  boundarySurfaces.push_back(std::shared_ptr<const Trk::PlaneSurface>(new Trk::PlaneSurface(counterPlaneTransform,counterPlaneBounds)));
77 
78  // (B) - bin X -----------------------------------------------------------
79  // easy stuff first, constant pitch size and
80  double pitchX = 2.*(m_activeBounds->maxHalflengthX()+m_activeBounds->minHalflengthX())*0.5/m_binsX;
81 
82  // now the rotation matrix for the xBins
83  Amg::RotationMatrix3D xBinRotationMatrix;
84  xBinRotationMatrix.col(0) = Amg::Vector3D::UnitY();
85  xBinRotationMatrix.col(1) = Amg::Vector3D::UnitZ();
86  xBinRotationMatrix.col(2) = Amg::Vector3D::UnitX();
87 
88  // reserve, it's always (number of bins-1) as the boundaries are within the boundarySurfaces
89  segmentationSurfacesX.reserve(m_binsX);
90  for (size_t ibinx = 0; ibinx <= m_binsX; ++ibinx){
91  // the current step x position
92  double cPosX = -(m_activeBounds->minHalflengthX()+m_activeBounds->maxHalflengthX())*0.5+ibinx*pitchX;
93 
94  // set position & rotation for all (boundaries and segmentations) --> Then you separate between them
95  Amg::Vector3D xPosition = Amg::Vector3D(cPosX, 0.,0.);
96  double stereoLocal = asin(sinStereoLocal(Amg::Vector2D(cPosX, 0.)));
97  const Amg::RotationMatrix3D xRotation = xBinRotationMatrix*Amg::AngleAxis3D(stereoLocal, Amg::Vector3D::UnitY());
98  // build the rotation from it
99  Amg::Transform3D binTransform(Amg::getTransformFromRotTransl(xRotation, xPosition));
100  // the correct bounds for this
101  std::unique_ptr<Trk::RectangleBounds> xBinBounds(new Trk::RectangleBounds(m_activeBounds->halflengthY()/cos(stereoLocal),halfThickness));
102  // these are the boundaries
103  if (ibinx==0 || ibinx == m_binsX) // (i) this is the low/high boundary --- ( ibin == 0/m_binsX )
104  boundarySurfaces.push_back(std::shared_ptr<const Trk::PlaneSurface>(new Trk::PlaneSurface(binTransform,&*xBinBounds)));
105  else // these are the bin boundaries
106  segmentationSurfacesX.push_back(std::shared_ptr<const Trk::PlaneSurface>(new Trk::PlaneSurface(binTransform,&*xBinBounds)));
107  }
108 
109  // (C) - bin Y surfaces - everything is defined -----------------------------------------------------------
110  // now the rotation matrix for the yBins - anticyclic
111  Amg::RotationMatrix3D yBinRotationMatrix;
112  yBinRotationMatrix.col(0) = Amg::Vector3D::UnitX();
113  yBinRotationMatrix.col(1) = Amg::Vector3D::UnitZ();
114  yBinRotationMatrix.col(2) = Amg::Vector3D(0.,-1.,0.);
115  // easy stuff first, constant pitch in Y
116  double pitchY = 2.*m_activeBounds->halflengthY()/m_binsY;
117  // reserve, it's always (number of bins-1) as the boundaries are within the boundarySurfaces
118  segmentationSurfacesY.reserve(m_binsY);
119  for (size_t ibiny = 0; ibiny <= m_binsY; ++ibiny){
120  // the position of the bin surface
121  double binPosY = -m_activeBounds->halflengthY()+ibiny*pitchY;
122  Amg::Vector3D binSurfaceCenter(0.,binPosY,0.);
123  double localPitchX = PitchX(Amg::Vector2D(0., binPosY));
124  std::unique_ptr<Trk::RectangleBounds> yBinBounds(new Trk::RectangleBounds(localPitchX*m_binsX*0.5,halfThickness));
125  Amg::Transform3D binTransform(Amg::getTransformFromRotTransl(yBinRotationMatrix,binSurfaceCenter));
126  // these are the boundaries
127  if (ibiny == 0 || ibiny == m_binsY)
128  boundarySurfaces.push_back(std::make_shared<Trk::PlaneSurface>(binTransform,&*yBinBounds));
129  else // these are the bin boundaries
130  segmentationSurfacesY.push_back(std::make_shared<Trk::PlaneSurface>(binTransform,&*yBinBounds));
131  }
132 }

◆ digitizationStep()

const Trk::DigitizationStep Trk::TrapezoidSegmentation::digitizationStep ( const Amg::Vector3D start,
const Amg::Vector3D end,
double  halfThickness,
int  readoutDirection = 1,
double  lorentzAngle = 0. 
) const
overridevirtual

Fill the associated digitisation cell from this start and end position, correct for lorentz effect if needed.

Get the digitization cell from 3D position, it used the projection to the readout surface to estimate the 2D positon.

Implements Trk::Segmentation.

Definition at line 145 of file TrapezoidSegmentation.cxx.

150 {
151 
152  Amg::Vector3D stepCenter = 0.5*(startStep+endStep);
153  // project to parameter surface
154  double lorentzDeltaX = -readoutDirection*stepCenter.z()*std::tan(lorentzAngle);
155  // take the full drift length
156  double driftInZ = (halfThickness-readoutDirection*stepCenter.z());
157  double driftLength = std::abs(driftInZ/std::cos(lorentzAngle));
158  // the projected center
159  Amg::Vector2D stepCenterProjected(stepCenter.x()+lorentzDeltaX,stepCenter.y());
160  // the cell & its center
161  Trk::DigitizationCell dCell = cell(stepCenterProjected);
162  Amg::Vector2D cellCenter = cellPosition(dCell);
163  // we are ready to return what we have
164  return Trk::DigitizationStep((endStep-startStep).mag(),driftLength,dCell,startStep,endStep,stepCenterProjected,cellCenter);
165 }

◆ moduleBounds()

const SurfaceBounds & Trk::TrapezoidSegmentation::moduleBounds ( ) const
inlineoverridevirtual

return the surface bounds by reference

Implements Trk::Segmentation.

Definition at line 109 of file TrapezoidSegmentation.h.

109 { return (*(m_activeBounds.get())); }

◆ numCellsX()

size_t Trk::TrapezoidSegmentation::numCellsX ( ) const
inline

Return the simple binning parameters.

Definition at line 111 of file TrapezoidSegmentation.h.

111 { return m_binsX; }

◆ numCellsY()

size_t Trk::TrapezoidSegmentation::numCellsY ( ) const
inline

Return the simple binning parameters.

Definition at line 113 of file TrapezoidSegmentation.h.

113 { return m_binsY; }

◆ operator=()

TrapezoidSegmentation& Trk::TrapezoidSegmentation::operator= ( const TrapezoidSegmentation )
delete

◆ PitchX()

double Trk::TrapezoidSegmentation::PitchX ( const Amg::Vector2D localPos) const
private

Return the local pitch X

Definition at line 152 of file TrapezoidSegmentation.h.

152  {
153  using Trk::locY;
154  double tanPhi = (m_activeBounds->maxHalflengthX()-m_activeBounds->minHalflengthX())/m_activeBounds->halflengthY();
155  double lengthXatHit = (radius()+localPos[Trk::locY])*tanPhi;
156  return lengthXatHit/float(m_binsX);
157  }

◆ projectLocX()

double Trk::TrapezoidSegmentation::projectLocX ( const Amg::Vector2D localPos) const
private

Return the projected x value on the y=0.

Definition at line 159 of file TrapezoidSegmentation.h.

159  {
160  return -radius()*tan(asin(sinStereoLocal(localPos)));
161  }

◆ radius()

double Trk::TrapezoidSegmentation::radius ( ) const
private

Return the radius correponding to the given module.

Definition at line 138 of file TrapezoidSegmentation.h.

139  {
140  return m_activeBounds->halflengthY()/(m_activeBounds->maxHalflengthX() - m_activeBounds->minHalflengthX())*(m_activeBounds->maxHalflengthX() + m_activeBounds->minHalflengthX());
141  }

◆ sinStereoLocal()

double Trk::TrapezoidSegmentation::sinStereoLocal ( const Amg::Vector2D localPos) const
private

Return the local sinStereo

Definition at line 143 of file TrapezoidSegmentation.h.

143  {
144  using Trk::locX;
145  using Trk::locY;
146  double oneOverRadius = 1./radius();
147  double x = localPos[Trk::locX];
148  double y = localPos[Trk::locY];
149  return -x*oneOverRadius / sqrt( (1+y*oneOverRadius)*(1+y*oneOverRadius) + x*oneOverRadius*x*oneOverRadius );
150  }

Member Data Documentation

◆ m_activeBounds

std::shared_ptr<const TrapezoidBounds> Trk::TrapezoidSegmentation::m_activeBounds
private

Definition at line 102 of file TrapezoidSegmentation.h.

◆ m_binsX

size_t Trk::TrapezoidSegmentation::m_binsX
private

Definition at line 104 of file TrapezoidSegmentation.h.

◆ m_binsY

size_t Trk::TrapezoidSegmentation::m_binsY
private

Definition at line 105 of file TrapezoidSegmentation.h.

◆ m_binUtility

BinUtility* Trk::TrapezoidSegmentation::m_binUtility
private

Definition at line 103 of file TrapezoidSegmentation.h.


The documentation for this class was generated from the following files:
Trk::TrapezoidSegmentation::numCellsY
size_t numCellsY() const
Return the simple binning parameters.
Definition: TrapezoidSegmentation.h:113
Trk::TrapezoidSegmentation::radius
double radius() const
Return the radius correponding to the given module.
Definition: TrapezoidSegmentation.h:138
Trk::y
@ y
Definition: ParamDefs.h:56
Trk::RectangleBounds
Definition: RectangleBounds.h:38
Trk::TrapezoidSegmentation::m_activeBounds
std::shared_ptr< const TrapezoidBounds > m_activeBounds
Definition: TrapezoidSegmentation.h:102
Trk::locX
@ locX
Definition: ParamDefs.h:37
Trk::locY
@ locY
local cartesian
Definition: ParamDefs.h:38
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:135
Trk::TrapezoidSegmentation::m_binUtility
BinUtility * m_binUtility
Definition: TrapezoidSegmentation.h:103
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
Trk::DigitizationCell
std::pair< size_t, size_t > DigitizationCell
Definition: DigitizationCell.h:18
Trk::TrapezoidSegmentation::cell
const DigitizationCell cell(const Amg::Vector3D &position) const override
Get the digitization cell from a 3D position - ignores the shift.
Definition: TrapezoidSegmentation.h:124
Amg::getTransformFromRotTransl
Amg::Transform3D getTransformFromRotTransl(Amg::RotationMatrix3D rot, Amg::Vector3D transl_vec)
Definition: GeoPrimitivesHelpers.h:172
Trk::binY
@ binY
Definition: BinningType.h:48
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
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::TrapezoidBounds
Definition: TrapezoidBounds.h:43
Trk::TrapezoidSegmentation::projectLocX
double projectLocX(const Amg::Vector2D &localPos) const
Return the projected x value on the y=0.
Definition: TrapezoidSegmentation.h:159
Trk::TrapezoidSegmentation::moduleBounds
const SurfaceBounds & moduleBounds() const override
return the surface bounds by reference
Definition: TrapezoidSegmentation.h:109
Trk::open
@ open
Definition: BinningType.h:40
Trk::SharedObject
std::shared_ptr< T > SharedObject
Definition: SharedObject.h:24
Trk::PlaneSurface
Definition: PlaneSurface.h:64
Amg::RotationMatrix3D
Eigen::Matrix< double, 3, 3 > RotationMatrix3D
Definition: GeoPrimitives.h:49
Trk::TrapezoidSegmentation::sinStereoLocal
double sinStereoLocal(const Amg::Vector2D &localPos) const
Return the local sinStereo
Definition: TrapezoidSegmentation.h:143
Amg::AngleAxis3D
Eigen::AngleAxisd AngleAxis3D
Definition: GeoPrimitives.h:45
Trk::BinUtility::binPosition
float binPosition(size_t bin, float pos, size_t ba=0) const
bin->BinningValue navigation : pos=+-1.
Definition: BinUtility.h:239
Trk::BinUtility::bin
size_t bin(const Amg::Vector3D &position, size_t ba=0) const
Bin from a 3D vector (already in binning frame)
Definition: BinUtility.h:136
Trk::x
@ x
Definition: ParamDefs.h:55
Trk::TrapezoidSegmentation::m_binsX
size_t m_binsX
Definition: TrapezoidSegmentation.h:104
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:26
readCCLHist.float
float
Definition: readCCLHist.py:83
Trk::TrapezoidSegmentation::m_binsY
size_t m_binsY
Definition: TrapezoidSegmentation.h:105
Trk::TrapezoidSegmentation::PitchX
double PitchX(const Amg::Vector2D &localPos) const
Return the local pitch X
Definition: TrapezoidSegmentation.h:152