12 #include <simulation/kernel/ExtMagFieldLimitProcess.h>
13 #include <G4TransportationManager.hh>
14 #include <G4FieldManager.hh>
17 #include <G4ForceCondition.hh>
19 #include <framework/logging/Logger.h>
23 using namespace Belle2::Simulation;
25 ExtMagFieldLimitProcess::ExtMagFieldLimitProcess(
const G4String& processName) :
26 G4VDiscreteProcess(processName),
27 m_stepLimit(kInfinity)
29 m_field = G4TransportationManager::GetTransportationManager()->GetFieldManager()->GetDetectorField();
33 G4ForceCondition* condition =
nullptr;
54 *condition = NotForced;
55 G4double stepLength = kInfinity;
57 G4ThreeVector trkPosi = aTrack.GetPosition();
58 G4double pos1[3] = { trkPosi.x(), trkPosi.y(), trkPosi.z() };
59 G4double h1[3] = { 0.0, 0.0, 0.0 };
60 m_field->GetFieldValue(pos1, h1);
61 G4ThreeVector BVec(h1[0], h1[1], h1[2]);
62 G4double pmag = aTrack.GetMomentum().mag();
63 G4double BPerpMom = BVec.cross(aTrack.GetMomentum()).mag() / pmag;
64 if (BPerpMom != 0.0) {
67 B2DEBUG(300,
"ExtMagFieldLimitProcess::PostStepGetPhysicalInteractionLength() stepLength "
68 << stepLength <<
" B " << BPerpMom <<
" BVec " << BVec <<
" pmag " << pmag);
75 aParticleChange.Initialize(track);
76 return &aParticleChange;