ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4UserActions
src
PhotonKiller.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
PhotonKiller.h
"
6
7
#include "G4Step.hh"
8
#include "G4Event.hh"
9
10
#include "G4Gamma.hh"
11
#include "G4RunManagerKernel.hh"
12
13
namespace
G4UA
14
{
15
16
//---------------------------------------------------------------------------
17
PhotonKiller::PhotonKiller
()
18
:
m_count
(0),
m_energy
(0)
19
{}
20
21
//---------------------------------------------------------------------------
22
void
PhotonKiller::PreUserTrackingAction
(
const
G4Track*)
23
{
24
// reset counters
25
m_count
=0;
26
m_energy
=0;
27
}
28
29
//---------------------------------------------------------------------------
30
void
PhotonKiller::UserSteppingAction
(
const
G4Step* aStep)
31
{
32
if
( fabs(
m_energy
-aStep->GetTrack()->GetKineticEnergy())<0.00001 ){
33
// same energy as last time
34
m_count
++;
35
}
else
{
36
m_count
=0;
37
m_energy
= aStep->GetTrack()->GetKineticEnergy();
38
return
;
39
}
40
41
if
(aStep->GetTrack()->GetKineticEnergy() < 0.0001){
// Less than one hundred eV
42
if
( (
m_count
>3 && aStep->GetTrack()->GetDefinition() == G4Gamma::Gamma() ) ||
43
(
m_count
>10000) ){
// more than three steps with less than one keV of energy...
44
// Drop the photon
45
aStep->GetTrack()->SetTrackStatus( fStopAndKill );
46
}
47
}
else
if
(
m_count
>1000000){
48
// Looper Killer functionality
49
aStep->GetTrack()->SetTrackStatus( fStopAndKill );
50
G4RunManagerKernel *rmk = G4RunManagerKernel::GetRunManagerKernel();
51
rmk->GetEventManager()->AbortCurrentEvent();
52
rmk->GetEventManager()->GetNonconstCurrentEvent()->SetEventAborted();
53
}
54
}
55
56
}
// namespace G4UA
PhotonKiller.h
G4UA::PhotonKiller::m_energy
float m_energy
Definition
PhotonKiller.h:24
G4UA::PhotonKiller::UserSteppingAction
virtual void UserSteppingAction(const G4Step *) override final
Definition
PhotonKiller.cxx:30
G4UA::PhotonKiller::PhotonKiller
PhotonKiller()
Definition
PhotonKiller.cxx:17
G4UA::PhotonKiller::PreUserTrackingAction
virtual void PreUserTrackingAction(const G4Track *) override final
Definition
PhotonKiller.cxx:22
G4UA::PhotonKiller::m_count
int m_count
Definition
PhotonKiller.h:23
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
Generated on
for ATLAS Offline Software by
1.17.0