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) 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 "BDSCollimatorRectangular.hh"
19
20#include "globals.hh"
21#include "G4Box.hh"
22#include "G4Trd.hh"
23
25 G4double lengthIn,
26 G4double horizontalWidthIn,
27 G4Material* collimatorMaterialIn,
28 G4Material* vacuumMaterialIn,
29 G4double xApertureIn,
30 G4double yApertureIn,
31 G4double xApertureOutIn,
32 G4double yApertureOutIn,
33 G4Colour* colourIn,
34 G4bool circularOuterIn):
35 BDSCollimator(nameIn, lengthIn, horizontalWidthIn, "rcol",
36 collimatorMaterialIn, vacuumMaterialIn, xApertureIn,
37 yApertureIn, xApertureOutIn, yApertureOutIn, colourIn, circularOuterIn)
38{;}
39
41{
42 if (tapered)
43 {
44 // Make subtracted volume longer than the solid volume by extrapolating
45 // linear gradient along 1% of the length of the element. May break down
46 // in the case of extreme gradients for really short collimators.
47 G4double xGradient = (xApertureOut - xAperture) / chordLength;
48 G4double yGradient = (yApertureOut - yAperture) / chordLength;
49
50 G4double deltam = 0.01 * chordLength; // +ve z here
51 G4double deltax = xGradient * deltam;
52 G4double deltay = yGradient * deltam;
53
54 // sign in front of deltax -> +ve for +ve z from centre, -ve for -ve x from centre
55 innerSolid = new G4Trd(name + "_inner_solid", // name
56 xAperture - deltax, // X entrance half length
57 xApertureOut + deltax, // X exit half length
58 yAperture - deltay, // Y entrance half length
59 yApertureOut + deltay, // Y exit half length
60 (chordLength + 2*deltam) * 0.5); // Z half length
61
62 vacuumSolid = new G4Trd(name + "_vacuum_solid", // name
63 xAperture - lengthSafetyLarge, // X entrance half length
64 xApertureOut - lengthSafetyLarge, // X exit half length
65 yAperture - lengthSafetyLarge, // Y entrance half length
66 yApertureOut - lengthSafetyLarge, // Y exit half length
67 chordLength*0.5 - lengthSafetyLarge); // Z half length
68 }
69 else
70 {
71 innerSolid = new G4Box(name + "_inner_solid", // name
72 xAperture, // x half width
73 yAperture, // y half width
74 chordLength); // z half length
75 // z half length long for unambiguous subtraction
76
77 vacuumSolid = new G4Box(name + "_vacuum_solid", // name
78 xAperture - lengthSafety, // x half width
79 yAperture - lengthSafety, // y half width
80 chordLength*0.5); // z half length
81 }
82
85}
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)