ATLAS Offline Software
Loading...
Searching...
No Matches
ITkSiSpacePointsProSeed.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6
9
10#include <cmath>
11
12namespace ITk
13{
14
16 {
17 m_s0 = nullptr ;
18 m_s1 = nullptr ;
19 m_s2 = nullptr ;
20 m_z = 0.;
21 m_q = 0.;
22 }
23
24 SiSpacePointsProSeed& SiSpacePointsProSeed::operator =
25 (const SiSpacePointsProSeed& sp)
26 {
27 if(&sp!=this) {
28
29 m_z = sp.m_z ;
30 m_q = sp.m_q ;
31 m_s0 = sp.m_s0;
32 m_s1 = sp.m_s1;
33 m_s2 = sp.m_s2;
34 }
35 return(*this);
36 }
37
43
45 // Copy constructor
47
52
53
55 // Set
57
60 {
61 m_z = z ;
62 m_s0 = s0;
63 m_s1 = s1;
64 m_s2 = s2;
65 }
66
68 // Set two space points seed
70
72 {
73 s.erase();
74 s.add(m_s0->spacepoint);
75 s.add(m_s1->spacepoint);
76 s.setZVertex(double(m_z));
77 }
78
80 // Set three space points seed
82
84 {
85 bool pixt = !m_s2->spacepoint->clusterList().second;
86
87 if(pixt) {
88 if(m_q > m_s0->quality() && m_q > m_s1->quality() && m_q > m_s2->quality()) return false;
89 }
90
91 m_s0->setQuality(m_q);
92 m_s1->setQuality(m_q);
93 m_s2->setQuality(m_q);
94
95 s.erase();
96 s.add(m_s0->spacepoint);
97 s.add(m_s1->spacepoint);
98 s.add(m_s2->spacepoint);
99 s.setZVertex(double(m_z));
100 s.setX1(m_s0->x());
101 s.setX2(m_s1->x());
102 s.setX3(m_s2->x());
103 s.setY1(m_s0->y());
104 s.setY2(m_s1->y());
105 s.setY3(m_s2->y());
106 s.setZ1(m_s0->z());
107 s.setZ2(m_s1->z());
108 s.setZ3(m_s2->z());
109 s.setR1(m_s0->radius());
110 s.setR2(m_s1->radius());
111 s.setR3(m_s2->radius());
112
113 estimateParameters(pTPerHelixRadius);
114 s.setD0(m_s2->param());
115 s.setEta(m_s2->eta());
116 s.setDZDR_B(m_s0->dzdr());
117 s.setDZDR_T(m_s2->dzdr());
118 s.setPt(m_s2->pt());
119
120 return true;
121 }
122
123 void SiSpacePointsProSeed::estimateParameters(float pTPerHelixRadius)
124 {
125
129
130 bool isPixel = !m_s2->spacepoint->clusterList().second;
131
132 auto extractCoordinates =
133 [] (const ITk::SiSpacePointForSeed& sp) -> std::array<float,4>
134 {
135 std::array<float, 4> coordinates {sp.x(), sp.y(), sp.z(), sp.radius()};
136 return coordinates;
137 };
138
139 auto extractQuantities =
140 [] (const std::array<float, 4>& sp,
141 const std::array<float, 4>& spM,
142 bool isBottom) -> std::array<float, 5>
143 {
144 const auto& [xM, yM, zM, rM] = spM;
145 const auto& [xO, yO, zO, rO] = sp;
146
147 float cosPhiM = xM / rM;
148 float sinPhiM = yM / rM;
149 float deltaX = xO - xM;
150 float deltaY = yO - yM;
151 float deltaZ = zO - zM;
152 float x = deltaX * cosPhiM + deltaY * sinPhiM;
153 float y = deltaY * cosPhiM - deltaX * sinPhiM;
154 float iDeltaR2 = 1. / (deltaX * deltaX + deltaY * deltaY);
155 float iDeltaR = std::sqrt(iDeltaR2);
156 int bottomFactor = 1 * (int(not isBottom)) - 1 * (int(isBottom));
157 float cot_theta = deltaZ * iDeltaR * bottomFactor;
158
159 // cotTheta, Zo, iDeltaR, U, V
160 std::array<float, 5> params =
161 {
162 cot_theta,
163 zM - rM * cot_theta,
164 iDeltaR,
165 x * iDeltaR2,
166 y * iDeltaR2
167 };
168
169 return params;
170 };
171
172 auto coo_b = extractCoordinates(bottom);
173 auto coo_m = extractCoordinates(medium);
174 auto coo_t = extractCoordinates(top);
175
176 // Compute the variables we need
177 auto [cotThetaB, Zob, iDeltaRB, Ub, Vb] = extractQuantities(coo_b, coo_m, true);
178 auto [cotThetaT, Zot, iDeltaRT, Ut, Vt] = extractQuantities(coo_t, coo_m, false);
179
180 float squarediDeltaR2B = iDeltaRB*iDeltaRB;
181 float squarediDeltaR2T = iDeltaRB*iDeltaRT;
182 float squarediDeltaR = std::min(squarediDeltaR2B, squarediDeltaR2T);
183
184 auto& [xB, yB, zB, rB] = coo_b;
185 auto& [xM, yM, zM, rM] = coo_m;
186 auto& [xT, yT, zT, rT] = coo_t;
187
188 float ax = xM / rM;
189 float ay = yM/ rM;
190
191 float dxb = xM - xB;
192 float dyb = yM - yB;
193 float dzb = zM - zB;
194 float xb = dxb * ax + dyb *ay;
195 float yb = dyb * ax - dxb * ay;
196 float dxyb = xb * xb + yb * yb;
197 float drb = std::sqrt( xb*xb + yb*yb + dzb*dzb );
198
199 float dxt = xT - xM;
200 float dyt = yT - yM;
201 float dzt = zT - zM;
202 float xt = dxt * ax + dyt *ay;
203 float yt = dyt * ax - dxt * ay;
204 float dxyt = xt * xt + yt * yt;
205 float drt = std::sqrt( xt*xt + yt*yt + dzt*dzt );
206
207 float tzb = dzb * std::sqrt( 1.f/dxyb );
208 float tzt = dzt * std::sqrt( 1.f/dxyt );
209
210 float sTzb2 = std::sqrt(1.f + tzb*tzb);
211
212 float dU = Ut - Ub;
213 if (dU == 0.) {
214 return;
215 }
216
217 float A = (Vt - Vb) / dU;
218 float S2 = 1.f + A * A;
219 float B = Vb - A * Ub;
220 if (B==0)
221 return;
222 float B2 = B * B;
223
224 // dzdr
225 float dzdr_b = (zM - zB) / (rM - rB);
226 float dzdr_t = (zT - zM) / (rT - rM);
227
228 // eta
229 float meanOneOverTanThetaSquare = isPixel ? (cotThetaB * cotThetaT) :
230 std::pow((cotThetaB + cotThetaT) / 2.f,2);
231 if (meanOneOverTanThetaSquare <= 0) {
232 return;
233 }
234 float theta = std::atan(1.f / std::sqrt(meanOneOverTanThetaSquare)); // [0, pi/2)
235 if (top.z()<0) {theta = -theta;} // (-pi/2, pi/2)
236 if (theta < 0.) {theta = theta + M_PI;} // [0, pi)
237 float eta = -std::log(std::tan(0.5f * theta));
238
239 // pt
240 float pt = pTPerHelixRadius*std::sqrt(S2 / B2);
241
242 // d0
243 float d0 = std::abs((A - B * rM) * rM);
244
245 // Attach variables to SPs
246 top.setDR(drt);
247 top.setDZDR(dzdr_t);
248 top.setScorePenalty( std::abs((tzb - tzt) / (squarediDeltaR * sTzb2)) );
249 top.setParam(d0);
250 top.setEta(eta);
251 top.setPt(pt);
252
253 bottom.setDR(drb);
254 bottom.setDZDR(dzdr_b);
255
256 }
257
259 // Set quality in pro seed
261
263 {
264 m_q = q;
265
266 if(!m_s2->spacepoint->clusterList().second) {
267 if(q > m_s0->quality() && q > m_s1->quality() && q > m_s2->quality()) return false;
268 }
269 m_s0->setQuality(m_q);
270 m_s1->setQuality(m_q);
271 m_s2->setQuality(m_q);
272 return true;
273 }
274
275} // end of name space ITk
#define M_PI
Scalar eta() const
pseudorapidity method
Scalar theta() const
theta method
bool isBottom(const T &p)
Definition AtlasPID.h:182
static Double_t sp
static Double_t s0
struct TBPatternUnitContext S2
@ top
#define y
#define xt
#define yt
#define x
void set2(InDet::SiSpacePointsSeed &)
void set(SiSpacePointForSeed *&, SiSpacePointForSeed *&, SiSpacePointForSeed *&, float)
bool set3(InDet::SiSpacePointsSeed &, float pTPerHelixRadius)
void estimateParameters(float pTPerHelixRadius)
hold the test vectors and ease the comparison