203{
206
208
210
211#ifdef G4EVERBOSE
214#endif
215
216
219
220
223
224 if( vpPre.
mag() == vpPre.
z() ) vpPre.
setX( 1.E-6*MeV );
225 if( vpPost.
mag() == vpPost.
z() ) vpPost.
setX( 1.E-6*MeV );
226
229#ifdef G4EVERBOSE
232 <<
"G4EP: vposPost " << vposPost <<
G4endl;
234 <<
"G4EP: vpPost " << vpPost <<
G4endl;
236 G4cout <<
"G4EP: stepLengthCm " << stepLengthCm <<
G4endl;
237 }
238#endif
239
240 if( pPre == 0. || pPost == 0 ) return 2;
243 G4double deltaPInv = pInvPost - pInvPre;
244 if(
iverbose >= 2 )
G4cout <<
"G4EP: pInvPre" << pInvPre<<
" pInvPost:" << pInvPost<<
" deltaPInv:" << deltaPInv<<
G4endl;
245
246
249 if(
iverbose >= 2 )
G4cout <<
"G4EP: vpPreNorm " << vpPreNorm <<
" vpPostNorm " << vpPostNorm <<
G4endl;
250
256
257#ifdef G4EVERBOSE
259#endif
260
261
263
264 transf[3][2] = stepLengthCm * sinpPost;
265 transf[4][1] = stepLengthCm;
266 for( size_t ii=0;ii < 5; ii++ ){
267 transf[ii][ii] = 1.;
268 }
269#ifdef G4EVERBOSE
271 G4cout <<
"G4EP: transf matrix neutral " << transf;
272 }
273#endif
274
275
278 charge *= -1.;
279 }
280
281
282
283
284
285
286
287 G4double pos1[3]; pos1[0] = vposPre.
x()*cm; pos1[1] = vposPre.
y()*cm; pos1[2] = vposPre.
z()*cm;
288 G4double pos2[3]; pos2[0] = vposPost.
x()*cm; pos2[1] = vposPost.
y()*cm; pos2[2] = vposPost.
z()*cm;
290
292 if( !field ) return 0;
293
294
295
296
297 if( charge != 0. && field ) {
298
305#ifdef G4EVERBOSE
308 << h1[0] <<
", " << h1[1] <<
", " << h1[2] <<
G4endl;
309 G4cout <<
"G4EP: pos1/mm = "
310 << pos1[0] <<
", " << pos1[1] <<
", " << pos1[2] <<
G4endl;
311 G4cout <<
"G4EP: pos2/mm = "
312 << pos2[0] <<
", " << pos2[1] <<
", " << pos2[2] <<
G4endl;
313 G4cout <<
"G4EP: B-filed in KGauss HPre " << HPre <<
G4endl
314 <<
"G4EP: in KGauss HPost " << HPost <<
G4endl;
315 }
316#endif
317
318 if( magHPre + magHPost != 0. ) {
319
320
322 if( magHPost != 0. ){
323 gam = HPost * vpPostNorm / magHPost;
324 }else {
325 gam = HPre * vpPreNorm / magHPre;
326 }
327
328
330 G4double diffHSqr = ( HPre * pInvPre - HPost * pInvPost ).mag2();
332#ifdef G4EVERBOSE
334 G4cout <<
" G4EP: gam " <<
gam <<
" alphaSqr " << alphaSqr
335 <<
" diffHSqr " << diffHSqr <<
G4endl;
337 }
338#endif
339 if( diffHSqr * alphaSqr > delhp6Sqr ) return 3;
340
341
342
343 G4double pInvAver = 1./(pInvPre + pInvPost );
345
346 G4ThreeVector vHAverNorm( (HPre*pInvPre + HPost*pInvPost ) * pInvAver * charge * CFACT8 );
349 vHAverNorm *= invHAver;
350#ifdef G4EVERBOSE
351 if(
iverbose >= 2 )
G4cout <<
" G4EP: HaverNorm " << vHAverNorm <<
" magHAver " << HAver <<
" charge " << charge<<
G4endl;
352#endif
353
356 G4double thetaAver = QAver * stepLengthCm;
357 G4double sinThetaAver = std::sin(thetaAver);
358 G4double cosThetaAver = std::cos(thetaAver);
359 G4double gamma = vHAverNorm * vpPostNorm;
361
362#ifdef G4EVERBOSE
363 if(
iverbose >= 2 )
G4cout <<
" G4EP: AN2 " << AN2 <<
" gamma:"<<gamma<<
" theta="<< thetaAver<<
G4endl;
364#endif
366
369 0. );
371 vpPreNorm.
z()*vUPre.x(),
372 vpPreNorm.
x()*vUPre.y() - vpPreNorm.
y()*vUPre.x() );
373
374
375 AU = 1./vpPostNorm.perp();
376
378 AU*vpPostNorm.x(),
379 0. );
381 vpPostNorm.z()*vUPost.x(),
382 vpPostNorm.x()*vUPost.y() - vpPostNorm.y()*vUPost.x() );
383#ifdef G4EVERBOSE
385 if(
iverbose >= 2 )
G4cout <<
" G4EP: AU " << AU <<
" vUPre " << vUPre <<
" vVPre " << vVPre <<
" vUPost " << vUPost <<
" vVPost " << vVPost <<
G4endl;
386#endif
387 G4Point3D deltaPos( vposPre - vposPost );
388
389
390
391
392
394#ifdef G4EVERBOSE
395 if(
iverbose >= 2)
G4cout <<
" G4EP: QP " << QP <<
" QAver " << QAver <<
" pAver " << pAver <<
G4endl;
396#endif
397 G4double ANV = -( vHAverNorm.x()*vUPost.x() + vHAverNorm.y()*vUPost.y() );
398 G4double ANU = ( vHAverNorm.x()*vVPost.x() + vHAverNorm.y()*vVPost.y() + vHAverNorm.z()*vVPost.z() );
399 G4double OMcosThetaAver = 1. - cosThetaAver;
400#ifdef G4EVERBOSE
401 if(
iverbose >= 2)
G4cout <<
"G4EP: OMcosThetaAver " << OMcosThetaAver <<
" cosThetaAver " << cosThetaAver <<
" thetaAver " << thetaAver <<
" QAver " << QAver <<
" stepLengthCm " << stepLengthCm <<
G4endl;
402#endif
403 G4double TMSINT = thetaAver - sinThetaAver;
404#ifdef G4EVERBOSE
406#endif
407
409 vHAverNorm.z() * vUPre.x(),
410 vHAverNorm.x() * vUPre.y() - vHAverNorm.y() * vUPre.x() );
411#ifdef G4EVERBOSE
412
413#endif
414 G4ThreeVector vHVPre( vHAverNorm.y() * vVPre.z() - vHAverNorm.z() * vVPre.y(),
415 vHAverNorm.z() * vVPre.x() - vHAverNorm.x() * vVPre.z(),
416 vHAverNorm.x() * vVPre.y() - vHAverNorm.y() * vVPre.x() );
417#ifdef G4EVERBOSE
419#endif
420
421
422
423
424 transf[0][0] = 1.-deltaPInv*pAver*(1.+(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())/stepLengthCm)
425 +2.*deltaPInv*pAver;
426
427 transf[0][1] = -deltaPInv/thetaAver*
428 ( TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) +
429 sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
430 OMcosThetaAver*(vHVPre.x()*vpPostNorm.x()+vHVPre.y()*vpPostNorm.y()+vHVPre.z()*vpPostNorm.z()) );
431
432 transf[0][2] = -sinpPre*deltaPInv/thetaAver*
433 ( TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) +
434 sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
435 OMcosThetaAver*(vHUPre.x()*vpPostNorm.x()+vHUPre.y()*vpPostNorm.y()+vHUPre.z()*vpPostNorm.z()) );
436
437 transf[0][3] = -deltaPInv/stepLengthCm*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() );
438
439 transf[0][4] = -deltaPInv/stepLengthCm*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z());
440
441
442 transf[1][0] = -QP*ANV*(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())
443 *(1.+deltaPInv*pAver);
444#ifdef G4EVERBOSE
445 if(
iverbose >= 3)
G4cout <<
"ctransf10= " << transf[1][0] <<
" " << -QP<<
" " << ANV<<
" " << vpPostNorm.x()<<
" " << deltaPos.x()<<
" " << vpPostNorm.y()<<
" " << deltaPos.y()<<
" " << vpPostNorm.z()<<
" " << deltaPos.z()
446 <<
" " << deltaPInv<<
" " << pAver <<
G4endl;
447#endif
448
449 transf[1][1] = cosThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) +
450 sinThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) +
451 OMcosThetaAver*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z())*
452 (vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) +
453 ANV*( -sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
454 OMcosThetaAver*(vVPre.x()*AN2.
x()+vVPre.y()*AN2.
y()+vVPre.z()*AN2.
z()) -
455 TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) );
456
457 transf[1][2] = cosThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) +
458 sinThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) +
459 OMcosThetaAver*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() )*
460 (vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z()) +
461 ANV*( -sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
462 OMcosThetaAver*(vUPre.x()*AN2.
x()+vUPre.y()*AN2.
y() ) -
463 TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) );
464 transf[1][2] = sinpPre*transf[1][2];
465
466 transf[1][3] = -QAver*ANV*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() );
467
468 transf[1][4] = -QAver*ANV*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z());
469
470
471
472 transf[2][0] = -QP*ANU*(vpPostNorm.x()*deltaPos.x()+vpPostNorm.y()*deltaPos.y()+vpPostNorm.z()*deltaPos.z())*sinpPostInv
473 *(1.+deltaPInv*pAver);
474#ifdef G4EVERBOSE
475 if(
iverbose >= 3)
G4cout <<
"ctransf20= " << transf[2][0] <<
" "<< -QP<<
" "<<ANU<<
" "<<vpPostNorm.x()<<
" "<<deltaPos.x()<<
" "<<vpPostNorm.y()<<
" "<<deltaPos.y()<<
" "<<vpPostNorm.z()<<
" "<<deltaPos.z()<<
" "<<sinpPostInv
476 <<
" "<<deltaPInv<<
" "<<pAver<<
G4endl;
477#endif
478 transf[2][1] = cosThetaAver*(vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() ) +
479 sinThetaAver*(vHVPre.x()*vUPost.x()+vHVPre.y()*vUPost.y() ) +
480 OMcosThetaAver*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z())*
481 (vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() ) +
482 ANU*( -sinThetaAver*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z()) +
483 OMcosThetaAver*(vVPre.x()*AN2.
x()+vVPre.y()*AN2.
y()+vVPre.z()*AN2.
z()) -
484 TMSINT*gamma*(vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) );
485 transf[2][1] = sinpPostInv*transf[2][1];
486
487 transf[2][2] = cosThetaAver*(vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() ) +
488 sinThetaAver*(vHUPre.x()*vUPost.x()+vHUPre.y()*vUPost.y() ) +
489 OMcosThetaAver*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() )*
490 (vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() ) +
491 ANU*( -sinThetaAver*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() ) +
492 OMcosThetaAver*(vUPre.x()*AN2.
x()+vUPre.y()*AN2.
y() ) -
493 TMSINT*gamma*(vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) );
494 transf[2][2] = sinpPostInv*sinpPre*transf[2][2];
495
496 transf[2][3] = -QAver*ANU*(vUPre.x()*vpPostNorm.x()+vUPre.y()*vpPostNorm.y() )*sinpPostInv;
497#ifdef G4EVERBOSE
498 if(
iverbose >= 3)
G4cout <<
"ctransf23= " << transf[2][3] <<
" "<< -QAver<<
" "<<ANU<<
" "<<vUPre.x()<<
" "<<vpPostNorm.x()<<
" "<< vUPre.y()<<
" "<<vpPostNorm.y()<<
" "<<sinpPostInv<<
G4endl;
499#endif
500
501 transf[2][4] = -QAver*ANU*(vVPre.x()*vpPostNorm.x()+vVPre.y()*vpPostNorm.y()+vVPre.z()*vpPostNorm.z())*sinpPostInv;
502
503
504
505 transf[3][0] = pAver*(vUPost.x()*deltaPos.x()+vUPost.y()*deltaPos.y() )
506 *(1.+deltaPInv*pAver);
507#ifdef G4EVERBOSE
508 if(
iverbose >= 3)
G4cout <<
"ctransf30= " << transf[3][0] <<
" "<< pAver<<
" "<<vUPost.x()<<
" "<<deltaPos.x()<<
" "<<vUPost.y()<<
" "<<deltaPos.y()
509 <<
" "<<deltaPInv<<
" "<<pAver<<
G4endl;
510#endif
511
512 transf[3][1] = ( sinThetaAver*(vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() ) +
513 OMcosThetaAver*(vHVPre.x()*vUPost.x()+vHVPre.y()*vUPost.y() ) +
514 TMSINT*(vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() )*
515 (vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) )/QAver;
516
517 transf[3][2] = ( sinThetaAver*(vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() ) +
518 OMcosThetaAver*(vHUPre.x()*vUPost.x()+vHUPre.y()*vUPost.y() ) +
519 TMSINT*(vHAverNorm.x()*vUPost.x()+vHAverNorm.y()*vUPost.y() )*
520 (vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) )*sinpPre/QAver;
521#ifdef G4EVERBOSE
522 if(
iverbose >= 3)
G4cout <<
"ctransf32= " << transf[3][2] <<
" "<< sinThetaAver<<
" "<<vUPre.x()<<
" "<<vUPost.x()<<
" "<<vUPre.y()<<
" "<<vUPost.y() <<
" "<<
523 OMcosThetaAver<<" "<<vHUPre.x()<<" "<<vUPost.x()<<" "<<vHUPre.y()<<" "<<vUPost.y() <<" "<<
524 TMSINT<<" "<<vHAverNorm.x()<<" "<<vUPost.x()<<" "<<vHAverNorm.y()<<" "<<vUPost.y() <<" "<<
525 vHAverNorm.x()<<
" "<<vUPre.x()<<
" "<<vHAverNorm.y()<<
" "<<vUPre.y() <<
" "<<sinpPre<<
" "<<QAver<<
G4endl;
526#endif
527
528 transf[3][3] = (vUPre.x()*vUPost.x()+vUPre.y()*vUPost.y() );
529
530 transf[3][4] = (vVPre.x()*vUPost.x()+vVPre.y()*vUPost.y() );
531
532
533 transf[4][0] = pAver*(vVPost.x()*deltaPos.x()+vVPost.y()*deltaPos.y()+vVPost.z()*deltaPos.z())
534 *(1.+deltaPInv*pAver);
535
536 transf[4][1] = ( sinThetaAver*(vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z()) +
537 OMcosThetaAver*(vHVPre.x()*vVPost.x()+vHVPre.y()*vVPost.y()+vHVPre.z()*vVPost.z()) +
538 TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())*
539 (vHAverNorm.x()*vVPre.x()+vHAverNorm.y()*vVPre.y()+vHAverNorm.z()*vVPre.z()) )/QAver;
540#ifdef G4EVERBOSE
541 if(
iverbose >= 3)
G4cout <<
"ctransf41= " << transf[4][1] <<
" "<< sinThetaAver<<
" "<< OMcosThetaAver <<
" "<<TMSINT<<
" "<< vVPre <<
" "<<vVPost <<
" "<<vHVPre<<
" "<<vHAverNorm <<
" "<< QAver<<
G4endl;
542#endif
543
544 transf[4][2] = ( sinThetaAver*(vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() ) +
545 OMcosThetaAver*(vHUPre.x()*vVPost.x()+vHUPre.y()*vVPost.y()+vHUPre.z()*vVPost.z()) +
546 TMSINT*(vHAverNorm.x()*vVPost.x()+vHAverNorm.y()*vVPost.y()+vHAverNorm.z()*vVPost.z())*
547 (vHAverNorm.x()*vUPre.x()+vHAverNorm.y()*vUPre.y() ) )*sinpPre/QAver;
548
549 transf[4][3] = (vUPre.x()*vVPost.x()+vUPre.y()*vVPost.y() );
550
551 transf[4][4] = (vVPre.x()*vVPost.x()+vVPre.y()*vVPost.y()+vVPre.z()*vVPost.z());
552
553
554
555#ifdef G4EVERBOSE
557#endif
558
559
560
561
562
563
564 }
565 }
566
567
568
569
570
571
572
573
574
575
576 theTransfMat = transf;
577#ifdef G4EVERBOSE
580 <<
" transf matrix " << theTransfMat.
T() <<
G4endl;
581#endif
582
584
585#ifdef G4EVERBOSE
587#endif
588
589
590
591
592
593 PropagateErrorMSC( aTrack );
594
595 PropagateErrorIoni( aTrack );
596
597 return 0;
598}
const G4double kCarTolerance
@ 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