BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSTerminatorUserLimits.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) BDSIM Collaboration, 2001 - 2026.
3
4This file is part of BDSIM.
5
6BDSIM is free software: you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published
8by the Free Software Foundation version 3 of the License.
9
10BDSIM is distributed in the hope that it will be useful, but
11WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
17*/
18#include "BDSDebug.hh"
19#include "BDSGlobalConstants.hh"
20#include "BDSTerminatorUserLimits.hh"
21
22#include "globals.hh" // geant4 types / globals
23#include "G4UserLimits.hh"
24
25#include <limits>
26
28 G4double utrakMax,
29 G4double utimeMax,
30 G4double uekinMin,
31 G4double urangMin):
32 G4UserLimits(ustepMax,
33 utrakMax,
34 utimeMax,
35 uekinMin,
36 urangMin),
37 keeprunningEK(0.0),
38 stoprunningEK(std::numeric_limits<double>::max()),
39 turnsToTake(BDSGlobalConstants::Instance()->TurnsToTake())
40{}
41
43 G4double ustepMax,
44 G4double utrakMax,
45 G4double utimeMax,
46 G4double uekinMin,
47 G4double urangMin):
48 G4UserLimits(type,
49 ustepMax,
50 utrakMax,
51 utimeMax,
52 uekinMin,
53 urangMin),
54 keeprunningEK(0.0),
55 stoprunningEK(std::numeric_limits<double>::max()),
56 turnsToTake(BDSGlobalConstants::Instance()->TurnsToTake())
57{}
58
59inline G4double BDSTerminatorUserLimits::GetUserMinEkine(const G4Track& /*trk*/)
60{
61 // does the number of turns passed == number of turns to take
62 G4int turnsTaken = BDSGlobalConstants::Instance()->TurnsTaken();
63#ifdef BDSDEBUG
64 G4cout << __METHOD_NAME__ << "turns taken : " << turnsTaken << G4endl;
65#endif
66 if (turnsTaken >= turnsToTake)
67 {
68#ifdef BDSDEBUG
69 G4cout << __METHOD_NAME__ << "Requested number of turns completed - stopping all particles" << G4endl;
70#endif
71 return stoprunningEK;
72 } // yes - stop: return DBL_MAX eV so no particles will be tracked
73 else
74 {
75 return keeprunningEK;
76 } // no - keep going: return 0 eV so all are tracked
77}
78
79
A class that holds global options and constants.
static BDSGlobalConstants * Instance()
Access method.
virtual G4double GetUserMinEkine(const G4Track &)
G4double keeprunningEK
Minimum energy particle must have to keep going.
G4double stoprunningEK
Same, so everything < DBL_MAX so everything stopped.
BDSTerminatorUserLimits(G4double ustepMax=std::numeric_limits< double >::max(), G4double utrakMax=std::numeric_limits< double >::max(), G4double utimeMax=std::numeric_limits< double >::max(), G4double uekinMin=0., G4double urangMin=0.)
STL namespace.