aboutsummaryrefslogtreecommitdiffstats
path: root/src/G4BeamTestUserSteppingAction.cxx
blob: b16098cfb6f56e65e0038770aef1f5045f5c74ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
/**
 * Copyright (C) 2011
 * The IceCube collaboration
 * ID: $Id$
 *
 * @file G4BeamTestUserSteppingAction.cxx
 * @version $Revision$
 * @date $Date$
 * @author Thomas Melzig
 *
 * $LastChangedBy$
 */


#include <g4-tankresponse/g4classes/G4BeamTestUserSteppingAction.h>

#include "G4Step.hh"
#include "G4Track.hh"
#include "G4LogicalVolume.hh"
#include "G4UserLimits.hh"
#include "G4SteppingManager.hh"

G4BeamTestUserSteppingAction::G4BeamTestUserSteppingAction(){}

void G4BeamTestUserSteppingAction::UserSteppingAction(const G4Step*)
{
  G4Track* track = fpSteppingManager->GetTrack();
  if(track)
  {
    const G4LogicalVolume *volume = track->GetLogicalVolumeAtVertex();
    G4UserLimits *limit = volume->GetUserLimits();
    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")
    {
      //check if particle energy is below threshold; if true, kill the particle
      G4double energy = track->GetTotalEnergy();
      if(energy < threshold) track->SetTrackStatus(fStopAndKill);
    }
  }
}