BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSCollimatorRectangular.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 "BDSCollimatorRectangular.hh"
20
21#include "globals.hh"
22#include "G4Box.hh"
23#include "G4Trd.hh"
24
26 G4double lengthIn,
27 G4double horizontalWidthIn,
28 G4Material* collimatorMaterialIn,
29 G4Material* vacuumMaterialIn,
30 G4double xApertureIn,
31 G4double yApertureIn,
32 G4double xApertureOutIn,
33 G4double yApertureOutIn,
34 G4Colour* colourIn,
35 G4bool circularOuterIn):
36 BDSCollimator(nameIn, lengthIn, horizontalWidthIn, "rcol",
37 collimatorMaterialIn, vacuumMaterialIn, xApertureIn,
38 yApertureIn, xApertureOutIn, yApertureOutIn, colourIn, circularOuterIn)
39{;}
40
42{
43 if (tapered)
44 {
45 // Make subtracted volume longer than the solid volume by extrapolating
46 // linear gradient along 1% of the length of the element. May break down
47 // in the case of extreme gradients for really short collimators.
48 G4double xGradient = (xApertureOut - xAperture) / chordLength;
49 G4double yGradient = (yApertureOut - yAperture) / chordLength;
50
51 G4double deltam = 0.01 * chordLength; // +ve z here
52 G4double deltax = xGradient * deltam;
53 G4double deltay = yGradient * deltam;
54
55 // sign in front of deltax -> +ve for +ve z from centre, -ve for -ve x from centre
56 innerSolid = new G4Trd(name + "_inner_solid", // name
57 xAperture - deltax, // X entrance half length
58 xApertureOut + deltax, // X exit half length
59 yAperture - deltay, // Y entrance half length
60 yApertureOut + deltay, // Y exit half length
61 (chordLength + 2*deltam) * 0.5); // Z half length
62
63 vacuumSolid = new G4Trd(name + "_vacuum_solid", // name
64 xAperture - lengthSafetyLarge, // X entrance half length
65 xApertureOut - lengthSafetyLarge, // X exit half length
66 yAperture - lengthSafetyLarge, // Y entrance half length
67 yApertureOut - lengthSafetyLarge, // Y exit half length
68 chordLength*0.5 - lengthSafetyLarge); // Z half length
69 }
70 else
71 {
72 innerSolid = new G4Box(name + "_inner_solid", // name
73 xAperture, // x half width
74 yAperture, // y half width
75 chordLength); // z half length
76 // z half length long for unambiguous subtraction
77
78 vacuumSolid = new G4Box(name + "_vacuum_solid", // name
79 xAperture - lengthSafety, // x half width
80 yAperture - lengthSafety, // y half width
81 chordLength*0.5); // z half length
82 }
83
86}
const G4String name
Const protected member variable that may not be changed by derived classes.
static G4double lengthSafety
Useful variable often used in construction.
G4double chordLength
Protected member variable that can be modified by derived classes.
BDSCollimatorRectangular()
Private default constructor to force the use of the supplied one.
Base class for collimators with common construction.
G4double xAperture
Aperture at entrance in x dimension.
G4bool tapered
Flag for tapered collimator.
G4double yApertureOut
Aperture at exit in y dimension.
G4VSolid * innerSolid
Geometrical objects:
G4double xApertureOut
Aperture at exit in x dimension.
G4VSolid * vacuumSolid
Geometrical objects:
G4double yAperture
Aperture at entrance in y dimension.
void RegisterSolid(G4VSolid *solid)