aboutsummaryrefslogtreecommitdiffstats
path: root/src/G4BeamTestUserSteppingAction.cxx
diff options
context:
space:
mode:
Diffstat (limited to 'src/G4BeamTestUserSteppingAction.cxx')
-rw-r--r--src/G4BeamTestUserSteppingAction.cxx43
1 files changed, 40 insertions, 3 deletions
diff --git a/src/G4BeamTestUserSteppingAction.cxx b/src/G4BeamTestUserSteppingAction.cxx
index e064628..f81ab62 100644
--- a/src/G4BeamTestUserSteppingAction.cxx
+++ b/src/G4BeamTestUserSteppingAction.cxx
@@ -5,11 +5,26 @@
#include "G4LogicalVolume.hh"
#include "G4UserLimits.hh"
#include "G4SteppingManager.hh"
+#include "G4OpticalPhoton.hh"
+#include "G4RunManager.hh"
G4BeamTestUserSteppingAction::G4BeamTestUserSteppingAction(){}
-void G4BeamTestUserSteppingAction::UserSteppingAction(const G4Step*)
+void G4BeamTestUserSteppingAction::UserSteppingAction(const G4Step* step)
{
+ G4int eventNumber = G4RunManager::GetRunManager()->
+ GetCurrentEvent()->GetEventID();
+
+ if (eventNumber != fEventNumber) {
+ /* G4cout << " Number of Scintillation Photons in previous event: " */
+ /* << fScintillationCounter << G4endl; */
+ /* G4cout << " Number of Cerenkov Photons in previous event: " */
+ /* << fCerenkovCounter << G4endl; */
+ fEventNumber = eventNumber;
+ fScintillationCounter = 0;
+ fCerenkovCounter = 0;
+ }
+
G4Track* track = fpSteppingManager->GetTrack();
if(track)
{
@@ -18,11 +33,33 @@ void G4BeamTestUserSteppingAction::UserSteppingAction(const G4Step*)
if(!limit) G4cout << "----> G4LogicalVolume: " << volume->GetName() << " has no defined G4UserLimit" << G4endl;
G4double threshold = limit->GetUserMinEkine(*track);
//check if particle is a gamma
- if(track->GetDefinition()->GetParticleName() == "gamma")
+ G4String particle = track->GetDefinition()->GetParticleName();
+ /* G4cout << "particle = " << particle << G4endl; */
+ if(particle == "gamma")
{
//check if particle energy is below threshold; if true, kill the particle
G4double energy = track->GetTotalEnergy();
- if(energy < threshold) track->SetTrackStatus(fStopAndKill);
+ if(energy < threshold){
+ G4cout << "SteppingAction: killing particle " << particle << " with energy " << energy << " < " << threshold << G4endl;
+ track->SetTrackStatus(fStopAndKill);
+ }
}
}
+
+ const std::vector<const G4Track*>* secondaries =
+ step->GetSecondaryInCurrentStep();
+
+ if (secondaries->size()>0) {
+ for(unsigned int i=0; i<secondaries->size(); ++i) {
+ if (secondaries->at(i)->GetParentID()>0) {
+ if(secondaries->at(i)->GetDynamicParticle()->GetParticleDefinition()
+ == G4OpticalPhoton::OpticalPhotonDefinition()){
+ if (secondaries->at(i)->GetCreatorProcess()->GetProcessName()
+ == "Scintillation")fScintillationCounter++;
+ if (secondaries->at(i)->GetCreatorProcess()->GetProcessName()
+ == "Cerenkov")fCerenkovCounter++;
+ }
+ }
+ }
+ }
}