18#include "BDSCollimatorBeamMask.hh"
19#include "BDSBeamPipe.hh"
20#include "BDSBeamPipeFactory.hh"
21#include "BDSBeamPipeInfo.hh"
22#include "BDSColours.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"
35#include "G4LogicalVolume.hh"
36#include "G4PVPlacement.hh"
37#include "G4SubtractionSolid.hh"
38#include "G4UnionSolid.hh"
39#include "G4UserLimits.hh"
40#include "G4VisAttributes.hh"
43BDSCollimatorBeamMask::BDSCollimatorBeamMask(
const G4String& nameIn,
46 G4double horizontalWidthIn,
47 G4Material* collimatorMaterialIn,
48 G4Material* vacuumMaterialIn,
51 G4double xApertureSlitIn,
52 G4double yApertureSlitIn,
55 G4double xOffsetSlitIn,
56 G4double yOffsetSlitIn,
59 G4bool circularOuterIn):
61 collimatorSolid(nullptr),
64 horizontalWidth(horizontalWidthIn),
65 collimatorMaterial(collimatorMaterialIn),
66 vacuumMaterial(vacuumMaterialIn),
67 xAperture(xApertureIn),
68 yAperture(yApertureIn),
69 xApertureSlit(xApertureSlitIn),
70 yApertureSlit(yApertureSlitIn),
73 xOffsetSlit(xOffsetSlitIn),
74 yOffsetSlit(yOffsetSlitIn),
78 circularOuter(circularOuterIn)
85 G4cerr << __METHOD_NAME__ <<
"half aperture bigger than width or height!" << G4endl;
86 G4cerr <<
"Full horizontal width is " <<
horizontalWidth <<
" mm for component named: \""
87 <<
name <<
"\"" << G4endl;
88 G4cerr <<
"x (half) aperture " <<
xAperture <<
" mm, y (half) aperture " <<
yAperture <<
" mm" << G4endl;
89 throw BDSException(__METHOD_NAME__,
"Error in beam mask");
94 G4cerr << __METHOD_NAME__ <<
"no aperture set for the main slit!" << G4endl;
95 G4cerr <<
"In element named " <<
name <<
" we have a x (half) aperture " <<
xAperture
96 <<
" mm, y (half) aperture " <<
yAperture <<
" mm" << G4endl;
97 throw BDSException(__METHOD_NAME__,
"Error in beam mask");
103 G4cerr << __METHOD_NAME__ <<
"no aperture set for the side slit!" << G4endl;
104 G4cerr <<
"In element named " <<
name <<
" we have a x (half) aperture " <<
xApertureSlit
105 <<
" mm, y (half) aperture " <<
yApertureSlit <<
" mm" << G4endl;
106 throw BDSException(__METHOD_NAME__,
"Error in beam mask");
144void BDSCollimatorBeamMask::BuildInner()
146 G4Box* inner1 =
new G4Box(
name +
"_inner_solid_1",
152 G4Box* inner2 =
new G4Box(
name +
"_inner_solid_2",
159 G4RotationMatrix* rot =
new G4RotationMatrix;
162 innerSolid =
new G4UnionSolid(
name +
"_inner_solid_union", inner1, inner2, rot, trans);
168 G4Box* vacuum1 =
new G4Box(
name +
"_vacuum_solid_1",
173 G4Box* vacuum2 =
new G4Box(
name +
"_vacuum_solid_2",
178 vacuumSolid =
new G4UnionSolid(
name +
"_vacuum_solid_union", vacuum1, vacuum2, rot, trans);
187 G4RotationMatrix* rot =
new G4RotationMatrix;
190 G4VSolid* outerSolid;
193 outerSolid =
new G4Tubs(
name +
"_outer_solid",
202 outerSolid =
new G4Box(
name +
"_outer_solid",
212 if (buildVacuumAndAperture)
225 name +
"_collimator_lv");
227 G4VisAttributes* collimatorVisAttr =
new G4VisAttributes(*
colour);
228 collimatorLV->SetVisAttributes(collimatorVisAttr);
238 G4PVPlacement* collPV =
new G4PVPlacement(rot,
241 name +
"_collimator_pv",
242 containerLogicalVolume,
249 if (buildVacuumAndAperture)
251 G4LogicalVolume* vacuumLV =
new G4LogicalVolume(
vacuumSolid,
253 name +
"_vacuum_lv");
263 G4PVPlacement* vacPV =
new G4PVPlacement(rot,
267 containerLogicalVolume,
281 G4UserLimits* collUserLimits =
new G4UserLimits(*
userLimits);
284 return collUserLimits;
Abstract class that represents a component of an accelerator.
G4UserLimits * userLimits
Cache of user limits.
void SetAcceleratorVacuumLogicalVolume(G4LogicalVolume *accVacLVIn)
const G4String name
Const protected member variable that may not be changed by derived classes.
static G4bool sensitiveOuter
Useful variable often used in construction.
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 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.
static G4VisAttributes * containerVisAttr
Useful variable often used in construction.
static G4bool sensitiveVacuum
Useful variable often used in construction.
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.
G4double yApertureSlit
Aperture of side slit in y dimension.
G4double yOffsetSlit
Offset of the side slit wrt the main slit in y.
G4double horizontalWidth
Horizontal width.
G4double yAperture
Aperture of main slit in y dimension.
virtual G4String Material() const
Accessor.
virtual void CheckParameters()
G4Colour * colour
Colour of beam mask.
G4Material * vacuumMaterial
Vacuum material.
G4Material * collimatorMaterial
Material.
G4VSolid * vacuumSolid
Geometrical objects:
G4bool circularOuter
Shape of the outer solid.
G4double yOffset
Offset of the mask in the pipe in y.
G4UserLimits * CollimatorUserLimits()
Return either default user limits or custom ones based on optional minimumKineticEnergy.
G4double xApertureSlit
Aperture of side slit in x dimension.
G4double xAperture
Aperture of main slit in x dimension.
G4double tiltSlit
Angle of the side slit.
virtual void BuildContainerLogicalVolume()
G4double xOffsetSlit
Offset of the side slit wrt the main slit in x.
G4VSolid * innerSolid
Geometrical objects:
G4VSolid * collimatorSolid
Geometrical objects:
G4double xOffset
Offset of the mask in the pipe in x.
G4double minKineticEnergy
Optional minimum kinetic energy for collimator materials.
G4Colour * GetColour(G4double red, G4double green, G4double blue, G4double alpha=1)
Get a cached anonymous colour by values.
static BDSColours * Instance()
singleton pattern
General exception with possible name of object and message.
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 RegisterRotationMatrix(G4RotationMatrix *rotationMatrix)
void RegisterDaughter(BDSGeometryComponent *anotherComponent)
void RegisterLogicalVolume(G4LogicalVolume *logicalVolume)
void RegisterPhysicalVolume(G4VPhysicalVolume *physicalVolume)
G4VSolid * GetContainerSolid() const
Accessor - see member for more info.
void RegisterUserLimits(G4UserLimits *userLimit)
void RegisterVisAttributes(G4VisAttributes *visAttribute)
void RegisterSolid(G4VSolid *solid)
void RegisterSensitiveVolume(G4LogicalVolume *sensitiveVolume, BDSSDType sensitivityType)
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())