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