19#include "BDSCollimatorBeamMask.hh"
20#include "BDSBeamPipe.hh"
21#include "BDSBeamPipeFactory.hh"
22#include "BDSBeamPipeInfo.hh"
23#include "BDSColours.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"
36#include "G4LogicalVolume.hh"
37#include "G4PVPlacement.hh"
38#include "G4SubtractionSolid.hh"
39#include "G4UnionSolid.hh"
40#include "G4UserLimits.hh"
41#include "G4VisAttributes.hh"
47 G4double horizontalWidthIn,
48 G4Material* collimatorMaterialIn,
49 G4Material* vacuumMaterialIn,
52 G4double xApertureSlitIn,
53 G4double yApertureSlitIn,
56 G4double xOffsetSlitIn,
57 G4double yOffsetSlitIn,
60 G4bool circularOuterIn):
62 collimatorSolid(nullptr),
65 horizontalWidth(horizontalWidthIn),
66 collimatorMaterial(collimatorMaterialIn),
67 vacuumMaterial(vacuumMaterialIn),
68 xAperture(xApertureIn),
69 yAperture(yApertureIn),
70 xApertureSlit(xApertureSlitIn),
71 yApertureSlit(yApertureSlitIn),
74 xOffsetSlit(xOffsetSlitIn),
75 yOffsetSlit(yOffsetSlitIn),
79 circularOuter(circularOuterIn)
86 G4cerr << __METHOD_NAME__ <<
"half aperture bigger than width or height!" << G4endl;
87 G4cerr <<
"Full horizontal width is " <<
horizontalWidth <<
" mm for component named: \""
88 <<
name <<
"\"" << G4endl;
89 G4cerr <<
"x (half) aperture " <<
xAperture <<
" mm, y (half) aperture " <<
yAperture <<
" mm" << G4endl;
90 throw BDSException(__METHOD_NAME__,
"Error in beam mask");
95 G4cerr << __METHOD_NAME__ <<
"no aperture set for the main slit!" << G4endl;
96 G4cerr <<
"In element named " <<
name <<
" we have a x (half) aperture " <<
xAperture <<
97 " mm, y (half) aperture " <<
yAperture <<
" mm" << G4endl;
98 throw BDSException(__METHOD_NAME__,
"Error in beam mask");
104 G4cerr << __METHOD_NAME__ <<
"no aperture set for the side slit!" << G4endl;
105 G4cerr <<
"In element named " <<
name <<
" we have a x (half) aperture " <<
xApertureSlit <<
106 " mm, y (half) aperture " <<
yApertureSlit <<
" mm" << G4endl;
107 throw BDSException(__METHOD_NAME__,
"Error in beam mask");
145void BDSCollimatorBeamMask::BuildInner()
147 G4Box* inner1 =
new G4Box(
name +
"_inner_solid_1",
153 G4Box* inner2 =
new G4Box(
name +
"_inner_solid_2",
160 G4RotationMatrix* Rot =
new G4RotationMatrix;
163 innerSolid =
new G4UnionSolid(
name +
"_inner_solid_union", inner1, inner2, Rot, Trans);
165 G4Box* vacuum1 =
new G4Box(
name +
"_vacuum_solid_1",
170 G4Box* vacuum2 =
new G4Box(
name +
"_vacuum_solid_2",
175 vacuumSolid =
new G4UnionSolid(
name +
"_vacuum_solid_union", vacuum1, vacuum2, Rot, Trans);
186 G4RotationMatrix* Rot =
new G4RotationMatrix;
189 G4VSolid* outerSolid;
192 outerSolid =
new G4Tubs(
name +
"_outer_solid",
201 outerSolid =
new G4Box(
name +
"_outer_solid",
211 if (buildVacuumAndAperture)
225 name +
"_collimator_lv");
228 G4VisAttributes* collimatorVisAttr =
new G4VisAttributes(*
colour);
229 collimatorLV->SetVisAttributes(collimatorVisAttr);
239 G4PVPlacement* collPV =
new G4PVPlacement(Rot,
242 name +
"_collimator_pv",
243 containerLogicalVolume,
250 if (buildVacuumAndAperture)
252 G4LogicalVolume* vacuumLV =
new G4LogicalVolume(
vacuumSolid,
254 name +
"_vacuum_lv");
264 G4PVPlacement* vacPV =
new G4PVPlacement(Rot,
268 containerLogicalVolume,
283 G4UserLimits* collUserLimits =
new G4UserLimits(*
userLimits);
286 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:
BDSCollimatorBeamMask()
Private default constructor to force the use of the supplied one.
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 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())