LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
larg4::G4BadIdeaAction Class Reference

#include "G4BadIdeaAction.h"

Inheritance diagram for larg4::G4BadIdeaAction:
g4b::UserAction

Public Member Functions

 G4BadIdeaAction (int)
 
virtual ~G4BadIdeaAction ()
 
virtual void SteppingAction (const G4Step *)
 G4UserSteppingAction interface. More...
 
virtual void Config (fhicl::ParameterSet const &)
 Override Config() to extract any necessary parameters. More...
 
virtual void PrintConfig (std::string const &)
 Override PrintConfig() to print out current configuration. More...
 
virtual void BeginOfRunAction (const G4Run *)
 G4UserRunAction interfaces. More...
 
virtual void EndOfRunAction (const G4Run *)
 
virtual void BeginOfEventAction (const G4Event *)
 G4UserEventAction interfaces. More...
 
virtual void EndOfEventAction (const G4Event *)
 
virtual void PreTrackingAction (const G4Track *)
 G4UserTrackingAction interfaces. More...
 
virtual void PostTrackingAction (const G4Track *)
 
virtual bool ProvidesStacking ()
 
virtual G4ClassificationOfNewTrack StackClassifyNewTrack (const G4Track *)
 G4UserStackingAction interfaces. More...
 
virtual void StackNewStage ()
 
virtual void StackPrepareNewEvent ()
 
std::string const & GetName () const
 
void SetName (std::string const &name)
 

Private Attributes

art::ServiceHandle< geo::Geometry const > fGeo
 
int fNoIncomingMuons
 

Detailed Description

Definition at line 29 of file G4BadIdeaAction.h.

Constructor & Destructor Documentation

larg4::G4BadIdeaAction::G4BadIdeaAction ( int  trkOption)

Definition at line 21 of file G4BadIdeaAction.cxx.

21  : fNoIncomingMuons(trkOption)
22  {
23  // trkOption comes from LArG4's fSmartStacking
24  // Negative values effect action in this routine. Positive values
25  // effect action in LArStackingAction.
26  mf::LogWarning("G4BadIdeaAction") << "instantiating the G4BadIdeaAction \n"
27  << "This UserAction is only to be used with "
28  << "Geant4 v4.9.4.p02 to solve a stepping bug.\n"
29  << "If you are using a different version of G4, "
30  << "remove this UserAction from your list in LArG4.cxx";
31  }
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
larg4::G4BadIdeaAction::~G4BadIdeaAction ( )
virtual

Definition at line 35 of file G4BadIdeaAction.cxx.

35 {}

Member Function Documentation

virtual void g4b::UserAction::BeginOfEventAction ( const G4Event *  )
inlinevirtualinherited

G4UserEventAction interfaces.

Reimplemented in larg4::ParticleListAction, larg4::VisualizationAction, and altns::ExampleAction.

Definition at line 78 of file UserAction.h.

78 {};
virtual void g4b::UserAction::BeginOfRunAction ( const G4Run *  )
inlinevirtualinherited

G4UserRunAction interfaces.

The following a list of methods that correspond to the available user action classes in Geant 4.0.1 and higher.

Reimplemented in larg4::VisualizationAction.

Definition at line 74 of file UserAction.h.

74 {};
virtual void g4b::UserAction::Config ( fhicl::ParameterSet const &  )
inlinevirtualinherited

Override Config() to extract any necessary parameters.

Reimplemented in altns::ExampleAction.

Definition at line 65 of file UserAction.h.

Referenced by g4b::UserAction::UserAction().

65 {};
virtual void g4b::UserAction::EndOfEventAction ( const G4Event *  )
inlinevirtualinherited

Reimplemented in larg4::ParticleListAction, larg4::VisualizationAction, and altns::ExampleAction.

Definition at line 79 of file UserAction.h.

79 {};
virtual void g4b::UserAction::EndOfRunAction ( const G4Run *  )
inlinevirtualinherited

Reimplemented in larg4::VisualizationAction.

Definition at line 75 of file UserAction.h.

75 {};
std::string const& g4b::UserAction::GetName ( ) const
inlineinherited

Definition at line 98 of file UserAction.h.

References g4b::UserAction::myName.

Referenced by g4b::UserActionManager::PrintActionList().

98 { return myName; }
std::string myName
self-knowledge
Definition: UserAction.h:101
virtual void g4b::UserAction::PostTrackingAction ( const G4Track *  )
inlinevirtualinherited

Reimplemented in larg4::ParticleListAction, and altns::ExampleAction.

Definition at line 83 of file UserAction.h.

83 {};
virtual void g4b::UserAction::PreTrackingAction ( const G4Track *  )
inlinevirtualinherited

G4UserTrackingAction interfaces.

Reimplemented in larg4::ParticleListAction, and altns::ExampleAction.

Definition at line 82 of file UserAction.h.

82 {};
virtual void g4b::UserAction::PrintConfig ( std::string const &  )
inlinevirtualinherited

Override PrintConfig() to print out current configuration.

Reimplemented in altns::ExampleAction.

Definition at line 68 of file UserAction.h.

Referenced by g4b::UserActionManager::PrintActionList().

68 {};
virtual bool g4b::UserAction::ProvidesStacking ( )
inlinevirtualinherited

Does this UserAction do stacking? Override to return "true" if the following interfaces are implemented

Reimplemented in altns::ExampleAction.

Definition at line 90 of file UserAction.h.

Referenced by g4b::UserActionManager::PrintActionList().

90 { return false; }
void g4b::UserAction::SetName ( std::string const &  name)
inlineinherited

Definition at line 99 of file UserAction.h.

References g4b::UserAction::myName.

Referenced by g4b::UserActionFactory::GetUserAction().

99 { myName = name; }
std::string myName
self-knowledge
Definition: UserAction.h:101
virtual G4ClassificationOfNewTrack g4b::UserAction::StackClassifyNewTrack ( const G4Track *  )
inlinevirtualinherited

G4UserStackingAction interfaces.

Reimplemented in altns::ExampleAction.

Definition at line 93 of file UserAction.h.

93 { return fUrgent; }
virtual void g4b::UserAction::StackNewStage ( )
inlinevirtualinherited

Reimplemented in altns::ExampleAction.

Definition at line 94 of file UserAction.h.

94 {};
virtual void g4b::UserAction::StackPrepareNewEvent ( )
inlinevirtualinherited

Reimplemented in altns::ExampleAction.

Definition at line 95 of file UserAction.h.

95 {};
void larg4::G4BadIdeaAction::SteppingAction ( const G4Step *  )
virtual

G4UserSteppingAction interface.

Todo:
Do not copy the code below. Contact Brian Rebel, Eric Church,
Todo:
Bill Seligman and Andrzej Szelc for reasons why not to!

Reimplemented from g4b::UserAction.

Definition at line 39 of file G4BadIdeaAction.cxx.

References util::abs(), fNoIncomingMuons, and art::ExceptionDetail::translate().

40  {
45 
46  // If the step size is such that the particle appears to be "stuck"
47  // in its trajectory, give it a kick.
48  const double epsilon = 5000. * std::numeric_limits<double>::epsilon();
49  const double stepSize = step->GetStepLength();
50  G4Track* nonConstTrack = const_cast<G4Track*>(step->GetTrack());
51 
52  if (step->GetTrack()->GetCurrentStepNumber() > 5e4 && stepSize < epsilon &&
53  (step->GetTrack()->GetCurrentStepNumber() % 1000) == 1) {
54 
55  // Cast away the const-ness of the pointer to G4Step.
56  // This is dangerous. Don't do this at home. We're
57  // only doing this because we're desperate.
58  // The need to do this is the result of a bug in Geant4 v4.9.4.p02
59  // We should no longer call this code when we move beyond that version
60  const double kick = 0.001;
61 
62  G4ThreeVector aValue = nonConstTrack->GetPosition();
63 
64  mf::LogWarning("G4BadIdeaAction")
65  << "##### In endless loop. Kicking particle by "
66  << " (+0.001,+0.001,+0.001) --- "
67  << " PDG and encoding " << step->GetTrack()->GetDynamicParticle()->GetPDGcode() << " "
68  << step->GetTrack()->GetDynamicParticle()->GetParticleDefinition()->GetParticleName()
69  << " current step number: " << step->GetTrack()->GetCurrentStepNumber()
70  << " stepsize: " << stepSize << " x,y,z " << aValue.x() << " " << aValue.y() << " "
71  << aValue.z();
72 
73  G4ThreeVector translate(kick, kick, kick);
74  aValue += translate;
75 
76  nonConstTrack->SetPosition(aValue);
77  }
78 
79  if (fNoIncomingMuons < 0) {
80  // This is for overlays of, say, rock muons, which we have
81  G4StepPoint* thePrePoint = step->GetPreStepPoint();
82  G4VPhysicalVolume* thePrePV = thePrePoint->GetPhysicalVolume();
83  G4String thePrePVname = thePrePV->GetName();
84  G4StepPoint* thePostPoint = step->GetPostStepPoint();
85  G4VPhysicalVolume* thePostPV = thePostPoint->GetPhysicalVolume();
86  G4String thePostPVname("null");
87  if (thePostPV) thePostPVname = thePostPV->GetName();
88 
89  if (abs(step->GetTrack()->GetDynamicParticle()->GetPDGcode()) == 13 &&
90  thePostPVname.contains("volTPCActive") && !thePrePVname.contains("volTPCActive"))
91  ((G4Track*)nonConstTrack)->SetTrackStatus(fStopAndKill);
92  }
93 
94  return;
95  }
constexpr auto abs(T v)
Returns the absolute value of the argument.
std::string translate(errors::ErrorCodes)
Definition: Exception.cc:18
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning

Member Data Documentation

art::ServiceHandle<geo::Geometry const> larg4::G4BadIdeaAction::fGeo
private

Definition at line 40 of file G4BadIdeaAction.h.

int larg4::G4BadIdeaAction::fNoIncomingMuons
private

Definition at line 41 of file G4BadIdeaAction.h.

Referenced by SteppingAction().


The documentation for this class was generated from the following files: