BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSShield.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 "BDSBeamPipe.hh"
19#include "BDSBeamPipeFactory.hh"
20#include "BDSBeamPipeInfo.hh"
21#include "BDSDebug.hh"
22#include "BDSSDType.hh"
23#include "BDSShield.hh"
24#include "BDSUtilities.hh"
25
26#include "globals.hh"
27#include "G4Box.hh"
28#include "G4LogicalVolume.hh"
29#include "G4SubtractionSolid.hh"
30#include "G4VisAttributes.hh"
31#include "G4PVPlacement.hh"
32
33class G4Colour;
34class G4Material;
35
36BDSShield::BDSShield(const G4String& nameIn,
37 G4double lengthIn,
38 G4double horizontalWidthIn,
39 G4double xSizeIn,
40 G4double ySizeIn,
41 G4Material* materialIn,
42 G4Colour* colourIn,
43 BDSBeamPipeInfo* beamPipeInfoIn):
44 BDSAcceleratorComponent(nameIn, lengthIn, 0, "shield", beamPipeInfoIn),
45 horizontalWidth(horizontalWidthIn),
46 xSize(xSizeIn),
47 ySize(ySizeIn),
48 material(materialIn),
49 colour(colourIn)
50{;}
51
52BDSShield::~BDSShield()
53{;}
54
61
63{
64 containerSolid = new G4Box(name + "_container_solid",
67 chordLength*0.5);
68 containerLogicalVolume = new G4LogicalVolume(containerSolid,
70 name + "_container_lv");
71}
72
74{
75 G4VSolid* outerSolid = new G4Box(name + "_outer_solid",
79 RegisterSolid(outerSolid);
80
81 G4VSolid* shieldSolid;
82 G4LogicalVolume* shieldLV;
83
84 // only subtract inner solid if shield aperture is finite.
86 {
87 G4VSolid* innerSolid = new G4Box(name + "_inner_solid",
88 xSize,
89 ySize,
90 chordLength); // extra long for unambiguous subtraction
91 RegisterSolid(innerSolid);
92
93 shieldSolid = new G4SubtractionSolid(name + "shield_solid",
94 outerSolid, // this
95 innerSolid); // minus this
96 RegisterSolid(shieldSolid);
97
98 shieldLV = new G4LogicalVolume(shieldSolid,
100 name+"_shield_lv");
101 }
102 else
103 {
104 shieldLV = new G4LogicalVolume(outerSolid,
105 material,
106 name+"_shield_lv");
107 }
108
109 RegisterLogicalVolume(shieldLV);
110 if (sensitiveOuter)
111 {RegisterSensitiveVolume(shieldLV, BDSSDType::energydep);}
112
113 G4VisAttributes* shieldVisAttr = new G4VisAttributes(*colour);
114 shieldVisAttr->SetVisibility(true);
115 shieldLV->SetVisAttributes(shieldVisAttr);
116 RegisterVisAttributes(shieldVisAttr);
117
118 G4PVPlacement* shieldPV = new G4PVPlacement(nullptr,
119 G4ThreeVector(),
120 shieldLV,
121 name + "_shield_pv",
122 containerLogicalVolume,
123 false,
124 0,
126
127 RegisterPhysicalVolume(shieldPV);
128}
129
131{
132 // check we should build a beam pipe
133 if (!beamPipeInfo)
134 {return;}
135
136 // check beam pipe fits
138 {
139 G4cout << __METHOD_NAME__ << "Shield will not fit around beam pipe - not building beam pipe!" << G4endl << G4endl;
140 return;
141 }
142
143 // construct and place beam pipe
144 auto bp = BDSBeamPipeFactory::Instance()->CreateBeamPipe(name,
148
149 G4PVPlacement* bpPV = new G4PVPlacement(nullptr,
150 G4ThreeVector(),
151 bp->GetContainerLogicalVolume(),
152 name+"_beampipe_pv",
153 containerLogicalVolume,
154 false,
155 0,
157
159}
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 G4bool sensitiveOuter
Useful variable often used in construction.
static G4double lengthSafety
Useful variable often used in construction.
static G4bool checkOverlaps
Useful variable often used in construction.
static G4Material * worldMaterial
Useful variable often used in construction.
G4double chordLength
Protected member variable that can be modified by derived classes.
BDSBeamPipeInfo * beamPipeInfo
Optional beam pipe recipe that is written out to the survey if it exists.
static BDSBeamPipeFactory * Instance()
Singleton accessor.
Holder class for all information required to describe a beam pipe model.
G4double aper1
Public member for direct access.
G4double beamPipeThickness
Public member for direct access.
G4double aper2
Public member for direct access.
void RegisterDaughter(BDSGeometryComponent *anotherComponent)
void RegisterLogicalVolume(G4LogicalVolume *logicalVolume)
void RegisterPhysicalVolume(G4VPhysicalVolume *physicalVolume)
void RegisterVisAttributes(G4VisAttributes *visAttribute)
void RegisterSolid(G4VSolid *solid)
void RegisterSensitiveVolume(G4LogicalVolume *sensitiveVolume, BDSSDType sensitivityType)
void BuildBeamPipe()
Build a beam pipe in the hole if required.
Definition BDSShield.cc:130
virtual void Build()
Definition BDSShield.cc:55
void BuildShield()
Build the outer shield geoemtry.
Definition BDSShield.cc:73
BDSShield()=delete
Default constructor, assignment and copy constructor not used.
G4double horizontalWidth
Outer size of shield.
Definition BDSShield.hh:72
G4Material * material
Shield material.
Definition BDSShield.hh:75
G4double ySize
Inner vertical half width of shield.
Definition BDSShield.hh:74
G4Colour * colour
Colour of shielding block.
Definition BDSShield.hh:76
G4double xSize
Inner horizontal half width of shield.
Definition BDSShield.hh:73
virtual void BuildContainerLogicalVolume()
Build a container volume for everything.
Definition BDSShield.cc:62
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())