BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSBeamPipeFactoryRaceTrack.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 "BDSBeamPipeFactoryRaceTrack.hh"
19#include "BDSBeamPipeFactoryPoints.hh"
20#include "BDSDebug.hh"
21
22#include "globals.hh" // geant4 globals / types
23#include "G4TwoVector.hh"
24
25#include <cmath>
26
27BDSBeamPipeFactoryRaceTrack::BDSBeamPipeFactoryRaceTrack()
28{;}
29
30void BDSBeamPipeFactoryRaceTrack::GenerateRaceTrack(std::vector<G4TwoVector>& vec,
31 G4double x,
32 G4double y,
33 G4double r,
34 G4int pointsPerTwoPi)
35{
36 G4int pointsPerCurve = pointsPerTwoPi / 4;
37 AppendAngle(vec, 0, 0.5*CLHEP::pi, r, pointsPerCurve, x, y);
38 AppendPoint(vec, x+r, y);
39 AppendAngle(vec, 0.5*CLHEP::pi, CLHEP::pi, r, pointsPerCurve, x, -y);
40 AppendPoint(vec, x, -y-r);
41 AppendAngle(vec, CLHEP::pi, (3./2.)*CLHEP::pi, r, pointsPerCurve, -x, -y);
42 AppendPoint(vec, -x-r, -y);
43 AppendAngle(vec, (3./2)*CLHEP::pi, CLHEP::twopi, r, pointsPerCurve, -x, y);
44 AppendPoint(vec, -x, y+r);
45}
46
47
49 G4double aper2,
50 G4double aper3,
51 G4double /*aper4*/,
52 G4double beamPipeThickness,
53 G4int pointsPerTwoPi)
54{
55 GenerateRaceTrack(vacuumEdge, aper1, aper2, aper3, pointsPerTwoPi);
56 G4double bpInner1 = aper1 + lengthSafetyLarge;
57 G4double bpInner2 = aper2 + lengthSafetyLarge;
58 G4double bpInner3 = aper3 + lengthSafetyLarge;
59 GenerateRaceTrack(beamPipeInnerEdge, bpInner1, bpInner2, bpInner3, pointsPerTwoPi);
60 G4double bpOuter1 = bpInner1 + beamPipeThickness;
61 G4double bpOuter2 = bpInner2 + beamPipeThickness;
62 G4double bpOuter3 = bpInner3 + beamPipeThickness;
63 GenerateRaceTrack(beamPipeOuterEdge, bpOuter1, bpOuter2, bpOuter3, pointsPerTwoPi);
64 G4double cont1 = bpOuter1 + lengthSafetyLarge;
65 G4double cont2 = bpOuter2 + lengthSafetyLarge;
66 G4double cont3 = bpOuter3 + lengthSafetyLarge;
67 GenerateRaceTrack(containerEdge, cont1, cont2, cont3, pointsPerTwoPi);
68 G4double contSub1 = cont1 + lengthSafetyLarge;
69 G4double contSub2 = cont2 + lengthSafetyLarge;
70 G4double contSub3 = cont3 + lengthSafetyLarge;
71 GenerateRaceTrack(containerSubtractionEdge, contSub1, contSub2, contSub3, pointsPerTwoPi);
72
73 extentX = contSub1 + contSub3;
74 extentY = contSub2 + contSub3;
75}
76
78 G4double aper2,
79 G4double aper3,
80 G4double /*aper4*/,
81 G4double beamPipeThickness)
82{
83 G4double result = std::hypot(aper1,aper2) + aper3 + beamPipeThickness;
84 result *= 1.5; // 50% margin
85#ifdef BDSDEBUG
86 G4cout << __METHOD_NAME__ << "intersection radius: " << result << G4endl;
87#endif
88 return result;
89}
std::vector< G4TwoVector > containerSubtractionEdge
Vector of x,y coordinates for the container subtraction volume.
std::vector< G4TwoVector > beamPipeInnerEdge
Vector of x,y coordinates for beam pipe inner edge.
G4double extentY
Extents prepared by GeneratePoints function as only it knows the extents.
G4double extentX
Extents prepared by GeneratePoints function as only it knows the extents.
std::vector< G4TwoVector > vacuumEdge
Vector of x,y coordinates for vacuum extruded solid edge.
void AppendAngle(std::vector< G4TwoVector > &vec, G4double startAngle, G4double finishAngle, G4double radius, G4int nPoints=10, G4double xOffset=0, G4double yOffset=0)
std::vector< G4TwoVector > containerEdge
Vector of x,y coordinates for the container volume.
std::vector< G4TwoVector > beamPipeOuterEdge
Vector of x,y coordinates for beam pipe outer edge.
virtual void GeneratePoints(G4double aper1, G4double aper2, G4double aper3, G4double aper4, G4double beamPipeThickness, G4int pointsPerTwoPi=40)
virtual G4double CalculateIntersectionRadius(G4double aper1, G4double aper2, G4double aper3, G4double aper4, G4double beamPipeThickness)
Calculate the radius of the solid used for intersection for angled faces.
G4double lengthSafetyLarge
Cache of global constants variable.