ATLAS Offline Software
Loading...
Searching...
No Matches
TRT_TrajectoryElement_xk.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
9
11// Set TRT helper and road width
13
15(const TRT_ID * m,
18 const Trk::IRIO_OnTrackCreator * riod,
19 const Trk::IRIO_OnTrackCreator * rion,
20 double scale)
21{
22 m_trtid = m ;
23 m_riomakerD = riod ;
24 m_riomakerN = rion ;
25 m_proptool = pr ;
26 m_updatortool = up ;
27 m_scale_error = scale ;
28}
29
36
38// Set trajectory element for precision seed
40
42(bool st,const InDetDD::TRT_BaseElement* de,
43 InDet::TRT_DriftCircleCollection::const_iterator& sb,
44 InDet::TRT_DriftCircleCollection::const_iterator& se,
45 std::pair<Amg::Vector3D,double>& gp,
46 const double* dir,double width2)
47{
48 m_isCluster = st;
49 m_detelement = de;
50
51 // Test boundary active region of detector elements
52 //
53 if(!boundaryTest(3.,gp)) return false;
54
55 // Trajectory element links production
56 //
57 initiateLinksForPrecisionSeed(sb,se,gp,dir,width2);
58 return true;
59}
60
62// Set trajectory element for TRT seed
64
66(bool st,const InDetDD::TRT_BaseElement* de,
67 InDet::TRT_DriftCircleCollection::const_iterator& sb,
68 InDet::TRT_DriftCircleCollection::const_iterator& se,
69 std::pair<Amg::Vector3D,double>& gp,
70 const double* dir,double width2)
71{
72
73 m_isCluster = st ;
74 m_detelement = de ;
75
76 // Test boundary active region of detector elements
77 //
78 bool boundary = boundaryTest(7.,gp);
79
80 // Trajectory element links production
81 //
82 initiateLinksForTRTSeed(sb,se,gp,dir,width2);
83 return boundary;
84}
85
87// Initiate trajectory element links to straws
89
91(double dw, std::pair<Amg::Vector3D,double>& gp)
92{
93 if (!m_detelement){
94 return false;
95 }
96
97 double x = gp.first.x();
98 double y = gp.first.y();
99 double z = gp.first.z();
100
101 const Amg::Vector3D& C = m_detelement->center();
102
103 // Test track position
104 //
105 const Trk::SurfaceBounds& surfBounds = m_detelement->bounds();
106 if (surfBounds.type() == Trk::SurfaceBounds::Rectangle) {
107 const Trk::RectangleBounds* rb =
108 static_cast<const Trk::RectangleBounds*>(&surfBounds);
109 // Barrel
110 //
111 m_barrel = true;
112 m_z = z;
113 m_zMin = C.z() - rb->halflengthY();
114 m_zMax = C.z() + rb->halflengthY();
115 double d = std::abs(z - C.z());
116 if (d > rb->halflengthY() + dw) {
117 return false;
118 }
119 } else if (surfBounds.type() == Trk::SurfaceBounds::Disc) {
120 const Trk::DiscBounds* db =
121 static_cast<const Trk::DiscBounds*>(&surfBounds);
122 // Endcap
123 //
124 m_barrel = false;
125 m_radius = std::sqrt(x * x + y * y);
126 m_z = z;
127 m_radiusMin = db->rMin();
128 m_radiusMax = db->rMax();
129
130 double d = m_radius - m_radiusMin;
131 if (d < -dw) {
132 return false;
133 }
134 d = m_radiusMax - m_radius;
135 if (d < -dw) {
136 return false;
137 }
138 }
139 return true;
140}
141
143// Initiate trajectory element links to straws for precision seed
145
146void
148 InDet::TRT_DriftCircleCollection::const_iterator& sb,
149 InDet::TRT_DriftCircleCollection::const_iterator& se,
150 std::pair<Amg::Vector3D, double>& gp,
151 const double* dir,
152 double width2)
153{
154 m_status = -1;
155 m_bestlink = -1;
156 m_nlinks = 0;
157 double x = gp.first.x();
158 double y = gp.first.y();
159 double z = gp.first.z();
160
161 const Amg::Transform3D& T = m_detelement->surface().transform();
162
163 double step = std::abs(dir[0] * T(0, 2) + dir[1] * T(1, 2) + dir[2] * T(2, 2));
164 step > .05 ? step = 1. / step : step = 20.;
165
166 int Nstraws = m_detelement->nStraws();
167
169
170 for (int ns = 0; ns != Nstraws; ++ns) {
171
172 const Amg::Transform3D& t = m_detelement->strawTransform(ns);
173
174 double xs = t(0, 3);
175 double ys = t(1, 3);
176 double dx = x - xs;
177 double dy = y - ys;
178 double d = dx * dx + dy * dy;
179 if (d > width2) {
180 continue;
181 }
182
183 double Az[3] = { t(0, 2), t(1, 2), t(2, 2) };
184 double D = dir[0] * Az[0] + dir[1] * Az[1] + dir[2] * Az[2];
185 double A = (1. - D) * (1. + D);
186 double dz = z - t(2, 3);
187 double S = (dx * (D * Az[0] - dir[0]) + dy * (D * Az[1] - dir[1]) +
188 dz * (D * Az[2] - dir[2])) /
189 A;
190 dx += (dir[0] * S);
191 dy += (dir[1] * S);
192 dz += (dir[2] * S);
193 double Bx = Az[1] * dir[2] - Az[2] * dir[1];
194 double By = Az[2] * dir[0] - Az[0] * dir[2];
195 double Bz = Az[0] * dir[1] - Az[1] * dir[0];
196 double im =
197 (dx * Bx + dy * By + dz * Bz) / std::sqrt(Bx * Bx + By * By + Bz * Bz);
198 double zl = dx * Az[0] + dy * Az[1] + dz * Az[2];
199 S += gp.second;
200 d = std::abs(im);
201 if (y * xs - x * ys > 0.) {
202 d = -d;
203 }
204 m_link[m_nlinks].set(ns, d, im, zl, S);
205 if (++m_nlinks == 24) {
206 break;
207 }
208 }
209 } else {
210
211 for (int ns = 0; ns != Nstraws; ++ns) {
212
213 const Amg::Transform3D& t = m_detelement->strawTransform(ns);
214
215 double xs = t(0, 3);
216 double ys = t(1, 3);
217 double as = m_radius / std::sqrt(xs * xs + ys * ys);
218 double dx = x - xs * as;
219 double dy = y - ys * as;
220 double d = dx * dx + dy * dy;
221 if (d > width2) {
222 continue;
223 }
224
225 double zs = t(2, 3);
226 double Az[3] = { t(0, 2), t(1, 2), t(2, 2) };
227 double D = dir[0] * Az[0] + dir[1] * Az[1] + dir[2] * Az[2];
228 double A = (1. - D) * (1. + D);
229 dx = x - xs;
230 dy = y - ys;
231 double dz = z - zs;
232 double S = (dx * (D * Az[0] - dir[0]) + dy * (D * Az[1] - dir[1]) +
233 dz * (D * Az[2] - dir[2])) /
234 A;
235 dx += (dir[0] * S);
236 dy += (dir[1] * S);
237 dz += (dir[2] * S);
238 double Bx = Az[1] * dir[2] - Az[2] * dir[1];
239 double By = Az[2] * dir[0] - Az[0] * dir[2];
240 double Bz = Az[0] * dir[1] - Az[1] * dir[0];
241 double im =
242 (dx * Bx + dy * By + dz * Bz) / std::sqrt(Bx * Bx + By * By + Bz * Bz);
243 double zl = dx * Az[0] + dy * Az[1] + dz * Az[2];
244 S += gp.second;
245 d = std::abs(im);
246 if (y * xs - x * ys > 0.) {
247 d = -d;
248 }
249 m_link[m_nlinks].set(ns, d, im, zl, S);
250 if (++m_nlinks == 24) {
251 break;
252 }
253 }
254 }
255 m_dpositive = 1000.;
256 m_dnegative = -1000.;
257 if (m_isCluster && m_nlinks) {
258
259 bool nl = false;
260 for (; sb != se; ++sb) {
261
262 int ns = m_trtid->straw((*sb)->identify());
263
264 for (int l = 0; l != m_nlinks; ++l) {
265 if (ns != m_link[l].number()) {
266 continue;
267 }
268 nl = true;
269 m_link[l].set((*sb));
270
271 double d = m_link[l].distance();
272 if (d >= 0.) {
273 if (d < m_dpositive)
274 m_dpositive = d;
275 } else {
276 if (d > m_dnegative) {
277 m_dnegative = d;
278 }
279 }
280 break;
281 }
282 }
283 if (!nl) {
284 m_isCluster = false;
285 }
286 }
287}
288
290// Initiate trajectory element links to straws for TRT seed
292
294(InDet::TRT_DriftCircleCollection::const_iterator& sb,
295 InDet::TRT_DriftCircleCollection::const_iterator& se,
296 std::pair<Amg::Vector3D,double>& gp,
297 const double* dir,double width2)
298{
299 m_status = -1;
300 m_bestlink = -1;
301 m_nlinks = 0;
302 double x = gp.first.x();
303 double y = gp.first.y();
304 double z = gp.first.z();
305
306 const Amg::Transform3D& T = m_detelement->surface().transform();
307
308 double step =
309 std::abs(dir[0] * T(0, 2) + dir[1] * T(1, 2) + dir[2] * T(2, 2));
310 step > .05 ? step = 1. / step : step = 20.;
311
312 int Nstraws = m_detelement->nStraws();
314
315 for (int ns = 0; ns != Nstraws; ++ns) {
316
317 const Amg::Transform3D& t = m_detelement->strawTransform(ns);
318
319 double xs = t(0, 3);
320 double ys = t(1, 3);
321 double dx = x - xs;
322 double dy = y - ys;
323 double d = dx * dx + dy * dy;
324 if (d > width2){
325 continue;
326 }
327
328 double Az[3] = { t(0, 2), t(1, 2), t(2, 2) };
329 double D = dir[0] * Az[0] + dir[1] * Az[1] + dir[2] * Az[2];
330 double A = (1. - D) * (1. + D);
331 double dz = z - t(2, 3);
332 double S = (dx * (D * Az[0] - dir[0]) + dy * (D * Az[1] - dir[1]) +
333 dz * (D * Az[2] - dir[2])) /
334 A;
335 dx += (dir[0] * S);
336 dy += (dir[1] * S);
337 dz += (dir[2] * S);
338 double Bx = Az[1] * dir[2] - Az[2] * dir[1];
339 double By = Az[2] * dir[0] - Az[0] * dir[2];
340 double Bz = Az[0] * dir[1] - Az[1] * dir[0];
341 double im =
342 (dx * Bx + dy * By + dz * Bz) / std::sqrt(Bx * Bx + By * By + Bz * Bz);
343 double zl = dx * Az[0] + dy * Az[1] + dz * Az[2];
344 S += gp.second;
345 d = std::abs(im);
346 if (y * xs - x * ys > 0.){
347 d = -d;
348 }
349 m_link[m_nlinks].set(ns, d, im, zl, S);
350 if (++m_nlinks == 24){
351 break;
352 }
353 }
354 } else {
355
356 double ri = 1. / m_radius;
357 double ax = x * ri;
358 double ay = y * ri;
359
360 for (int ns = 0; ns != Nstraws; ++ns) {
361
362 const Amg::Transform3D& t = m_detelement->strawTransform(ns);
363
364 double xs = t(0, 3);
365 double ys = t(1, 3);
366 double as = m_radius / std::sqrt(xs * xs + ys * ys);
367 double dx = x - xs * as;
368 double dy = y - ys * as;
369 double d = dx * dx + dy * dy;
370 if (d > width2){
371 continue;
372 }
373
374 double zs = t(2, 3);
375 double Az[3] = { t(0, 2), t(1, 2), t(2, 2) };
376 double D = dir[0] * Az[0] + dir[1] * Az[1] + dir[2] * Az[2];
377 double A = 1. / ((1. - D) * (1. + D));
378 dx = x - xs;
379 dy = y - ys;
380 double dz = z - zs;
381 double Dx = (D * Az[0] - dir[0]);
382 double Dy = (D * Az[1] - dir[1]);
383 double S = (dx * Dx + dy * Dy + dz * (D * Az[2] - dir[2])) * A;
384 dx += (dir[0] * S);
385 dy += (dir[1] * S);
386 dz += (dir[2] * S);
387 double Bx = Az[1] * dir[2] - Az[2] * dir[1];
388 double By = Az[2] * dir[0] - Az[0] * dir[2];
389 double Bz = Az[0] * dir[1] - Az[1] * dir[0];
390 double B = 1. / std::sqrt(Bx * Bx + By * By + Bz * Bz);
391 double im = (dx * Bx + dy * By + dz * Bz) * B;
392 double zl = dx * Az[0] + dy * Az[1] + dz * Az[2];
393
394 // d(im)/dr calculation for endcap
395 //
396 double dS = (ax * Dx + ay * Dy) * A;
397 double sx = ax + dir[0] * dS;
398 double sy = ay + dir[1] * dS;
399 double sd = (sx * Bx + sy * By) * B;
400 double sz = sx * Az[0] + sy * Az[1];
401 S += gp.second;
402 if (y * xs - x * ys > 0.) {
403 d = -std::abs(im);
404 sd = -std::abs(im + sd) - d;
405 } else {
406 d = std::abs(im);
407 sd = std::abs(im + sd) - d;
408 }
409
410 m_link[m_nlinks].set(ns, d, im, zl, S, sd, sz);
411 if (++m_nlinks == 24){
412 break;
413 }
414 }
415 }
416
417 m_dpositive = 1000.;
418 m_dnegative = -1000.;
419 if (m_isCluster && m_nlinks) {
420
421 bool nl = false;
422 for (; sb != se; ++sb) {
423
424 int ns = m_trtid->straw((*sb)->identify());
425
426 for (int l = 0; l != m_nlinks; ++l) {
427 if (ns != m_link[l].number())
428 continue;
429 nl = true;
430 m_link[l].set((*sb));
431
432 double d = m_link[l].distance();
433 if (d >= 0.) {
434 if (d < m_dpositive){
435 m_dpositive = d;
436 }
437 } else {
438 if (d > m_dnegative){
439 m_dnegative = d;
440 }
441 }
442 break;
443 }
444 }
445 if (!nl){
446 m_isCluster = false;
447 }
448 }
449}
450
452// Build trajectory element without propagation for precision seed
454
456(double a,double b,bool& useDriftTime, bool& hole)
457{
458
459 m_bestlink = -1;
460 m_status = -1;
461 hole = false; if(!m_nlinks) return false;
462
463 for(int l=0; l!=m_nlinks; ++l) {
464
465 double v = (a*m_link[l].way()+b)*m_link[l].way();
466 double d = m_link[l].distance()-v;
467 double ad = std::abs(d);
468
469 if(ad > 2.05) continue;
470
471 if(!m_link[l].cluster()) {
472
473 if(ad < 1.85) {
474 m_status = 0; hole=true; m_bestlink=l; m_link[l].newImpactParameter(d);
475 }
476 return false;
477 }
478
479 m_status = 1; m_bestlink=l; m_link[l].newImpactParameter(d);
480 if(!useDriftTime) return true;
481
482 double r = m_link[l].cluster()->localPosition()[Trk::driftRadius];
483 double e = m_scale_error*std::sqrt(m_link[l].cluster()->localCovariance()(0,0));
484
485 if(r > 2.05) r = 2.05;
486 double r2 = r+e; if(r2 > 2.05) r2 = 2.05;
487 double r1 = r-e; if(r1 >= r2) r1 = r2-2.*e;
488
489 if(ad < r1 || ad > r2) useDriftTime = false; else m_status = 2;
490
491 return true;
492 }
493 return false;
494}
495
497// Build trajectory element without propagation for TRT seed
498// without radius correction
500
502(double a,double b,bool& useDriftTime, bool& hole)
503{
504
505 m_status = -1;
506 hole = false; if( m_bestlink < 0) return false;
507 int l = m_bestlink;
508
509 double v = (a*m_link[l].way()+b)*m_link[l].way();
510 double d = m_link[l].distance()-v;
511 double ad = std::abs(d);
512
513 if(ad > 2.05) return false;
514
515 if(!m_link[l].cluster()) {
516
517 if(ad < 1.85) {
518 m_status = 0; hole=true; m_bestlink=l; m_link[l].newImpactParameter(d);
519 }
520 return false;
521 }
522 m_status = 1; m_link[l].newImpactParameter(d);
523 if(!useDriftTime) return true;
524
525 double r = m_link[l].cluster()->localPosition()[Trk::driftRadius];
526 double e = m_scale_error*std::sqrt(m_link[l].cluster()->localCovariance()(0,0));
527
528 if(r > 2.05) r = 2.05;
529 double r2 = r+e; if(r2 > 2.05) r2 = 2.05;
530 double r1 = r-e; if(r1 >= r2) r1 = r2-2.*e;
531 if(ad < r1 || ad > r2) useDriftTime = false; else m_status = 2;
532 return true;
533}
534
536// Find close linek
538
540(double a,double b)
541{
542 m_bestlink = -1;
543 double dm = 10000.;
544
545 for(int l=0; l < m_nlinks; ++l) {
546
547 double v = (a*m_link[l].way()+b)*m_link[l].way();
548 double d = std::abs(m_link[l].distance()-v);
549
550 if(d < dm) {dm=d; m_bestlink=l;}
551 }
552 return dm;
553}
554
556// Build RIOnTrack
558
560{
561 if(m_bestlink < 0 || m_status<=0) return nullptr;
562
563 int l = m_bestlink;
564
565 const Trk::StraightLineSurface* line = static_cast<const Trk::StraightLineSurface*>
566 (&(m_link[l].cluster()->detectorElement())->surface(m_link[l].cluster()->identify()));
567 Trk::AtaStraightLine Tp(m_link[l].impact(),m_link[l].zlocal(),1.,1.,1.,*line);
568 if(m_status==2)
569 return m_riomakerD->correct(*m_link[l].cluster(),Tp, Gaudi::Hive::currentContext());
570 else
571 return m_riomakerN->correct(*m_link[l].cluster(),Tp, Gaudi::Hive::currentContext());
572}
573
575// Build simple RIOnTrack
577
578std::unique_ptr<Trk::RIO_OnTrack>
580{
581 if(m_bestlink < 0 || m_status<=0) return nullptr;
582
583 int l = m_bestlink;
584 Amg::Vector3D dir(1.,0.,0.);
586 Amg::MatrixX cov(1,1);
587 cov(0,0) = 1.;
588 if(m_status==2) {
589 return std::make_unique<InDet::TRT_DriftCircleOnTrack>(m_link[l].cluster(),Trk::LocalParameters(radius),
590 std::move(cov),0,0.,dir,Trk::DECIDED);
591 }
592 return std::make_unique<InDet::TRT_DriftCircleOnTrack>(m_link[l].cluster(),Trk::LocalParameters(radius),
593 std::move(cov),0,0.,dir,Trk::NODRIFTTIME);
594}
595
597// Propagate track parameters to closest drift circles
599
602{
603 if(m_bestlink<0) return false;
604
605 return m_proptool->propagate
606 (Gaudi::Hive::currentContext(),
608}
609
611// Add drift circles information to track parameters
613
616{
617
618 if(m_status <=0) return false;
619
620 int n;
621 if(m_status==2) {
622
623 const TRT_DriftCircle* DS = m_link[m_bestlink].cluster();
624 double dr = DS->localPosition().x(); if(m_link[m_bestlink].impact() < 0.) dr=-dr;
625
628
630 bool Q = m_updatortool->addToState(Ta,lp,DS->localCovariance(),Tb,Xi2,n);
631 if(Q && Xi2 < 15.) return Q;
632 m_status = 1; Ta = To;
633 }
634
637
638 AmgSymMatrix(1) cov; cov<<1.33333;
639 return m_updatortool->addToState(Ta,lp,cov,Tb,Xi2,n);
640}
641
643// Global trajectory coordinates calculation
645
647(Amg::Vector3D& G,double& WAY)
648{
649 int l = m_bestlink;
650 if( l<0 ) return false;
651
652 const Amg::Transform3D& t = m_detelement->strawTransform(m_link[l].number());
653
654 double Az[3] = {t(0,2),t(1,2),t(2,2)};
655 double Rc[3] = {t(0,3),t(1,3),t(2,3)};
656
657 double Bx,By;
658
659 if(std::abs(Az[2]) > .7) { // Barrel
660
661 double Ri = 1./std::sqrt(Rc[0]*Rc[0]+Rc[1]*Rc[1]);
662 Bx =-Az[2]*Rc[1]*Ri; By = Az[2]*Rc[0]*Ri;
663 }
664 else if(Rc[2] > 0. ) { // Positive endcap
665
666 Bx = Az[1]; By =-Az[0];
667 }
668 else { // Negative endcap
669
670 Bx =-Az[1]; By = Az[0];
671 }
672 double zl = m_link[l].zlocal();
673 double im = m_link[l].impact();
674 G[0] = zl*Az[0]+Bx*im+Rc[0];
675 G[1] = zl*Az[1]+By*im+Rc[1];
676 G[2] = zl*Az[2] +Rc[2];
677 WAY = m_link[l].way() ;
678 return true;
679}
680
682// Track parameters estimation on detector element
684
687 double ZvHW)
688{
689
690 if(!E1) return false;
691
692 Amg::Vector3D Gp[3];
693 double Wa[3];
694
695 if (! trajectoryGlobalPosition(Gp[0],Wa[0])) return false;
696 if (!E1->trajectoryGlobalPosition(Gp[1],Wa[1])) return false;
697
698 int mode; Wa[0] > Wa[1] ? mode=0 : mode=1;
699
700 if(E2) {
701 if(!E2->trajectoryGlobalPosition(Gp[2],Wa[2])) return false;
702 }
703 else {
704 double dx = Gp[1][0]-Gp[0][0];
705 double dy = Gp[1][1]-Gp[0][1];
706 Gp[2][0] = 0.;
707 Gp[2][1] = 0.;
708 Gp[2][2] = Gp[0][2]-(Gp[1][2]-Gp[0][2])*std::sqrt((Gp[0][0]*Gp[0][0]+Gp[0][1]*Gp[0][1])/(dx*dx+dy*dy));
709 Wa[2] = 0.;
710 mode = 2 ;
711 }
712
713 double x0 = Gp[0][0] ;
714 double y0 = Gp[0][1] ;
715 double x1 = Gp[1][0]-x0 ;
716 double y1 = Gp[1][1]-y0 ;
717 double x2 = Gp[2][0]-x0 ;
718 double y2 = Gp[2][1]-y0 ;
719 double r1 = std::sqrt(x1*x1+y1*y1) ;
720 double u1 = 1./r1 ;
721 double r2 = 1./(x2*x2+y2*y2) ;
722 double a = x1*u1 ;
723 double b = y1*u1 ;
724 double u2 = (a*x2+b*y2)*r2 ;
725 double v2 = (a*y2-b*x2)*r2 ;
726 double A = v2/(u2-u1) ;
727 double B = 2.*(v2-A*u2) ;
728 double C = B/std::sqrt(1.+A*A) ;
729
730 double f,TP[3];
731
732 if(mode==0) {
733 f = atan2(-b-a*A,-a+b*A); C=-C; polarAngleEstimation(E2,Gp[0],Gp[2],C,ZvHW,TP);
734 }
735 else if(mode==1) {
736 f = atan2( b+a*A, a-b*A); polarAngleEstimation(E2,Gp[0],Gp[2],C,ZvHW,TP);
737 }
738 else {
739 f = atan2( b+a*A, a-b*A); polarAngleEstimation(E1,Gp[0],Gp[1],C,ZvHW,TP);
740 }
741
742 // Track parameters estimation
743 //
744 double P[5] = {m_link[m_bestlink].impact(),m_link[m_bestlink].zlocal(),f,atan2(1.,TP[0]),.0001};
745
746 double pos0[3]; pos0[0]=Gp[0][0]; pos0[1]=Gp[0][1]; pos0[2]=Gp[0][2];
747 double pos1[3]; pos1[0]=Gp[1][0]; pos1[1]=Gp[1][1]; pos1[2]=Gp[1][2];
748 double pos2[3]; pos2[0]=Gp[2][0]; pos2[1]=Gp[2][1]; pos2[2]=Gp[2][2];
749 double H0 [3];
750 double H1 [3];
751 double H2 [3];
752 m_fieldCache.getFieldZR (pos0,H0);
753 m_fieldCache.getFieldZR (pos1,H1);
754 m_fieldCache.getFieldZR (pos2,H2);
755
756 double Hz = .333333*(H0[2]+H1[2]+H2[2]);
757
758 // If magnetic field exist
759 //
760 double Cm = 1. ;
761 double T2 = TP[0]*TP[0];
762 if(std::abs(Hz)>1.e-9) {Cm = 1./(300.*Hz*std::sqrt(1.+T2)); P[4] = -C*Cm;}
763
764 // Covariance of track parameters estimation
765 //
766 double wa; mode != 2 ? wa = 1./(Wa[0]-Wa[2]) : wa = 1./Wa[1];
767 const double dS = 4. ;
768
769 double df = dS*wa ;
770 double dp = 8.*df*wa*Cm ;
771 double c0 = 4. ;
772 double c1 = TP[1] ;
773 double c2 = df*df*(1.+T2);
774 double c3 = TP[2] ;
775 double c4 = dp*dp ;
776 double V[15] ={c0,
777 0.,c1,
778 0.,0.,c2,
779 0.,0.,0.,c3,
780 0.,0.,0.,0.,c4};
781
782 Tp.setParametersWithCovariance(&m_link[m_bestlink].surface(),P,V);
783 return true;
784}
785
787// Track parameters estimation for perigee
789
792{
793
794 if(!E1) return false;
795
796 Amg::Vector3D Gp[3];
797 double Wa[3];
798 if (! trajectoryGlobalPosition(Gp[1],Wa[1])) return false;
799 if (!E1->trajectoryGlobalPosition(Gp[2],Wa[2])) return false;
800
801 double dx = Gp[2][0]-Gp[1][0];
802 double dy = Gp[2][1]-Gp[1][1];
803 Gp[0][0] = 0.;
804 Gp[0][1] = 0.;
805 Gp[0][2] = Gp[1][2]-(Gp[2][2]-Gp[1][2])*std::sqrt((Gp[1][0]*Gp[1][0]+Gp[1][1]*Gp[1][1])/(dx*dx+dy*dy));
806 Wa[0] = 0.;
807
808 double x0 = Gp[0][0] ;
809 double y0 = Gp[0][1] ;
810 double x1 = Gp[1][0]-x0 ;
811 double y1 = Gp[1][1]-y0 ;
812 double x2 = Gp[2][0]-x0 ;
813 double y2 = Gp[2][1]-y0 ;
814 double r1 = std::sqrt(x1*x1+y1*y1) ;
815 double u1 = 1./r1 ;
816 double r2 = 1./(x2*x2+y2*y2) ;
817 double a = x1*u1 ;
818 double b = y1*u1 ;
819 double u2 = (a*x2+b*y2)*r2 ;
820 double v2 = (a*y2-b*x2)*r2 ;
821 double A = v2/(u2-u1) ;
822 double B = 2.*(v2-A*u2) ;
823 double C = B/std::sqrt(1.+A*A) ;
824
825 double f,TP[3];
826
827 f = atan2( b+a*A, a-b*A); polarAngleEstimation(E1,Gp[1],Gp[2],C,ZvHW,TP);
828
829 // Track parameters estimation
830 //
831 double P[5] = {0.,Gp[0][2],f,atan2(1.,TP[0]),.0001};
832
833 double pos0[3]; pos0[0]=Gp[0][0]; pos0[1]=Gp[0][1]; pos0[2]=Gp[0][2];
834 double pos1[3]; pos1[0]=Gp[1][0]; pos1[1]=Gp[1][1]; pos1[2]=Gp[1][2];
835 double pos2[3]; pos2[0]=Gp[2][0]; pos2[1]=Gp[2][1]; pos2[2]=Gp[2][2];
836 double H0 [3];
837 double H1 [3];
838 double H2 [3];
839 m_fieldCache.getFieldZR (pos0,H0);
840 m_fieldCache.getFieldZR (pos1,H1);
841 m_fieldCache.getFieldZR (pos2,H2);
842
843 double Hz = .333333*(H0[2]+H1[2]+H2[2]);
844
845 // If magnetic field exist
846 //
847 double Cm = 1.;
848 double T2 = TP[0]*TP[0];
849 if(std::abs(Hz)>1.e-9) {Cm = 1./(300.*Hz*std::sqrt(1.+T2)); P[4] = -C*Cm;}
850
851 // Covariance of track parameters estimation
852 //
853 double wa = 1./Wa[2];
854
855 const double dS = 4. ;
856 double df = dS*wa ;
857 double dp = 8.*df*wa*Cm ;
858 double c0 = .1 ;
859 double c1 = ZvHW*ZvHW*.1 ;
860 double c2 = df*df*(1.+T2);
861 double c3 = TP[2] ;
862 double c4 = dp*dp ;
863 double V[15] ={c0,
864 0.,c1,
865 0.,0.,c2,
866 0.,0.,0.,c3,
867 0.,0.,0.,0.,c4};
868
869 Tp.setParametersWithCovariance(nullptr,P,V);
870 return true;
871}
872
874// Polar angle estimation
875//
876// Tp[0] = dz/dr=1./tan(Theta)
877// Tp[1] = cov(Z loc)
878// Tp[2] = cov(Theta)
880
882(TRT_TrajectoryElement_xk* E,Amg::Vector3D& G0,Amg::Vector3D& G1,double C,double VZ,double* Tp) const
883{
884 double dx = G1[0]-G0[0] ;
885 double dy = G1[1]-G0[1] ;
886 double dz = G1[2]-G0[2] ;
887 double dr = std::sqrt(dx*dx+dy*dy) ;
888 double rc = dr*C ;
889 Tp[0] = dz/(dr*(1.+.04*rc*rc));
890
891 double r0 = G0[0]*G0[0]+G0[1]*G0[1];
892 double r1 = G1[0]*G1[0]+G1[1]*G1[1];
893
894 if( r0 > r1) {
895
896 Tp[0] =-Tp[0];
897 if ( m_barrel ) { //---------------------------->BB
898
899 double dZ = m_zMax-m_zMin ;
900 double dT = (dZ+2.*VZ) ;
901 Tp[1] = dZ*dZ*.1 ;
902 Tp[2] = dT*dT*.1/r0 ;
903 }
904 else if(E->m_barrel) { //---------------------------->EB
905
906 double T2 = Tp[0]*Tp[0] ;
907 Tp[1] = 400. ;
908 Tp[2] = (VZ*VZ)/((1.+T2)*r0) ;
909 }
910 else { //---------------------------->EE
911
912 double T2 = Tp[0]*Tp[0] ;
913 Tp[1] = 400. ;
914 Tp[2] = (VZ*VZ)/((1.+T2)*r0) ;
915 }
916 }
917 else {
918 if (E->m_barrel) { //---------------------------->BB
919
920 double dZ = m_zMax-m_zMin ;
921 double dT = (E->m_zMax-E->m_zMin+2.*VZ);
922 Tp[1] = dZ*dZ*.1 ;
923 Tp[2] = dT*dT*.1/r1 ;
924 }
925 else if( m_barrel ) { //---------------------------->BE
926
927 double T2 = Tp[0]*Tp[0] ;
928 double dr = std::sqrt(r1)-std::sqrt(r0) ;
929 Tp[1] = dr*dr*VZ*VZ/r1 ;
930 Tp[2] = (VZ*VZ)/((1.+T2)*r1) ;
931
932 }
933 else { //---------------------------->EE
934
935 double T2 = Tp[0]*Tp[0] ;
936 Tp[1] = 400. ;
937 Tp[2] = (VZ*VZ)/((1.+T2)*r1) ;
938 }
939 }
940}
#define AmgSymMatrix(dim)
#define G(x, y, z)
Definition MD5.cxx:113
#define H2(x, y, z)
Definition MD5.cxx:115
#define y
#define x
void getInitializedCache(MagField::AtlasFieldCache &cache) const
get B field cache for evaluation as a function of 2-d or 3-d position.
Virtual base class of TRT readout elements.
bool trackParametersEstimation(TRT_TrajectoryElement_xk *, TRT_TrajectoryElement_xk *, Trk::PatternTrackParameters &, double)
bool addCluster(Trk::PatternTrackParameters &, Trk::PatternTrackParameters &, double &)
void polarAngleEstimation(TRT_TrajectoryElement_xk *, Amg::Vector3D &, Amg::Vector3D &, double, double, double *) const
TRT_ExtensionDriftCircleLink_xk m_link[24]
void set(const TRT_ID *, const Trk::IPatternParametersPropagator *, const Trk::IPatternParametersUpdator *, const Trk::IRIO_OnTrackCreator *, const Trk::IRIO_OnTrackCreator *, double)
bool buildForTRTSeed(double, double, bool &, bool &)
void initiateLinksForPrecisionSeed(InDet::TRT_DriftCircleCollection::const_iterator &, InDet::TRT_DriftCircleCollection::const_iterator &, std::pair< Amg::Vector3D, double > &, const double *, double)
const Trk::IPatternParametersPropagator * m_proptool
bool boundaryTest(double, std::pair< Amg::Vector3D, double > &)
const Trk::IRIO_OnTrackCreator * m_riomakerD
bool trajectoryGlobalPosition(Amg::Vector3D &, double &)
bool initiateForTRTSeed(bool, const InDetDD::TRT_BaseElement *, InDet::TRT_DriftCircleCollection::const_iterator &, InDet::TRT_DriftCircleCollection::const_iterator &, std::pair< Amg::Vector3D, double > &, const double *, double)
bool propagate(Trk::PatternTrackParameters &, Trk::PatternTrackParameters &)
bool buildForPrecisionSeed(double, double, bool &, bool &)
const Trk::IPatternParametersUpdator * m_updatortool
std::unique_ptr< Trk::RIO_OnTrack > rioOnTrackSimple() const
const Trk::IRIO_OnTrackCreator * m_riomakerN
Trk::MagneticFieldProperties m_fieldprop
const InDetDD::TRT_BaseElement * m_detelement
bool initiateForPrecisionSeed(bool, const InDetDD::TRT_BaseElement *, InDet::TRT_DriftCircleCollection::const_iterator &, InDet::TRT_DriftCircleCollection::const_iterator &, std::pair< Amg::Vector3D, double > &, const double *, double)
void initiateLinksForTRTSeed(InDet::TRT_DriftCircleCollection::const_iterator &, InDet::TRT_DriftCircleCollection::const_iterator &, std::pair< Amg::Vector3D, double > &, const double *, double)
This is an Identifier helper class for the TRT subdetector.
Definition TRT_ID.h:82
Class to describe the bounds for a planar DiscSurface.
Definition DiscBounds.h:44
interface for track parameter propagation through the magnetic field, using the Trk::PatternTrackPara...
Interface for updating Trk::PatternTrackParameters, the fast internal representation of track paramet...
Interface class for transforming Trk::PrepRawData to Trk::RIO_OnTrack using a local track hypothesis.
magnetic field properties to steer the behavior of the extrapolation
const Amg::Vector2D & localPosition() const
return the local position reference
const Amg::MatrixX & localCovariance() const
return const ref to the error matrix
Class to handle RIO On Tracks ROT) for InDet and Muons, it inherits from the common MeasurementBase.
Definition RIO_OnTrack.h:70
Bounds for a rectangular, planar surface.
Class for a StraightLineSurface in the ATLAS detector to describe dirft tube and straw like detectors...
Abstract base class for surface bounds to be specified.
virtual BoundsType type() const =0
Return the bounds type - for persistency optimization.
int r
Definition globals.cxx:22
struct color C
Eigen::Matrix< double, Eigen::Dynamic, Eigen::Dynamic > MatrixX
Dynamic Matrix - dynamic allocation.
Eigen::Affine3d Transform3D
Eigen::Matrix< double, 3, 1 > Vector3D
@ anyDirection
ParametersT< TrackParametersDim, Charged, StraightLineSurface > AtaStraightLine
@ NODRIFTTIME
drift time was not used - drift radius is 0.
@ DECIDED
sign of drift radius has been determined
@ driftRadius
trt, straws
Definition ParamDefs.h:53
@ locX
Definition ParamDefs.h:37
std::pair< double, ParamDefs > DefinedParameter
Typedef to of a std::pair<double, ParamDefs> to identify a passed-through double as a specific type o...
hold the test vectors and ease the comparison
std::string number(const double &d, const std::string &s)
Definition utils.cxx:186