ATLAS Offline Software
PrepRawDataComparisonFunction.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 // PrepRawDataComparisonFunction.h
7 // Header file for struct PrepRawDataComparisonFunction
9 // (c) ATLAS Detector software
11 // Wolfgang.Liebig@cern.ch / Andreas.Salzburger@cern.ch
13 
14 #ifndef TRKNIRVANA_PREPRAWDATACOMPARISONFUNCTION_H
15 #define TRKNIRVANA_PREPRAWDATACOMPARISONFUNCTION_H
16 
17 // Trk
23 // STL
24 #include <cmath>
25 #include <stdexcept>
26 
27 namespace Trk {
33 {
34 public:
37  const Amg::Vector3D& dir)
38  : m_point(sp)
39  , m_direction(dir.unit())
40  {}
41 
44  default;
46 
48  const PrepRawDataComparisonFunction& PCF) = default;
49 
51  PrepRawDataComparisonFunction&& PCF) = default;
52 
54 
58  const Trk::PrepRawData* two) const
59  {
60 
61  // --- identify the surface type and get intersection path for surface 1
62  //
63  double path1 = 0;
64  const Trk::Surface& sf1 = one->detectorElement()->surface(one->identify());
65  const Trk::SurfaceType surfType1 = sf1.type();
66  switch (surfType1) {
68  const Trk::PlaneSurface& opsf =
69  static_cast<const Trk::PlaneSurface&>(sf1);
70  path1 = this->pathIntersectWithPlane(opsf);
71  } break;
73  const Trk::StraightLineSurface& ossf =
74  static_cast<const Trk::StraightLineSurface&>(sf1);
75  path1 = this->pathIntersectWithLine(ossf);
76  } break;
78  const Trk::DiscSurface& odsf =
79  static_cast<const Trk::DiscSurface&>(sf1);
80  path1 = this->pathIntersectWithDisc(odsf);
81  } break;
82  default: {
83  throw std::runtime_error(
84  "PrepRawDataComparisonFunction: surface type error!");
85  }
86  } // --- no raw data on Cylinder. Ever.
87 
88  // --- identify the surface type and get intersection path for surface 1
89  //
90  double path2 = 0;
91  const Trk::Surface& sf2 = two->detectorElement()->surface(two->identify());
92  const Trk::SurfaceType surfType2 = sf2.type();
93  switch (surfType2) {
95  const Trk::PlaneSurface& opsf =
96  static_cast<const Trk::PlaneSurface&>(sf2);
97  path2 = this->pathIntersectWithPlane(opsf);
98  } break;
100  const Trk::StraightLineSurface& ossf =
101  static_cast<const Trk::StraightLineSurface&>(sf2);
102  path2 = this->pathIntersectWithLine(ossf);
103  } break;
104  case Trk::SurfaceType::Disc: {
105  const Trk::DiscSurface& odsf =
106  static_cast<const Trk::DiscSurface&>(sf2);
107  path2 = this->pathIntersectWithDisc(odsf);
108  } break;
109  default: {
110  throw std::runtime_error(
111  "PrepRawDataComparisonFunction: surface type error!");
112  }
113  } // --- no raw data on Cylinder. Ever.
114 
115  return path1 < path2;
116  }
117 
118 private:
121 
122  double pathIntersectWithPlane(const Trk::PlaneSurface& psf) const
123  {
124  double denom = m_direction.dot(psf.normal());
125  return (denom) ? psf.normal().dot(psf.center() - m_point) / (denom)
126  : denom;
127  }
128 
130  {
131  Amg::Vector3D dirWire(lsf.transform().rotation().col(2).unit());
132  Amg::Vector3D trackToWire(lsf.center() - m_point);
133  double parallelity = m_direction.dot(dirWire);
134  double denom = 1 - parallelity * parallelity;
135  return (std::abs(denom) > 10e-7)
136  ? (trackToWire.dot(m_direction) -
137  trackToWire.dot(dirWire) * parallelity) /
138  denom
139  : 0.;
140  }
141 
142  double pathIntersectWithDisc(const Trk::DiscSurface& dsf) const
143  {
144  double denom = m_direction.dot(dsf.normal());
145  return (denom) ? dsf.normal().dot(dsf.center() - m_point) / (denom)
146  : denom;
147  }
148 };
149 
150 } // end of namespace
151 
152 #endif // TRKNIRVANA_PREPRAWDATACOMPARISONFUNCTION_H
153 
Trk::PrepRawDataComparisonFunction::PrepRawDataComparisonFunction
PrepRawDataComparisonFunction(const Amg::Vector3D &sp, const Amg::Vector3D &dir)
Full relation definition using a straight line propagation.
Definition: PrepRawDataComparisonFunction.h:36
AllowedVariables::e
e
Definition: AsgElectronSelectorTool.cxx:37
StraightLineSurface.h
Trk::PrepRawDataComparisonFunction::operator=
PrepRawDataComparisonFunction & operator=(PrepRawDataComparisonFunction &&PCF)=default
Trk::PrepRawDataComparisonFunction::operator=
PrepRawDataComparisonFunction & operator=(const PrepRawDataComparisonFunction &PCF)=default
Trk::one
@ one
Definition: TrkDetDescr/TrkSurfaces/TrkSurfaces/RealQuadraticEquation.h:22
Trk::SurfaceType
SurfaceType
Definition: SurfaceTypes.h:17
Trk::DiscSurface
Definition: DiscSurface.h:54
Trk::Surface::center
const Amg::Vector3D & center() const
Returns the center position of the Surface.
PrepRawData.h
GeoPrimitives.h
Trk::two
@ two
Definition: TrkDetDescr/TrkSurfaces/TrkSurfaces/RealQuadraticEquation.h:23
Trk::PrepRawDataComparisonFunction::pathIntersectWithDisc
double pathIntersectWithDisc(const Trk::DiscSurface &dsf) const
Definition: PrepRawDataComparisonFunction.h:142
Trk::Surface::normal
virtual const Amg::Vector3D & normal() const
Returns the normal vector of the Surface (i.e.
Trk::PrepRawDataComparisonFunction::PrepRawDataComparisonFunction
PrepRawDataComparisonFunction(const PrepRawDataComparisonFunction &PCF)=default
compute_lumi.denom
denom
Definition: compute_lumi.py:76
beamspotman.dir
string dir
Definition: beamspotman.py:623
Trk::PrepRawData
Definition: PrepRawData.h:62
Trk
Ensure that the ATLAS eigen extensions are properly loaded.
Definition: FakeTrackBuilder.h:9
Trk::PrepRawDataComparisonFunction::PrepRawDataComparisonFunction
PrepRawDataComparisonFunction()=delete
Trk::PrepRawDataComparisonFunction::m_point
Amg::Vector3D m_point
Definition: PrepRawDataComparisonFunction.h:119
Trk::PrepRawDataComparisonFunction::pathIntersectWithLine
double pathIntersectWithLine(const Trk::StraightLineSurface &lsf) const
Definition: PrepRawDataComparisonFunction.h:129
Amg::Vector3D
Eigen::Matrix< double, 3, 1 > Vector3D
Definition: GeoPrimitives.h:47
Trk::PrepRawDataComparisonFunction::PrepRawDataComparisonFunction
PrepRawDataComparisonFunction(PrepRawDataComparisonFunction &&PCF)=default
Trk::PrepRawDataComparisonFunction::~PrepRawDataComparisonFunction
~PrepRawDataComparisonFunction()=default
Trk::PrepRawDataComparisonFunction::m_direction
Amg::Vector3D m_direction
Definition: PrepRawDataComparisonFunction.h:120
Trk::PlaneSurface
Definition: PlaneSurface.h:64
PlaneSurface.h
unit
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
Definition: AmgMatrixBasePlugin.h:21
Trk::SurfaceType::Disc
@ Disc
DiscSurface.h
Trk::SurfaceType::Plane
@ Plane
Trk::PrepRawDataComparisonFunction
Class providing comparison function, or relational definition, for PrepRawData.
Definition: PrepRawDataComparisonFunction.h:33
Trk::PrepRawDataComparisonFunction::operator()
bool operator()(const Trk::PrepRawData *one, const Trk::PrepRawData *two) const
The comparison function defining in what case a PRD is 'smaller' than a second one.
Definition: PrepRawDataComparisonFunction.h:57
Trk::SurfaceType::Line
@ Line
Trk::Surface
Definition: Tracking/TrkDetDescr/TrkSurfaces/TrkSurfaces/Surface.h:75
Trk::PrepRawDataComparisonFunction::pathIntersectWithPlane
double pathIntersectWithPlane(const Trk::PlaneSurface &psf) const
Definition: PrepRawDataComparisonFunction.h:122
Trk::Surface::transform
const Amg::Transform3D & transform() const
Returns HepGeom::Transform3D by reference.
Trk::Surface::type
constexpr virtual SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
Trk::StraightLineSurface
Definition: StraightLineSurface.h:51