28 declareProperty(
"Extrapolator", m_extrapolator);
29 declareInterface<IVertexLinearizedTrackFactory>(
this);
40 return StatusCode::SUCCESS;
53 if (!trackPars)
return nullptr;
65 const double extrapolationDirection = gMomentum.dot( gDirection);
72 Gaudi::Hive::currentContext(),
76 if (
dynamic_cast<const Trk::Perigee*
>(parsAtVertex)==
nullptr ||
77 parsAtVertex->covariance()==nullptr ) {
78 ATH_MSG_INFO (
"Could not extrapolate Perigee to vertex pos: x " << lp.x() <<
" y " <<
79 lp.y() <<
" z " << lp.z() <<
". Normal if outside ID acceptance ");
81 if (
dynamic_cast<const Trk::Perigee*
>(trackPars) && trackPars->covariance()) {
82 if (parsAtVertex)
delete parsAtVertex;
83 parsAtVertex = trackPars->
clone();
85 delete parsAtVertex;
return nullptr;
89 if (parsAtVertex && parsAtVertex->covariance() && parsAtVertex->covariance()->determinant()<=0)
91 ATH_MSG_DEBUG (
"The track covariance matrix det after extrapolation is: " << parsAtVertex->covariance()->determinant() <<
92 " --> Using non extrapolated track parameters");
94 parsAtVertex=trackPars->
clone();
102 double phi_v = param(
Trk::
phi);
103 double sin_phi_v =
sin(phi_v);
104 double cos_phi_v =
cos(phi_v);
108 double sin_th =
sin(
th);
109 double tan_th =
tan(
th);
113 int sgn_h = (q_ov_p<0.)? -1:1;
122 fieldCondObj->getInitializedCache (fieldCache);
125 fieldCache.
getField(expPoint.data(),mField);
127 double B_z=mField[2]*299.792;
134 if(mField[2] == 0. || fabs(q_ov_p) <= 1
e-15)
rho = 1
e+15 ;
135 else rho = sin_th / (q_ov_p * B_z);
138 double X = expPoint(0) - lp.x() +
rho*sin_phi_v;
139 double Y = expPoint(1) - lp.y() -
rho*cos_phi_v;
140 double SS = (
X *
X +
Y *
Y);
145 AmgVector(5) parAtExpansionPoint; parAtExpansionPoint.setZero();
146 parAtExpansionPoint[0] =
rho - sgn_h *
S;
150 int sgnY = (
Y<0)? -1:1;
151 int sgnX = (
X<0)? -1:1;
152 double pi = TMath::Pi();
154 if(fabs(
X)>fabs(
Y)) phiAtEp = sgn_h*sgnX* acos(-sgn_h *
Y /
S);
157 phiAtEp = asin(sgn_h *
X /
S);
158 if( (sgn_h * sgnY)> 0) phiAtEp = sgn_h * sgnX *
pi - phiAtEp;
161 parAtExpansionPoint[2] = phiAtEp;
162 parAtExpansionPoint[1] = expPoint(2) - lp.z() +
rho*(phi_v - parAtExpansionPoint[2])/tan_th;
163 parAtExpansionPoint[3] =
th;
164 parAtExpansionPoint[4] = q_ov_p;
169 AmgMatrix(5,3) positionJacobian; positionJacobian.setZero();
172 positionJacobian(0,0) = -sgn_h *
X /
S;
173 positionJacobian(0,1) = -sgn_h *
Y /
S;
176 positionJacobian(1,0) =
rho *
Y / (tan_th * SS);
177 positionJacobian(1,1) = -
rho *
X / (tan_th * SS);
178 positionJacobian(1,2) = 1.;
181 positionJacobian(2,0) = -
Y / SS;
182 positionJacobian(2,1) =
X / SS;
186 AmgMatrix(5,3) momentumJacobian; momentumJacobian.setZero();
187 double R =
X*cos_phi_v +
Y * sin_phi_v;
188 double Q =
X*sin_phi_v -
Y * cos_phi_v;
189 double d_phi = parAtExpansionPoint[2] - phi_v;
192 momentumJacobian(0,0) = -sgn_h *
rho * R /
S ;
194 double qOvS_red = 1 - sgn_h * Q /
S;
195 momentumJacobian(0,1) = qOvS_red *
rho / tan_th;
196 momentumJacobian(0,2) = - qOvS_red *
rho / q_ov_p;
199 momentumJacobian(1,0) = (1 -
rho*Q/SS )*
rho/tan_th;
200 momentumJacobian(1,1) = (d_phi +
rho * R / (SS * tan_th * tan_th) ) *
rho;
201 momentumJacobian(1,2) = (d_phi -
rho * R /SS ) *
rho / (q_ov_p*tan_th);
204 momentumJacobian(2,0) =
rho * Q / SS;
205 momentumJacobian(2,1) = -
rho * R / (SS*tan_th);
206 momentumJacobian(2,2) =
rho * R / (q_ov_p*SS);
209 momentumJacobian(3,1) = 1.;
210 momentumJacobian(4,2) = 1.;
213 AmgVector(5) constantTerm = parAtExpansionPoint - positionJacobian*expPoint - momentumJacobian*expMomentum;
216 LinearizedTrack* toreturn=
new LinearizedTrack(parsAtVertex->
parameters(),
217 *parsAtVertex->covariance(),
234 if (!neutralPars)
return nullptr;
252 parsAtVertex->covariance()==
nullptr ) {
253 ATH_MSG_INFO (
"Could not extrapolate Perigee to vertex pos: x " << lp.x() <<
" y " <<
254 lp.y() <<
" z " << lp.z() <<
". Should not happen. ");
257 if (parsAtVertex)
delete parsAtVertex;
258 parsAtVertex = neutralPars->
clone();
260 delete parsAtVertex;
return nullptr;
265 AmgVector(5) param = parsAtVertex->parameters();
269 double sin_phi_v =
sin(phi_v);
270 double cos_phi_v =
cos(phi_v);
272 double tan_th =
tan(
th);
277 double X = expPoint(0) - lp.x();
278 double Y = expPoint(1) - lp.y();
280 AmgVector(5) parAtExpansionPoint; parAtExpansionPoint.setZero();
281 parAtExpansionPoint[0] =
Y*cos_phi_v-
X*sin_phi_v;
286 double phiAtEp=phi_v;
287 parAtExpansionPoint[2] = phiAtEp;
288 parAtExpansionPoint[1] = expPoint[2] - lp.z() - 1./tan_th*(
X*cos_phi_v+
Y*sin_phi_v);
289 parAtExpansionPoint[3] =
th;
290 parAtExpansionPoint[4] = q_ov_p;
293 AmgMatrix(5,3) positionJacobian; positionJacobian.setZero();
296 positionJacobian(0,0) = -sin_phi_v;
297 positionJacobian(0,1) = +cos_phi_v;
300 positionJacobian(1,0) = -cos_phi_v/tan_th;
301 positionJacobian(1,1) = -sin_phi_v/tan_th;
302 positionJacobian(1,2) = 1.;
307 AmgMatrix(5,3) momentumJacobian; momentumJacobian.setZero();
308 momentumJacobian(2,0) = 1.;
309 momentumJacobian(3,1) = 1.;
310 momentumJacobian(4,2) = 1.;
313 AmgVector(5) constantTerm = parAtExpansionPoint - positionJacobian*expPoint - momentumJacobian*expMomentum;
317 *parsAtVertex->covariance(),