File indexing completed on 2026-07-26 08:22:01
0001
0002
0003
0004
0005
0006
0007
0008 #pragma once
0009
0010
0011 #include "traccc/definitions/math.hpp"
0012 #include "traccc/edm/spacepoint_collection.hpp"
0013 #include "traccc/seeding/detail/doublet.hpp"
0014 #include "traccc/seeding/detail/lin_circle.hpp"
0015 #include "traccc/seeding/detail/seeding_config.hpp"
0016 #include "traccc/seeding/detail/spacepoint_type.hpp"
0017
0018 namespace traccc {
0019
0020
0021 struct doublet_finding_helper {
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032 template <details::spacepoint_type otherSpType, typename T1, typename T2>
0033 static inline TRACCC_HOST_DEVICE bool isCompatible(
0034 const edm::spacepoint<T1>& sp1, const edm::spacepoint<T2>& sp2,
0035 const seedfinder_config& config);
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046 template <details::spacepoint_type otherSpType, typename T1, typename T2>
0047 static inline TRACCC_HOST_DEVICE lin_circle transform_coordinates(
0048 const edm::spacepoint<T1>& sp1, const edm::spacepoint<T2>& sp2);
0049 };
0050
0051 template <details::spacepoint_type otherSpType, typename T1, typename T2>
0052 bool TRACCC_HOST_DEVICE doublet_finding_helper::isCompatible(
0053 const edm::spacepoint<T1>& sp1, const edm::spacepoint<T2>& sp2,
0054 const seedfinder_config& config) {
0055 static_assert(otherSpType == details::spacepoint_type::bottom ||
0056 otherSpType == details::spacepoint_type::top);
0057
0058 scalar deltaR, cotTheta, zOrigin;
0059 if constexpr (otherSpType == details::spacepoint_type::bottom) {
0060
0061 deltaR = sp1.radius() - sp2.radius();
0062
0063 cotTheta = sp1.z() - sp2.z();
0064
0065 zOrigin = sp1.z() * deltaR - sp1.radius() * cotTheta;
0066 } else {
0067
0068 deltaR = sp2.radius() - sp1.radius();
0069
0070 cotTheta = (sp2.z() - sp1.z());
0071
0072 zOrigin = sp1.z() * deltaR - sp1.radius() * cotTheta;
0073 }
0074
0075 if ((deltaR >= config.deltaRMax) || (deltaR <= config.deltaRMin) ||
0076 (math::fabs(cotTheta) >= config.cotThetaMax * deltaR) ||
0077 (zOrigin <= config.collisionRegionMin * deltaR) ||
0078 (zOrigin >= config.collisionRegionMax * deltaR) ||
0079 math::fabs(cotTheta) >= config.deltaZMax) {
0080 return false;
0081 }
0082
0083
0084
0085
0086
0087
0088
0089
0090
0091
0092
0093
0094
0095
0096
0097
0098
0099
0100
0101
0102
0103
0104
0105
0106
0107
0108
0109
0110
0111
0112
0113
0114
0115
0116
0117
0118
0119 scalar midX = 0.5f * (sp1.x() + sp2.x());
0120 scalar midY = 0.5f * (sp1.y() + sp2.y());
0121
0122
0123
0124
0125
0126
0127
0128
0129 scalar slope = (sp2.y() - sp1.y()) / (sp2.x() - sp1.x());
0130
0131
0132
0133
0134
0135
0136
0137
0138
0139
0140
0141
0142
0143
0144 scalar deltaX = sp2.x() - sp1.x();
0145 scalar deltaY = sp2.y() - sp1.y();
0146 scalar deltaXY2 = deltaX * deltaX + deltaY * deltaY;
0147 scalar sagittaLength = math::sqrt(
0148 config.minHelixRadius * config.minHelixRadius - deltaXY2 / 4.f);
0149
0150
0151
0152
0153
0154
0155
0156
0157
0158
0159
0160
0161
0162
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173
0174
0175
0176
0177 scalar denom = math::sqrt((slope * slope + 1) / (slope * slope));
0178 scalar cosCentralAngle = 1.f / denom;
0179 scalar sinCentralAngle = -1.f / (slope * denom);
0180
0181 scalar mpDeltaX = sagittaLength * cosCentralAngle;
0182 scalar mpDeltaY = sagittaLength * sinCentralAngle;
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192 scalar mp1X = midX + mpDeltaX;
0193 scalar mp2X = midX - mpDeltaX;
0194 scalar mp1Y = midY + mpDeltaY;
0195 scalar mp2Y = midY - mpDeltaY;
0196
0197
0198
0199
0200
0201
0202
0203
0204
0205 scalar mp1R2 = mp1X * mp1X + mp1Y * mp1Y;
0206 scalar mp2R2 = mp2X * mp2X + mp2Y * mp2Y;
0207
0208 if (math::min(mp1R2, mp2R2) <= ((config.minHelixRadius - config.impactMax) *
0209 (config.minHelixRadius - config.impactMax))) {
0210 return false;
0211 }
0212
0213 return true;
0214 }
0215
0216 template <details::spacepoint_type otherSpType, typename T1, typename T2>
0217 lin_circle TRACCC_HOST_DEVICE doublet_finding_helper::transform_coordinates(
0218 const edm::spacepoint<T1>& sp1, const edm::spacepoint<T2>& sp2) {
0219 static_assert(otherSpType == details::spacepoint_type::bottom ||
0220 otherSpType == details::spacepoint_type::top);
0221
0222 const scalar& xM = sp1.x();
0223 const scalar& yM = sp1.y();
0224 const scalar& zM = sp1.z();
0225 const scalar& rM = sp1.radius();
0226 const scalar& varianceZM = sp1.z_variance();
0227 const scalar& varianceRM = sp1.radius_variance();
0228 scalar cosPhiM = xM / rM;
0229 scalar sinPhiM = yM / rM;
0230
0231 scalar deltaX = sp2.x() - xM;
0232 scalar deltaY = sp2.y() - yM;
0233 scalar deltaZ = sp2.z() - zM;
0234
0235
0236
0237
0238 scalar x = deltaX * cosPhiM + deltaY * sinPhiM;
0239 scalar y = deltaY * cosPhiM - deltaX * sinPhiM;
0240
0241 scalar iDeltaR2 =
0242 static_cast<scalar>(1.) / (deltaX * deltaX + deltaY * deltaY);
0243 scalar iDeltaR = std::sqrt(iDeltaR2);
0244
0245 scalar cot_theta = deltaZ * iDeltaR;
0246 if constexpr (otherSpType == details::spacepoint_type::bottom) {
0247 cot_theta = -cot_theta;
0248 }
0249
0250 lin_circle l;
0251 l.m_cotTheta = cot_theta;
0252
0253 l.m_Zo = zM - rM * cot_theta;
0254 l.m_iDeltaR = iDeltaR;
0255
0256
0257
0258
0259
0260
0261 l.m_U = x * iDeltaR2;
0262 l.m_V = y * iDeltaR2;
0263
0264 l.m_Er = ((varianceZM + sp2.z_variance()) +
0265 (cot_theta * cot_theta) * (varianceRM + sp2.radius_variance())) *
0266 iDeltaR2;
0267
0268 return l;
0269 }
0270
0271 }