ATLAS Offline Software
Loading...
Searching...
No Matches
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
27namespace Trk {
33{
34public:
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;
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
118private:
121
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
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
const PlainObject unit() const
This is a plugin that makes Eigen look like CLHEP & defines some convenience methods.
static Double_t sp
Class for a DiscSurface in the ATLAS detector.
Definition DiscSurface.h:54
Class for a planaer rectangular or trapezoidal surface in the ATLAS detector.
double pathIntersectWithPlane(const Trk::PlaneSurface &psf) const
PrepRawDataComparisonFunction & operator=(PrepRawDataComparisonFunction &&PCF)=default
PrepRawDataComparisonFunction(const Amg::Vector3D &sp, const Amg::Vector3D &dir)
Full relation definition using a straight line propagation.
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.
double pathIntersectWithLine(const Trk::StraightLineSurface &lsf) const
PrepRawDataComparisonFunction(const PrepRawDataComparisonFunction &PCF)=default
double pathIntersectWithDisc(const Trk::DiscSurface &dsf) const
PrepRawDataComparisonFunction(PrepRawDataComparisonFunction &&PCF)=default
PrepRawDataComparisonFunction & operator=(const PrepRawDataComparisonFunction &PCF)=default
Class for a StraightLineSurface in the ATLAS detector to describe dirft tube and straw like detectors...
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.
virtual constexpr SurfaceType type() const =0
Returns the Surface type to avoid dynamic casts.
const Amg::Vector3D & center() const
Returns the center position of the Surface.
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the ATLAS eigen extensions are properly loaded.
SurfaceType
This enumerator simplifies the persistency & calculations,.