Pandora
Pandora source code navigator
Loading...
Searching...
No Matches
DetectorGap.cc
Go to the documentation of this file.
1
10
11namespace pandora
12{
13
17
18//------------------------------------------------------------------------------------------------------------------------------------------
19//------------------------------------------------------------------------------------------------------------------------------------------
20
22 m_lineGapType(parameters.m_lineGapType.Get()),
23 m_lineStartX(parameters.m_lineStartX.Get()),
24 m_lineEndX(parameters.m_lineEndX.Get()),
25 m_lineStartZ(parameters.m_lineStartZ.Get()),
26 m_lineEndZ(parameters.m_lineEndZ.Get())
27{
29 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
30}
31
32//------------------------------------------------------------------------------------------------------------------------------------------
33
34bool LineGap::IsInGap(const CartesianVector &positionVector, const HitType hitType, const float gapTolerance) const
35{
36 if (!((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType) || (TPC_3D == hitType)))
37 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
38
39 if (((TPC_VIEW_U == hitType) && (TPC_WIRE_GAP_VIEW_U == m_lineGapType)) ||
40 ((TPC_VIEW_V == hitType) && (TPC_WIRE_GAP_VIEW_V == m_lineGapType)) ||
41 ((TPC_VIEW_W == hitType) && (TPC_WIRE_GAP_VIEW_W == m_lineGapType)))
42 {
43 if ((positionVector.GetZ() > m_lineStartZ - gapTolerance) && (positionVector.GetZ() < m_lineEndZ + gapTolerance))
44 return true;
45 }
46 else if (TPC_DRIFT_GAP == m_lineGapType)
47 {
48 if ((positionVector.GetX() > m_lineStartX - gapTolerance) && (positionVector.GetX() < m_lineEndX + gapTolerance))
49 return true;
50 }
51
52 return false;
53}
54
55//------------------------------------------------------------------------------------------------------------------------------------------
56//------------------------------------------------------------------------------------------------------------------------------------------
57
59 m_vertex(parameters.m_vertex.Get()),
60 m_side1(parameters.m_side1.Get()),
61 m_side2(parameters.m_side2.Get()),
62 m_side3(parameters.m_side3.Get())
63{
64}
65
66//------------------------------------------------------------------------------------------------------------------------------------------
67
68bool BoxGap::IsInGap(const CartesianVector &positionVector, const HitType hitType, const float gapTolerance) const
69{
70 if ((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType))
71 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
72
73 const CartesianVector relativePosition(positionVector - m_vertex);
74
75 const float projection1(relativePosition.GetDotProduct(m_side1.GetUnitVector()));
76
77 if ((projection1 < -gapTolerance) || (projection1 > m_side1.GetMagnitude() + gapTolerance))
78 return false;
79
80 const float projection2(relativePosition.GetDotProduct(m_side2.GetUnitVector()));
81
82 if ((projection2 < -gapTolerance) || (projection2 > m_side2.GetMagnitude() + gapTolerance))
83 return false;
84
85 const float projection3(relativePosition.GetDotProduct(m_side3.GetUnitVector()));
86
87 if ((projection3 < -gapTolerance) || (projection3 > m_side3.GetMagnitude() + gapTolerance))
88 return false;
89
90 return true;
91}
92
93//------------------------------------------------------------------------------------------------------------------------------------------
94//------------------------------------------------------------------------------------------------------------------------------------------
95
97 m_minZCoordinate(parameters.m_minZCoordinate.Get()),
98 m_maxZCoordinate(parameters.m_maxZCoordinate.Get()),
99 m_innerRCoordinate(parameters.m_innerRCoordinate.Get()),
100 m_innerPhiCoordinate(parameters.m_innerPhiCoordinate.Get()),
101 m_innerSymmetryOrder(parameters.m_innerSymmetryOrder.Get()),
102 m_outerRCoordinate(parameters.m_outerRCoordinate.Get()),
103 m_outerPhiCoordinate(parameters.m_outerPhiCoordinate.Get()),
104 m_outerSymmetryOrder(parameters.m_outerSymmetryOrder.Get())
105{
106 if ((0 == m_innerSymmetryOrder) || (0 == m_outerSymmetryOrder))
107 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
108
109 const float centralZCoordinate(0.5f * (m_maxZCoordinate + m_minZCoordinate));
112}
113
114//------------------------------------------------------------------------------------------------------------------------------------------
115
116bool ConcentricGap::IsInGap(const CartesianVector &positionVector, const HitType hitType, const float gapTolerance) const
117{
118 if ((TPC_VIEW_U == hitType) || (TPC_VIEW_V == hitType) || (TPC_VIEW_W == hitType))
119 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
120
121 const float z(positionVector.GetZ());
122
123 if ((z < m_minZCoordinate - gapTolerance) || (z > m_maxZCoordinate + gapTolerance))
124 return false;
125
126 // ATTN: For concentric gaps, the gap tolerance is currently only used for the z position check
127 const float x(positionVector.GetX()), y(positionVector.GetY());
128 const float r(std::sqrt(x * x + y * y));
129
130 if (r < m_innerRCoordinate)
131 return false;
132
133 static const float pi(std::acos(-1.f));
134
135 if (r > m_outerRCoordinate / std::cos(pi / static_cast<float>(m_outerSymmetryOrder)))
136 return false;
137
138 if (!this->IsIn2DPolygon(positionVector, m_outerVertexPointList, m_outerSymmetryOrder))
139 return false;
140
142 return false;
143
144 return true;
145}
146
147//------------------------------------------------------------------------------------------------------------------------------------------
148
149void ConcentricGap::GetPolygonVertices(const float rCoordinate, const float zCoordinate, const float phiCoordinate,
150 const unsigned int symmetryOrder, VertexPointList &vertexPointList) const
151{
152 if (0 == symmetryOrder)
153 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
154
155 static const float pi(std::acos(-1.f));
156 const float firstVertexAngle(pi / static_cast<float>(symmetryOrder));
157 const float rMax(rCoordinate / std::cos(firstVertexAngle));
158
159 for (unsigned int i = 0; i < symmetryOrder + 1; ++i)
160 {
161 const float phi = phiCoordinate + firstVertexAngle + (2.f * pi * static_cast<float>(i) / static_cast<float>(symmetryOrder));
162 const float sinPhi(std::sin(phi));
163 const float cosPhi(std::cos(phi));
164 vertexPointList.push_back(CartesianVector(sinPhi * rMax, cosPhi * rMax, zCoordinate));
165 }
166}
167
168//------------------------------------------------------------------------------------------------------------------------------------------
169
170bool ConcentricGap::IsIn2DPolygon(const CartesianVector &point, const VertexPointList &vertexPointList, const unsigned int symmetryOrder) const
171{
172 if (vertexPointList.size() != (symmetryOrder + 1))
173 throw StatusCodeException(STATUS_CODE_INVALID_PARAMETER);
174
175 int windingNumber(0);
176
177 for (unsigned int i = 0; i < symmetryOrder; ++i)
178 {
179 if (vertexPointList[i].GetY() <= point.GetY())
180 {
181 if (vertexPointList[i + 1].GetY() > point.GetY())
182 {
183 // If point is left of edge, identify an upward crossing
184 if (((vertexPointList[i + 1].GetX() - vertexPointList[i].GetX()) * (point.GetY() - vertexPointList[i].GetY()) -
185 (point.GetX() - vertexPointList[i].GetX()) * (vertexPointList[i + 1].GetY() - vertexPointList[i].GetY()) ) > 0.f)
186 {
187 ++windingNumber;
188 }
189 }
190 }
191 else
192 {
193 if (vertexPointList[i + 1].GetY() <= point.GetY())
194 {
195 // If point is right of edge, identify a downward crossing
196 if (((vertexPointList[i + 1].GetX() - vertexPointList[i].GetX()) * (point.GetY() - vertexPointList[i].GetY()) -
197 (point.GetX() - vertexPointList[i].GetX()) * (vertexPointList[i + 1].GetY() - vertexPointList[i].GetY()) ) < 0.f)
198 {
199 --windingNumber;
200 }
201 }
202 }
203 }
204
205 return (0 != windingNumber);
206}
207
208} // namespace pandora
Header file for the detector gap class.
const CartesianVector m_vertex
Cartesian coordinates of a gap vertex, units mm.
BoxGap(const object_creation::Geometry::BoxGap::Parameters &parameters)
Constructor.
const CartesianVector m_side2
Cartesian vector describing second side meeting vertex, units mm.
const CartesianVector m_side3
Cartesian vector describing third side meeting vertex, units mm.
bool IsInGap(const CartesianVector &positionVector, const HitType hitType, const float gapTolerance) const
Whether a specified position lies within the gap.
const CartesianVector m_side1
Cartesian vector describing first side meeting vertex, units mm.
CartesianVector class.
float GetX() const
Get the cartesian x coordinate.
CartesianVector GetUnitVector() const
Get a unit vector in the direction of the cartesian vector.
float GetZ() const
Get the cartesian z coordinate.
float GetDotProduct(const CartesianVector &rhs) const
Get the dot product of the cartesian vector with a second cartesian vector.
float GetMagnitude() const
Get the magnitude.
float GetY() const
Get the cartesian y coordinate.
const float m_outerPhiCoordinate
Outer cylindrical polar phi coordinate (angle wrt cartesian x axis)
VertexPointList m_outerVertexPointList
The vertex points of the outer polygon.
const float m_innerRCoordinate
Inner cylindrical polar r coordinate, origin interaction point, units mm.
VertexPointList m_innerVertexPointList
The vertex points of the inner polygon.
ConcentricGap(const object_creation::Geometry::ConcentricGap::Parameters &parameters)
Constructor.
const float m_maxZCoordinate
Max cylindrical polar z coordinate, origin interaction point, units mm.
const unsigned int m_outerSymmetryOrder
Order of symmetry of the outermost edge of gap.
const float m_outerRCoordinate
Outer cylindrical polar r coordinate, origin interaction point, units mm.
bool IsIn2DPolygon(const CartesianVector &point, const VertexPointList &vertexPointList, const unsigned int symmetryOrder) const
Winding number test for a point in a 2D polygon in the XY plane (z coordinates are ignored)
bool IsInGap(const CartesianVector &positionVector, const HitType hitType, const float gapTolerance) const
Whether a specified position lies within the gap.
void GetPolygonVertices(const float rCoordinate, const float zCoordinate, const float phiCoordinate, const unsigned int symmetryOrder, VertexPointList &vertexPointList) const
Populate list of polygon vertices, assuming regular polygon in XY plane at constant z coordinate.
const float m_innerPhiCoordinate
Inner cylindrical polar phi coordinate (angle wrt cartesian x axis)
const float m_minZCoordinate
Min cylindrical polar z coordinate, origin interaction point, units mm.
const unsigned int m_innerSymmetryOrder
Order of symmetry of the innermost edge of gap.
virtual ~DetectorGap()
Destructor.
bool IsInGap(const CartesianVector &positionVector, const HitType hitType, const float gapTolerance) const
Whether a specified position lies within the gap.
const float m_lineStartZ
The line z start coordinate, units mm.
const float m_lineStartX
The line x start coordinate, units mm.
Definition DetectorGap.h:98
LineGap(const object_creation::Geometry::LineGap::Parameters &parameters)
Constructor.
const LineGapType m_lineGapType
The type of line gap, e.g. TPC wire-type gap (u, v, w), or drift-type gap.
Definition DetectorGap.h:97
const float m_lineEndX
The line x end coordinate, units mm.
Definition DetectorGap.h:99
const float m_lineEndZ
The line z end coordinate, units mm.
StatusCodeException class.
HitType
Calorimeter hit type enum.
std::vector< CartesianVector > VertexPointList
Definition DetectorGap.h:16