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,
60 component(componentIn),
61 positionStart(positionStartIn), positionMiddle(positionMiddleIn), positionEnd(positionEndIn),
62 rotationStart(rotationStartIn), rotationMiddle(rotationMiddleIn), rotationEnd(rotationEndIn),
63 referencePositionStart(referencePositionStartIn),
64 referencePositionMiddle(referencePositionMiddleIn),
65 referencePositionEnd(referencePositionEndIn),
66 referenceRotationStart(referenceRotationStartIn),
67 referenceRotationMiddle(referenceRotationMiddleIn),
68 referenceRotationEnd(referenceRotationEndIn),
69 sPositionStart(sPositionStartIn), sPositionMiddle(sPositionMiddleIn), sPositionEnd(sPositionEndIn),
70 tiltOffset(tiltOffsetIn),
71 samplerInfo(samplerInfoIn),
72 samplerPlacementTransform(nullptr),
86 if (samplerType == BDSSamplerType::plane)
88 G4ThreeVector dZLocal = G4ThreeVector(0,0,1);
95 else if (samplerType == BDSSamplerType::cylinder)
99BDSBeamlineElement::~BDSBeamlineElement()
116 std::vector<G4VPhysicalVolume*> allPlacementsFromThisAssembly;
117 auto it = av->GetVolumesIterator();
118 for (G4int i = 0; i < (G4int)av->TotalImprintedVolumes(); it++, i++)
119 {allPlacementsFromThisAssembly.push_back(*it);}
120 std::set<G4VPhysicalVolume*> result(allPlacementsFromThisAssembly.begin(), allPlacementsFromThisAssembly.end());
125 G4VPhysicalVolume* motherPV,
126 G4bool useCLPlacementTransform,
128 G4bool checkOverlaps)
const
131 if (useCLPlacementTransform)
134 std::set<G4VPhysicalVolume*> result;
139 av->MakeImprint(motherPV->GetLogicalVolume(),
141 pvCopyNumber,checkOverlaps);
145 std::set_difference(updatedPVSet.begin(), updatedPVSet.end(),
146 existingPVSet.begin(), existingPVSet.end(),
147 std::inserter(result, result.begin()));
152 result.insert(
new G4PVPlacement(*pvTransform,
174 {
return inputFNLocal;}
178 return inputFNGlobal;
186 {
return outputFNLocal;}
190 return outputFNGlobal;
203 out <<
"Start, middle & end position: "
205 <<
"Start, middle & end rotation: "
207 <<
"Start, middle & end s position: "
220 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.