ATLAS Offline Software
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
12 #include "TrkSurfaces/DiscBounds.h"
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)
33  , m_depth(offset)
34  , m_etaBin(bu)
35 {}
36 
37 
38 bool
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 
53 void
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 
70 bool
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 
79 bool
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 }
Trk::SlidingDiscSurface
Definition: SlidingDiscSurface.h:45
DiscBounds.h
Trk::DistanceSolution
Definition: DistanceSolution.h:25
Amg::Vector2D
Eigen::Matrix< double, 2, 1 > Vector2D
Definition: GeoPrimitives.h:48
hist_file_dump.d
d
Definition: hist_file_dump.py:137
ALFA_EventTPCnv_Dict::t0
std::vector< ALFA_RawData_p1 > t0
Definition: ALFA_EventTPCnvDict.h:42
Trk::DiscSurface
Definition: DiscSurface.h:54
JetTiledMap::N
@ N
Definition: TiledEtaPhiMap.h:44
Trk::locR
@ locR
Definition: ParamDefs.h:50
drawFromPickle.cos
cos
Definition: drawFromPickle.py:36
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
Trk::SlidingDiscSurface::isOnSurface
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...
Definition: SlidingDiscSurface.cxx:80
JetTiledMap::S
@ S
Definition: TiledEtaPhiMap.h:44
GeoPrimitives.h
Trk::SlidingDiscSurface::SlidingDiscSurface
SlidingDiscSurface(DiscSurface &surf, const Trk::BinUtility &bu, const std::vector< float > &offset)
Constructor.
SlidingDiscSurface.h
Trk::SlidingDiscSurface::localToGlobal
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.
Definition: SlidingDiscSurface.cxx:54
Trk::SlidingDiscSurface::straightLineDistanceEstimate
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...
Definition: SlidingDiscSurface.cxx:96
Trk::SlidingDiscSurface::operator==
virtual bool operator==(const Surface &sf) const override final
Equality operator.
Definition: SlidingDiscSurface.cxx:39
Amg::Transform3D
Eigen::Affine3d Transform3D
Definition: GeoPrimitives.h:46
Trk::DiscSurface::bounds
const SurfaceBounds & bounds() const override final
This method returns the bounds by reference.
Amg::transform
Amg::Vector3D transform(Amg::Vector3D &v, Amg::Transform3D &tr)
Transform a point from a Trasformation3D.
Definition: GeoPrimitivesHelpers.h:156
dot.dot
def dot(G, fn, nodesToHighlight=[])
Definition: dot.py:5
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::BinUtility
Definition: BinUtility.h:39
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
Trk::locPhi
@ locPhi
local polar
Definition: ParamDefs.h:51
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
LocalParameters.h
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
Trk::NoBounds
Definition: NoBounds.h:30
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
mapkey::sf
@ sf
Definition: TElectronEfficiencyCorrectionTool.cxx:38
Trk::BoundaryCheck
Definition: BoundaryCheck.h:51
convertTimingResiduals.offset
offset
Definition: convertTimingResiduals.py:71
drawFromPickle.sin
sin
Definition: drawFromPickle.py:36
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::SlidingDiscSurface::globalToLocal
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 ...
Definition: SlidingDiscSurface.cxx:71
Trk::Surface::transform
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Trk::DiscSurface::s_boundless
static const NoBounds s_boundless
Definition: DiscSurface.h:289