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