BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
BDSGasJet.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 "BDSGasJet.hh"
19#include "BDSBeamPipe.hh"
20#include "BDSBeamPipeFactory.hh"
21#include "BDSBeamPipeInfo.hh"
22#include "BDSColours.hh"
23#include "BDSDebug.hh"
24#include "BDSException.hh"
25#include "BDSGlobalConstants.hh"
26#include "BDSMaterials.hh"
27#include "BDSSDType.hh"
28#include "BDSUtilities.hh"
29#include "BDSWarning.hh"
30
31#include "globals.hh"
32#include "G4Box.hh"
33#include "G4LogicalVolume.hh"
34#include "G4PVPlacement.hh"
35#include "G4VisAttributes.hh"
36
37
38BDSGasJet::BDSGasJet(const G4String& nameIn,
39 G4double lengthIn,
40 BDSBeamPipeInfo* beamPipeInfoIn,
41 G4Material* gasMaterialIn,
42 G4double xSizeIn,
43 G4double ySizeIn,
44 G4double zSizeIn,
45 G4double xAngleIn,
46 G4double yAngleIn,
47 G4double zAngleIn,
48 G4double xOffsetIn,
49 G4double yOffsetIn):
50 BDSAcceleratorComponent(nameIn, lengthIn, 0, "gasjet", beamPipeInfoIn),
51 gasSolid(nullptr),
52 gasMaterial(gasMaterialIn),
53 xSize(xSizeIn),
54 ySize(ySizeIn),
55 zSize(zSizeIn),
56 xAngle(xAngleIn),
57 yAngle(yAngleIn),
58 zAngle(zAngleIn),
59 xOffset(xOffsetIn),
60 yOffset(yOffsetIn)
61{;}
62
64{
65 if (xSize <= 0 || !BDS::IsFinite(xSize))
66 {
67 G4cerr << __METHOD_NAME__ << "must provide positive non-zero dimension to gas jet!" << G4endl;
68 G4cerr << "x size : " << xSize << " mm" << G4endl;
69 throw BDSException(__METHOD_NAME__, "Error in gas jet");
70 }
71
72 if (ySize <= 0 || !BDS::IsFinite(ySize))
73 {
74 G4cerr << __METHOD_NAME__ << "must provide positive non-zero dimension to gas jet!" << G4endl;
75 G4cerr << "y size : " << ySize << " mm" << G4endl;
76 throw BDSException(__METHOD_NAME__, "Error in gas jet");
77 }
78
79 if (zSize <= 0 || !BDS::IsFinite(zSize))
80 {
81 G4cerr << __METHOD_NAME__ << "must provide positive non-zero dimension to gas jet!" << G4endl;
82 G4cerr << "z size : " << zSize << " mm" << G4endl;
83 throw BDSException(__METHOD_NAME__, "Error in gas jet");
84 }
85}
86
87G4String BDSGasJet::Material() const
88{
89 if (gasMaterial)
90 {return gasMaterial->GetName();}
91 else
92 {return "none";}
93}
94
96{
98 BDSBeamPipe* pipe = factory->CreateBeamPipe(name + "_beampipe",
101 RegisterDaughter(pipe);
102
103 // make the beam pipe container, this object's container
104 containerLogicalVolume = pipe->GetContainerLogicalVolume();
105 containerSolid = pipe->GetContainerSolid();
106
107 // register vacuum volume (for biasing)
109
110 // update extents
111 InheritExtents(pipe);
112
113 // update faces
116}
117
119{
121 BDSAcceleratorComponent::Build(); // calls BuildContainer and sets limits and vis for container
122
123 G4RotationMatrix* Rot = new G4RotationMatrix(xAngle, yAngle, zAngle);
124 G4ThreeVector Trans(xOffset, yOffset, 0);
125
126 gasSolid = new G4Box(name + "_gas_solid",
127 xSize * 0.5 - lengthSafety,
128 ySize * 0.5 - lengthSafety,
129 zSize * 0.5 - lengthSafety);
131
132 G4LogicalVolume* gasLV = new G4LogicalVolume(gasSolid, // solid
133 gasMaterial, // material
134 name + "_gas_lv"); // name
135
136
137 G4VisAttributes* gasVisAttr = new G4VisAttributes(*BDSColours::Instance()->GetColour("capillarygas"));
138 gasLV->SetVisAttributes(gasVisAttr);
139 RegisterVisAttributes(gasVisAttr);
140
141 // register with base class (BDSGeometryComponent)
143
144 G4LogicalVolume* vac = *(GetAcceleratorVacuumLogicalVolumes().begin()); // take the first one
145
146 G4PVPlacement* gasPV = new G4PVPlacement(Rot, // rotation
147 Trans, // position
148 gasLV, // its logical volume
149 name + "_gas_pv", // its name
150 vac, // its mother volume
151 false, // no boolean operation
152 0, // copy number
154
156}
Abstract class that represents a component of an accelerator.
void SetAcceleratorVacuumLogicalVolume(G4LogicalVolume *accVacLVIn)
const G4String name
Const protected member variable that may not be changed by derived classes.
virtual void SetOutputFaceNormal(const G4ThreeVector &output)
Allow updating of face normals. Virtual so derived class may apply it to daughters.
static G4double lengthSafety
Useful variable often used in construction.
static G4bool checkOverlaps
Useful variable often used in construction.
virtual std::set< G4LogicalVolume * > GetAcceleratorVacuumLogicalVolumes() const
Access the 'vacuum' volume(s) in this component if any. Default is empty set.
virtual void SetInputFaceNormal(const G4ThreeVector &input)
Allow updating of face normals. Virtual so derived class may apply it to daughters.
G4double chordLength
Protected member variable that can be modified by derived classes.
BDSBeamPipeInfo * beamPipeInfo
Optional beam pipe recipe that is written out to the survey if it exists.
The main interface for using the beam pipe factories.
static BDSBeamPipeFactory * Instance()
Singleton accessor.
Holder class for all information required to describe a beam pipe model.
A holder class for a piece of beam pipe geometry.
G4LogicalVolume * GetVacuumLogicalVolume() const
Access the vacuum volume to set fields and limits.
G4ThreeVector InputFaceNormal() const
Accessor.
G4ThreeVector OutputFaceNormal() const
Accessor.
static BDSColours * Instance()
singleton pattern
Definition BDSColours.cc:32
General exception with possible name of object and message.
G4Material * gasMaterial
Gas material.
Definition BDSGasJet.hh:67
BDSGasJet()=delete
Private default constructor to force the use of the supplied one.
G4double ySize
Aperture of main slit in y dimension.
Definition BDSGasJet.hh:69
G4double xOffset
Offset of the side slit wrt the main slit in x.
Definition BDSGasJet.hh:74
virtual G4String Material() const
Accessor.
Definition BDSGasJet.cc:87
G4double xSize
Aperture of main slit in x dimension.
Definition BDSGasJet.hh:68
G4double zAngle
Offset of the mask in the pipe in y.
Definition BDSGasJet.hh:73
virtual void CheckParameters()
Definition BDSGasJet.cc:63
G4VSolid * gasSolid
Geometrical objects:
Definition BDSGasJet.hh:64
virtual void Build()
Definition BDSGasJet.cc:118
G4double zSize
Aperture of side slit in x dimension.
Definition BDSGasJet.hh:70
G4double yOffset
Offset of the side slit wrt the main slit in y.
Definition BDSGasJet.hh:75
G4double xAngle
Aperture of side slit in y dimension.
Definition BDSGasJet.hh:71
G4double yAngle
Offset of the mask in the pipe in x.
Definition BDSGasJet.hh:72
virtual void BuildContainerLogicalVolume()
Definition BDSGasJet.cc:95
G4LogicalVolume * GetContainerLogicalVolume() const
Accessor - see member for more info.
void InheritExtents(BDSGeometryComponent const *const anotherComponent)
Update the extents of this object with those of another object.
void RegisterDaughter(BDSGeometryComponent *anotherComponent)
void RegisterLogicalVolume(G4LogicalVolume *logicalVolume)
void RegisterPhysicalVolume(G4VPhysicalVolume *physicalVolume)
G4VSolid * GetContainerSolid() const
Accessor - see member for more info.
void RegisterVisAttributes(G4VisAttributes *visAttribute)
void RegisterSolid(G4VSolid *solid)
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())