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) 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 "BDSExtent.hh"
19#include "BDSGlobalConstants.hh"
20#include "BDSSamplerPlane.hh"
21#include "BDSSDManager.hh"
22#include "BDSTerminator.hh"
23#include "BDSSDTerminator.hh"
24#include "BDSTerminatorUserLimits.hh"
25
26#include "G4Box.hh"
27#include "G4LogicalVolume.hh"
28
29#include <limits>
30
31BDSTerminator::BDSTerminator(G4double horizontalWidthIn):
32 BDSAcceleratorComponent("terminator", BDSSamplerPlane::ChordLength(), 0, "terminator"),
33 horizontalWidth(horizontalWidthIn)
34{;}
35
36BDSTerminator::~BDSTerminator()
37{;}
38
43
45{
46 containerSolid = new G4Box(name + "_container_solid",
47 horizontalWidth * 0.5,
48 horizontalWidth * 0.5,
49 chordLength * 0.5);
50 containerLogicalVolume = new G4LogicalVolume(containerSolid,
52 name + "_container_lv");
53
54 // Make the terminator sensitive to count the turns of the primary particle
55 containerLogicalVolume->SetSensitiveDetector(BDSSDManager::Instance()->Terminator());
56
57 // Dynamic user limits - the logic of killing particles on last turn.
58 // The numerical values are the default G4UserLimit values so everything will
59 // normally be tracked. BDSTerminatorUserLimits has the logic inside it to
60 // respond to turn number.
61 BDSTerminatorUserLimits* termUL = new BDSTerminatorUserLimits(std::numeric_limits<double>::max(),
62 std::numeric_limits<double>::max(),
63 std::numeric_limits<double>::max(),
64 0.,0.);
65 RegisterUserLimits(termUL);
66 containerLogicalVolume->SetUserLimits(termUL);
67
68 // visual attributes
69 containerLogicalVolume->SetVisAttributes(containerVisAttr);
70
71 // register extents with BDSGeometryComponent base class
73}
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:38
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()