8 #include "G4FieldTrack.hh"
9 #include "G4FieldTrackUpdator.hh"
10 #include "G4LogicalVolumeStore.hh"
11 #include "G4Navigator.hh"
12 #include "G4PVPlacement.hh"
13 #include "G4PathFinder.hh"
14 #include "G4TransportationManager.hh"
17 const std::string&
name,
29 delete mapPair.second->GetNavigatorForPropagating();
30 delete mapPair.second;
33 return StatusCode::SUCCESS;
37 ATH_MSG_INFO(
"Initializing G4PropagatorInField for thread "
38 << G4Threading::G4GetThreadId());
45 G4Exception(
"G4CaloTransportTool",
"FailedToGetWorldVolume",
47 "G4CaloTransportTool: Failed to get world volume.");
53 ATH_MSG_INFO(
"Maximum allowed number of steps in particle transport: "
64 ATH_MSG_ERROR(
"G4CaloTransportTool::initializePropagator() Propagator already initialized!");
67 return StatusCode::SUCCESS;
74 ATH_MSG_INFO(
"Creating simplified world volume for particle transport");
76 G4LogicalVolume* logVol = G4LogicalVolumeStore::GetInstance()->GetVolume(
80 return new G4PVPlacement(
82 G4ThreeVector(0, 0, 0),
84 "simplifiedWorldPhysVol",
91 ATH_MSG_INFO(
"Using full geometry for particle transport");
92 return G4TransportationManager::GetTransportationManager()
93 ->GetNavigatorForTracking()
100 G4Navigator* navigator =
new G4Navigator();
104 G4FieldManager* fieldMgr =
105 G4TransportationManager::GetTransportationManager()->GetFieldManager();
107 G4PropagatorInField* propagator =
108 new G4PropagatorInField(navigator, fieldMgr);
117 auto navigator = propagator->GetNavigatorForPropagating();
119 G4double retSafety = -1.0;
120 G4double currentMinimumStep = 10.0 *
CLHEP::m;
122 G4VPhysicalVolume* currentPhysVol =
123 navigator->LocateGlobalPointAndSetup(fieldTrack.GetPosition(),
nullptr);
125 G4ThreeVector direction = fieldTrack.GetMomentumDirection();
127 navigator->LocateGlobalPointAndSetup(fieldTrack.GetPosition(), &direction);
129 if (fieldTrack.GetCharge() == 0) {
133 G4double stepLength = navigator->ComputeStep(
134 fieldTrack.GetPosition(), fieldTrack.GetMomentumDirection(),
135 currentMinimumStep, retSafety);
138 fieldTrack.SetPosition(fieldTrack.GetPosition() +
140 fieldTrack.GetMomentumDirection().unit());
144 propagator->ComputeStep(fieldTrack, currentMinimumStep, retSafety,
152 const G4Track& G4InputTrack) {
158 std::vector<G4FieldTrack> outputStepVector;
160 G4FieldTrack tmpFieldTrack(
'0');
161 G4FieldTrackUpdator::Update(&tmpFieldTrack, &G4InputTrack);
163 outputStepVector.push_back(tmpFieldTrack);
166 for (
unsigned int iStep = 0; iStep <
m_maxSteps; iStep++) {
170 outputStepVector.push_back(tmpFieldTrack);
172 auto volumn = navigator->LocateGlobalPointAndSetup(tmpFieldTrack.GetPosition(),
nullptr);
173 if (volumn !=
nullptr) {
174 std::string volName = volumn->GetName();
180 description <<
"at step " << iStep <<
"/" <<
m_maxSteps.value() <<
" with position " << tmpFieldTrack.GetPosition() <<
" and momentum " << tmpFieldTrack.GetMomentum();
181 G4Exception(
"G4CaloTransportTool::transport",
182 "Cannot get LocateGlobalPointAndSetup",
188 return outputStepVector;