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

#include <RectangularSegmentation.h>

Inheritance diagram for Trk::RectangularSegmentation:
Collaboration diagram for Trk::RectangularSegmentation:

Public Member Functions

 RectangularSegmentation (std::shared_ptr< const Trk::RectangleBounds >, size_t numCellsX, size_t numCellsY=1)
 Constructor for all same-size pixels or strips (in cas numCellsY is set to 1) More...
 
 RectangularSegmentation (std::shared_ptr< const Trk::RectangleBounds >, size_t numCellsX, double longY, size_t numCellsY, double numOfChips)
 Constructor for ATLAS module type pixels or strips. More...
 
 RectangularSegmentation (const RectangularSegmentation &)=delete
 TODO contructor from BinUtilities for more complex readouts. More...
 
RectangularSegmentationoperator= (const RectangularSegmentation &)=delete
 
virtual ~RectangularSegmentation ()
 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 fropm a 3D position - ignores the shift. More...
 
const DigitizationCell cell (const Amg::Vector2D &position) const override
 Get the digitization cell fropm 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 digitsation 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
 

Private Attributes

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

Detailed Description

Definition at line 36 of file RectangularSegmentation.h.

Constructor & Destructor Documentation

◆ RectangularSegmentation() [1/3]

Trk::RectangularSegmentation::RectangularSegmentation ( std::shared_ptr< const Trk::RectangleBounds mBounds,
size_t  numCellsX,
size_t  numCellsY = 1 
)

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

Definition at line 21 of file RectangularSegmentation.cxx.

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

◆ RectangularSegmentation() [2/3]

Trk::RectangularSegmentation::RectangularSegmentation ( std::shared_ptr< const Trk::RectangleBounds mBounds,
size_t  numCellsX,
double  longY,
size_t  numCellsY,
double  numOfChips 
)

Constructor for ATLAS module type pixels or strips.

Constructor for ATLAS module type pixels.

Definition at line 42 of file RectangularSegmentation.cxx.

42  :
43  m_activeBounds(std::move(mBounds)),
44  m_binUtility(nullptr),
47 {
48  // first the x dimension if needed
49  if (numCellsX > 1)
50  m_binUtility = new Trk::BinUtility(numCellsX, -m_activeBounds->halflengthX(), m_activeBounds->halflengthX(), Trk::open, Trk::binX);
51  // use y dimension if needed
52  if (numCellsY > 1){
53 
54  int numCellsYinChip = numCellsY/numberOfChip;
55  double begin = -m_activeBounds->halflengthY();
56  double end = (2. * m_activeBounds->halflengthY() / numberOfChip) - m_activeBounds->halflengthY();
57  std::vector<float> boundaries;
58 
59  boundaries.push_back(begin);
60 
61  for (int i = 0; i< numberOfChip; i++){
62  Trk::BinUtility SmallBinUtility((size_t) numCellsYinChip-2, begin+longY, end-longY, Trk::open, Trk::binY);
63 
64 
65  boundaries.insert(boundaries.end(), SmallBinUtility.binningData().at(0).boundaries.begin(), SmallBinUtility.binningData().at(0).boundaries.end());
66  boundaries.push_back(end);
67 
68  begin=end;
69  end+=(2 * m_activeBounds->halflengthY() / numberOfChip);
70 
71  }
72 
73 
74  if (boundaries.size() != numCellsY+1) {
75  throw std::runtime_error("RectangularSegmentation: invalid numCellsY");
76  }
77 
78  Trk::BinUtility yBinUtility(boundaries, Trk::open, Trk::binY);
79  if (m_binUtility)
80  (*m_binUtility) += yBinUtility;
81  else
82  m_binUtility = new Trk::BinUtility(yBinUtility);
83 
84  boundaries.clear();
85  }
86 }

◆ RectangularSegmentation() [3/3]

Trk::RectangularSegmentation::RectangularSegmentation ( const RectangularSegmentation )
delete

TODO contructor from BinUtilities for more complex readouts.

◆ ~RectangularSegmentation()

Trk::RectangularSegmentation::~RectangularSegmentation ( )
virtual

Virtual Destructor.

Definition at line 89 of file RectangularSegmentation.cxx.

90 {
91  delete m_binUtility;
92 }

Member Function Documentation

◆ cell() [1/2]

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

Get the digitization cell fropm a position.

Implements Trk::Segmentation.

Definition at line 117 of file RectangularSegmentation.h.

117 { return cellT<Amg::Vector2D>(position); }

◆ cell() [2/2]

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

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

Implements Trk::Segmentation.

Definition at line 115 of file RectangularSegmentation.h.

115 { return cellT<Amg::Vector3D>(position); }

◆ cellPosition()

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

calculate the cell Position from the Id

Implements Trk::Segmentation.

Definition at line 210 of file RectangularSegmentation.cxx.

211 {
212 
213  // use the bin utility for this job
214  double bX = m_binsX ? m_binUtility->binPosition(dCell.first,0.,0) : 0.;
215  double bY = m_binsY ? m_binUtility->binPosition(dCell.second,0.,1) : 0.;
216  return Amg::Vector2D(bX,bY);
217 }

◆ cellT()

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

Definition at line 106 of file RectangularSegmentation.h.

107  {
108  if (m_binsX == 1)
109  return DigitizationCell(0, m_binUtility->bin(position,0));
110  else if (m_binsY == 1 )
111  return DigitizationCell(m_binUtility->bin(position,0), 0);
112  return DigitizationCell(m_binUtility->bin(position,0), m_binUtility->bin(position,1));
113  }

◆ createSegmenationSurfaces()

void Trk::RectangularSegmentation::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 94 of file RectangularSegmentation.cxx.

100 {
101  // may be needed throughout
102  double lorentzAngleTan = std::tan(lorentzAngle);
103  double lorentzPlaneShiftX = halfThickness*lorentzAngleTan;
104 
105  // (A) --- top/bottom surfaces -----------------------------------------------------------
106  // let's create the top/botten surfaces first - we call them readout / counter readout
107  // there are some things to consider
108  // - they share the RectangleBounds only if the lorentzAngle is 0, otherwise only the readout surface has full length bounds like the module
109  Trk::SharedObject<const Trk::SurfaceBounds> moduleBounds = std::make_shared<Trk::RectangleBounds>(m_activeBounds->halflengthX(),m_activeBounds->halflengthY());
110  // - they are separated by half a thickness in z
111  Amg::Transform3D readoutPlaneTransform(Amg::Transform3D::Identity());
112  Amg::Transform3D counterPlaneTransform(Amg::Transform3D::Identity());
113  // readout and counter readout bounds, the bounds of the readout plane are like the active ones
115  Trk::SharedObject<const Trk::SurfaceBounds> counterPlaneBounds(nullptr);
116  // the transform of the readout plane is always centric
117  readoutPlaneTransform.translation() = Amg::Vector3D(0.,0.,readoutDirection*halfThickness);
118  // no lorentz angle and everything is straight-forward
119  if (lorentzAngle == 0.){
120  counterPlaneBounds = moduleBounds;
121  counterPlaneTransform.translation() = Amg::Vector3D(0.,0.,-readoutDirection*halfThickness);
122  } else {
123  // lorentz reduced Bounds
124  double lorentzReducedHalfX = m_activeBounds->halflengthX() - std::abs(lorentzPlaneShiftX);
125  Trk::SharedObject<const Trk::SurfaceBounds> lorentzReducedBounds(std::make_shared<Trk::RectangleBounds>(lorentzReducedHalfX,m_activeBounds->halflengthY()));
126  counterPlaneBounds = lorentzReducedBounds;
127  // now we shift the counter plane in position - this depends on lorentz angle
128  double counterPlaneShift = -readoutDirection*lorentzPlaneShiftX;
129  counterPlaneTransform.translation() = Amg::Vector3D(counterPlaneShift,0.,-readoutDirection*halfThickness);
130  }
131  // - build the readout & counter readout surfaces
132  boundarySurfaces.push_back(std::make_shared<Trk::PlaneSurface>(readoutPlaneTransform,readoutPlaneBounds));
133  boundarySurfaces.push_back(std::make_shared<Trk::PlaneSurface>(counterPlaneTransform,counterPlaneBounds));
134 
135  // (B) - bin X and lorentz surfaces -----------------------------------------------------------
136  // easy stuff first, constant pitch size and
137  double pitchX = 2.*m_activeBounds->halflengthX()/m_binsX;
138 
139  // now, let's create the SharedBounds of all surfaces marking x bins - choice fixes orientation of the matrix
140  Trk::SharedObject<const Trk::SurfaceBounds> xBinBounds(std::make_shared<Trk::RectangleBounds>(m_activeBounds->halflengthY(),halfThickness));
141  // now, let's create the SharedBounds of all surfaces marking lorentz planes
142  double lorentzPlaneHalfX = std::abs(halfThickness/std::cos(lorentzAngle));
143  // the bounds of the lorentz plane
144  Trk::SharedObject<const Trk::SurfaceBounds> lorentzPlaneBounds = (lorentzAngle==0.) ? xBinBounds :
145  Trk::SharedObject<const Trk::SurfaceBounds>(std::make_shared<Trk::RectangleBounds>(m_activeBounds->halflengthY(),lorentzPlaneHalfX));
146 
147  // now the rotation matrix for the xBins
148  Amg::RotationMatrix3D xBinRotationMatrix;
149  xBinRotationMatrix.col(0) = Amg::Vector3D::UnitY();
150  xBinRotationMatrix.col(1) = Amg::Vector3D::UnitZ();
151  xBinRotationMatrix.col(2) = Amg::Vector3D::UnitX();
152  // now the lorentz plane rotation should be the xBin rotation, rotated by the lorentz angle around y
153  Amg::RotationMatrix3D lorentzPlaneRotationMatrix = (lorentzAngle !=0.) ?
154  xBinRotationMatrix * Amg::AngleAxis3D(lorentzAngle, Amg::Vector3D::UnitX()) : xBinRotationMatrix;
155 
156  // reserve, it's always (number of bins-1) as the boundaries are within the boundarySurfaces
157  segmentationSurfacesX.reserve(m_binsX);
158  for (size_t ibinx = 0; ibinx <= m_binsX; ++ibinx){
159  // the current step x position
160  double cPosX = -m_activeBounds->halflengthX()+ibinx*pitchX;
161  // (i) this is the low/high boundary --- ( ibin == 0/m_binsX )
162  if (!ibinx || ibinx == m_binsX){
163  // check if it a straight boundary or not: always straight for no lorentz angle, and either the first boundary or the last dependening on lorentz & readout
164  bool boundaryStraight = (lorentzAngle == 0. || (!ibinx && readoutDirection*lorentzAngle > 0.) || (ibinx==m_binsX && readoutDirection*lorentzAngle < 0));
165  // set the low boundary parameters : position & rotation
166  Amg::Vector3D boundaryXPosition = boundaryStraight ? Amg::Vector3D(cPosX, 0.,0.) : Amg::Vector3D(cPosX-readoutDirection*lorentzPlaneShiftX, 0., 0.);
167  const Amg::RotationMatrix3D& boundaryXRotation = boundaryStraight ? xBinRotationMatrix : lorentzPlaneRotationMatrix;
168  // build the rotation from it
169  Amg::Transform3D boundaryXTransform(Amg::getTransformFromRotTransl(boundaryXRotation, boundaryXPosition));
170  // the correct bounds for this
171  Trk::SharedObject<const Trk::SurfaceBounds> boundaryXBounds = boundaryStraight ? xBinBounds : lorentzPlaneBounds;
172  // boundary surfaces
173  boundarySurfaces.push_back(std::shared_ptr<const Trk::PlaneSurface>(new Trk::PlaneSurface(boundaryXTransform,boundaryXBounds)));
174  // (ii) this is the in between bins --- ( 1 <= ibin < m_mbnsX )
175  } else {
176  // shift by the lorentz angle
177  Amg::Vector3D lorentzPlanePosition(cPosX-readoutDirection*lorentzPlaneShiftX, 0., 0.);
178  Amg::Transform3D lorentzPlaneTransform(Amg::getTransformFromRotTransl(lorentzPlaneRotationMatrix,lorentzPlanePosition));
179  // lorentz plane surfaces
180  segmentationSurfacesX.push_back(std::make_shared<Trk::PlaneSurface>(lorentzPlaneTransform,lorentzPlaneBounds));
181  }
182  }
183 
184  // (C) - bin Y surfaces - everything is defined -----------------------------------------------------------
185  // now the rotation matrix for the yBins - anticyclic
186  Amg::RotationMatrix3D yBinRotationMatrix;
187  yBinRotationMatrix.col(0) = Amg::Vector3D::UnitX();
188  yBinRotationMatrix.col(1) = Amg::Vector3D::UnitZ();
189  yBinRotationMatrix.col(2) = Amg::Vector3D(0.,-1.,0.);
190  // easy stuff first, constant pitch in Y
191  // let's create the SharedBounds of all surfaces marking y bins
192  Trk::SharedObject<const Trk::SurfaceBounds> yBinBounds(std::make_shared<Trk::RectangleBounds>(m_activeBounds->halflengthX(),halfThickness));
193  // reserve, it's always (number of bins-1) as the boundaries are within the boundarySurfaces
194  segmentationSurfacesY.reserve(m_binsY);
195  for (size_t ibiny = 0; ibiny <= m_binsY; ++ibiny){
196  // the position of the bin surface
197  //Use the bin utility to find center of different surfaces
198  double binPosY = m_binUtility->binningData().at(1).boundaries[ibiny];
199  Amg::Vector3D binSurfaceCenter(0.,binPosY,0.);
200  Amg::Transform3D binTransform(Amg::getTransformFromRotTransl(yBinRotationMatrix,binSurfaceCenter));
201  // these are the boundaries
202  if (ibiny == 0 || ibiny == m_binsY)
203  boundarySurfaces.push_back(std::make_shared<Trk::PlaneSurface>(binTransform,yBinBounds));
204  else // these are the bin boundaries
205  segmentationSurfacesY.push_back(std::make_shared<Trk::PlaneSurface>(binTransform,yBinBounds));
206  }
207 }

◆ digitizationStep()

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

Fill the associated digitsation 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 221 of file RectangularSegmentation.cxx.

226 {
227  Amg::Vector3D stepCenter = 0.5*(startStep+endStep);
228  // take the full drift length
229  // this is the absolute drift in z
230  double driftInZ = halfThickness-readoutDirection*stepCenter.z();
231  // this is the absolute drift length
232  double driftLength = driftInZ/cos(lorentzAngle);
233  // project to parameter the readout surface
234  double lorentzDeltaX = readoutDirection*driftInZ*tan(lorentzAngle);
235  // the projected center, it has the lorentz shift applied
236  Amg::Vector2D stepCenterProjected(stepCenter.x()+lorentzDeltaX,stepCenter.y());
237  // the cell & its center
238  Trk::DigitizationCell dCell = cell(stepCenterProjected);
239  Amg::Vector2D cellCenter = cellPosition(dCell);
240  // we are ready to return what we have
241  return Trk::DigitizationStep((endStep-startStep).mag(),driftLength,dCell,startStep,endStep,stepCenterProjected,cellCenter);
242 }

◆ moduleBounds()

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

return the surface bounds by reference

Implements Trk::Segmentation.

Definition at line 100 of file RectangularSegmentation.h.

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

◆ numCellsX()

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

Return the simple binning parameters.

Definition at line 102 of file RectangularSegmentation.h.

102 { return m_binsX; }

◆ numCellsY()

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

Return the simple binning parameters.

Definition at line 104 of file RectangularSegmentation.h.

104 { return m_binsY; }

◆ operator=()

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

Member Data Documentation

◆ m_activeBounds

std::shared_ptr<const RectangleBounds> Trk::RectangularSegmentation::m_activeBounds
private

Definition at line 93 of file RectangularSegmentation.h.

◆ m_binsX

size_t Trk::RectangularSegmentation::m_binsX
private

Definition at line 95 of file RectangularSegmentation.h.

◆ m_binsY

size_t Trk::RectangularSegmentation::m_binsY
private

Definition at line 96 of file RectangularSegmentation.h.

◆ m_binUtility

BinUtility* Trk::RectangularSegmentation::m_binUtility
private

Definition at line 94 of file RectangularSegmentation.h.


The documentation for this class was generated from the following files:
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
Trk::RectangularSegmentation::m_activeBounds
std::shared_ptr< const RectangleBounds > m_activeBounds
Definition: RectangularSegmentation.h:93
PlotCalibFromCool.begin
begin
Definition: PlotCalibFromCool.py:94
Trk::RectangularSegmentation::numCellsY
size_t numCellsY() const
Return the simple binning parameters.
Definition: RectangularSegmentation.h:104
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
Trk::DigitizationCell
std::pair< size_t, size_t > DigitizationCell
Definition: DigitizationCell.h:18
mergePhysValFiles.end
end
Definition: DataQuality/DataQualityUtils/scripts/mergePhysValFiles.py:93
Amg::getTransformFromRotTransl
Amg::Transform3D getTransformFromRotTransl(Amg::RotationMatrix3D rot, Amg::Vector3D transl_vec)
Definition: GeoPrimitivesHelpers.h:172
Trk::binY
@ binY
Definition: BinningType.h:48
Trk::RectangularSegmentation::m_binsX
size_t m_binsX
Definition: RectangularSegmentation.h:95
Trk::RectangularSegmentation::m_binsY
size_t m_binsY
Definition: RectangularSegmentation.h:96
Trk::RectangularSegmentation::moduleBounds
const SurfaceBounds & moduleBounds() const override
return the surface bounds by reference
Definition: RectangularSegmentation.h:100
lumiFormat.i
int i
Definition: lumiFormat.py:85
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::RectangularSegmentation::cell
const DigitizationCell cell(const Amg::Vector3D &position) const override
Get the digitization cell fropm a 3D position - ignores the shift.
Definition: RectangularSegmentation.h:115
Amg
Definition of ATLAS Math & Geometry primitives (Amg)
Definition: AmgStringHelpers.h:19
Trk::RectangularSegmentation::numCellsX
size_t numCellsX() const
Return the simple binning parameters.
Definition: RectangularSegmentation.h:102
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
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
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::BinUtility::binningData
const std::vector< BinningData > & binningData() const
return the binning data
Definition: BinUtility.h:133
mag
Scalar mag() const
mag method
Definition: AmgMatrixBasePlugin.h:26
Trk::RectangularSegmentation::m_binUtility
BinUtility * m_binUtility
Definition: RectangularSegmentation.h:94
Trk::RectangularSegmentation::cellPosition
const Amg::Vector2D cellPosition(const DigitizationCell &cId) const override
calculate the cell Position from the Id
Definition: RectangularSegmentation.cxx:210