ATLAS Offline Software
Loading...
Searching...
No Matches
SlidingCylinderSurface.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3*/
4
6// SlidingCylinderSurface.cxx, (c) ATLAS Detector Software
8
9// Trk
13
14// Eigen
16// STD
17#include <cmath>
18
19
20
21// constructor
23 const Trk::BinUtility & bu,
24 const std::vector<float> & offset)
25 : Trk::CylinderSurface(dsf)
27 , m_etaBin(bu)
28{}
29
30
31bool
33{
34 // first check the type not to compare apples with oranges
35 const Trk::SlidingCylinderSurface* dsf = dynamic_cast<const Trk::SlidingCylinderSurface*>(&sf);
36 if (!dsf)
37 return false;
38 if (this == dsf)
39 return true;
40 bool transfEqual(transform().isApprox(dsf->transform(), 10e-8));
41 bool centerEqual = (transfEqual) ? (center() == dsf->center()) : false;
42 bool boundsEqual = (centerEqual) ? (bounds() == dsf->bounds()) : false;
43 return boundsEqual;
44}
45
46void
48 const Amg::Vector3D&,
49 Amg::Vector3D& glopos) const
50{
51 // create the position in the local 3d frame
52 double r0 = bounds().r();
53 double phi0 = locpos[Trk::locRPhi] / r0;
54 Amg::Vector3D loc3D0(r0 * std::cos(phi0), r0 * std::sin(phi0), locpos[Trk::locZ]);
55 // correct for alignment, retrieve offset correction
57 float offset = m_depth[m_etaBin.bin(t0 * loc3D0)];
58 double r = r0 + offset;
59 double phi = locpos[Trk::locRPhi] / r;
60 Amg::Vector3D loc3Dframe(r * std::cos(phi), r * std::sin(phi), locpos[Trk::locZ]);
61 // transport it to the globalframe
62 glopos = Trk::Surface::transform() * loc3Dframe;
63}
64
66bool
68 const Amg::Vector3D&,
69 Amg::Vector2D& locpos) const
70{
71 // get the transform & transform global position into cylinder frame
72 // transform it to the globalframe: CylinderSurfaces are allowed to have 0 pointer transform
73 double radius = 0.;
74 const double inttol = std::max(bounds().r() * 0.0001, 0.01);
75 // realign to find local eta bin
76 const Amg::Vector3D& loc3D0 = glopos;
77 float offset = m_depth[m_etaBin.bin(loc3D0)];
78 // do the transformation or not
80 const Amg::Transform3D& surfaceTrans = transform();
81 Amg::Transform3D inverseTrans(surfaceTrans.inverse());
82 Amg::Vector3D loc3Dframe(inverseTrans * glopos);
83 locpos = Amg::Vector2D((bounds().r() + offset) * loc3Dframe.phi(), loc3Dframe.z());
84 radius = loc3Dframe.perp();
85 } else {
86 locpos = Amg::Vector2D((bounds().r() + offset) * glopos.phi(), glopos.z());
87 radius = glopos.perp();
88 }
89 // return true or false
90 return (std::abs(radius - bounds().r() - offset) <= inttol);
91}
92
93bool
95 const Trk::BoundaryCheck& bchk,
96 double tol1,
97 double tol2) const
98{
99 const Amg::Vector3D& loc3D0 = glopo;
100 Amg::Vector3D loc3Dframe = m_transforms ? (transform().inverse()) * glopo : glopo;
101 float offset = m_depth[m_etaBin.bin(loc3D0)];
102 // recalculate r to match bounds
103 Amg::Vector3D loc3Dbase((loc3Dframe.perp() - offset) * std::cos(loc3Dframe.phi()),
104 (loc3Dframe.perp() - offset) * std::sin(loc3Dframe.phi()),
105 loc3Dframe.z());
106
107 return (bchk ? bounds().inside3D(loc3Dbase, tol1, tol2) : true);
108}
109
113{
114 double tol = 0.001;
115
116 // retrieve localEta bin using current position
117 const Amg::Vector3D& loc3D0 = pos; // used to retrieve localEta bin
118 float offset = m_depth[m_etaBin.bin(loc3D0)];
119
120 const Amg::Vector3D& X = Trk::Surface::center(); // point
121 const Amg::Vector3D& S = Trk::Surface::normal(); // vector
122
123 double radius = bounds().r() + offset;
124 double sp = pos.dot(S);
125 double sc = X.dot(S);
126 double dp = dir.dot(S);
127 Amg::Vector3D dx = X - pos - (sc - sp) * S; // vector
128 Amg::Vector3D ax = dir - dp * S; // vector
129
130 double A = ax.dot(ax); // size of projected direction (squared)
131 double B = ax.dot(dx); // dot product (->cos angle)
132 double C = dx.dot(dx); // distance to axis (squared)
133 double currDist = radius - std::sqrt(C);
134 const double bOverA{B/A};
135 if (A == 0.) { // direction parallel to cylinder axis
136 if (std::abs(currDist) < tol) {
137 return {1, 0., true, 0.}; // solution at surface
138 }
139 return {0, currDist, true, 0.}; // point of closest approach without intersection
140
141 }
142 // minimal distance to cylinder axis
143 double rmin = C - B * bOverA < 0. ? 0. : std::sqrt(C - B * bOverA);
144 if (rmin > radius) { // no intersection
145 return {0, currDist, true, bOverA}; // point of closest approach without intersection
146 }
147 if (std::abs(rmin - radius) < tol) { // tangential 'intersection' - return double solution
148 return {2, currDist, true, bOverA, bOverA};
149 }
150 const double sqrtTerm = std::sqrt((radius - rmin) * (radius + rmin)/A) ;
151 double first = bOverA - sqrtTerm;
152 double second = bOverA + sqrtTerm;
153 if (first >= 0.) {
154 return {2, currDist, true, first, second};
155 } if (second <= 0.) {
156 return {2, currDist, true, second, first};
157 } // inside cylinder
158 return {2, currDist, true, second, first};
159}
160
163 const Amg::Vector3D& dir,
164 bool /*bound*/) const
165{
166 return straightLineDistanceEstimate(pos, dir);
167}
static Double_t sp
static Double_t sc
static Double_t t0
A generic symmetric BinUtility, for fully symmetric binning in terms of binning grid and binning type...
Definition BinUtility.h:39
The BoundaryCheck class allows to steer the way surface boundaries are used for inside/outside checks...
Class for a CylinderSurface in the ATLAS detector.
CylinderSurface()
Default Constructor.
virtual const CylinderBounds & bounds() const override final
This method returns the CylinderBounds by reference (NoBounds is not possible for cylinder)
Access to distance solutions.
Class for a Calo CylinderSurface with variable depth in the ATLAS detector.
virtual DistanceSolution straightLineDistanceEstimate(const Amg::Vector3D &pos, const Amg::Vector3D &dir) const override final
fast straight line distance evaluation to Surface
virtual bool globalToLocal(const Amg::Vector3D &glob, const Amg::Vector3D &mom, Amg::Vector2D &loc) const override final
Specialized for DiscSurface: GlobalToLocal method without dynamic memory allocation - boolean checks ...
virtual void localToGlobal(const Amg::Vector2D &locp, const Amg::Vector3D &mom, Amg::Vector3D &glob) const override final
Specialized for DiscSurface: LocalToGlobal method without dynamic memory allocation.
const std::vector< float > & offset() const
This method allows access to the radial offset values.
SlidingCylinderSurface(const CylinderSurface &surf, const Trk::BinUtility &bu, const std::vector< float > &offset)
Constructor.
virtual bool operator==(const Surface &sf) const override final
Equality operator.
virtual bool isOnSurface(const Amg::Vector3D &glopo, const BoundaryCheck &bchk=true, double tol1=0., double tol2=0.) const override final
This method returns true if the GlobalPosition is on the Surface for both, within or without check of...
Abstract Base Class for tracking surfaces.
virtual const Amg::Vector3D & normal() const
Returns the normal vector of the Surface (i.e.
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
std::unique_ptr< Transforms > m_transforms
Unique Pointer to the Transforms struct.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
int r
Definition globals.cxx:22
struct color C
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 2, 1 > Vector2D
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
@ locRPhi
Definition ParamDefs.h:40
@ phi0
Definition ParamDefs.h:65
@ phi
Definition ParamDefs.h:75
@ locZ
local cylindrical
Definition ParamDefs.h:42
hold the test vectors and ease the comparison