LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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::GeometryfGeo
 
int fNoIncomingMuons
 

Detailed Description

Definition at line 32 of file G4BadIdeaAction.h.

Constructor & Destructor Documentation

larg4::G4BadIdeaAction::G4BadIdeaAction ( int  trkOption)

Definition at line 23 of file G4BadIdeaAction.cxx.

23  :
24  fNoIncomingMuons(trkOption)
25  {
26  // trkOption comes from LArG4's fSmartStacking
27  // Negative values effect action in this routine. Positive values
28  // effect action in LArStackingAction.
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";
34  }
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning
larg4::G4BadIdeaAction::~G4BadIdeaAction ( )
virtual

Definition at line 38 of file G4BadIdeaAction.cxx.

39  {
40  }

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 44 of file G4BadIdeaAction.cxx.

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

45  {
50 
51  // If the step size is such that the particle appears to be "stuck"
52  // in its trajectory, give it a kick.
53  const double epsilon = 5000. * std::numeric_limits<double>::epsilon();
54  const double stepSize = step->GetStepLength();
55  G4Track* nonConstTrack = const_cast<G4Track*>( step->GetTrack() );
56 
57  if (step->GetTrack()->GetCurrentStepNumber() > 5e4
58  && stepSize < epsilon
59  && (step->GetTrack()->GetCurrentStepNumber()%1000) == 1 ){
60 
61  // Cast away the const-ness of the pointer to G4Step.
62  // This is dangerous. Don't do this at home. We're
63  // only doing this because we're desperate.
64  // The need to do this is the result of a bug in Geant4 v4.9.4.p02
65  // We should no longer call this code when we move beyond that version
66  const double kick = 0.001;
67 
68  G4ThreeVector aValue = nonConstTrack->GetPosition();
69 
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()
74  << " "
75  << step->GetTrack()->GetDynamicParticle()->GetParticleDefinition()->GetParticleName()
76  << " current step number: "
77  << step->GetTrack()->GetCurrentStepNumber()
78  << " stepsize: " << stepSize
79  << " x,y,z "
80  << aValue.x() << " " << aValue.y() << " " << aValue.z();
81 
82  G4ThreeVector translate(kick,kick,kick);
83  aValue+=translate;
84 
85  nonConstTrack->SetPosition(aValue);
86  }
87 
88 
89  if (fNoIncomingMuons<0)
90  {
91  // This is for overlays of, say, rock muons, which we have
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();
97  G4String thePostPVname("null");
98  if (thePostPV) thePostPVname = thePostPV->GetName();
99 
100  if (abs(step->GetTrack()->GetDynamicParticle()->GetPDGcode()) == 13
101  && thePostPVname.contains("volTPCActive")
102  && !thePrePVname.contains("volTPCActive")
103  )
104  ((G4Track*)nonConstTrack)->SetTrackStatus(fStopAndKill);
105  }
106 
107  return;
108  }
std::string translate(errors::ErrorCodes)
Definition: Exception.cc:18
MaybeLogger_< ELseverityLevel::ELsev_warning, false > LogWarning

Member Data Documentation

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

Definition at line 45 of file G4BadIdeaAction.h.

int larg4::G4BadIdeaAction::fNoIncomingMuons
private

Definition at line 46 of file G4BadIdeaAction.h.

Referenced by SteppingAction().


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