BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSCollimatorElliptical.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 "BDSCollimatorElliptical.hh"
19#include "BDSDebug.hh"
20#include "BDSUtilities.hh"
21#include "BDSWarning.hh"
22
23#include "globals.hh" // geant4 globals / types
24#include "G4EllipticalTube.hh"
25#include "G4EllipticalCone.hh"
26#include "G4VSolid.hh"
27
29 G4double lengthIn,
30 G4double horizontalWidthIn,
31 G4Material* collimatorMaterialIn,
32 G4Material* vacuumMaterialIn,
33 G4double xApertureIn,
34 G4double yApertureIn,
35 G4double xApertureOutIn,
36 G4double yApertureOutIn,
37 G4Colour* colourIn,
38 G4bool circularOuterIn):
39 BDSCollimator(nameIn, lengthIn, horizontalWidthIn, "ecol",
40 collimatorMaterialIn, vacuumMaterialIn,
41 xApertureIn, yApertureIn, xApertureOutIn, yApertureOutIn, colourIn, circularOuterIn)
42{;}
43
45{
49 {
51 {BDS::Warning(__METHOD_NAME__, "element: \"" + name + "\": X/Y half axes ratio at entrance and exit apertures are not equal");}
52 }
53}
54
56{
57 if (tapered)
58 {
59 // we use the notes from G4EllipticalCone.hh
60 // 1. half length in Z = zTopCut
61 // 2. Dx and Dy = half length of ellipse axis at z = -zTopCut
62 // 3. dx and dy = half length of ellipse axis at z = zTopCut
63 // ! Attention : dx/dy=Dx/Dy
64 // xSemiAxis = (Dx-dx)/(2*zTopCut)
65 // ySemiAxis = (Dy-dy)/(2*zTopCut)
66 // z height = (Dx+dx)/(2*xSemiAxis)
67 G4double xSemiAxis = (xAperture - xApertureOut) / chordLength;
68 G4double ySemiAxis = (yAperture - yApertureOut) / chordLength;
69 G4double zHeight = (xAperture + xApertureOut) / (2*xSemiAxis);
70
71 innerSolid = new G4EllipticalCone(name + "_inner_solid", // name
72 xSemiAxis, // major axis of largest ellipse
73 ySemiAxis, // minor axis of largest ellipse
74 zHeight, // height of cone
75 1.02*chordLength*0.5); // cut
76
77 vacuumSolid = new G4EllipticalCone(name + "_vacuum_solid",// name
78 xSemiAxis, // major axis of largest ellipse
79 ySemiAxis, // minor axis of largest ellipse
80 zHeight, // height of cone
81 chordLength*0.5 - lengthSafety); // cut
82 }
83 else
84 {
85 innerSolid = new G4EllipticalTube(name + "_inner_solid", // name
86 xAperture, // x half width
87 yAperture, // y half width
88 chordLength); // z half length
89 // z half length long for unambiguous subtraction
90
91 vacuumSolid = new G4EllipticalTube(name + "_inner_solid", // name
92 xAperture - lengthSafety, // x half width
93 yAperture - lengthSafety, // y half width
94 chordLength * 0.5); // z half length
95 }
96
99}
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.
BDSCollimatorElliptical()
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:
virtual void CheckParameters()
G4double xApertureOut
Aperture at exit in x dimension.
G4VSolid * vacuumSolid
Geometrical objects:
G4double yAperture
Aperture at entrance in y dimension.
void RegisterSolid(G4VSolid *solid)
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())