224{
228 stepLengthCm *= -1.;
229
232
234 return 0;
235
236#ifdef G4EVERBOSE
238 G4cout <<
" G4ErrorFreeTrajState::PropagateError " <<
G4endl;
240#endif
241
242
245
246
249
250 if(vpPre.
mag() == vpPre.
z())
251 vpPre.
setX(1.E-6 * MeV);
252 if(vpPost.
mag() == vpPost.
z())
253 vpPost.
setX(1.E-6 * MeV);
254
257#ifdef G4EVERBOSE
259 {
260 G4cout <<
"G4EP: vposPre " << vposPre <<
G4endl <<
"G4EP: vposPost "
262 G4cout <<
"G4EP: vpPre " << vpPre <<
G4endl <<
"G4EP: vpPost " << vpPost
265 G4cout <<
"G4EP: stepLengthCm " << stepLengthCm <<
G4endl;
266 }
267#endif
268
269 if(pPre == 0. || pPost == 0)
270 return 2;
273 G4double deltaPInv = pInvPost - pInvPre;
275 G4cout <<
"G4EP: pInvPre" << pInvPre <<
" pInvPost:" << pInvPost
276 <<
" deltaPInv:" << deltaPInv <<
G4endl;
277
281 G4cout <<
"G4EP: vpPreNorm " << vpPreNorm <<
" vpPostNorm " << vpPostNorm
283
285 return 4;
287 return 4;
289 std::sin(vpPreNorm.
theta());
291 std::sin(vpPostNorm.
theta());
293
294#ifdef G4EVERBOSE
296 G4cout <<
"G4EP: cosl " << sinpPre <<
" cosl0 " << sinpPost <<
G4endl;
297#endif
298
299
301
302 transf[3][2] = stepLengthCm * sinpPost;
303 transf[4][1] = stepLengthCm;
304 for(auto ii = 0; ii < 5; ++ii)
305 {
306 transf[ii][ii] = 1.;
307 }
308#ifdef G4EVERBOSE
310 {
311 G4cout <<
"G4EP: transf matrix neutral " << transf;
312 }
313#endif
314
315
319 {
320 charge *= -1.;
321 }
322
323
324
325
326
327
328
329
331 pos1[0] = vposPre.
x() * cm;
332 pos1[1] = vposPre.
y() * cm;
333 pos1[2] = vposPre.
z() * cm;
335 pos2[0] = vposPost.
x() * cm;
336 pos2[1] = vposPost.
y() * cm;
337 pos2[2] = vposPost.
z() * cm;
339
343 if(!field)
344 return 0;
345
346
347 if(charge != 0. && field)
348 {
350 h1);
354 10.;
358#ifdef G4EVERBOSE
360 {
361 G4cout <<
"G4EP: h1 = " << h1[0] <<
", " << h1[1] <<
", " << h1[2]
363 G4cout <<
"G4EP: pos1/mm = " << pos1[0] <<
", " << pos1[1] <<
", "
365 G4cout <<
"G4EP: pos2/mm = " << pos2[0] <<
", " << pos2[1] <<
", "
367 G4cout <<
"G4EP: B-filed in KGauss HPre " << HPre <<
G4endl
368 <<
"G4EP: in KGauss HPost " << HPost <<
G4endl;
369 }
370#endif
371
372 if(magHPre + magHPost != 0.)
373 {
374
376 if(magHPost != 0.)
377 {
378 gam = HPost * vpPostNorm / magHPost;
379 }
380 else
381 {
382 gam = HPre * vpPreNorm / magHPre;
383 }
384
385
386
388 G4double diffHSqr = (HPre * pInvPre - HPost * pInvPost).mag2();
390#ifdef G4EVERBOSE
392 {
393 G4cout <<
" G4EP: gam " <<
gam <<
" alphaSqr " << alphaSqr
394 <<
" diffHSqr " << diffHSqr <<
G4endl;
396 }
397#endif
398 if(diffHSqr * alphaSqr > delhp6Sqr)
399 return 3;
400
401
402 G4double pInvAver = 1. / (pInvPre + pInvPost);
404
405 G4ThreeVector vHAverNorm((HPre * pInvPre + HPost * pInvPost) * pInvAver *
406 charge * CFACT8);
409 vHAverNorm *= invHAver;
410#ifdef G4EVERBOSE
412 G4cout <<
" G4EP: HaverNorm " << vHAverNorm <<
" magHAver " << HAver
413 <<
" charge " << charge <<
G4endl;
414#endif
415
416 G4double pAver = (pPre + pPost) * 0.5;
418 G4double thetaAver = QAver * stepLengthCm;
419 G4double sinThetaAver = std::sin(thetaAver);
420 G4double cosThetaAver = std::cos(thetaAver);
421 G4double gamma = vHAverNorm * vpPostNorm;
423
424#ifdef G4EVERBOSE
426 G4cout <<
" G4EP: AN2 " << AN2 <<
" gamma:" << gamma
427 <<
" theta=" << thetaAver <<
G4endl;
428#endif
430
432 G4ThreeVector vVPre(-vpPreNorm.
z() * vUPre.y(), vpPreNorm.
z() * vUPre.x(),
433 vpPreNorm.
x() * vUPre.y() -
434 vpPreNorm.
y() * vUPre.x());
435
436
437 AU = 1. / vpPostNorm.perp();
438
439
440 G4ThreeVector vUPost(-AU * vpPostNorm.y(), AU * vpPostNorm.x(), 0.);
442 -vpPostNorm.z() * vUPost.y(), vpPostNorm.z() * vUPost.x(),
443 vpPostNorm.x() * vUPost.y() - vpPostNorm.y() * vUPost.x());
444#ifdef G4EVERBOSE
447 G4cout <<
" G4EP: AU " << AU <<
" vUPre " << vUPre <<
" vVPre " << vVPre
448 <<
" vUPost " << vUPost <<
" vVPost " << vVPost <<
G4endl;
449#endif
451
452
453
454
455
457#ifdef G4EVERBOSE
459 G4cout <<
" G4EP: QP " << QP <<
" QAver " << QAver <<
" pAver " << pAver
461#endif
463 -(vHAverNorm.x() * vUPost.x() + vHAverNorm.y() * vUPost.y());
465 (vHAverNorm.x() * vVPost.x() + vHAverNorm.y() * vVPost.y() +
466 vHAverNorm.z() * vVPost.z());
467 G4double OMcosThetaAver = 1. - cosThetaAver;
468#ifdef G4EVERBOSE
470 G4cout <<
"G4EP: OMcosThetaAver " << OMcosThetaAver <<
" cosThetaAver "
471 << cosThetaAver << " thetaAver " << thetaAver << " QAver "
472 << QAver <<
" stepLengthCm " << stepLengthCm <<
G4endl;
473#endif
474 G4double TMSINT = thetaAver - sinThetaAver;
475#ifdef G4EVERBOSE
477 G4cout <<
" G4EP: ANV " << ANV <<
" ANU " << ANU <<
G4endl;
478#endif
479
481 -vHAverNorm.z() * vUPre.y(), vHAverNorm.z() * vUPre.x(),
482 vHAverNorm.x() * vUPre.y() - vHAverNorm.y() * vUPre.x());
483#ifdef G4EVERBOSE
484
485
486#endif
488 vHAverNorm.y() * vVPre.z() - vHAverNorm.z() * vVPre.y(),
489 vHAverNorm.z() * vVPre.x() - vHAverNorm.x() * vVPre.z(),
490 vHAverNorm.x() * vVPre.y() - vHAverNorm.y() * vVPre.x());
491#ifdef G4EVERBOSE
493 G4cout <<
" G4EP: HUPre " << vHUPre <<
" HVPre " << vHVPre <<
G4endl;
494#endif
495
496
497
498
499 transf[0][0] =
500 1. -
501 deltaPInv * pAver *
502 (1. + (vpPostNorm.x() * deltaPos.x() + vpPostNorm.y() * deltaPos.y() +
503 vpPostNorm.z() * deltaPos.z()) /
504 stepLengthCm) +
505 2. * deltaPInv * pAver;
506
507 transf[0][1] =
508 -deltaPInv / thetaAver *
509 (TMSINT * gamma *
510 (vHAverNorm.x() * vVPre.x() + vHAverNorm.y() * vVPre.y() +
511 vHAverNorm.z() * vVPre.z()) +
512 sinThetaAver *
513 (vVPre.x() * vpPostNorm.x() + vVPre.y() * vpPostNorm.y() +
514 vVPre.z() * vpPostNorm.z()) +
515 OMcosThetaAver *
516 (vHVPre.x() * vpPostNorm.x() + vHVPre.y() * vpPostNorm.y() +
517 vHVPre.z() * vpPostNorm.z()));
518
519 transf[0][2] =
520 -sinpPre * deltaPInv / thetaAver *
521 (TMSINT * gamma *
522 (vHAverNorm.x() * vUPre.x() + vHAverNorm.y() * vUPre.y()) +
523 sinThetaAver *
524 (vUPre.x() * vpPostNorm.x() + vUPre.y() * vpPostNorm.y()) +
525 OMcosThetaAver *
526 (vHUPre.x() * vpPostNorm.x() + vHUPre.y() * vpPostNorm.y() +
527 vHUPre.z() * vpPostNorm.z()));
528
529 transf[0][3] = -deltaPInv / stepLengthCm *
530 (vUPre.x() * vpPostNorm.x() + vUPre.y() * vpPostNorm.y());
531
532 transf[0][4] = -deltaPInv / stepLengthCm *
533 (vVPre.x() * vpPostNorm.x() + vVPre.y() * vpPostNorm.y() +
534 vVPre.z() * vpPostNorm.z());
535
536
537 transf[1][0] =
538 -QP * ANV *
539 (vpPostNorm.x() * deltaPos.x() + vpPostNorm.y() * deltaPos.y() +
540 vpPostNorm.z() * deltaPos.z()) *
541 (1. + deltaPInv * pAver);
542#ifdef G4EVERBOSE
544 G4cout <<
"ctransf10= " << transf[1][0] <<
" " << -QP <<
" " << ANV
545 << " " << vpPostNorm.x() << " " << deltaPos.x() << " "
546 << vpPostNorm.y() << " " << deltaPos.y() << " " << vpPostNorm.z()
547 << " " << deltaPos.z() << " " << deltaPInv << " " << pAver
549#endif
550
551 transf[1][1] =
552 cosThetaAver * (vVPre.x() * vVPost.x() + vVPre.y() * vVPost.y() +
553 vVPre.z() * vVPost.z()) +
554 sinThetaAver * (vHVPre.x() * vVPost.x() + vHVPre.y() * vVPost.y() +
555 vHVPre.z() * vVPost.z()) +
556 OMcosThetaAver *
557 (vHAverNorm.x() * vVPre.x() + vHAverNorm.y() * vVPre.y() +
558 vHAverNorm.z() * vVPre.z()) *
559 (vHAverNorm.x() * vVPost.x() + vHAverNorm.y() * vVPost.y() +
560 vHAverNorm.z() * vVPost.z()) +
561 ANV * (-sinThetaAver *
562 (vVPre.x() * vpPostNorm.x() + vVPre.y() * vpPostNorm.y() +
563 vVPre.z() * vpPostNorm.z()) +
564 OMcosThetaAver * (vVPre.x() * AN2.
x() + vVPre.y() * AN2.
y() +
565 vVPre.z() * AN2.
z()) -
566 TMSINT * gamma *
567 (vHAverNorm.x() * vVPre.x() + vHAverNorm.y() * vVPre.y() +
568 vHAverNorm.z() * vVPre.z()));
569
570 transf[1][2] =
571 cosThetaAver * (vUPre.x() * vVPost.x() + vUPre.y() * vVPost.y()) +
572 sinThetaAver * (vHUPre.x() * vVPost.x() + vHUPre.y() * vVPost.y() +
573 vHUPre.z() * vVPost.z()) +
574 OMcosThetaAver *
575 (vHAverNorm.x() * vUPre.x() + vHAverNorm.y() * vUPre.y()) *
576 (vHAverNorm.x() * vVPost.x() + vHAverNorm.y() * vVPost.y() +
577 vHAverNorm.z() * vVPost.z()) +
578 ANV * (-sinThetaAver *
579 (vUPre.x() * vpPostNorm.x() + vUPre.y() * vpPostNorm.y()) +
580 OMcosThetaAver * (vUPre.x() * AN2.
x() + vUPre.y() * AN2.
y()) -
581 TMSINT * gamma *
582 (vHAverNorm.x() * vUPre.x() + vHAverNorm.y() * vUPre.y()));
583 transf[1][2] = sinpPre * transf[1][2];
584
585 transf[1][3] = -QAver * ANV *
586 (vUPre.x() * vpPostNorm.x() + vUPre.y() * vpPostNorm.y());
587
588 transf[1][4] = -QAver * ANV *
589 (vVPre.x() * vpPostNorm.x() + vVPre.y() * vpPostNorm.y() +
590 vVPre.z() * vpPostNorm.z());
591
592
593
594 transf[2][0] =
595 -QP * ANU *
596 (vpPostNorm.x() * deltaPos.x() + vpPostNorm.y() * deltaPos.y() +
597 vpPostNorm.z() * deltaPos.z()) *
598 sinpPostInv * (1. + deltaPInv * pAver);
599#ifdef G4EVERBOSE
601 G4cout <<
"ctransf20= " << transf[2][0] <<
" " << -QP <<
" " << ANU
602 << " " << vpPostNorm.x() << " " << deltaPos.x() << " "
603 << vpPostNorm.y() << " " << deltaPos.y() << " " << vpPostNorm.z()
604 << " " << deltaPos.z() << " " << sinpPostInv << " " << deltaPInv
605 <<
" " << pAver <<
G4endl;
606#endif
607 transf[2][1] =
608 cosThetaAver * (vVPre.x() * vUPost.x() + vVPre.y() * vUPost.y()) +
609 sinThetaAver * (vHVPre.x() * vUPost.x() + vHVPre.y() * vUPost.y()) +
610 OMcosThetaAver *
611 (vHAverNorm.x() * vVPre.x() + vHAverNorm.y() * vVPre.y() +
612 vHAverNorm.z() * vVPre.z()) *
613 (vHAverNorm.x() * vUPost.x() + vHAverNorm.y() * vUPost.y()) +
614 ANU * (-sinThetaAver *
615 (vVPre.x() * vpPostNorm.x() + vVPre.y() * vpPostNorm.y() +
616 vVPre.z() * vpPostNorm.z()) +
617 OMcosThetaAver * (vVPre.x() * AN2.
x() + vVPre.y() * AN2.
y() +
618 vVPre.z() * AN2.
z()) -
619 TMSINT * gamma *
620 (vHAverNorm.x() * vVPre.x() + vHAverNorm.y() * vVPre.y() +
621 vHAverNorm.z() * vVPre.z()));
622 transf[2][1] = sinpPostInv * transf[2][1];
623
624 transf[2][2] =
625 cosThetaAver * (vUPre.x() * vUPost.x() + vUPre.y() * vUPost.y()) +
626 sinThetaAver * (vHUPre.x() * vUPost.x() + vHUPre.y() * vUPost.y()) +
627 OMcosThetaAver *
628 (vHAverNorm.x() * vUPre.x() + vHAverNorm.y() * vUPre.y()) *
629 (vHAverNorm.x() * vUPost.x() + vHAverNorm.y() * vUPost.y()) +
630 ANU * (-sinThetaAver *
631 (vUPre.x() * vpPostNorm.x() + vUPre.y() * vpPostNorm.y()) +
632 OMcosThetaAver * (vUPre.x() * AN2.
x() + vUPre.y() * AN2.
y()) -
633 TMSINT * gamma *
634 (vHAverNorm.x() * vUPre.x() + vHAverNorm.y() * vUPre.y()));
635 transf[2][2] = sinpPostInv * sinpPre * transf[2][2];
636
637 transf[2][3] = -QAver * ANU *
638 (vUPre.x() * vpPostNorm.x() + vUPre.y() * vpPostNorm.y()) *
639 sinpPostInv;
640#ifdef G4EVERBOSE
642 G4cout <<
"ctransf23= " << transf[2][3] <<
" " << -QAver <<
" " << ANU
643 << " " << vUPre.x() << " " << vpPostNorm.x() << " " << vUPre.y()
644 <<
" " << vpPostNorm.y() <<
" " << sinpPostInv <<
G4endl;
645#endif
646
647 transf[2][4] = -QAver * ANU *
648 (vVPre.x() * vpPostNorm.x() + vVPre.y() * vpPostNorm.y() +
649 vVPre.z() * vpPostNorm.z()) *
650 sinpPostInv;
651
652
653
654 transf[3][0] = pAver *
655 (vUPost.x() * deltaPos.x() + vUPost.y() * deltaPos.y()) *
656 (1. + deltaPInv * pAver);
657#ifdef G4EVERBOSE
659 G4cout <<
"ctransf30= " << transf[3][0] <<
" " << pAver <<
" "
660 << vUPost.x() << " " << deltaPos.x() << " " << vUPost.y() << " "
661 << deltaPos.y() <<
" " << deltaPInv <<
" " << pAver <<
G4endl;
662#endif
663
664 transf[3][1] =
665 (sinThetaAver * (vVPre.x() * vUPost.x() + vVPre.y() * vUPost.y()) +
666 OMcosThetaAver * (vHVPre.x() * vUPost.x() + vHVPre.y() * vUPost.y()) +
667 TMSINT * (vHAverNorm.x() * vUPost.x() + vHAverNorm.y() * vUPost.y()) *
668 (vHAverNorm.x() * vVPre.x() + vHAverNorm.y() * vVPre.y() +
669 vHAverNorm.z() * vVPre.z())) /
670 QAver;
671
672 transf[3][2] =
673 (sinThetaAver * (vUPre.x() * vUPost.x() + vUPre.y() * vUPost.y()) +
674 OMcosThetaAver * (vHUPre.x() * vUPost.x() + vHUPre.y() * vUPost.y()) +
675 TMSINT * (vHAverNorm.x() * vUPost.x() + vHAverNorm.y() * vUPost.y()) *
676 (vHAverNorm.x() * vUPre.x() + vHAverNorm.y() * vUPre.y())) *
677 sinpPre / QAver;
678#ifdef G4EVERBOSE
680 G4cout <<
"ctransf32= " << transf[3][2] <<
" " << sinThetaAver <<
" "
681 << vUPre.x() << " " << vUPost.x() << " " << vUPre.y() << " "
682 << vUPost.y() << " " << OMcosThetaAver << " " << vHUPre.x()
683 << " " << vUPost.x() << " " << vHUPre.y() << " " << vUPost.y()
684 << " " << TMSINT << " " << vHAverNorm.x() << " " << vUPost.x()
685 << " " << vHAverNorm.y() << " " << vUPost.y() << " "
686 << vHAverNorm.x() << " " << vUPre.x() << " " << vHAverNorm.y()
687 <<
" " << vUPre.y() <<
" " << sinpPre <<
" " << QAver <<
G4endl;
688#endif
689
690 transf[3][3] = (vUPre.x() * vUPost.x() + vUPre.y() * vUPost.y());
691
692 transf[3][4] = (vVPre.x() * vUPost.x() + vVPre.y() * vUPost.y());
693
694
695 transf[4][0] = pAver *
696 (vVPost.x() * deltaPos.x() + vVPost.y() * deltaPos.y() +
697 vVPost.z() * deltaPos.z()) *
698 (1. + deltaPInv * pAver);
699
700 transf[4][1] =
701 (sinThetaAver * (vVPre.x() * vVPost.x() + vVPre.y() * vVPost.y() +
702 vVPre.z() * vVPost.z()) +
703 OMcosThetaAver * (vHVPre.x() * vVPost.x() + vHVPre.y() * vVPost.y() +
704 vHVPre.z() * vVPost.z()) +
705 TMSINT *
706 (vHAverNorm.x() * vVPost.x() + vHAverNorm.y() * vVPost.y() +
707 vHAverNorm.z() * vVPost.z()) *
708 (vHAverNorm.x() * vVPre.x() + vHAverNorm.y() * vVPre.y() +
709 vHAverNorm.z() * vVPre.z())) /
710 QAver;
711#ifdef G4EVERBOSE
713 G4cout <<
"ctransf41= " << transf[4][1] <<
" " << sinThetaAver <<
" "
714 << OMcosThetaAver << " " << TMSINT << " " << vVPre << " "
715 << vVPost << " " << vHVPre << " " << vHAverNorm << " " << QAver
717#endif
718
719 transf[4][2] =
720 (sinThetaAver * (vUPre.x() * vVPost.x() + vUPre.y() * vVPost.y()) +
721 OMcosThetaAver * (vHUPre.x() * vVPost.x() + vHUPre.y() * vVPost.y() +
722 vHUPre.z() * vVPost.z()) +
723 TMSINT *
724 (vHAverNorm.x() * vVPost.x() + vHAverNorm.y() * vVPost.y() +
725 vHAverNorm.z() * vVPost.z()) *
726 (vHAverNorm.x() * vUPre.x() + vHAverNorm.y() * vUPre.y())) *
727 sinpPre / QAver;
728
729 transf[4][3] = (vUPre.x() * vVPost.x() + vUPre.y() * vVPost.y());
730
731 transf[4][4] = (vVPre.x() * vVPost.x() + vVPre.y() * vVPost.y() +
732 vVPre.z() * vVPost.z());
733
734
735
736
737#ifdef G4EVERBOSE
739 G4cout <<
"G4EP: transf matrix computed " << transf <<
G4endl;
740#endif
741
742
743
744
745
746
747 }
748 }
749
750
751
752
753
754
755
756
757
758
759
760 theTransfMat = transf;
761#ifdef G4EVERBOSE
766 <<
" transf matrix " << theTransfMat.
T() <<
G4endl;
767#endif
768
770
771#ifdef G4EVERBOSE
774#endif
775
776
777
778
779
780
781 PropagateErrorMSC(aTrack);
782
783 PropagateErrorIoni(aTrack);
784
785 return 0;
786}
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