19#include "BDSBeamlineElement.hh"
21#include "BDSAcceleratorComponent.hh"
22#include "BDSBeamline.hh"
23#include "BDSExtentGlobal.hh"
24#include "BDSSamplerPlane.hh"
25#include "BDSSamplerType.hh"
26#include "BDSTiltOffset.hh"
27#include "BDSUtilities.hh"
29#include "G4AssemblyVolume.hh"
30#include "G4PVPlacement.hh"
31#include "G4RotationMatrix.hh"
33#include "G4ThreeVector.hh"
42 const G4ThreeVector& positionStartIn,
43 const G4ThreeVector& positionMiddleIn,
44 const G4ThreeVector& positionEndIn,
45 G4RotationMatrix* rotationStartIn,
46 G4RotationMatrix* rotationMiddleIn,
47 G4RotationMatrix* rotationEndIn,
48 const G4ThreeVector& referencePositionStartIn,
49 const G4ThreeVector& referencePositionMiddleIn,
50 const G4ThreeVector& referencePositionEndIn,
51 G4RotationMatrix* referenceRotationStartIn,
52 G4RotationMatrix* referenceRotationMiddleIn,
53 G4RotationMatrix* referenceRotationEndIn,
54 G4double sPositionStartIn,
55 G4double sPositionMiddleIn,
56 G4double sPositionEndIn,
57 G4double synchronousTMiddleIn,
58 G4double startMomentumIn,
59 G4double startKineticEnergyIn,
63 component(componentIn),
64 positionStart(positionStartIn), positionMiddle(positionMiddleIn), positionEnd(positionEndIn),
65 rotationStart(rotationStartIn), rotationMiddle(rotationMiddleIn), rotationEnd(rotationEndIn),
66 referencePositionStart(referencePositionStartIn),
67 referencePositionMiddle(referencePositionMiddleIn),
68 referencePositionEnd(referencePositionEndIn),
69 referenceRotationStart(referenceRotationStartIn),
70 referenceRotationMiddle(referenceRotationMiddleIn),
71 referenceRotationEnd(referenceRotationEndIn),
72 sPositionStart(sPositionStartIn), sPositionMiddle(sPositionMiddleIn), sPositionEnd(sPositionEndIn),
73 synchronousTMiddle(synchronousTMiddleIn),
74 startMomentum(startMomentumIn),
75 startKineticEnergy(startKineticEnergyIn),
76 tiltOffset(tiltOffsetIn),
77 samplerInfo(samplerInfoIn),
78 samplerPlacementTransform(nullptr),
92 if (samplerType == BDSSamplerType::plane)
94 G4ThreeVector dZLocal = G4ThreeVector(0,0,1);
101 else if (samplerType == BDSSamplerType::cylinder)
105BDSBeamlineElement::~BDSBeamlineElement()
122 std::vector<G4VPhysicalVolume*> allPlacementsFromThisAssembly;
123 auto it = av->GetVolumesIterator();
124 for (G4int i = 0; i < (G4int)av->TotalImprintedVolumes(); it++, i++)
125 {allPlacementsFromThisAssembly.push_back(*it);}
126 std::set<G4VPhysicalVolume*> result(allPlacementsFromThisAssembly.begin(), allPlacementsFromThisAssembly.end());
131 G4VPhysicalVolume* motherPV,
132 G4bool useCLPlacementTransform,
134 G4bool checkOverlaps)
const
137 if (useCLPlacementTransform)
140 std::set<G4VPhysicalVolume*> result;
145 av->MakeImprint(motherPV->GetLogicalVolume(),
147 pvCopyNumber,checkOverlaps);
151 std::set_difference(updatedPVSet.begin(), updatedPVSet.end(),
152 existingPVSet.begin(), existingPVSet.end(),
153 std::inserter(result, result.begin()));
158 result.insert(
new G4PVPlacement(*pvTransform,
180 {
return inputFNLocal;}
184 return inputFNGlobal;
192 {
return outputFNLocal;}
196 return outputFNGlobal;
209 out <<
"Start, middle & end position: "
211 <<
"Start, middle & end rotation: "
213 <<
"Start, middle & end s position: "
226 return thisGlobal.Overlaps(otherGlobal);
Abstract class that represents a component of an accelerator.
virtual G4String GetName() const
The name of the component without modification.
G4ThreeVector OutputFaceNormal() const
G4int GetCopyNumber() const
Get the number of times this component has been copied.
G4ThreeVector InputFaceNormal() const
void IncrementCopyNumber()
Increment (+1) the number of times this component has been copied.
A class that holds a fully constructed BDSAcceleratorComponent as well as any information relevant to...
G4ThreeVector OutputFaceNormal() const
Return face normal accounting for placement tilt of this component.
G4ThreeVector GetPositionMiddle() const
Accessor.
G4RotationMatrix * referenceRotationMiddle
BDSAcceleratorComponent * component
The accelerator component.
G4ThreeVector GetPositionEnd() const
Accessor.
BDSTiltOffset * tiltOffset
The tilt and offset this element was constructed with. Default is nullptr.
BDSSamplerType GetSamplerType() const
Accessor.
G4Transform3D * placementTransform
G4RotationMatrix * GetRotationEnd() const
Accessor.
std::set< G4VPhysicalVolume * > PlaceElement(const G4String &pvName, G4VPhysicalVolume *containerPV, G4bool useCLPlacementTransform, G4int copyNumber, G4bool checkOverlaps) const
G4ThreeVector GetPositionStart() const
Accessor.
void UpdateSamplerPlacementTransform(const G4Transform3D &tranfsormIn)
G4ThreeVector referencePositionEnd
G4ThreeVector InputFaceNormal() const
Return face normal accounting for placement tilt of this component.
G4Transform3D * samplerPlacementTransform
G4Transform3D * GetPlacementTransform() const
Accessor.
G4Transform3D * placementTransformCL
G4double GetSPositionEnd() const
Accessor.
G4RotationMatrix * GetRotationStart() const
Accessor.
BDSAcceleratorComponent * GetAcceleratorComponent() const
Accessor.
G4Transform3D * GetPlacementTransformCL() const
Accessor.
G4bool Overlaps(const BDSBeamlineElement *otherElement) const
Whether this beam line element will overlaps in 3D Cartesian coordinates with another.
G4ThreeVector positionMiddle
Global coordinates for the start, middle and end of this beamline element.
G4int copyNumber
identification number of AcceleratorComponent (0 for first volume of given type)
G4RotationMatrix * referenceRotationStart
G4RotationMatrix * rotationStart
Global rotation matrices for the start, middle and end of this beamline element.
G4RotationMatrix * rotationMiddle
Global rotation matrices for the start, middle and end of this beamline element.
G4double GetSPositionMiddle() const
Accessor.
G4RotationMatrix * rotationEnd
Global rotation matrices for the start, middle and end of this beamline element.
G4RotationMatrix * referenceRotationEnd
G4RotationMatrix * GetRotationMiddle() const
Accessor.
static std::set< G4VPhysicalVolume * > GetPVsFromAssembly(G4AssemblyVolume *av)
Utility method to account for the interface in G4AssemblyVolume.
G4ThreeVector referencePositionMiddle
BDSExtentGlobal GetExtentGlobal() const
Create a global extent object from the extent of the component.
G4double GetSPositionStart() const
Accessor.
static G4double PaddingLength()
Access the padding length between each element added to the beamline.
Holder for +- extents in 3 dimensions with a rotation and translation.
Holder for +- extents in 3 dimensions.
G4LogicalVolume * GetContainerLogicalVolume() const
Accessor - see member for more info.
G4bool ContainerIsAssembly() const
Whether the container is an assembly. If not, it's a logical volume.
BDSExtent GetExtent() const
Accessor - see member for more info.
G4AssemblyVolume * GetContainerAssemblyVolume() const
Accessor - see member for more info.
All info required to build a sampler but not place it.
static G4double ChordLength()
Access the sampler plane length in other classes.
A holder for any placement offsets and rotations for a BDSAcceleratorComponent.
G4double GetTilt() const
Accessor.