19#include "BDSAcceleratorModel.hh"
20#include "BDSBeamPipeInfo.hh"
21#include "BDSCollimator.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"
33#include "G4LogicalVolume.hh"
34#include "G4PVPlacement.hh"
35#include "G4SubtractionSolid.hh"
37#include "G4UserLimits.hh"
38#include "G4VisAttributes.hh"
44 G4double horizontalWidthIn,
45 const G4String& typeIn,
46 G4Material* collimatorMaterialIn,
47 G4Material* vacuumMaterialIn,
50 G4double xApertureOutIn,
51 G4double yApertureOutIn,
53 G4bool circularOuterIn):
55 collimatorSolid(nullptr),
58 horizontalWidth(horizontalWidthIn),
59 collimatorMaterial(collimatorMaterialIn),
60 vacuumMaterial(vacuumMaterialIn),
61 xAperture(xApertureIn),
62 yAperture(yApertureIn),
63 xApertureOut(xApertureOutIn),
64 yApertureOut(yApertureOutIn),
68 circularOuter(circularOuterIn)
71BDSCollimator::~BDSCollimator()
78 G4cerr << __METHOD_NAME__ <<
"half aperture bigger than width or height!" << G4endl;
79 G4cerr <<
"Full horizontal width is " <<
horizontalWidth <<
" mm for component named: \""
80 <<
name <<
"\"" << G4endl;
81 G4cerr <<
"x (half) aperture " <<
xAperture <<
" mm, y (half) aperture " <<
yAperture <<
" mm" << G4endl;
82 throw BDSException(__METHOD_NAME__,
"Error in collimator");
87 G4cerr << __METHOD_NAME__ <<
"half aperture exit bigger than width or height!" << G4endl;
88 G4cerr <<
"Full horizontal width is " <<
horizontalWidth <<
" mm for component named: \""
89 <<
name <<
"\"" << G4endl;
91 throw BDSException(__METHOD_NAME__,
"Error in collimator");
95 {BDS::Warning(__METHOD_NAME__,
"element: \"" +
name +
"\": no entrance aperture set for collimator - exit aperture parameters will be ignored");}
120 containerSolid =
new G4Tubs(
name +
"_solid",
129 containerSolid =
new G4Box(
name +
"_container_solid",
135 containerLogicalVolume =
new G4LogicalVolume(containerSolid,
137 name +
"_container_lv");
151 G4RotationMatrix* colRotate;
156 colRotate =
new G4RotationMatrix;
157 colRotate->rotateX(CLHEP::pi);
161 {colRotate =
nullptr;}
163 G4VSolid* outerSolid;
166 outerSolid =
new G4Tubs(
name +
"_outer_solid",
175 outerSolid =
new G4Box(
name +
"_outer_solid",
185 if (buildVacuumAndAperture)
199 name +
"_collimator_lv");
202 BDSAcceleratorModel::Instance()->
VolumeSet(
"collimators")->insert(collimatorLV);
204 G4VisAttributes* collimatorVisAttr =
new G4VisAttributes(*
colour);
205 collimatorLV->SetVisAttributes(collimatorVisAttr);
215 G4PVPlacement* collPV =
new G4PVPlacement(colRotate,
218 name +
"_collimator_pv",
219 containerLogicalVolume,
226 if (buildVacuumAndAperture)
228 G4LogicalVolume* vacuumLV =
new G4LogicalVolume(
vacuumSolid,
230 name +
"_vacuum_lv");
240 G4PVPlacement* vacPV =
new G4PVPlacement(colRotate,
244 containerLogicalVolume,
259 G4UserLimits* collUserLimits =
new G4UserLimits(*
userLimits);
262 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 G4Material * emptyMaterial
Useful variable often used in construction.
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.
G4bool circularOuter
Aperture type of the collimator.
G4double minKineticEnergy
Optional minimum kinetic energy for collimator materials.
G4double xAperture
Aperture at entrance in x dimension.
G4UserLimits * CollimatorUserLimits()
Return either default user limits or custom ones based on optional minimumKineticEnergy.
G4bool tapered
Flag for tapered collimator.
virtual void BuildInnerCollimator()=0
G4double yApertureOut
Aperture at exit in y dimension.
G4VSolid * innerSolid
Geometrical objects:
virtual void CheckParameters()
G4double xApertureOut
Aperture at exit in x dimension.
virtual G4String Material() const
Accessor.
G4Material * vacuumMaterial
Vacuum material.
G4double horizontalWidth
Horizontal width.
G4VSolid * vacuumSolid
Geometrical objects:
G4double yAperture
Aperture at entrance in y dimension.
virtual void BuildContainerLogicalVolume()
BDSCollimator()=delete
Private default constructor to force the use of the supplied one.
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 RegisterRotationMatrix(G4RotationMatrix *rotationMatrix)
void RegisterLogicalVolume(G4LogicalVolume *logicalVolume)
void RegisterPhysicalVolume(G4VPhysicalVolume *physicalVolume)
void RegisterUserLimits(G4UserLimits *userLimit)
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())