19#include "BDSAcceleratorModel.hh"
20#include "BDSCollimatorJaw.hh"
21#include "BDSBeamPipeInfo.hh"
22#include "BDSColours.hh"
24#include "BDSException.hh"
25#include "BDSMaterials.hh"
26#include "BDSSDType.hh"
27#include "BDSUtilities.hh"
30#include "G4LogicalVolume.hh"
31#include "G4PVPlacement.hh"
32#include "G4VisAttributes.hh"
40 G4double horizontalWidthIn,
42 G4double yHalfHeightIn,
44 G4double xSizeRightIn,
45 G4bool buildLeftJawIn,
46 G4bool buildRightJawIn,
47 G4Material* collimatorMaterialIn,
48 G4Material* vacuumMaterialIn,
62 xSizeLeft(xSizeLeftIn),
63 xSizeRight(xSizeRightIn),
66 yHalfHeight(yHalfHeightIn),
67 buildLeftJaw(buildLeftJawIn),
68 buildRightJaw(buildRightJawIn),
71 jawHalfWidth = 0.5 * (0.5*horizontalWidth - lengthSafetyLarge - xHalfGap);
74BDSCollimatorJaw::~BDSCollimatorJaw()
84 {
throw BDSException(__METHOD_NAME__,
"horizontalWidth insufficient given xsize of jcol \"" +
name +
"\"");}
91 {
throw BDSException(__METHOD_NAME__,
"insufficient ysize for jcol \"" +
name +
"\"");}
94 {
throw BDSException(__METHOD_NAME__,
"insufficient ysize for jcol \"" +
name +
"\"");}
97 {
throw BDSException(__METHOD_NAME__,
"left jcol jaw cannot have negative half aperture size: \"" +
name +
"\"");}
99 {
throw BDSException(__METHOD_NAME__,
"left jcol jaw cannot have negative half aperture size: \"" +
name +
"\"");}
103 G4cerr << __METHOD_NAME__ <<
"jcol \"" <<
name
104 <<
"\" left jaw offset is greater the element half width, jaw "
105 <<
"will not be constructed" << G4endl;
110 G4cerr << __METHOD_NAME__ <<
"jcol \"" <<
name
111 <<
"\" right jaw offset is greater the element half width, jaw "
112 <<
"will not be constructed" << G4endl;
117 {
throw BDSException(__METHOD_NAME__,
"no jaws being built: \"" +
name +
"\"");}
125 containerSolid =
new G4Box(
name +
"_container_solid",
130 containerLogicalVolume =
new G4LogicalVolume(containerSolid,
132 name +
"_container_lv");
144 G4double rightJawHalfGap =
xHalfGap;
155 G4double vacuumWidth = 0.5 * (leftJawHalfGap + rightJawHalfGap);
158 G4double leftJawCentre = 0.5*leftJawWidth + leftJawHalfGap;
159 G4double rightJawCentre = 0.5*rightJawWidth + rightJawHalfGap;
160 G4double vacuumCentre = 0.5*(leftJawHalfGap - rightJawHalfGap);
162 G4ThreeVector leftJawPos = G4ThreeVector(leftJawCentre, 0, 0);
163 G4ThreeVector rightJawPos = G4ThreeVector(-rightJawCentre, 0, 0);
164 G4ThreeVector vacuumOffset = G4ThreeVector(vacuumCentre, 0, 0);
166 G4VisAttributes* collimatorVisAttr =
new G4VisAttributes(*
colour);
175 G4VSolid* leftJawSolid =
new G4Box(
name +
"_leftjaw_solid",
181 G4LogicalVolume* leftJawLV =
new G4LogicalVolume(leftJawSolid,
183 name +
"_leftjaw_lv");
184 leftJawLV->SetVisAttributes(collimatorVisAttr);
187 leftJawLV->SetUserLimits(collUserLimits);
192 BDSAcceleratorModel::Instance()->
VolumeSet(
"collimators")->insert(leftJawLV);
197 G4PVPlacement* leftJawPV =
new G4PVPlacement(
nullptr,
200 name +
"_leftjaw_pv",
201 containerLogicalVolume,
209 G4VSolid* rightJawSolid =
new G4Box(
name +
"_rightjaw_solid",
215 G4LogicalVolume* rightJawLV =
new G4LogicalVolume(rightJawSolid,
217 name +
"_rightjaw_lv");
218 rightJawLV->SetVisAttributes(collimatorVisAttr);
221 rightJawLV->SetUserLimits(collUserLimits);
226 BDSAcceleratorModel::Instance()->
VolumeSet(
"collimators")->insert(rightJawLV);
231 G4PVPlacement* rightJawPV =
new G4PVPlacement(
nullptr,
234 name +
"_rightjaw_pv",
235 containerLogicalVolume,
253 collimatorLV->SetVisAttributes(collimatorVisAttr);
264 G4PVPlacement* collimatorPV =
new G4PVPlacement(
nullptr,
268 containerLogicalVolume,
285 G4LogicalVolume* vacuumLV =
new G4LogicalVolume(
vacuumSolid,
287 name +
"_vacuum_lv");
297 G4PVPlacement* vacPV =
new G4PVPlacement(
nullptr,
301 containerLogicalVolume,
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.
static G4double lengthSafety
Useful variable often used in construction.
static G4bool checkOverlaps
Useful variable often used in construction.
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.
std::set< G4LogicalVolume * > * VolumeSet(const G4String &name)
Returns pointer to a set of logical volumes. If no set by that name exits, create it.
G4double jawHalfWidth
Half width of each jaw.
G4bool buildAperture
Build aperture or not.
virtual void Build() override
Override function in BDSCollimator for totally different construction.
G4double xSizeRight
Offset of jaw 2.
virtual void BuildContainerLogicalVolume() override
Override function in BDSCollimator for different size based container.
G4double xSizeLeft
Offset of jaw 1.
G4double yHalfHeight
Half height of each jaw.
G4bool buildRightJaw
Build right jaw or not.
virtual void CheckParameters() override
G4double xHalfGap
Half gap separation between jaws.
G4bool buildLeftJaw
Build left jaw or not.
BDSCollimatorJaw()=delete
Private default constructor to force the use of the supplied one.
Base class for collimators with common construction.
G4UserLimits * CollimatorUserLimits()
Return either default user limits or custom ones based on optional minimumKineticEnergy.
G4Material * vacuumMaterial
Vacuum material.
G4double horizontalWidth
Horizontal width.
G4VSolid * vacuumSolid
Geometrical objects:
G4Material * collimatorMaterial
Material.
G4VSolid * collimatorSolid
Geometrical objects:
G4Colour * colour
Colour of collimator.
static BDSColours * Instance()
singleton pattern
G4Colour * GetColour(const G4String &type, G4bool normaliseTo255=true)
Get colour from name.
General exception with possible name of object and message.
Holder for +- extents in 3 dimensions.
void RegisterLogicalVolume(G4LogicalVolume *logicalVolume)
void RegisterPhysicalVolume(G4VPhysicalVolume *physicalVolume)
void SetExtent(const BDSExtent &extIn)
Set extent.
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())