BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSBeamPipe.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 "BDSBeamPipe.hh"
19#include "BDSUtilities.hh"
20
21#include "globals.hh" // geant4 globals / types
22#include "G4VSolid.hh"
23
24BDSBeamPipe::BDSBeamPipe(G4VSolid* containerSolidIn,
25 G4LogicalVolume* containerLVIn,
26 BDSExtent extentIn,
27 G4VSolid* containerSubtractionSolidIn,
28 G4LogicalVolume* vacuumLVIn,
29 G4bool containerIsCircularIn,
30 G4double containerRadiusIn,
31 G4ThreeVector inputFaceNormalIn,
32 G4ThreeVector outputFaceNormalIn):
33 BDSGeometryComponent(containerSolidIn, containerLVIn, extentIn),
34 containerSubtractionSolid(containerSubtractionSolidIn),
35 vacuumLogicalVolume(vacuumLVIn),
36 containerIsCircular(containerIsCircularIn),
37 containerRadius(containerRadiusIn),
38 inputFaceNormal(inputFaceNormalIn.unit()),
39 outputFaceNormal(outputFaceNormalIn.unit())
40{;}
41
42BDSBeamPipe::~BDSBeamPipe()
43{
44 // we leak containerSubtractionSolid as it's slow to delete lots
45 // of them because of g4 deregistering them - g4 will clean up
46 //delete containerSubtractionSolid;
47}
48
49std::set<G4LogicalVolume*> BDSBeamPipe::GetVolumesForField() const
50{
51 std::set<G4LogicalVolume*> result = GetAllLogicalVolumes(); // from base class
52 // We avoid setting the field on a tight-fitting container volume to avoid strong
53 // field in small gaps. However, in the case of only a container volume, we should
54 // return that - for when there's no beam pipe geometry.
55 if (result.size() > 1)
56 {result.erase(GetContainerLogicalVolume());}
57 else if (!BDS::IsFinite((G4double)result.size()))
58 {result = {GetContainerLogicalVolume()};}
59
60 return result;
61}
BDSBeamPipe(G4VSolid *containerSolidIn, G4LogicalVolume *containerLVIn, BDSExtent extentIn, G4VSolid *containerSubtractionSolidIn, G4LogicalVolume *vacuumLVIn, G4bool containerIsCircularIn=false, G4double containerRadiusIn=0.0, G4ThreeVector inputFaceNormalIn=G4ThreeVector(0, 0,-1), G4ThreeVector outputFaceNormalIn=G4ThreeVector(0, 0, 1))
std::set< G4LogicalVolume * > GetVolumesForField() const
Holder for +- extents in 3 dimensions.
Definition BDSExtent.hh:38
A generic geometry component for a bdsim model.
G4LogicalVolume * GetContainerLogicalVolume() const
Accessor - see member for more info.
virtual std::set< G4LogicalVolume * > GetAllLogicalVolumes() const
Access all logical volumes belonging to this component.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())