ATLAS Offline Software
Loading...
Searching...
No Matches
cfNewPm.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
12#include <cmath>
13
14namespace Trk {
15
16void cfnewpm(const double *par, const double *xyzStart, const double *xyzEnd,
17 const double ustep, double *parn, double *closePoint,
18 const VKalVrtControlBase * CONTROL)
19{
20 double d__1, d__2,dist_left;
21 double vect[7], stmg, vout[7]={0.}, dpar0[5];
22 double perig[3], dstep, xyzst[3], charge;
23 double posold, poscur, totway, dp;
24 double dX, dY, dZ;
25 long int ich;
26
27/* --------------------------------------------------------- */
28/* The same as CFNEWP but for the case on nonuniform */
29/* magnetic field */
30/* */
31/* Propagation from xyzStart reference point to xyzEnd point*/
32/* PAR - perigee parameters wrt xyzStart */
33/* PARN - perigee parameters wrt xyzEnd */
34/* Author: V.Kostyukhin */
35/* --------------------------------------------------------- */
36 /* Parameter adjustments */
37 --par;
38
39 d__1 = tan(par[3]);
40 totway = (ustep) * sqrt(1. / (d__1 * d__1) + 1.);
41
42 if (fabs(ustep) < 10. && fabs(totway) < 20.) return; // Distance(mm) is small. Simplest propagation is used
43
44 stmg = 40.; //Propagation step in mm for nonuniform field
45
46 vect[0] = sin(par[4]) * par[1] +xyzStart[0];
47 vect[1] = -cos(par[4]) * par[1] +xyzStart[1];
48 vect[2] = par[2] +xyzStart[2];
49
50 double constB = Trk::vkalMagFld::getMagFld(vect,CONTROL) * Trk::vkalMagFld::getCnvCst();
51
52 double pt = constB / fabs(par[5]);
53 double px = pt * cos(par[4]);
54 double py = pt * sin(par[4]);
55 double pz = pt / tan(par[3]);
56 double p = sqrt(pt * pt + pz * pz);
57
58 vect[3] = px / p;
59 vect[4] = py / p;
60 vect[5] = pz / p;
61 vect[6] = p;
62 charge = -d_sign( 1., par[5]);
63 poscur = 0.;
64//std::cout <<"VkGrkuta vect="<<vect[0]<<", "<<vect[1]<<", "<<vect[2]<<", "<<vect[3]<<", "
65// <<vect[4]<<", "<<vect[5]<<", "<<vect[6]<<'\n';
66 while(fabs(poscur) < fabs(totway)) {
67 posold = poscur;
68 d__1 = fabs(poscur) + stmg;
69 d__2 = fabs(totway);
70 poscur = d__1 < d__2 ? d__1 : d__2;
71 poscur = d_sign(poscur, totway);
72 dstep = poscur - posold;
73 vkgrkuta_(charge, dstep, vect, vout, CONTROL);
74 vect[0] = vout[0];
75 vect[1] = vout[1];
76 vect[2] = vout[2];
77 vect[3] = vout[3];
78 vect[4] = vout[4];
79 vect[5] = vout[5];
80// safety for strongly nonuniform field
81 dX = vect[0]-xyzEnd[0];
82 dY = vect[1]-xyzEnd[1];
83 dZ = vect[2]-xyzEnd[2];
84 dist_left = sqrt( dX*dX + dY*dY + dZ*dZ);
85 if(dist_left < stmg) break; // arrived
86 }
87
88/* --- Now we are in the new point. Calculate track parameters */
89/* at new point with new mag.field */
90
91 constB = Trk::vkalMagFld::getMagFld(xyzEnd,CONTROL) * Trk::vkalMagFld::getCnvCst() ;
92 if(std::abs(constB)<0.001)constB=0.001; //Protection against zero field
93
94 dpar0[0] = 0.;
95 dpar0[1] = 0.;
96 dpar0[2] = acos(vout[5]);
97 dpar0[3] = atan2(vout[4], vout[3]);
98// if (dpar0[3] < 0.) dpar0[3] += 6.2831853071794;
99
100 px = vect[3] * vect[6];
101 py = vect[4] * vect[6];
102 dpar0[4] = d_sign( (constB/sqrt(px*px+py*py)), par[5]); /* new value of curvature */
103 ich = (long int) charge;
104 xyzst[0] = xyzEnd[0] - vout[0];
105 xyzst[1] = xyzEnd[1] - vout[1];
106 xyzst[2] = xyzEnd[2] - vout[2];
107
108 cfnewp(ich, dpar0, xyzst, &dp, parn, perig); // Last step of propagation
109 closePoint[0] = perig[0] + vout[0]; // with simple program
110 closePoint[1] = perig[1] + vout[1];
111 closePoint[2] = perig[2] + vout[2];
112}
113
114} /* End of namespace */
double charge(const T &p)
Definition AtlasPID.h:1003
static void getMagFld(const double, const double, const double, double &, double &, double &, const VKalVrtControlBase *)
static double getCnvCst()
Definition VKalVrtBMag.h:59
Ensure that the ATLAS eigen extensions are properly loaded.
void cfnewpm(const double *par, const double *xyzStart, const double *xyzEnd, const double ustep, double *parn, double *closePoint, const VKalVrtControlBase *CONTROL)
Definition cfNewPm.cxx:16
@ pz
global momentum (cartesian)
Definition ParamDefs.h:61
@ px
Definition ParamDefs.h:59
@ py
Definition ParamDefs.h:60
void vkgrkuta_(const double charge, const double step, double *vect, double *vout, const VKalVrtControlBase *CONTROL)
Definition VKgrkuta.cxx:14
double d_sign(double value, double sign)
void cfnewp(const long int ich, const double *parold, const double *ref, double *s, double *parnew, double *per)
Definition cfNewP.cxx:10