BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSTerminator.cc
1/*
2Beam Delivery Simulation (BDSIM) Copyright (C) Royal Holloway,
3University of London 2001 - 2023.
4
5This file is part of BDSIM.
6
7BDSIM is free software: you can redistribute it and/or modify
8it under the terms of the GNU General Public License as published
9by the Free Software Foundation version 3 of the License.
10
11BDSIM is distributed in the hope that it will be useful, but
12WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with BDSIM. If not, see <http://www.gnu.org/licenses/>.
18*/
19#include "BDSExtent.hh"
20#include "BDSGlobalConstants.hh"
21#include "BDSSamplerPlane.hh"
22#include "BDSSDManager.hh"
23#include "BDSTerminator.hh"
24#include "BDSSDTerminator.hh"
25#include "BDSTerminatorUserLimits.hh"
26
27#include "G4Box.hh"
28#include "G4LogicalVolume.hh"
29
30#include <limits>
31
32BDSTerminator::BDSTerminator(G4double horizontalWidthIn):
33 BDSAcceleratorComponent("terminator", BDSSamplerPlane::ChordLength(), 0, "terminator"),
34 horizontalWidth(horizontalWidthIn)
35{;}
36
37BDSTerminator::~BDSTerminator()
38{;}
39
41{
43}
44
46{
47 containerSolid = new G4Box(name + "_container_solid",
48 horizontalWidth * 0.5,
49 horizontalWidth * 0.5,
50 chordLength * 0.5);
51 containerLogicalVolume = new G4LogicalVolume(containerSolid,
53 name + "_container_lv");
54
55 // Make the terminator sensitive to count the turns of the primary particle
56 containerLogicalVolume->SetSensitiveDetector(BDSSDManager::Instance()->Terminator());
57
58 // Dynamic user limits - the logic of killing particles on last turn.
59 // The numerical values are the default G4UserLimit values so everything will
60 // normally be tracked. BDSTerminatorUserLimits has the logic inside it to
61 // respond to turn number.
62 BDSTerminatorUserLimits* termUL = new BDSTerminatorUserLimits(std::numeric_limits<double>::max(),
63 std::numeric_limits<double>::max(),
64 std::numeric_limits<double>::max(),
65 0.,0.);
66 RegisterUserLimits(termUL);
67 containerLogicalVolume->SetUserLimits(termUL);
68
69 // visual attributes
70 containerLogicalVolume->SetVisAttributes(containerVisAttr);
71
72 // register extents with BDSGeometryComponent base class
74}
Abstract class that represents a component of an accelerator.
const G4String name
Const protected member variable that may not be changed by derived classes.
static G4Material * emptyMaterial
Useful variable often used in construction.
G4double chordLength
Protected member variable that can be modified by derived classes.
static G4VisAttributes * containerVisAttr
Useful variable often used in construction.
Holder for +- extents in 3 dimensions.
Definition: BDSExtent.hh:39
void RegisterUserLimits(G4UserLimits *userLimit)
void SetExtent(const BDSExtent &extIn)
Set extent.
Rectangular sampler with fixed thickness but variable x,y.
Dynamic user limits for a volume that changed based on the parameter turnstaken in BDSGlobalConstants...
virtual void BuildContainerLogicalVolume()
G4double horizontalWidth
The terminator's full horizontal width.
virtual void Build()