19#include "BDSAcceleratorModel.hh"
20#include "BDSBeamPipeInfo.hh"
21#include "BDSTipCollimator.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* collimatorTipMaterialIn,
48 G4Material* vacuumMaterialIn,
51 G4double xApertureOutIn,
52 G4double yApertureOutIn,
54 G4Colour* tipColourIn,
55 G4double tipThicknessIn,
56 G4bool circularOuterIn):
58 collimatorSolid(nullptr),
61 horizontalWidth(horizontalWidthIn),
62 collimatorMaterial(collimatorMaterialIn),
63 collimatorTipMaterial(collimatorTipMaterialIn),
64 vacuumMaterial(vacuumMaterialIn),
65 xAperture(xApertureIn),
66 yAperture(yApertureIn),
67 xApertureOut(xApertureOutIn),
68 yApertureOut(yApertureOutIn),
71 tipColour(tipColourIn),
72 tipThickness(tipThicknessIn),
74 circularOuter(circularOuterIn)
77BDSTipCollimator::~BDSTipCollimator()
84 G4cerr << __METHOD_NAME__ <<
"half aperture bigger than width or height!" << G4endl;
85 G4cerr <<
"Full horizontal width is " <<
horizontalWidth <<
" mm for component named: \""
86 <<
name <<
"\"" << G4endl;
87 G4cerr <<
"x (half) aperture " <<
xAperture <<
" mm, y (half) aperture " <<
yAperture <<
" mm" << G4endl;
88 throw BDSException(__METHOD_NAME__,
"Error in collimator");
93 G4cerr << __METHOD_NAME__ <<
"half aperture exit bigger than width or height!" << G4endl;
94 G4cerr <<
"Full horizontal width is " <<
horizontalWidth <<
" mm for component named: \""
95 <<
name <<
"\"" << G4endl;
97 throw BDSException(__METHOD_NAME__,
"Error in collimator");
101 {BDS::Warning(__METHOD_NAME__,
"element: \"" +
name +
"\": no entrance aperture set for collimator - exit aperture parameters will be ignored");}
128 containerSolid =
new G4Tubs(
name +
"_solid",
137 containerSolid =
new G4Box(
name +
"_container_solid",
143 containerLogicalVolume =
new G4LogicalVolume(containerSolid,
145 name +
"_container_lv");
159 G4RotationMatrix* colRotate;
164 colRotate =
new G4RotationMatrix;
165 colRotate->rotateX(CLHEP::pi);
169 {colRotate =
nullptr;}
171 G4VSolid* outerSolid;
174 outerSolid =
new G4Tubs(
name +
"_outer_solid",
183 outerSolid =
new G4Box(
name +
"_outer_solid",
193 if (buildVacuumAndAperture)
207 name +
"_collimator_lv");
210 BDSAcceleratorModel::Instance()->
VolumeSet(
"collimators")->insert(collimatorLV);
212 G4VisAttributes* collimatorVisAttr =
new G4VisAttributes(*
colour);
213 collimatorLV->SetVisAttributes(collimatorVisAttr);
223 G4PVPlacement* collPV =
new G4PVPlacement(colRotate,
226 name +
"_collimator_pv",
227 containerLogicalVolume,
234 if (buildVacuumAndAperture)
236 G4LogicalVolume* vacuumLV =
new G4LogicalVolume(
vacuumSolid,
238 name +
"_vacuum_lv");
248 G4PVPlacement* vacPV =
new G4PVPlacement(colRotate,
252 containerLogicalVolume,
267 G4UserLimits* collUserLimits =
new G4UserLimits(*
userLimits);
270 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.
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.
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)
G4double xApertureOut
Aperture at exit in x dimension.
G4double yAperture
Aperture at entrance in y dimension.
virtual void CheckParameters()
G4VSolid * innerSolid
Geometrical objects:
G4double minKineticEnergy
Optional minimum kinetic energy for collimator materials.
G4double horizontalWidth
Horizontal width.
G4Colour * tipColour
Colour of collimator tip.
G4VSolid * collimatorSolid
Geometrical objects:
virtual G4String Material() const
Accessor.
G4double yApertureOut
Aperture at exit in y dimension.
G4Material * vacuumMaterial
Vacuum material.
G4Colour * colour
Colour of collimator.
G4Material * collimatorMaterial
Material.
BDSTipCollimator()=delete
Private default constructor to force the use of the supplied one.
virtual void BuildContainerLogicalVolume()
G4UserLimits * CollimatorUserLimits()
Return either default user limits or custom ones based on optional minimumKineticEnergy.
G4double xAperture
Aperture at entrance in x dimension.
virtual void BuildInnerCollimator()=0
G4bool tapered
Flag for tapered collimator.
G4VSolid * vacuumSolid
Geometrical objects:
G4bool circularOuter
Aperture type of the collimator.
G4bool IsFinite(G4double value, G4double tolerance=std::numeric_limits< double >::epsilon())