18#include "BDSAcceleratorModel.hh"
19#include "BDSCollimatorJawTip.hh"
20#include "BDSColourFromMaterial.hh"
21#include "BDSBeamPipeInfo.hh"
22#include "BDSCollimatorJaw.hh"
23#include "BDSColours.hh"
25#include "BDSException.hh"
26#include "BDSSDType.hh"
30#include "G4LogicalVolume.hh"
31#include "G4PVPlacement.hh"
32#include "G4VisAttributes.hh"
37BDSCollimatorJawTip::BDSCollimatorJawTip(
const G4String& nameIn,
39 G4double horizontalWidthIn,
41 G4double yHalfHeightIn,
43 G4double xSizeRightIn,
44 G4double leftJawTiltIn,
45 G4double rightJawTiltIn,
46 G4double tipThicknessIn,
47 G4bool buildLeftJawIn,
48 G4bool buildRightJawIn,
49 G4Material* collimatorMaterialIn,
50 G4Material* collimatorTipMaterialIn,
51 G4Material* vacuumMaterialIn,
53 G4Colour* tipColourIn):
54BDSCollimatorJaw(nameIn, lengthIn, horizontalWidthIn, xHalfGapIn, yHalfHeightIn, xSizeLeftIn, xSizeRightIn,
55 leftJawTiltIn, rightJawTiltIn, buildLeftJawIn, buildRightJawIn, collimatorMaterialIn,
56 vacuumMaterialIn, colourIn,
"jcoltip"),
57 tipColour(tipColourIn),
58 tipThickness(tipThicknessIn),
59 collimatorTipMaterial(collimatorTipMaterialIn)
69BDSCollimatorJawTip::~BDSCollimatorJawTip()
79 leftJawWidth -= tipSpace;
80 leftJawPos += G4ThreeVector(0.5*tipSpace, 0, 0);
81 rightJawWidth -= tipSpace;
82 rightJawPos -= G4ThreeVector(0.5*tipSpace, 0, 0);
84 leftJawTipPos = G4ThreeVector(leftJawHalfGap + 0.5*tipThickness, 0, 0);
85 rightJawTipPos = G4ThreeVector(-(rightJawHalfGap + 0.5*tipThickness), 0, 0);
94 {
throw BDSException(__METHOD_NAME__,
"2x tipThickness is greater than the horizontal width for zero opening jcoltip \"" +
name +
"\"");}
100 {
throw BDSException(__METHOD_NAME__,
"insufficient tipThickness for jcoltip \"" +
name +
"\"");}
104 {
throw BDSException(__METHOD_NAME__,
"left jaw of jcoltip \"" +
name +
"\" too thin given horizontalWidth, aperture and tipThickness");}
106 {
throw BDSException(__METHOD_NAME__,
"right jaw of jcoltip \"" +
name +
"\" too thin given horizontalWidth, aperture and tipThickness");}
116void BDSCollimatorJawTip::BuildTips()
118 G4VisAttributes* tipVisAttr =
new G4VisAttributes(*tipColour);
127 G4VSolid* tipSolid =
new G4Box(
name +
"_tip_solid",
134 G4LogicalVolume* collimatorTipLV =
new G4LogicalVolume(tipSolid, collimatorTipMaterial,
name +
"_tip_lv");
135 collimatorTipLV->SetVisAttributes(tipVisAttr);
136 collimatorTipLV->SetUserLimits(tipCollUserLimits);
140 BDSAcceleratorModel::Instance()->
VolumeSet(
"collimators")->insert(collimatorTipLV);
145 G4PVPlacement* collimatorTipPV =
new G4PVPlacement(
nullptr,
157 G4VSolid* leftJawTipSolid =
nullptr;
163 leftJawTipSolid =
new G4Para(
name +
"_leftjawtip_solid",
171 leftJawTipSolid =
new G4Box(
name +
"_leftjawtip_solid",
178 G4LogicalVolume* leftJawTipLV =
new G4LogicalVolume(leftJawTipSolid, collimatorTipMaterial,
name +
"_leftjawtip_lv");
179 leftJawTipLV->SetVisAttributes(tipVisAttr);
180 leftJawTipLV->SetUserLimits(tipCollUserLimits);
182 BDSAcceleratorModel::Instance()->
VolumeSet(
"collimators")->insert(leftJawTipLV);
187 G4PVPlacement* leftJawTipPV =
new G4PVPlacement(
nullptr,
190 name +
"_leftjawtip_pv",
191 containerLogicalVolume,
198 G4VSolid* rightJawTipSolid =
nullptr;
204 rightJawTipSolid =
new G4Para(
name +
"_rightjawtip_solid",
212 rightJawTipSolid =
new G4Box(
name +
"_rightjawtip_solid",
219 G4LogicalVolume* rightJawTipLV =
new G4LogicalVolume(rightJawTipSolid, collimatorTipMaterial,
name +
"_rightjawtip_lv");
220 rightJawTipLV->SetVisAttributes(tipVisAttr);
221 rightJawTipLV->SetUserLimits(tipCollUserLimits);
223 BDSAcceleratorModel::Instance()->
VolumeSet(
"collimators")->insert(rightJawTipLV);
228 G4PVPlacement* rightJawTipPV =
new G4PVPlacement(
nullptr,
231 name +
"_rightjawtip_pv",
232 containerLogicalVolume,
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.
std::set< G4LogicalVolume * > * VolumeSet(const G4String &name)
Returns pointer to a set of logical volumes. If no set by that name exits, create it.
virtual void Build() override
Override function in BDSCollimator for totally different construction.
void CheckParametersForTips()
void UpdateCalculations()
Adjust the calculated values to include the space for the tips that are separate placements.
Collimator with only two jaw and no top bit.
G4bool buildAperture
Build aperture or not.
virtual void Build() override
Override function in BDSCollimator for totally different construction.
G4double jawTiltLeft
Tilt of jaw 1 (angle in x-z plane)
G4double jawTiltRight
Tilt of jaw 2 (angle in x-z plane)
void Calculations()
Calculate offsets and sizes.
G4double yHalfHeight
Half height of each jaw.
G4bool buildRightJaw
Build right jaw or not.
G4bool buildLeftJaw
Build left jaw or not.
G4LogicalVolume * collimatorLV
In case of no aperture, cache this volume for derived classes to place inside.
G4UserLimits * CollimatorUserLimits()
Return either default user limits or custom ones based on optional minimumKineticEnergy.
G4double horizontalWidth
Horizontal width.
static BDSColourFromMaterial * Instance()
Singleton pattern.
G4Colour * GetColourWithDefault(const G4Material *material, G4Colour *defaultIn) const
Get colour from name - if not found return the supplied default.
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.
void RegisterLogicalVolume(G4LogicalVolume *logicalVolume)
void RegisterPhysicalVolume(G4VPhysicalVolume *physicalVolume)
void RegisterVisAttributes(G4VisAttributes *visAttribute)
void RegisterSolid(G4VSolid *solid)
void RegisterSensitiveVolume(G4LogicalVolume *sensitiveVolume, BDSSDType sensitivityType)