All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
larg4::G4BadIdeaAction Class Reference

#include <G4BadIdeaAction.h>

Inheritance diagram for larg4::G4BadIdeaAction:

Public Member Functions

 G4BadIdeaAction (int)
 
virtual ~G4BadIdeaAction ()
 
virtual void SteppingAction (const G4Step *)
 

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  :
22  fNoIncomingMuons(trkOption)
23  {
24  // trkOption comes from LArG4's fSmartStacking
25  // Negative values effect action in this routine. Positive values
26  // effect action in LArStackingAction.
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";
32  }
larg4::G4BadIdeaAction::~G4BadIdeaAction ( )
virtual

Definition at line 36 of file G4BadIdeaAction.cxx.

37  {
38  }

Member Function Documentation

void larg4::G4BadIdeaAction::SteppingAction ( const G4Step *  step)
virtual
Todo:
Do not copy the code below. Contact Brian Rebel, Eric Church,
Todo:
Bill Seligman and Andrzej Szelc for reasons why not to!

Definition at line 42 of file G4BadIdeaAction.cxx.

43  {
44  ////////////////////////////////////////////////////////////////////
45  ///\todo Do not copy the code below. Contact Brian Rebel, Eric Church,
46  ///\todo Bill Seligman and Andrzej Szelc for reasons why not to!
47  ////////////////////////////////////////////////////////////////////////
48 
49  // If the step size is such that the particle appears to be "stuck"
50  // in its trajectory, give it a kick.
51  const double epsilon = 5000. * std::numeric_limits<double>::epsilon();
52  const double stepSize = step->GetStepLength();
53  G4Track* nonConstTrack = const_cast<G4Track*>( step->GetTrack() );
54 
55  if (step->GetTrack()->GetCurrentStepNumber() > 5e4
56  && stepSize < epsilon
57  && (step->GetTrack()->GetCurrentStepNumber()%1000) == 1 ){
58 
59  // Cast away the const-ness of the pointer to G4Step.
60  // This is dangerous. Don't do this at home. We're
61  // only doing this because we're desperate.
62  // The need to do this is the result of a bug in Geant4 v4.9.4.p02
63  // We should no longer call this code when we move beyond that version
64  const double kick = 0.001;
65 
66  G4ThreeVector aValue = nonConstTrack->GetPosition();
67 
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()
72  << " "
73  << step->GetTrack()->GetDynamicParticle()->GetParticleDefinition()->GetParticleName()
74  << " current step number: "
75  << step->GetTrack()->GetCurrentStepNumber()
76  << " stepsize: " << stepSize
77  << " x,y,z "
78  << aValue.x() << " " << aValue.y() << " " << aValue.z();
79 
80  G4ThreeVector translate(kick,kick,kick);
81  aValue+=translate;
82 
83  nonConstTrack->SetPosition(aValue);
84  }
85 
86 
87  if (fNoIncomingMuons<0)
88  {
89  // This is for overlays of, say, rock muons, which we have
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();
97 
98  if (abs(step->GetTrack()->GetDynamicParticle()->GetPDGcode()) == 13
99  && thePostPVname.contains("volTPCActive")
100  && !thePrePVname.contains("volTPCActive")
101  )
102  ((G4Track*)nonConstTrack)->SetTrackStatus(fStopAndKill);
103  }
104 
105  return;
106  }
T abs(T value)

Member Data Documentation

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

Definition at line 42 of file G4BadIdeaAction.h.

int larg4::G4BadIdeaAction::fNoIncomingMuons
private

Definition at line 43 of file G4BadIdeaAction.h.


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