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