12 #include "Geant4/G4Track.hh" 13 #include "Geant4/G4ThreeVector.hh" 14 #include "Geant4/G4Step.hh" 15 #include "Geant4/G4StepPoint.hh" 24 fNoIncomingMuons(trkOption)
29 mf::LogWarning(
"G4BadIdeaAction") <<
"instantiating the G4BadIdeaAction \n" 30 <<
"This UserAction is only to be used with " 31 <<
"Geant4 v4.9.4.p02 to solve a stepping bug.\n" 32 <<
"If you are using a different version of G4, " 33 <<
"remove this UserAction from your list in LArG4.cxx";
53 const double epsilon = 5000. * std::numeric_limits<double>::epsilon();
54 const double stepSize = step->GetStepLength();
55 G4Track* nonConstTrack =
const_cast<G4Track*
>( step->GetTrack() );
57 if (step->GetTrack()->GetCurrentStepNumber() > 5e4
59 && (step->GetTrack()->GetCurrentStepNumber()%1000) == 1 ){
66 const double kick = 0.001;
68 G4ThreeVector aValue = nonConstTrack->GetPosition();
70 mf::LogWarning(
"G4BadIdeaAction") <<
"##### In endless loop. Kicking particle by " 71 <<
" (+0.001,+0.001,+0.001) --- " 72 <<
" PDG and encoding " 73 << step->GetTrack()->GetDynamicParticle()->GetPDGcode()
75 << step->GetTrack()->GetDynamicParticle()->GetParticleDefinition()->GetParticleName()
76 <<
" current step number: " 77 << step->GetTrack()->GetCurrentStepNumber()
78 <<
" stepsize: " << stepSize
80 << aValue.x() <<
" " << aValue.y() <<
" " << aValue.z();
85 nonConstTrack->SetPosition(aValue);
92 G4StepPoint * thePrePoint = step->GetPreStepPoint();
93 G4VPhysicalVolume * thePrePV = thePrePoint->GetPhysicalVolume();
94 G4String thePrePVname = thePrePV->GetName();
95 G4StepPoint * thePostPoint = step->GetPostStepPoint();
96 G4VPhysicalVolume * thePostPV = thePostPoint->GetPhysicalVolume();
98 if (thePostPV) thePostPVname = thePostPV->GetName();
100 if (abs(step->GetTrack()->GetDynamicParticle()->GetPDGcode()) == 13
101 && thePostPVname.contains(
"volTPCActive")
102 && !thePrePVname.contains(
"volTPCActive")
104 ((G4Track*)nonConstTrack)->SetTrackStatus(fStopAndKill);
this UserAction derived class is to implement catches to known bugs in Geant4 that require grabbing c...
std::string translate(errors::ErrorCodes)
virtual void SteppingAction(const G4Step *)
G4UserSteppingAction interface.
virtual ~G4BadIdeaAction()
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning