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) Royal Holloway,
3University of London 2001 - 2024.
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 "BDSGasJet.hh"
20#include "BDSBeamPipe.hh"
21#include "BDSBeamPipeFactory.hh"
22#include "BDSBeamPipeInfo.hh"
23#include "BDSColours.hh"
24#include "BDSDebug.hh"
25#include "BDSException.hh"
26#include "BDSGlobalConstants.hh"
27#include "BDSMaterials.hh"
28#include "BDSSDType.hh"
29#include "BDSUtilities.hh"
30#include "BDSWarning.hh"
31
32#include "globals.hh"
33#include "G4Box.hh"
34#include "G4LogicalVolume.hh"
35#include "G4PVPlacement.hh"
36#include "G4VisAttributes.hh"
37
38
39BDSGasJet::BDSGasJet(const G4String& nameIn,
40 G4double lengthIn,
41 BDSBeamPipeInfo* beamPipeInfoIn,
42 G4Material* gasMaterialIn,
43 G4double xSizeIn,
44 G4double ySizeIn,
45 G4double zSizeIn,
46 G4double xAngleIn,
47 G4double yAngleIn,
48 G4double zAngleIn,
49 G4double xOffsetIn,
50 G4double yOffsetIn):
51 BDSAcceleratorComponent(nameIn, lengthIn, 0, "gasjet", beamPipeInfoIn),
52 gasSolid(nullptr),
53 gasMaterial(gasMaterialIn),
54 xSize(xSizeIn),
55 ySize(ySizeIn),
56 zSize(zSizeIn),
57 xAngle(xAngleIn),
58 yAngle(yAngleIn),
59 zAngle(zAngleIn),
60 xOffset(xOffsetIn),
61 yOffset(yOffsetIn)
62{;}
63
65{
66 if (xSize <= 0 || !BDS::IsFinite(xSize))
67 {
68 G4cerr << __METHOD_NAME__ << "must provide positive non-zero dimension to gas jet!" << G4endl;
69 G4cerr << "x size : " << xSize << " mm" << G4endl;
70 throw BDSException(__METHOD_NAME__, "Error in gas jet");
71 }
72
73 if (ySize <= 0 || !BDS::IsFinite(ySize))
74 {
75 G4cerr << __METHOD_NAME__ << "must provide positive non-zero dimension to gas jet!" << G4endl;
76 G4cerr << "y size : " << ySize << " mm" << G4endl;
77 throw BDSException(__METHOD_NAME__, "Error in gas jet");
78 }
79
80 if (zSize <= 0 || !BDS::IsFinite(zSize))
81 {
82 G4cerr << __METHOD_NAME__ << "must provide positive non-zero dimension to gas jet!" << G4endl;
83 G4cerr << "z size : " << zSize << " mm" << G4endl;
84 throw BDSException(__METHOD_NAME__, "Error in gas jet");
85 }
86}
87
88G4String BDSGasJet::Material() const
89{
90 if (gasMaterial)
91 {return gasMaterial->GetName();}
92 else
93 {return "none";}
94}
95
97{
99 BDSBeamPipe* pipe = factory->CreateBeamPipe(name + "_beampipe",
102 RegisterDaughter(pipe);
103
104 // make the beam pipe container, this object's container
105 containerLogicalVolume = pipe->GetContainerLogicalVolume();
106 containerSolid = pipe->GetContainerSolid();
107
108 // register vacuum volume (for biasing)
110
111 // update extents
112 InheritExtents(pipe);
113
114 // update faces
117}
118
120{
122 BDSAcceleratorComponent::Build(); // calls BuildContainer and sets limits and vis for container
123
124 G4RotationMatrix* Rot = new G4RotationMatrix(xAngle, yAngle, zAngle);
125 G4ThreeVector Trans(xOffset, yOffset, 0);
126
127 gasSolid = new G4Box(name + "_gas_solid",
128 xSize * 0.5 - lengthSafety,
129 ySize * 0.5 - lengthSafety,
130 zSize * 0.5 - lengthSafety);
132
133 G4LogicalVolume* gasLV = new G4LogicalVolume(gasSolid, // solid
134 gasMaterial, // material
135 name + "_gas_lv"); // name
136
137
138 G4VisAttributes* gasVisAttr = new G4VisAttributes(*BDSColours::Instance()->GetColour("capillarygas"));
139 gasLV->SetVisAttributes(gasVisAttr);
140 RegisterVisAttributes(gasVisAttr);
141
142 // register with base class (BDSGeometryComponent)
144
145 G4LogicalVolume* vac = *(GetAcceleratorVacuumLogicalVolumes().begin()); // take the first one
146
147 G4PVPlacement* gasPV = new G4PVPlacement(Rot, // rotation
148 Trans, // position
149 gasLV, // its logical volume
150 name + "_gas_pv", // its name
151 vac, // its mother volume
152 false, // no boolean operation
153 0, // copy number
155
157}
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:33
General exception with possible name of object and message.
G4Material * gasMaterial
Gas material.
Definition BDSGasJet.hh:68
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:70
G4double xOffset
Offset of the side slit wrt the main slit in x.
Definition BDSGasJet.hh:75
virtual G4String Material() const
Accessor.
Definition BDSGasJet.cc:88
G4double xSize
Aperture of main slit in x dimension.
Definition BDSGasJet.hh:69
G4double zAngle
Offset of the mask in the pipe in y.
Definition BDSGasJet.hh:74
virtual void CheckParameters()
Definition BDSGasJet.cc:64
G4VSolid * gasSolid
Geometrical objects:
Definition BDSGasJet.hh:65
virtual void Build()
Definition BDSGasJet.cc:119
G4double zSize
Aperture of side slit in x dimension.
Definition BDSGasJet.hh:71
G4double yOffset
Offset of the side slit wrt the main slit in y.
Definition BDSGasJet.hh:76
G4double xAngle
Aperture of side slit in y dimension.
Definition BDSGasJet.hh:72
G4double yAngle
Offset of the mask in the pipe in x.
Definition BDSGasJet.hh:73
virtual void BuildContainerLogicalVolume()
Definition BDSGasJet.cc:96
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())