205{
208
210
211 if( std::fabs(stepLengthCm) <= kCarTolerance/cm ) return 0;
212
213#ifdef G4EVERBOSE
215#endif
216
217
220
221
224
225 if( vpPre.
mag() == vpPre.
z() ) vpPre.
setX( 1.E-6*MeV );
226 if( vpPost.
mag() == vpPost.
z() ) vpPost.
setX( 1.E-6*MeV );
227
230#ifdef G4EVERBOSE
233 <<
"G4EP: vposPost " << vposPost <<
G4endl;
235 <<
"G4EP: vpPost " << vpPost <<
G4endl;
237 G4cout <<
"G4EP: stepLengthCm " << stepLengthCm <<
G4endl;
238 }
239#endif
240
241 if( pPre == 0. || pPost == 0 ) return 2;
244 G4double deltaPInv = pInvPost - pInvPre;
245
248
249
250 if( 1. - std::fabs(vpPostNorm.
z()) < kCarTolerance )
return 4;
254
255#ifdef G4EVERBOSE
257#endif
258
259
261
262 transf[3][2] = stepLengthCm * sinpPost;
263 transf[4][1] = stepLengthCm;
264 for( size_t ii=0;ii < 5; ii++ ){
265 transf[ii][ii] = 1.;
266 }
267#ifdef G4EVERBOSE
269 G4cout <<
"G4EP: transf matrix neutral " << transf;
270 }
271#endif
272
273
276 charge *= -1.;
277 }
278
279
280
281
282
283
284 G4double pos1[3]; pos1[0] = vposPre.
x()*cm; pos1[1] = vposPre.
y()*cm; pos1[2] = vposPre.
z()*cm;
285 G4double pos2[3]; pos2[0] = vposPost.
x()*cm; pos2[1] = vposPost.
y()*cm; pos2[2] = vposPost.
z()*cm;
287
289 if( !field ) return 0;
290
291
292 if( charge != 0. && field ) {
293
300#ifdef G4EVERBOSE
302 <<
"G4EP: HPost " << HPost <<
G4endl;
303#endif
304
305 if( magHPre + magHPost != 0. ) {
306
307
309 if( magHPost != 0. ){
310 gam = HPost * vpPostNorm / magHPost;
311 }else {
312 gam = HPre * vpPreNorm / magHPre;
313 }
314
315
317 G4double diffHSqr = ( HPre * pInvPre - HPost * pInvPost ).mag2();
319#ifdef G4EVERBOSE
320 if(
iverbose >= 2 )
G4cout <<
" G4EP: gam " <<
gam <<
" alphaSqr " << alphaSqr <<
" diffHSqr " << diffHSqr <<
G4endl;
321#endif
322 if( diffHSqr * alphaSqr > delhp6Sqr ) return 3;
323
324
325
326 G4double pInvAver = 1./(pInvPre + pInvPost );
328
329 G4ThreeVector vHAverNorm( (HPre*pInvPre + HPost*pInvPost ) * pInvAver * charge * CFACT8 );
332 vHAverNorm *= invHAver;
333#ifdef G4EVERBOSE
334 if(
iverbose >= 2 )
G4cout <<
" G4EP: HaverNorm " << vHAverNorm <<
" magHAver " << HAver <<
" charge " << charge<<
G4endl;
335#endif
336
339 G4double thetaAver = QAver * stepLengthCm;
340 G4double sinThetaAver = std::sin(thetaAver);
341 G4double cosThetaAver = std::cos(thetaAver);
342 G4double gamma = vHAverNorm * vpPostNorm;
344
345#ifdef G4EVERBOSE
347#endif
349
352 0. );
354 vpPreNorm.
z()*vUPre.x(),
355 vpPreNorm.
x()*vUPre.y() - vpPreNorm.
y()*vUPre.x() );
356
357
358 AU = 1./vpPostNorm.perp();
359
361 AU*vpPostNorm.x(),
362 0. );
364 vpPostNorm.z()*vUPost.x(),
365 vpPostNorm.x()*vUPost.y() - vpPostNorm.y()*vUPost.x() );
366#ifdef G4EVERBOSE
367
368 if(
iverbose >= 2 )
G4cout <<
" G4EP: AU " << AU <<
" vUPre " << vUPre <<
" vVPre " << vVPre <<
" vUPost " << vUPost <<
" vVPost " << vVPost <<
G4endl;
369#endif
370 G4Point3D deltaPos( vposPre - vposPost );
371
372
373
374
375
377#ifdef G4EVERBOSE
378 if(
iverbose >= 2)
G4cout <<
" G4EP: QP " << QP <<
" QAver " << QAver <<
" pAver " << pAver <<
G4endl;
379#endif
380 G4double ANV = -( vHAverNorm.x()*vUPost.x() + vHAverNorm.y()*vUPost.y() );
381 G4double ANU = ( vHAverNorm.x()*vVPost.x() + vHAverNorm.y()*vVPost.y() + vHAverNorm.z()*vVPost.z() );
382 G4double OMcosThetaAver = 1. - cosThetaAver;
383#ifdef G4EVERBOSE
384 if(
iverbose >= 2)
G4cout <<
"G4EP: OMcosThetaAver " << OMcosThetaAver <<
" cosThetaAver " << cosThetaAver <<
" thetaAver " << thetaAver <<
" QAver " << QAver <<
" stepLengthCm " << stepLengthCm <<
G4endl;
385#endif
386 G4double TMSINT = thetaAver - sinThetaAver;
387#ifdef G4EVERBOSE
389#endif
390
392 vHAverNorm.z() * vUPre.x(),
393 vHAverNorm.x() * vUPre.y() - vHAverNorm.y() * vUPre.x() );
394#ifdef G4EVERBOSE
395
396#endif
397 G4ThreeVector vHVPre( vHAverNorm.y() * vVPre.z() - vHAverNorm.z() * vVPre.y(),
398 vHAverNorm.z() * vVPre.x() - vHAverNorm.x() * vVPre.z(),
399 vHAverNorm.x() * vVPre.y() - vHAverNorm.y() * vVPre.x() );
400#ifdef G4EVERBOSE
402#endif
403
404
405
406
407 transf[0][0] = 1.-deltaPInv*pAver*(1.+(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())/stepLengthCm)
408 +2.*deltaPInv*pAver;
409
410 transf[0][1] = -deltaPInv/thetaAver*
411 ( TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) +
412 sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
413 OMcosThetaAver*(vHVPre.x()*vpPostNorm.x()+vHVPre.y()*vpPostNorm.y()+vHVPre.z()*vpPostNorm.z()) );
414
415 transf[0][2] = -sinpPre*deltaPInv/thetaAver*
416 ( TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) +
417 sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
418 OMcosThetaAver*(vHUPre.x()*vpPostNorm.x()+vHUPre.y()*vpPostNorm.y()+vHUPre.z()*vpPostNorm.z()) );
419
420 transf[0][3] = -deltaPInv/stepLengthCm*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() );
421
422 transf[0][4] = -deltaPInv/stepLengthCm*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z());
423
424
425 transf[1][0] = -QP*ANV*(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())
426 *(1.+deltaPInv*pAver);
427#ifdef G4EVERBOSE
428 if(
iverbose >= 3)
G4cout <<
"ctransf10= " << transf[1][0] <<
" " << -QP<<
" " << ANV<<
" " << vpPostNorm.x()<<
" " << deltaPos.x()<<
" " << vpPostNorm.y()<<
" " << deltaPos.y()<<
" " << vpPostNorm.z()<<
" " << deltaPos.z()
429 <<
" " << deltaPInv<<
" " << pAver <<
G4endl;
430#endif
431
432 transf[1][1] = cosThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) +
433 sinThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) +
434 OMcosThetaAver*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z())*
435 (vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) +
436 ANV*( -sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
437 OMcosThetaAver*(vVPre.x()*AN2.
x()+vVPre.y()*AN2.
y()+vVPre.z()*AN2.
z()) -
438 TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) );
439
440 transf[1][2] = cosThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) +
441 sinThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) +
442 OMcosThetaAver*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() )*
443 (vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) +
444 ANV*( -sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
445 OMcosThetaAver*(vUPre.x()*AN2.
x()+vUPre.y()*AN2.
y() ) -
446 TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) );
447 transf[1][2] = sinpPre*transf[1][2];
448
449 transf[1][3] = -QAver*ANV*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() );
450
451 transf[1][4] = -QAver*ANV*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z());
452
453
454
455 transf[2][0] = -QP*ANU*(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())*sinpPostInv
456 *(1.+deltaPInv*pAver);
457#ifdef G4EVERBOSE
458 if(
iverbose >= 3)
G4cout <<
"ctransf20= " << transf[2][0] <<
" "<< -QP<<
" "<<ANU<<
" "<<vpPostNorm.x()<<
" "<<deltaPos.x()<<
" "<<vpPostNorm.y()<<
" "<<deltaPos.y()<<
" "<<vpPostNorm.z()<<
" "<<deltaPos.z()<<
" "<<sinpPostInv
459 <<
" "<<deltaPInv<<
" "<<pAver<<
G4endl;
460#endif
461 transf[2][1] = cosThetaAver*(vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() ) +
462 sinThetaAver*(vHVPre.x()*vUPost.x()+vHVPre.y()*vUPost.y() ) +
463 OMcosThetaAver*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z())*
464 (vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() ) +
465 ANU*( -sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
466 OMcosThetaAver*(vVPre.x()*AN2.
x()+vVPre.y()*AN2.
y()+vVPre.z()*AN2.
z()) -
467 TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) );
468 transf[2][1] = sinpPostInv*transf[2][1];
469
470 transf[2][2] = cosThetaAver*(vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() ) +
471 sinThetaAver*(vHUPre.x()*vUPost.x()+vHUPre.y()*vUPost.y() ) +
472 OMcosThetaAver*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() )*
473 (vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() ) +
474 ANU*( -sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
475 OMcosThetaAver*(vUPre.x()*AN2.
x()+vUPre.y()*AN2.
y() ) -
476 TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) );
477 transf[2][2] = sinpPostInv*sinpPre*transf[2][2];
478
479 transf[2][3] = -QAver*ANU*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() )*sinpPostInv;
480#ifdef G4EVERBOSE
481 if(
iverbose >= 3)
G4cout <<
"ctransf23= " << transf[2][3] <<
" "<< -QAver<<
" "<<ANU<<
" "<<vUPre.x()<<
" "<<vpPostNorm.x()<<
" "<< vUPre.y()<<
" "<<vpPostNorm.y()<<
" "<<sinpPostInv<<
G4endl;
482#endif
483
484 transf[2][4] = -QAver*ANU*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z())*sinpPostInv;
485
486
487
488 transf[3][0] = pAver*(vUPost.x()*deltaPos.x()+vUPost.y()*deltaPos.y() )
489 *(1.+deltaPInv*pAver);
490#ifdef G4EVERBOSE
491 if(
iverbose >= 3)
G4cout <<
"ctransf30= " << transf[3][0] <<
" "<< pAver<<
" "<<vUPost.x()<<
" "<<deltaPos.x()<<
" "<<vUPost.y()<<
" "<<deltaPos.y()
492 <<
" "<<deltaPInv<<
" "<<pAver<<
G4endl;
493#endif
494
495 transf[3][1] = ( sinThetaAver*(vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() ) +
496 OMcosThetaAver*(vHVPre.x()*vUPost.x()+vHVPre.y()*vUPost.y() ) +
497 TMSINT*(vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() )*
498 (vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) )/QAver;
499
500 transf[3][2] = ( sinThetaAver*(vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() ) +
501 OMcosThetaAver*(vHUPre.x()*vUPost.x()+vHUPre.y()*vUPost.y() ) +
502 TMSINT*(vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() )*
503 (vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) )*sinpPre/QAver;
504#ifdef G4EVERBOSE
505 if(
iverbose >= 3)
G4cout <<
"ctransf32= " << transf[3][2] <<
" "<< sinThetaAver<<
" "<<vUPre.x()<<
" "<<vUPost.x()<<
" "<<vUPre.y()<<
" "<<vUPost.y() <<
" "<<
506 OMcosThetaAver<<" "<<vHUPre.x()<<" "<<vUPost.x()<<" "<<vHUPre.y()<<" "<<vUPost.y() <<" "<<
507 TMSINT<<" "<<vHAverNorm.x()<<" "<<vUPost.x()<<" "<<vHAverNorm.y()<<" "<<vUPost.y() <<" "<<
508 vHAverNorm.x()<<
" "<<vUPre.x()<<
" "<<vHAverNorm.y()<<
" "<<vUPre.y() <<
" "<<sinpPre<<
" "<<QAver<<
G4endl;
509#endif
510
511 transf[3][3] = (vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() );
512
513 transf[3][4] = (vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() );
514
515
516 transf[4][0] = pAver*(vVPost.x()*deltaPos.x()+vVPost.y()*deltaPos.y()+vVPost.z()*deltaPos.z())
517 *(1.+deltaPInv*pAver);
518
519 transf[4][1] = ( sinThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) +
520 OMcosThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) +
521 TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())*
522 (vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) )/QAver;
523#ifdef G4EVERBOSE
524 if(
iverbose >= 3)
G4cout <<
"ctransf41= " << transf[4][1] <<
" "<< sinThetaAver<<
" "<< OMcosThetaAver <<
" "<<TMSINT<<
" "<< vVPre <<
" "<<vVPost <<
" "<<vHVPre<<
" "<<vHAverNorm <<
" "<< QAver<<
G4endl;
525#endif
526
527 transf[4][2] = ( sinThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) +
528 OMcosThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) +
529 TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())*
530 (vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) )*sinpPre/QAver;
531
532 transf[4][3] = (vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() );
533
534 transf[4][4] = (vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z());
535
536
537
538#ifdef G4EVERBOSE
540#endif
541
542
543
544
545
546
547 }
548 }
549
550
551
552
553
554
555
556
557
558
559 theTransfMat = transf;
560#ifdef G4EVERBOSE
563 <<
" transf matrix " << theTransfMat.
T() <<
G4endl;
564#endif
565
567
568#ifdef G4EVERBOSE
570#endif
571
572
573
574
575
576 PropagateErrorMSC( aTrack );
577
578 PropagateErrorIoni( aTrack );
579
580 return 0;
581}
@ G4ErrorMode_PropBackwards
Hep3Vector cross(const Hep3Vector &) const
G4double GetCharge() const
static G4ErrorPropagatorData * GetErrorPropagatorData()
G4ErrorSymMatrix similarity(const G4ErrorMatrix &m1) const
G4ErrorSymMatrix T() const
G4double GetSurfaceTolerance() const
static G4GeometryTolerance * GetInstance()
G4ThreeVector GetMomentum() const
const G4ThreeVector & GetPosition() const
G4StepPoint * GetPreStepPoint() const
G4double GetStepLength() const
const G4ThreeVector & GetPosition() const
G4ThreeVector GetMomentum() const
const G4DynamicParticle * GetDynamicParticle() const
const G4Step * GetStep() const