BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSDump.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 "BDSAcceleratorComponent.hh"
20#include "BDSColours.hh"
21#include "BDSDump.hh"
22#include "BDSExtent.hh"
23
24#include "globals.hh" // geant4 globals / types
25#include "G4Box.hh"
26#include "G4Colour.hh"
27#include "G4LogicalVolume.hh"
28#include "G4Tubs.hh"
29#include "G4UserLimits.hh"
30#include "G4VisAttributes.hh"
31
32#include "CLHEP/Units/SystemOfUnits.h"
33
34BDSDump::BDSDump(G4String nameIn,
35 G4double lengthIn,
36 G4double horizontalWidthIn,
37 G4bool circularIn):
38 BDSAcceleratorComponent(nameIn, lengthIn, 0, "dump"),
39 horizontalWidth(horizontalWidthIn),
40 circular(circularIn)
41{;}
42
43BDSDump::~BDSDump()
44{;}
45
47{
48 // default construction
50
51 // update container visualisation attributes
52 G4Colour* reallyreallydarkgrey = BDSColours::Instance()->GetColour("reallyreallydarkgrey");
53 G4VisAttributes* dumpVis = new G4VisAttributes(*reallyreallydarkgrey);
54 RegisterVisAttributes(dumpVis);
55 containerLogicalVolume->SetVisAttributes(dumpVis);
56}
57
59{
60 if (circular)
61 {
62 containerSolid = new G4Tubs(name + "_solid",
63 0,
64 0.5*horizontalWidth,
66 0,
67 CLHEP::twopi);
68 }
69 else
70 {
71 containerSolid = new G4Box(name + "_solid",
72 0.5*horizontalWidth,
73 0.5*horizontalWidth,
75 }
76
77 containerLogicalVolume = new G4LogicalVolume(containerSolid,
79 name + "_lv");
80
81 BDSExtent ext(0.5*horizontalWidth, 0.5*horizontalWidth, 0.5*chordLength);
82 SetExtent(ext);
83}
84
86{
87 userLimits = new G4UserLimits(1, // max 1mm step into dump
88 0, // max track length
89 0, // max time
90 0, // max kinetic energy
91 std::numeric_limits<double>::max());
92
94}
Abstract class that represents a component of an accelerator.
G4UserLimits * userLimits
Cache of user limits.
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 BDSColours * Instance()
singleton pattern
Definition: BDSColours.cc:33
G4Colour * GetColour(const G4String &type, G4bool normaliseTo255=true)
Get colour from name.
Definition: BDSColours.cc:204
BDSDump()=delete
No default constructor.
virtual void BuildContainerLogicalVolume() override
Build a simple box or cylinder.
Definition: BDSDump.cc:58
virtual void Build() override
Call default build then override visualisation attributes.
Definition: BDSDump.cc:46
virtual void BuildUserLimits() override
Customised user limits.
Definition: BDSDump.cc:85
Holder for +- extents in 3 dimensions.
Definition: BDSExtent.hh:39
void RegisterUserLimits(G4UserLimits *userLimit)
void SetExtent(const BDSExtent &extIn)
Set extent.
void RegisterVisAttributes(G4VisAttributes *visAttribute)