BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSMagnetOuter.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 "BDSGeometryComponent.hh"
20#include "BDSGeometryExternal.hh"
21#include "BDSMagnetOuter.hh"
22#include "BDSSimpleComponent.hh"
23
24#include "G4ThreeVector.hh"
25
26BDSMagnetOuter::BDSMagnetOuter(G4VSolid* containerSolidIn,
27 G4LogicalVolume* containerLVIn,
28 const BDSExtent& extentIn,
29 BDSGeometryComponent* magnetContainerIn,
30 const G4ThreeVector& placementOffsetIn,
31 BDSSimpleComponent* endPieceBeforeIn,
32 BDSSimpleComponent* endPieceAfterIn,
33 const G4ThreeVector& inputFaceNormalIn,
34 const G4ThreeVector& outputFaceNormalIn):
35 BDSGeometryComponent(containerSolidIn, containerLVIn, extentIn, BDSExtent(),
36 placementOffsetIn),
37 magnetContainer(magnetContainerIn),
38 endPieceBefore(endPieceBeforeIn),
39 endPieceAfter(endPieceAfterIn),
40 inputFaceNormal(inputFaceNormalIn),
41 outputFaceNormal(outputFaceNormalIn),
42 externalGeometry(nullptr)
43{;}
44
45BDSMagnetOuter::BDSMagnetOuter(BDSGeometryComponent* componentIn,
46 BDSGeometryComponent* magnetContainerIn,
47 BDSSimpleComponent* endPieceBeforeIn,
48 BDSSimpleComponent* endPieceAfterIn,
49 const G4ThreeVector& inputFaceNormalIn,
50 const G4ThreeVector& outputFaceNormalIn):
51 BDSGeometryComponent(*componentIn),
52 magnetContainer(magnetContainerIn),
53 endPieceBefore(endPieceBeforeIn),
54 endPieceAfter(endPieceAfterIn),
55 inputFaceNormal(inputFaceNormalIn),
56 outputFaceNormal(outputFaceNormalIn),
57 externalGeometry(nullptr)
58{;}
59
60BDSMagnetOuter::BDSMagnetOuter(BDSGeometryExternal* external,
61 BDSGeometryComponent* magnetContainerIn):
62 BDSGeometryComponent(*(static_cast<BDSGeometryComponent*>(external))),
63 magnetContainer(magnetContainerIn),
64 endPieceBefore(nullptr),
65 endPieceAfter(nullptr),
66 inputFaceNormal(G4ThreeVector(0,0,-1)),
67 outputFaceNormal(G4ThreeVector(0,0,1)),
68 externalGeometry(external)
69{;}
70
71BDSMagnetOuter::~BDSMagnetOuter()
72{
75}
76
78{
79 if (magnetContainer)
80 {
81 delete magnetContainer;
82 magnetContainer = nullptr;
83 }
84}
85
87{
88 if (endPieceAfter && (endPieceAfter != endPieceBefore))
89 {delete endPieceAfter; endPieceAfter = nullptr;}
90 if (endPieceBefore)
91 {delete endPieceBefore; endPieceBefore = nullptr;}
92}
93
94void BDSMagnetOuter::SetInputFaceNormal(const G4ThreeVector& input)
95{
96 inputFaceNormal = input;
97 if (endPieceBefore)
98 {endPieceBefore->SetInputFaceNormal(input);}
99}
100
101void BDSMagnetOuter::SetOutputFaceNormal(const G4ThreeVector& output)
102{
103 outputFaceNormal = output;
104 if (endPieceAfter)
105 {endPieceBefore->SetInputFaceNormal(output);}
106}
virtual void SetInputFaceNormal(const G4ThreeVector &input)
Allow updating of face normals. Virtual so derived class may apply it to daughters.
Holder for +- extents in 3 dimensions.
Definition: BDSExtent.hh:39
A generic geometry component for a bdsim model.
A loaded piece of externally provided geometry.
void ClearMagnetContainer()
Clear the memory of the now unneeded magnet container object.
void ClearEndPieces()
Clear the memory of the possibly unneeded end piece objects.
void SetInputFaceNormal(const G4ThreeVector &input)
Setter for face normals.
void SetOutputFaceNormal(const G4ThreeVector &output)
Setter for face normals.
A BDSAcceleratorComponent wrapper for BDSGeometryComponent.