ATLAS Offline Software
Loading...
Searching...
No Matches
SlidingDiscSurface.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3*/
4
6// SlidingDiscSurface.cxx, (c) ATLAS Detector Software
8
9// Trk
13
14// Eigen
16#include <cmath>
17
19
20// copy constructor with shift
22 const Amg::Transform3D& transf)
23 : Trk::DiscSurface(dsf, transf)
24 , m_depth(dsf.m_depth)
25 , m_etaBin(dsf.m_etaBin)
26{}
27
28// constructor
30 const Trk::BinUtility & bu,
31 const std::vector<float>& offset)
32 : Trk::DiscSurface(dsf)
34 , m_etaBin(bu)
35{}
36
37
38bool
40{
41 // first check the type not to compare apples with oranges
42 const Trk::SlidingDiscSurface* dsf = dynamic_cast<const Trk::SlidingDiscSurface*>(&sf);
43 if (!dsf)
44 return false;
45 if (this == dsf)
46 return true;
47 bool transfEqual(transform().isApprox(dsf->transform(), 10e-8));
48 bool centerEqual = (transfEqual) ? (center() == dsf->center()) : false;
49 bool boundsEqual = (centerEqual) ? (bounds() == dsf->bounds()) : false;
50 return boundsEqual;
51}
52
53void
55{
56 // create the position in the local 3d frame
57 Amg::Vector3D loc3D0(locpos[Trk::locR] * std::cos(locpos[Trk::locPhi]),
58 locpos[Trk::locR] * std::sin(locpos[Trk::locPhi]), 0.);
59 // correct for alignment, retrieve offset correction
61 float offset = m_depth[m_etaBin.bin(t0 * loc3D0)];
62 Amg::Vector3D loc3Dframe(
63 locpos[Trk::locR] * std::cos(locpos[Trk::locPhi]),
64 locpos[Trk::locR] * std::sin(locpos[Trk::locPhi]), offset);
65 // transport it to the globalframe
66 glopos = Trk::Surface::transform() * loc3Dframe;
67}
68
70bool
72{
73 const Amg::Vector3D& loc3D0 = glopos; // used to retrieve localEta bin
74 Amg::Vector3D loc3Dframe(Trk::Surface::transform().inverse() * glopos);
75 locpos = Amg::Vector2D(loc3Dframe.perp(), loc3Dframe.phi());
76 return (std::abs(loc3Dframe.z() - m_depth[m_etaBin.bin(loc3D0)]) <= s_onSurfaceTolerance);
77}
78
79bool
81 const Trk::BoundaryCheck& bchk,
82 double tol1,
83 double tol2) const
84{
85 const Amg::Vector3D& loc3D0 = glopo; // used to retrieve localEta bin
86 Amg::Vector3D loc3Dframe = (transform().inverse()) * glopo;
87 float offset = m_depth[m_etaBin.bin(loc3D0)];
88 if (std::abs(loc3Dframe.z() - offset) > (s_onSurfaceTolerance + tol1)){
89 return false;
90 }
91 return (bchk ? bounds().inside(Amg::Vector2D(loc3Dframe.perp(), loc3Dframe.phi()), tol1, tol2) : true);
92}
93
97{
98 double tol = 0.001;
99
100 // retrieve localEta bin using current position
101 const Amg::Vector3D& loc3D0 = pos; // used to retrieve localEta bin
102 float offset = m_depth[m_etaBin.bin(loc3D0)];
103
104 // slide surface
105 Amg::Vector3D N = normal();
106 Amg::Vector3D C = center() + offset * N;
107
108 double S = C.dot(N);
109 double b = S < 0. ? -1 : 1;
110 double A = b * dir.dot(N);
111 double d = (pos - C).dot(N); // distance to surface
112
113 if (A == 0.) { // direction parallel to surface
114 if (std::abs(d) < tol) {
115 return {1, 0., true, 0.};
116 }
117 return {0, d, true, 0.};
118
119 }
120
121 double D = b * (S - (pos.dot(N))) / A;
122
123 return {1, d, true, D};
124}
125
128 const Amg::Vector3D& dir,
129 bool /*bound*/) const
130{
131 return straightLineDistanceEstimate(pos, dir);
132}
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 DiscSurface in the ATLAS detector.
Definition DiscSurface.h:54
DiscSurface()
Default Constructor.
const SurfaceBounds & bounds() const override final
This method returns the bounds by reference.
static const NoBounds s_boundless
Access to distance solutions.
Bounds object for a boundless surface (...)
Definition NoBounds.h:30
Class for a Calo DiscSurface with variable depth in the ATLAS detector.
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.
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...
std::vector< float > m_depth
< data members
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 ...
const std::vector< float > & offset() const
This method allows access to the radial offset values.
SlidingDiscSurface(DiscSurface &surf, const Trk::BinUtility &bu, const std::vector< float > &offset)
Constructor.
virtual bool operator==(const Surface &sf) const override final
Equality operator.
virtual DistanceSolution straightLineDistanceEstimate(const Amg::Vector3D &pos, const Amg::Vector3D &dir) const override final
fast straight line intersection schema - standard: provides closest intersection and (signed) path le...
Abstract Base Class for tracking surfaces.
static constexpr double s_onSurfaceTolerance
Tolerance for being on Surface.
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.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
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.
@ locR
Definition ParamDefs.h:44
@ locPhi
local polar
Definition ParamDefs.h:45
Definition dot.py:1
hold the test vectors and ease the comparison