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"
31#include "G4GenericTrap.hh"
32#include "G4LogicalVolume.hh"
33#include "G4PVPlacement.hh"
34#include "G4VisAttributes.hh"
43 G4double horizontalWidthIn,
45 G4double yHalfHeightIn,
47 G4double xSizeRightIn,
48 G4double leftJawTiltIn,
49 G4double rightJawTiltIn,
50 G4bool buildLeftJawIn,
51 G4bool buildRightJawIn,
52 G4Material* collimatorMaterialIn,
53 G4Material* vacuumMaterialIn,
55BDSCollimator(nameIn, lengthIn, horizontalWidthIn,
"jcol", collimatorMaterialIn, vacuumMaterialIn,
56 xHalfGapIn, yHalfHeightIn, xHalfGapIn, yHalfHeightIn, colourIn),
58 xSizeLeft(xSizeLeftIn),
59 xSizeRight(xSizeRightIn),
61 jawTiltLeft(leftJawTiltIn),
62 jawTiltRight(rightJawTiltIn),
64 yHalfHeight(yHalfHeightIn),
65 buildLeftJaw(buildLeftJawIn),
66 buildRightJaw(buildRightJawIn),
69 jawHalfWidth = 0.5 * (0.5*horizontalWidth - lengthSafetyLarge - xHalfGap);
72BDSCollimatorJaw::~BDSCollimatorJaw()
82 {
throw BDSException(__METHOD_NAME__,
"horizontalWidth insufficient given xsize of jcol \"" +
name +
"\"");}
89 {
throw BDSException(__METHOD_NAME__,
"insufficient ysize for jcol \"" +
name +
"\"");}
92 {
throw BDSException(__METHOD_NAME__,
"insufficient ysize for jcol \"" +
name +
"\"");}
95 {
throw BDSException(__METHOD_NAME__,
"left jcol jaw cannot have negative half aperture size: \"" +
name +
"\"");}
97 {
throw BDSException(__METHOD_NAME__,
"left jcol jaw cannot have negative half aperture size: \"" +
name +
"\"");}
101 G4cerr << __METHOD_NAME__ <<
"jcol \"" <<
name
102 <<
"\" left jaw offset is greater the element half width, jaw "
103 <<
"will not be constructed" << G4endl;
108 G4cerr << __METHOD_NAME__ <<
"jcol \"" <<
name
109 <<
"\" right jaw offset is greater the element half width, jaw "
110 <<
"will not be constructed" << G4endl;
115 {
throw BDSException(__METHOD_NAME__,
"tilted left jaw not allowed to cross the mid-plane: \"" +
name +
"\"");}
118 {
throw BDSException(__METHOD_NAME__,
"tilted right jaw not allowed to cross the mid-plane: \"" +
name +
"\"");}
121 {
throw BDSException(__METHOD_NAME__,
"no jaws being built: \"" +
name +
"\"");}
138 containerSolid =
new G4Box(
name +
"_container_solid",
143 containerLogicalVolume =
new G4LogicalVolume(containerSolid,
145 name +
"_container_lv");
157 G4double rightJawHalfGap =
xHalfGap;
180 G4double vacuumWidth = 0.5 * (leftJawHalfGap + rightJawHalfGap);
183 G4double leftJawCentre = 0.5*leftJawWidth + leftJawHalfGap;
184 G4double rightJawCentre = 0.5*rightJawWidth + rightJawHalfGap;
185 G4double vacuumCentre = 0.5*(leftJawHalfGap - rightJawHalfGap);
187 G4ThreeVector leftJawPos = G4ThreeVector(leftJawCentre, 0, 0);
188 G4ThreeVector rightJawPos = G4ThreeVector(-rightJawCentre, 0, 0);
189 G4ThreeVector vacuumOffset = G4ThreeVector(vacuumCentre, 0, 0);
191 G4VisAttributes* collimatorVisAttr =
new G4VisAttributes(*
colour);
200 G4VSolid* leftJawSolid =
nullptr;
209 leftJawSolid =
new G4Para(
name +
"_leftjaw_solid",
219 leftJawSolid =
new G4Box(
name +
"_leftjaw_solid",
227 G4LogicalVolume* leftJawLV =
new G4LogicalVolume(leftJawSolid,
229 name +
"_leftjaw_lv");
230 leftJawLV->SetVisAttributes(collimatorVisAttr);
233 leftJawLV->SetUserLimits(collUserLimits);
238 BDSAcceleratorModel::Instance()->
VolumeSet(
"collimators")->insert(leftJawLV);
243 G4PVPlacement* leftJawPV =
new G4PVPlacement(
nullptr,
246 name +
"_leftjaw_pv",
247 containerLogicalVolume,
255 G4VSolid* rightJawSolid =
nullptr;
264 rightJawSolid =
new G4Para(
name +
"_rightjaw_solid",
274 rightJawSolid =
new G4Box(
name +
"_rightjaw_solid",
282 G4LogicalVolume* rightJawLV =
new G4LogicalVolume(rightJawSolid,
284 name +
"_rightjaw_lv");
285 rightJawLV->SetVisAttributes(collimatorVisAttr);
288 rightJawLV->SetUserLimits(collUserLimits);
293 BDSAcceleratorModel::Instance()->
VolumeSet(
"collimators")->insert(rightJawLV);
298 G4PVPlacement* rightJawPV =
new G4PVPlacement(
nullptr,
301 name +
"_rightjaw_pv",
302 containerLogicalVolume,
320 collimatorLV->SetVisAttributes(collimatorVisAttr);
331 G4PVPlacement* collimatorPV =
new G4PVPlacement(
nullptr,
335 containerLogicalVolume,
353 G4double halfLengthLeftEff = (
chordLength * 0.5) / std::cos(tiltLeft);
354 G4double halfLengthRightEff = (
chordLength * 0.5) / std::cos(tiltRight);
358 G4double xGapLeftUpstream = -halfLengthLeftEff * std::sin(tiltLeft) + leftJawHalfGap;
359 G4double xGapLeftDownstream = halfLengthLeftEff * std::sin(tiltLeft) + leftJawHalfGap;
360 G4double xGapRightUpstream = -halfLengthRightEff * std::sin(tiltRight) - rightJawHalfGap;
361 G4double xGapRightDownstream = halfLengthRightEff * std::sin(tiltRight) - rightJawHalfGap;
377 vacuumOffset = G4ThreeVector(0, 0, 0);
389 G4LogicalVolume* vacuumLV =
new G4LogicalVolume(
vacuumSolid,
391 name +
"_vacuum_lv");
401 G4PVPlacement* vacPV =
new G4PVPlacement(
nullptr,
405 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 jawTiltLeft
Tilt of jaw 1 (angle in x-z plane)
G4double jawTiltRight
Tilt of jaw 2 (angle in x-z plane)
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())