ATLAS Offline Software
Loading...
Searching...
No Matches
Trk::AnnulusBoundsPC Class Referencefinal

Class that implements the asymmetric shape of the ITk strip endcap modules. More...

#include <AnnulusBoundsPC.h>

Inheritance diagram for Trk::AnnulusBoundsPC:
Collaboration diagram for Trk::AnnulusBoundsPC:

Public Types

enum  BoundValues {
  bv_minR , bv_maxR , bv_phiMin , bv_phiMax ,
  bv_phiAvg , bv_originX , bv_originY
}
enum  BoundsType {
  Cone = 0 , Cylinder = 1 , Diamond = 2 , Disc = 3 ,
  Ellipse = 5 , Rectangle = 6 , RotatedTrapezoid = 7 , Trapezoid = 8 ,
  Triangle = 9 , DiscTrapezoidal = 10 , Annulus = 11 , Other = 12
}
 This enumerator simplifies the persistency, by saving a dynamic_cast to happen. More...

Public Member Functions

 AnnulusBoundsPC (double minR, double maxR, double phiMin, double phiMax, Amg::Vector2D moduleOrigin={0, 0}, double phiAvg=0)
 Default constructor from parameters.
 AnnulusBoundsPC (const AnnulusBoundsPC &annbo)=default
 Copy constructor.
AnnulusBoundsPCoperator= (const AnnulusBoundsPC &sbo)=default
 Assignment operator.
 AnnulusBoundsPC (AnnulusBoundsPC &&annbo)=default
 Move constructor.
AnnulusBoundsPCoperator= (AnnulusBoundsPC &&sbo)=default
 Move assignment.
virtual AnnulusBoundsPCclone () const override
 clone() method to make deep copy in Surface copy constructor and for assigment operator of the Surface class.
bool operator== (const SurfaceBounds &sb) const override
 Equality operator.
SurfaceBounds::BoundsType type () const override
 Return the bounds type - for persistency optimization.
bool inside (const Amg::Vector2D &locpo, double tol1=0., double tol2=0.) const override final
 Returns if a point in local coordinates is inside the bounds.
bool inside (const Amg::Vector2D &locpo, const BoundaryCheck &bchk) const override final
 Returns if a point in local coordinates is inside the bounds.
bool insideLoc1 (const Amg::Vector2D &locpo, double tol1=0.) const override final
 Check if local point is inside of r bounds.
bool insideLoc2 (const Amg::Vector2D &locpo, double tol2=0.) const override final
 Check if local point is inside of phi bounds.
double minDistance (const Amg::Vector2D &locpo) const override final
 Return minimum distance a point is away from the bounds.
double r () const override
 Returns middle radius.
double rMin () const
 Returns inner radial bounds (module system)
double rMax () const
 Returns outer radial bounds (module system)
double phiMin () const
 Returns the right angular edge of the module.
double phiMax () const
 Returns the left angular edge of the module.
Amg::Vector2D moduleOrigin () const
 Returns moduleOrigin, but rotated out, so avgPhi is already considered.
MsgStream & dump (MsgStream &sl) const override
 helper which dumps the configuration into a stream.
std::ostream & dump (std::ostream &sl) const override
 Output Method for std::ostream, to be overloaded by child classes.
std::array< std::pair< double, double >, 4 > corners () const
 Returns the four corners of the bounds.
virtual bool operator!= (const SurfaceBounds &sb) const
 Non-Equality operator.

Static Public Member Functions

static std::pair< AnnulusBoundsPC, double > fromCartesian (const AnnulusBounds &annbo)
 Static factory method to produce an instance of this class from the cartesian implementation.

Protected Member Functions

void swap (double &b1, double &b2)
 Swap method to be called from DiscBounds or TrapezoidalBounds.
virtual void initCache ()
 virtual initCache method for object persistency

Private Types

using Rotation2D = Eigen::Rotation2D<double>
using Transform2D = Eigen::Transform<double, 2, Eigen::Affine>
using Matrix2D = Eigen::Matrix<double, 2, 2>

Private Member Functions

Amg::Vector2D stripXYToModulePC (const Amg::Vector2D &vStripXY) const

Static Private Member Functions

static Amg::Vector2D closestOnSegment (const Amg::Vector2D &a, const Amg::Vector2D &b, const Amg::Vector2D &p, const Eigen::Matrix< double, 2, 2 > &weight)
static double squaredNorm (const Amg::Vector2D &v, const Eigen::Matrix< double, 2, 2 > &weight)

Private Attributes

friend AnnulusTestAlg
double m_minR
double m_maxR
double m_phiMin
double m_phiMax
Amg::Vector2D m_moduleOrigin
Amg::Vector2D m_shiftXY
Amg::Vector2D m_shiftPC
double m_phiAvg
Transform2D m_rotationStripPC
Transform2D m_translation
Amg::Vector2D m_outLeftStripPC
Amg::Vector2D m_inLeftStripPC
Amg::Vector2D m_outRightStripPC
Amg::Vector2D m_inRightStripPC
Amg::Vector2D m_outLeftModulePC
Amg::Vector2D m_inLeftModulePC
Amg::Vector2D m_outRightModulePC
Amg::Vector2D m_inRightModulePC
Amg::Vector2D m_outLeftStripXY
Amg::Vector2D m_inLeftStripXY
Amg::Vector2D m_outRightStripXY
Amg::Vector2D m_inRightStripXY
std::vector< TDD_real_tm_boundValues

Detailed Description

Class that implements the asymmetric shape of the ITk strip endcap modules.

Definition at line 30 of file AnnulusBoundsPC.h.

Member Typedef Documentation

◆ Matrix2D

using Trk::AnnulusBoundsPC::Matrix2D = Eigen::Matrix<double, 2, 2>
private

Definition at line 34 of file AnnulusBoundsPC.h.

◆ Rotation2D

using Trk::AnnulusBoundsPC::Rotation2D = Eigen::Rotation2D<double>
private

Definition at line 32 of file AnnulusBoundsPC.h.

◆ Transform2D

using Trk::AnnulusBoundsPC::Transform2D = Eigen::Transform<double, 2, Eigen::Affine>
private

Definition at line 33 of file AnnulusBoundsPC.h.

Member Enumeration Documentation

◆ BoundsType

This enumerator simplifies the persistency, by saving a dynamic_cast to happen.

Other is reserved for the GeometrySurfaces implementation.

Enumerator
Cone 
Cylinder 
Diamond 
Disc 
Ellipse 
Rectangle 
RotatedTrapezoid 
Trapezoid 
Triangle 
DiscTrapezoidal 
Annulus 
Other 

Definition at line 58 of file SurfaceBounds.h.

◆ BoundValues

Enumerator
bv_minR 
bv_maxR 
bv_phiMin 
bv_phiMax 
bv_phiAvg 
bv_originX 
bv_originY 

Definition at line 40 of file AnnulusBoundsPC.h.

Constructor & Destructor Documentation

◆ AnnulusBoundsPC() [1/3]

Trk::AnnulusBoundsPC::AnnulusBoundsPC ( double minR,
double maxR,
double phiMin,
double phiMax,
Amg::Vector2D moduleOrigin = {0, 0},
double phiAvg = 0 )

Default constructor from parameters.

Parameters
minRinner radius, in module system
maxRouter radius, in module system
phiMinright angular edge, in strip system
phiMaxleft angular edge, in strip system
moduleOriginThe origin offset between the two systems.
phiAvg(Optional) internal rotation of this bounds object's local frame
Note
For moduleOrigin you need to actually calculate the cartesian offset

Definition at line 11 of file AnnulusBoundsPC.cxx.

17 : m_minR(minR),
18 m_maxR(maxR),
22 m_phiAvg(phiAvg)
23{
24
25 m_boundValues.resize(7);
33
34 m_rotationStripPC = Eigen::Translation<double, 2>(Amg::Vector2D(0, -m_phiAvg));
35 m_translation = Eigen::Translation<double, 2>(m_moduleOrigin);
36
39
40 // we need the corner points of the module to do the inside
41 // checking, calculate them here once, they don't change
42
43 // find inner outter radius at edges in STRIP PC
44 auto circIx = [](double O_x, double O_y, double r, double phi)
45 -> Amg::Vector2D {
46 // _____________________________________________
47 // / 2 2 2 2 2 2
48 // O_x + O_y*m - \/ - O_x *m + 2*O_x*O_y*m - O_y + m *r + r
49 // x = --------------------------------------------------------------
50 // 2
51 // m + 1
52 //
53 // y = m*x
54 //
55 double m = std::tan(phi);
56 Amg::Vector2D dir(std::cos(phi), std::sin(phi));
57 double x1 = (O_x + O_y*m - std::sqrt(-std::pow(O_x, 2)*std::pow(m, 2) + 2*O_x*O_y*m - std::pow(O_y, 2) + std::pow(m, 2)*std::pow(r, 2) + std::pow(r, 2)))/(std::pow(m, 2) + 1);
58 double x2 = (O_x + O_y*m + std::sqrt(-std::pow(O_x, 2)*std::pow(m, 2) + 2*O_x*O_y*m - std::pow(O_y, 2) + std::pow(m, 2)*std::pow(r, 2) + std::pow(r, 2)))/(std::pow(m, 2) + 1);
59
60 Amg::Vector2D v1(x1, m*x1);
61 if(v1.dot(dir) > 0) return v1;
62 return {x2, m*x2};
63 };
64
65 // calculate corners in STRIP XY, keep them we need them for minDistance()
70
75
80}
double phiMax() const
Returns the left angular edge of the module.
Amg::Vector2D m_outLeftModulePC
Amg::Vector2D stripXYToModulePC(const Amg::Vector2D &vStripXY) const
Amg::Vector2D m_inRightStripPC
Transform2D m_rotationStripPC
Amg::Vector2D m_outRightStripPC
Amg::Vector2D m_outLeftStripPC
Amg::Vector2D m_inRightModulePC
Amg::Vector2D m_inLeftStripPC
double phiMin() const
Returns the right angular edge of the module.
Amg::Vector2D m_inRightStripXY
Amg::Vector2D m_outRightModulePC
Amg::Vector2D m_inLeftModulePC
Amg::Vector2D m_inLeftStripXY
std::vector< TDD_real_t > m_boundValues
Amg::Vector2D m_outRightStripXY
Amg::Vector2D moduleOrigin() const
Returns moduleOrigin, but rotated out, so avgPhi is already considered.
double r() const override
Returns middle radius.
Amg::Vector2D m_moduleOrigin
Amg::Vector2D m_outLeftStripXY
Eigen::Matrix< double, 2, 1 > Vector2D
@ locY
local cartesian
Definition ParamDefs.h:38
@ locX
Definition ParamDefs.h:37
@ phi
Definition ParamDefs.h:75

◆ AnnulusBoundsPC() [2/3]

Trk::AnnulusBoundsPC::AnnulusBoundsPC ( const AnnulusBoundsPC & annbo)
default

Copy constructor.

◆ AnnulusBoundsPC() [3/3]

Trk::AnnulusBoundsPC::AnnulusBoundsPC ( AnnulusBoundsPC && annbo)
default

Move constructor.

Member Function Documentation

◆ clone()

virtual AnnulusBoundsPC * Trk::AnnulusBoundsPC::clone ( ) const
overridevirtual

clone() method to make deep copy in Surface copy constructor and for assigment operator of the Surface class.

Implements Trk::SurfaceBounds.

◆ closestOnSegment()

Amg::Vector2D Trk::AnnulusBoundsPC::closestOnSegment ( const Amg::Vector2D & a,
const Amg::Vector2D & b,
const Amg::Vector2D & p,
const Eigen::Matrix< double, 2, 2 > & weight )
staticprivate

Definition at line 505 of file AnnulusBoundsPC.cxx.

509{
510 // connecting vector
511 auto n = b - a;
512 // squared norm of line
513 auto f = (n.transpose() * weight * n).value();
514 // weighted scalar product of line to point and segment line
515 auto u = ((p - a).transpose() * weight * n).value() / f;
516 // clamp to [0, 1], convert to point
517 return std::min(std::max(u, 0.0), 1.0) * n + a;
518}
static Double_t a
@ u
Enums for curvilinear frames.
Definition ParamDefs.h:77

◆ corners()

std::array< std::pair< double, double >, 4 > Trk::AnnulusBoundsPC::corners ( ) const

Returns the four corners of the bounds.

Returns the module corners starting from the upper right (max R, pos locPhi) and proceding clock-wise, i.e. (max R; pos locPhi), (min R; pos locPhi), (min R; neg loc X), (max R; neg locPhi).

This method is only intended for debug purposes. If used for production code, this should be changed to a return-by-reference. This will necessitate the vector being stored in the class.

Returns
array of pairs of doubles giving the (R, phi) of each corner clockwise from upper-right

Definition at line 480 of file AnnulusBoundsPC.cxx.

480 {
481 auto rot = m_rotationStripPC.inverse();
482
483 auto to_pair = [](const Amg::Vector2D& v) -> std::pair<double, double>
484 {
485 return {v[0], v[1]};
486 };
487
488 return {
489 to_pair(rot * m_outRightStripPC),
490 to_pair(rot * m_outLeftStripPC),
491 to_pair(rot * m_inLeftStripPC),
492 to_pair(rot * m_inRightStripPC)
493 };
494
495}
@ v
Definition ParamDefs.h:78

◆ dump() [1/2]

MsgStream & Trk::AnnulusBoundsPC::dump ( MsgStream & sl) const
overridevirtual

helper which dumps the configuration into a stream.

Parameters
slThe stream
Returns
the stream given in sl

Implements Trk::SurfaceBounds.

Definition at line 454 of file AnnulusBoundsPC.cxx.

455{
456 std::stringstream ss;
457 dump(ss);
458 sl << ss.str();
459 return sl;
460}
static Double_t ss
MsgStream & dump(MsgStream &sl) const override
helper which dumps the configuration into a stream.

◆ dump() [2/2]

std::ostream & Trk::AnnulusBoundsPC::dump ( std::ostream & sl) const
overridevirtual

Output Method for std::ostream, to be overloaded by child classes.

Implements Trk::SurfaceBounds.

Definition at line 462 of file AnnulusBoundsPC.cxx.

463{
464 sl << std::setiosflags(std::ios::fixed);
465 sl << std::setprecision(7);
466 sl << "Trk::AnnulusBoundsPC: (minR, maxR, phiMin, phiMax, phiAvg, origin(x, y)) = " << "(" ;
474 sl << ")";
475 sl << std::setprecision(-1);
476 return sl;
477}

◆ fromCartesian()

std::pair< Trk::AnnulusBoundsPC, double > Trk::AnnulusBoundsPC::fromCartesian ( const AnnulusBounds & annbo)
static

Static factory method to produce an instance of this class from the cartesian implementation.

Parameters
annboA reference to the original cartesian bounds object
Returns
pair containing the PC bounds, and an angular shift phiShift
Note
The local frame of the cartesian implementation is such that the module sits around the y-axis. This implementation sits around the x axis. The local frame needs to be rotated to account for this. phiShift contains necessary information to (re)construct a transform that will perform this rotation.

Definition at line 83 of file AnnulusBoundsPC.cxx.

84{
85 auto [k_L, k_R, d_L, d_R] = annbo.getEdgeLines();
86
87 double O_x = (d_L - d_R) / (k_R - k_L);
88 double O_y = std::fma(O_x, k_L, d_L); // O_x * k_L + d_L
89 Amg::Vector2D originStripXY(-O_x, -O_y);
90
91 const auto& bounds = annbo.getBoundsValues();
92
93 double minR = bounds[AnnulusBounds::bv_minR];
94 double maxR = bounds[AnnulusBounds::bv_maxR];
95 double phi = bounds[AnnulusBounds::bv_phi];
96 double phiS = bounds[AnnulusBounds::bv_phiS];
97 double phiAvg = 0; // phiAvg is the bounds-internal local rotation. We don't want one
98
99 // phi is the total opening angle, set up symmetric phi bounds
100 double phiMax = phi/2.0;
101 double phiMin = -phiMax;
102
103 // need to rotate pi/2 to reproduce ABCartesian orientation, phiS so that phi=0 is center and symmetric
104 double phiShift = M_PI_2 - phiS;
105
106 // we need to rotate the origin into the bounds local coordinate system
107 Transform2D avgPhiRotation;
108 avgPhiRotation = Rotation2D(-phiShift);
109 Amg::Vector2D originStripXYRotated = avgPhiRotation * originStripXY;
110
111 AnnulusBoundsPC abpc(minR,
112 maxR,
113 phiMin,
114 phiMax,
115 originStripXYRotated,
116 phiAvg);
117
118 return std::make_pair(std::move(abpc), phiShift);
119}
Eigen::Transform< double, 2, Eigen::Affine > Transform2D
Eigen::Rotation2D< double > Rotation2D
AnnulusBoundsPC(double minR, double maxR, double phiMin, double phiMax, Amg::Vector2D moduleOrigin={0, 0}, double phiAvg=0)
Default constructor from parameters.

◆ initCache()

virtual void Trk::SurfaceBounds::initCache ( )
inlineprotectedvirtualinherited

virtual initCache method for object persistency

Reimplemented in Trk::ConeBounds, Trk::DiamondBounds, Trk::RotatedDiamondBounds, and Trk::RotatedTrapezoidBounds.

Definition at line 129 of file SurfaceBounds.h.

129{}

◆ inside() [1/2]

bool Trk::AnnulusBoundsPC::inside ( const Amg::Vector2D & locpo,
const BoundaryCheck & bchk ) const
finaloverridevirtual

Returns if a point in local coordinates is inside the bounds.

Parameters
locpoLocal position
bchkThe boundary check object to consult for inside checks
Returns
true if is inside, false if not

Implements Trk::SurfaceBounds.

Definition at line 161 of file AnnulusBoundsPC.cxx.

162{
163
164 // locpo is PC in STRIP SYSTEM
165
166 if(bchk.bcType == BoundaryCheck::absolute) {
167 // unpack tolerances and use other methods
168 if(bchk.checkLoc1 && bchk.checkLoc2) {
169 return inside(locpo, bchk.toleranceLoc1, bchk.toleranceLoc2);
170 }
171 else {
172 if(bchk.checkLoc1) {
173 return insideLoc1(locpo, bchk.toleranceLoc1);
174 }
175 else /* bchk.checkLoc2 */ {
176 return insideLoc2(locpo, bchk.toleranceLoc2);
177 }
178 }
179 }
180 else {
181 // first check if inside. We don't need to look into the covariance if inside
182 if(inside(locpo)) {
183 return true;
184 }
185
186 // we need to rotated the locpo
187 Amg::Vector2D locpo_rotated = m_rotationStripPC * locpo;
188
189 // covariance is given in STRIP SYSTEM in PC
190 // we need to convert the covariance to the MODULE SYSTEM in PC
191 // via jacobian.
192 // The following transforms into STRIP XY, does the shift into MODULE XY,
193 // and then transforms into MODULE PC
194 double dphi = m_phiAvg;
195 double phi_strip = locpo_rotated[Trk::locPhi];
196 double r_strip = locpo_rotated[Trk::locR];
197 double O_x = m_shiftXY[Trk::locX];
198 double O_y = m_shiftXY[Trk::locY];
199
200 // For a transformation from cartesian into polar coordinates
201 //
202 // [ _________ ]
203 // [ / 2 2 ]
204 // [ \/ x + y ]
205 // [ r' ] [ ]
206 // v = [ ] = [ / y \]
207 // [phi'] [2*atan|----------------|]
208 // [ | _________|]
209 // [ | / 2 2 |]
210 // [ \x + \/ x + y /]
211 //
212 // Where x, y are polar coordinates that can be rotated by dPhi
213 //
214 // [x] [O_x + r*cos(dPhi - phi)]
215 // [ ] = [ ]
216 // [y] [O_y - r*sin(dPhi - phi)]
217 //
218 // The general jacobian is:
219 //
220 // [d d ]
221 // [--(f_x) --(f_x)]
222 // [dx dy ]
223 // Jgen = [ ]
224 // [d d ]
225 // [--(f_y) --(f_y)]
226 // [dx dy ]
227 //
228 // which means in this case:
229 //
230 // [ d d ]
231 // [ ----------(rMod) ---------(rMod) ]
232 // [ dr_{strip} dphiStrip ]
233 // J = [ ]
234 // [ d d ]
235 // [----------(phiMod) ---------(phiMod)]
236 // [dr_{strip} dphiStrip ]
237 //
238 // Performing the derivative one gets:
239 //
240 // [B*O_x + C*O_y + rStrip rStrip*(B*O_y + O_x*sin(dPhi - phiStrip))]
241 // [---------------------- -----------------------------------------]
242 // [ ___ ___ ]
243 // [ \/ A \/ A ]
244 // J = [ ]
245 // [ -(B*O_y - C*O_x) rStrip*(B*O_x + C*O_y + rStrip) ]
246 // [ ----------------- ------------------------------- ]
247 // [ A A ]
248 //
249 // where
250 // 2 2 2
251 // A = O_x + 2*O_x*rStrip*cos(dPhi - phiStrip) + O_y - 2*O_y*rStrip*sin(dPhi - phiStrip) + rStrip
252 // B = cos(dPhi - phiStrip)
253 // C = -sin(dPhi - phiStrip)
254
255 double cosDPhiPhiStrip = std::cos(dphi - phi_strip);
256 double sinDPhiPhiStrip = std::sin(dphi - phi_strip);
257
258 double A = O_x*O_x + 2*O_x*r_strip*cosDPhiPhiStrip
259 + O_y*O_y - 2*O_y*r_strip*sinDPhiPhiStrip
260 + r_strip*r_strip;
261 double sqrtA = std::sqrt(A);
262
263
264 double B = cosDPhiPhiStrip;
265 double C = -sinDPhiPhiStrip;
266 Eigen::Matrix<double, 2, 2> jacobianStripPCToModulePC;
267 jacobianStripPCToModulePC(0, 0) = (B*O_x + C*O_y + r_strip)/sqrtA;
268 jacobianStripPCToModulePC(0, 1) = r_strip*(B*O_y + O_x*sinDPhiPhiStrip)/sqrtA;
269 jacobianStripPCToModulePC(1, 0) = -(B*O_y - C*O_x)/A;
270 jacobianStripPCToModulePC(1, 1) = r_strip*(B*O_x + C*O_y + r_strip)/A;
271
272 // covariance is given in STRIP PC
273 Matrix2D covStripPC = bchk.lCovariance;
274 // calculate covariance in MODULE PC using jacobian from above
275 Matrix2D covModulePC;
276 covModulePC = jacobianStripPCToModulePC * covStripPC * jacobianStripPCToModulePC.transpose();
277
278 // Mahalanobis distance uses inverse covariance as weights
279 Matrix2D weightStripPC = covStripPC.inverse();
280 Matrix2D weightModulePC = covModulePC.inverse();
281
282
283 double minDist = std::numeric_limits<double>::max();
284
285 Amg::Vector2D currentClosest;
286 double currentDist{0.0}; // initialise to zero
287
288 // do projection in STRIP PC
289
290 // first: STRIP system. locpo is in STRIP PC already
291 currentClosest = closestOnSegment(m_inLeftStripPC, m_outLeftStripPC, locpo_rotated, weightStripPC);
292 currentDist = squaredNorm(locpo_rotated-currentClosest, weightStripPC);
293 minDist = currentDist;
294
295 currentClosest = closestOnSegment(m_inRightStripPC, m_outRightStripPC, locpo_rotated, weightStripPC);
296 currentDist = squaredNorm(locpo_rotated-currentClosest, weightStripPC);
297 if(currentDist < minDist) {
298 minDist = currentDist;
299 }
300
301 // now: MODULE system. Need to transform locpo to MODULE PC
302 // transform is STRIP PC -> STRIP XY -> MODULE XY -> MODULE PC
303 Amg::Vector2D locpoStripXY(locpo_rotated[Trk::locR]*std::cos(locpo_rotated[Trk::locPhi]),
304 locpo_rotated[Trk::locR]*std::sin(locpo_rotated[Trk::locPhi]));
305 Amg::Vector2D locpoModulePC = stripXYToModulePC(locpoStripXY);
306
307
308 // now check edges in MODULE PC (inner and outer circle)
309 // assuming Mahalanobis distances are of same unit if covariance
310 // is correctly transformed
311 currentClosest = closestOnSegment(m_inLeftModulePC, m_inRightModulePC, locpoModulePC, weightModulePC);
312 currentDist = squaredNorm(locpoModulePC-currentClosest, weightModulePC);
313 if(currentDist < minDist) {
314 minDist = currentDist;
315 }
316
317 currentClosest = closestOnSegment(m_outLeftModulePC, m_outRightModulePC, locpoModulePC, weightModulePC);
318 currentDist = squaredNorm(locpoModulePC-currentClosest, weightModulePC);
319 if(currentDist < minDist) {
320 minDist = currentDist;
321 }
322
323 // compare resulting Mahalanobis distance to configured
324 // "number of sigmas"
325 // we square it b/c we never took the square root of the distance
326 return minDist < bchk.nSigmas*bchk.nSigmas;
327 }
328}
static double squaredNorm(const Amg::Vector2D &v, const Eigen::Matrix< double, 2, 2 > &weight)
Eigen::Matrix< double, 2, 2 > Matrix2D
bool insideLoc2(const Amg::Vector2D &locpo, double tol2=0.) const override final
Check if local point is inside of phi bounds.
static Amg::Vector2D closestOnSegment(const Amg::Vector2D &a, const Amg::Vector2D &b, const Amg::Vector2D &p, const Eigen::Matrix< double, 2, 2 > &weight)
bool insideLoc1(const Amg::Vector2D &locpo, double tol1=0.) const override final
Check if local point is inside of r bounds.
@ absolute
absolute check including tolerances
struct color C
@ locR
Definition ParamDefs.h:44
@ locPhi
local polar
Definition ParamDefs.h:45

◆ inside() [2/2]

bool Trk::AnnulusBoundsPC::inside ( const Amg::Vector2D & locpo,
double tol1 = 0.,
double tol2 = 0. ) const
finaloverridevirtual

Returns if a point in local coordinates is inside the bounds.

Parameters
locpoLocal position
tol1Tolerance in r
tol2Tolerance in phi
Returns
true if is inside, false if not

Implements Trk::SurfaceBounds.

Definition at line 122 of file AnnulusBoundsPC.cxx.

123{
124 // locpo is PC in STRIP SYSTEM
125 // need to perform internal rotation induced by m_phiAvg
126 Amg::Vector2D locpo_rotated = m_rotationStripPC * locpo;
127 double tolR = tol1;
128 double tolPhi = tol2;
129 double phiLoc = locpo_rotated[Trk::locPhi];
130 double rLoc = locpo_rotated[Trk::locR];
131
132 if (phiLoc < (m_phiMin - tolPhi) || phiLoc > (m_phiMax + tolPhi)) {
133 return false;
134 }
135
136 // calculate R in MODULE SYSTEM to evaluate R-bounds
137 if (tolR == 0.) {
138 // don't need R, can use R^2
139 double r_mod2 = m_shiftPC[Trk::locR]*m_shiftPC[Trk::locR]
140 + rLoc*rLoc + 2*m_shiftPC[Trk::locR]*rLoc * std::cos(phiLoc - m_shiftPC[Trk::locPhi]);
141
142 if (r_mod2 < m_minR*m_minR || r_mod2 > m_maxR*m_maxR) {
143 return false;
144 }
145 }
146 else {
147 // use R
148 double r_mod = std::sqrt(m_shiftPC[Trk::locR]*m_shiftPC[Trk::locR]
149 + rLoc*rLoc + 2*m_shiftPC[Trk::locR]*rLoc * cos(phiLoc - m_shiftPC[Trk::locPhi]));
150
151 if (r_mod < (m_minR - tolR) || r_mod > (m_maxR + tolR)) {
152 return false;
153 }
154 }
155
156 return true;
157}

◆ insideLoc1()

bool Trk::AnnulusBoundsPC::insideLoc1 ( const Amg::Vector2D & locpo,
double tol1 = 0. ) const
finaloverridevirtual

Check if local point is inside of r bounds.

Parameters
locpoLocal position
tol1Tolerance in r
Returns
true if is inside, false if not

Implements Trk::SurfaceBounds.

Definition at line 342 of file AnnulusBoundsPC.cxx.

343{
344 // locpo is PC in STRIP SYSTEM
345 // need to perform internal rotation induced by m_phiAvg
346 Amg::Vector2D locpo_rotated = m_rotationStripPC * locpo;
347 double tolR = tol1;
348 double phiLoc = locpo_rotated[Trk::locPhi];
349 double rLoc = locpo_rotated[Trk::locR];
350
351 // calculate R in MODULE SYSTEM to evaluate R-bounds
352 if (tolR == 0.) {
353 // don't need R, can use R^2
354 double r_mod2 = m_shiftPC[Trk::locR]*m_shiftPC[Trk::locR]
355 + rLoc*rLoc + 2.0*m_shiftPC[Trk::locR]*rLoc * std::cos(phiLoc - m_shiftPC[Trk::locPhi]);
356
357 if (r_mod2 < m_minR*m_minR || r_mod2 > m_maxR*m_maxR) {
358 return false;
359 }
360 }
361 else {
362 // use R
363 double r_mod = sqrt(m_shiftPC[Trk::locR]*m_shiftPC[Trk::locR]
364 + rLoc*rLoc + 2.0*m_shiftPC[Trk::locR]*rLoc * std::cos(phiLoc - m_shiftPC[Trk::locPhi]));
365
366 if (r_mod < (m_minR - tolR) || r_mod > (m_maxR + tolR)) {
367 return false;
368 }
369 }
370
371 return true;
372}

◆ insideLoc2()

bool Trk::AnnulusBoundsPC::insideLoc2 ( const Amg::Vector2D & locpo,
double tol2 = 0. ) const
finaloverridevirtual

Check if local point is inside of phi bounds.

Parameters
locpoLocal position
tol2Tolerance in phi
Returns
true if is inside, false if not

Implements Trk::SurfaceBounds.

Definition at line 331 of file AnnulusBoundsPC.cxx.

332{
333 // locpo is PC in STRIP SYSTEM
334 // need to perform internal rotation induced by m_phiAvg
335 Amg::Vector2D locpo_rotated = m_rotationStripPC * locpo;
336 double tolPhi = tol2;
337 double phiLoc = locpo_rotated[Trk::locPhi];
338
339 return phiLoc >= (m_phiMin - tolPhi) && phiLoc < (m_phiMax + tolPhi);
340}

◆ minDistance()

double Trk::AnnulusBoundsPC::minDistance ( const Amg::Vector2D & locpo) const
finaloverridevirtual

Return minimum distance a point is away from the bounds.

Parameters
locpoLocal position
Note
Even though locpo is considered in STRIP system, the distance will be calculated with cartesian metric.

Implements Trk::SurfaceBounds.

Definition at line 375 of file AnnulusBoundsPC.cxx.

376{
377 // find the closest point on all edges, calculate distance
378 // return smallest one
379 // closest distance is cartesian, we want the result in mm.
380
381 Amg::Vector2D locpo_rotated = m_rotationStripPC * locpo;
382
383 // locpo is given in STRIP PC, we need it in STRIP XY and possibly MODULE XY
384 double rStrip = locpo_rotated[Trk::locR];
385 double phiStrip = locpo_rotated[Trk::locPhi];
386 Amg::Vector2D locpoStripXY(rStrip*std::cos(phiStrip), rStrip*std::sin(phiStrip));
387 Amg::Vector2D locpoModuleXY = locpoStripXY + m_shiftXY;
388 double rMod = locpoModuleXY.norm();
389 double phiMod = locpoModuleXY.phi();
390
391 Amg::Vector2D closestStripPC;
392 double minDist = std::numeric_limits<double>::max();;
393 double curDist{0.0}; // initialise to 0
394
395 // for rmin
396 if (m_inRightModulePC[Trk::locPhi] <= phiMod && phiMod < m_inLeftModulePC[Trk::locPhi]) {
397 // is inside phi bounds, to comparison to rmin and r max
398 // r min
399 curDist = std::abs(m_minR - rMod);
400 minDist = std::min(minDist, curDist);
401 }
402 else {
403 // is outside phi bounds, closest can only be the edge points here
404
405 // in left
406 curDist = (m_inLeftStripXY - locpoStripXY).norm();
407 minDist = std::min(minDist, curDist);
408
409 // in right
410 curDist = (m_inRightStripXY - locpoStripXY).norm();
411 minDist = std::min(minDist, curDist);
412 }
413
414 if (m_phiMin <= phiStrip && phiStrip < m_phiMax) {
415 // r max
416 curDist = std::abs(m_maxR - rMod);
417 minDist = std::min(minDist, curDist);
418 }
419 else {
420 // out left
421 curDist = (m_outLeftStripXY - locpoStripXY).norm();
422 minDist = std::min(minDist, curDist);
423
424 // out right
425 curDist = (m_outRightStripXY - locpoStripXY).norm();
426 minDist = std::min(minDist, curDist);
427 }
428
429 Matrix2D weight = Matrix2D::Identity();
430
431 // phi left
432 Amg::Vector2D closestLeft = closestOnSegment(m_inLeftStripXY, m_outLeftStripXY, locpoStripXY, weight);
433 curDist = (closestLeft - locpoStripXY).norm();
434 if (curDist < minDist) {
435 minDist = curDist;
436 }
437
438 // phi right
439 Amg::Vector2D closestRight = closestOnSegment(m_inRightStripXY, m_outRightStripXY, locpoStripXY, weight);
440 curDist = (closestRight - locpoStripXY).norm();
441 if (curDist < minDist) {
442 minDist = curDist;
443 }
444
445 return minDist;
446}

◆ moduleOrigin()

Amg::Vector2D Trk::AnnulusBoundsPC::moduleOrigin ( ) const

Returns moduleOrigin, but rotated out, so avgPhi is already considered.

The module origin needs to consider the rotation introduced by avgPhi

Returns
The origin of the local frame

Definition at line 527 of file AnnulusBoundsPC.cxx.

528{
529 return Eigen::Rotation2D<double>(m_phiAvg) * m_moduleOrigin;
530}

◆ operator!=()

bool Trk::SurfaceBounds::operator!= ( const SurfaceBounds & sb) const
inlinevirtualinherited

Non-Equality operator.

Reimplemented in Trk::InvalidBounds.

Definition at line 141 of file SurfaceBounds.h.

142{
143 return !((*this) == sb);
144}

◆ operator=() [1/2]

AnnulusBoundsPC & Trk::AnnulusBoundsPC::operator= ( AnnulusBoundsPC && sbo)
default

Move assignment.

◆ operator=() [2/2]

AnnulusBoundsPC & Trk::AnnulusBoundsPC::operator= ( const AnnulusBoundsPC & sbo)
default

Assignment operator.

◆ operator==()

bool Trk::AnnulusBoundsPC::operator== ( const SurfaceBounds & sb) const
overridevirtual

Equality operator.

Implements Trk::SurfaceBounds.

◆ phiMax()

double Trk::AnnulusBoundsPC::phiMax ( ) const
inline

Returns the left angular edge of the module.

Returns
The left side angle

Definition at line 143 of file AnnulusBoundsPC.h.

143{ return m_phiMax + m_phiAvg; }

◆ phiMin()

double Trk::AnnulusBoundsPC::phiMin ( ) const
inline

Returns the right angular edge of the module.

Returns
The right side angle

Definition at line 139 of file AnnulusBoundsPC.h.

139{ return m_phiMin + m_phiAvg; }

◆ r()

double Trk::AnnulusBoundsPC::r ( ) const
overridevirtual

Returns middle radius.

Returns
The middle radius

Implements Trk::SurfaceBounds.

Definition at line 449 of file AnnulusBoundsPC.cxx.

450{
451 return (rMax() + rMin()) * 0.5;
452}
double rMin() const
Returns inner radial bounds (module system)
double rMax() const
Returns outer radial bounds (module system)

◆ rMax()

double Trk::AnnulusBoundsPC::rMax ( ) const
inline

Returns outer radial bounds (module system)

Returns
The outer radius

Definition at line 135 of file AnnulusBoundsPC.h.

135{ return m_maxR; }

◆ rMin()

double Trk::AnnulusBoundsPC::rMin ( ) const
inline

Returns inner radial bounds (module system)

Returns
The inner radius

Definition at line 131 of file AnnulusBoundsPC.h.

131{ return m_minR; }

◆ squaredNorm()

double Trk::AnnulusBoundsPC::squaredNorm ( const Amg::Vector2D & v,
const Eigen::Matrix< double, 2, 2 > & weight )
staticprivate

Definition at line 521 of file AnnulusBoundsPC.cxx.

522{
523 return (v.transpose() * weight * v).value();
524}

◆ stripXYToModulePC()

Amg::Vector2D Trk::AnnulusBoundsPC::stripXYToModulePC ( const Amg::Vector2D & vStripXY) const
private

Definition at line 498 of file AnnulusBoundsPC.cxx.

499{
500 Amg::Vector2D vecModuleXY = vStripXY + m_shiftXY;
501 return {vecModuleXY.norm(), vecModuleXY.phi()};
502}

◆ swap()

void Trk::SurfaceBounds::swap ( double & b1,
double & b2 )
inlineprotectedinherited

Swap method to be called from DiscBounds or TrapezoidalBounds.

Definition at line 133 of file SurfaceBounds.h.

134{
135 double tmp = b1;
136 b1 = b2;
137 b2 = tmp;
138}

◆ type()

SurfaceBounds::BoundsType Trk::AnnulusBoundsPC::type ( ) const
overridevirtual

Return the bounds type - for persistency optimization.

Implements Trk::SurfaceBounds.

Member Data Documentation

◆ AnnulusTestAlg

friend Trk::AnnulusBoundsPC::AnnulusTestAlg
private

Definition at line 36 of file AnnulusBoundsPC.h.

◆ m_boundValues

std::vector<TDD_real_t> Trk::AnnulusBoundsPC::m_boundValues
private

Definition at line 198 of file AnnulusBoundsPC.h.

◆ m_inLeftModulePC

Amg::Vector2D Trk::AnnulusBoundsPC::m_inLeftModulePC
private

Definition at line 189 of file AnnulusBoundsPC.h.

◆ m_inLeftStripPC

Amg::Vector2D Trk::AnnulusBoundsPC::m_inLeftStripPC
private

Definition at line 184 of file AnnulusBoundsPC.h.

◆ m_inLeftStripXY

Amg::Vector2D Trk::AnnulusBoundsPC::m_inLeftStripXY
private

Definition at line 194 of file AnnulusBoundsPC.h.

◆ m_inRightModulePC

Amg::Vector2D Trk::AnnulusBoundsPC::m_inRightModulePC
private

Definition at line 191 of file AnnulusBoundsPC.h.

◆ m_inRightStripPC

Amg::Vector2D Trk::AnnulusBoundsPC::m_inRightStripPC
private

Definition at line 186 of file AnnulusBoundsPC.h.

◆ m_inRightStripXY

Amg::Vector2D Trk::AnnulusBoundsPC::m_inRightStripXY
private

Definition at line 196 of file AnnulusBoundsPC.h.

◆ m_maxR

double Trk::AnnulusBoundsPC::m_maxR
private

Definition at line 171 of file AnnulusBoundsPC.h.

◆ m_minR

double Trk::AnnulusBoundsPC::m_minR
private

Definition at line 170 of file AnnulusBoundsPC.h.

◆ m_moduleOrigin

Amg::Vector2D Trk::AnnulusBoundsPC::m_moduleOrigin
private

Definition at line 175 of file AnnulusBoundsPC.h.

◆ m_outLeftModulePC

Amg::Vector2D Trk::AnnulusBoundsPC::m_outLeftModulePC
private

Definition at line 188 of file AnnulusBoundsPC.h.

◆ m_outLeftStripPC

Amg::Vector2D Trk::AnnulusBoundsPC::m_outLeftStripPC
private

Definition at line 183 of file AnnulusBoundsPC.h.

◆ m_outLeftStripXY

Amg::Vector2D Trk::AnnulusBoundsPC::m_outLeftStripXY
private

Definition at line 193 of file AnnulusBoundsPC.h.

◆ m_outRightModulePC

Amg::Vector2D Trk::AnnulusBoundsPC::m_outRightModulePC
private

Definition at line 190 of file AnnulusBoundsPC.h.

◆ m_outRightStripPC

Amg::Vector2D Trk::AnnulusBoundsPC::m_outRightStripPC
private

Definition at line 185 of file AnnulusBoundsPC.h.

◆ m_outRightStripXY

Amg::Vector2D Trk::AnnulusBoundsPC::m_outRightStripXY
private

Definition at line 195 of file AnnulusBoundsPC.h.

◆ m_phiAvg

double Trk::AnnulusBoundsPC::m_phiAvg
private

Definition at line 178 of file AnnulusBoundsPC.h.

◆ m_phiMax

double Trk::AnnulusBoundsPC::m_phiMax
private

Definition at line 173 of file AnnulusBoundsPC.h.

◆ m_phiMin

double Trk::AnnulusBoundsPC::m_phiMin
private

Definition at line 172 of file AnnulusBoundsPC.h.

◆ m_rotationStripPC

Transform2D Trk::AnnulusBoundsPC::m_rotationStripPC
private

Definition at line 179 of file AnnulusBoundsPC.h.

◆ m_shiftPC

Amg::Vector2D Trk::AnnulusBoundsPC::m_shiftPC
private

Definition at line 177 of file AnnulusBoundsPC.h.

◆ m_shiftXY

Amg::Vector2D Trk::AnnulusBoundsPC::m_shiftXY
private

Definition at line 176 of file AnnulusBoundsPC.h.

◆ m_translation

Transform2D Trk::AnnulusBoundsPC::m_translation
private

Definition at line 180 of file AnnulusBoundsPC.h.


The documentation for this class was generated from the following files: