DLG4::VolumeBuilders
A fluent interface for Geant4 geometry definition.
Loading...
Searching...
No Matches
Functions
PlacementConfigs

Functions

DerivedPtr PlaceAndFork ()
 
DerivedPtr SetPhysRotation (const G4RotationMatrix &rot)
 
DerivedPtr SetPhysOffset (const Unit3Vec &offset={CLHEP::mm, 0, 0, 0})
 
DerivedPtr SetPhysTransform (const UnitlessG4Transform3D &new_transform)
 
G4Transform3D GetPhysTransform () const
 
DerivedPtr OverridePlacementName (const G4String &pName)
 
DerivedPtr SetCopyNo (G4int pCopyNo)
 
DerivedPtr SetSurfaceCheck (G4bool pSurfChk)
 
DerivedPtr SetMother (const BuilderView &mother)
 
DerivedPtr SetAutoPlacementNaming (bool set)
 
DerivedPtr SetAutoCopyNo (bool set)
 
DerivedPtr PlaceAndFork ()
 
DerivedPtr SetLogicalVolume (G4LogicalVolume *logical_volume)
 
DerivedPtr SetBooleanName (const G4String &name)
 
DerivedPtr SetPhysRotation (const G4RotationMatrix &rot)
 
DerivedPtr SetPhysOffset (const Unit3Vec &offset={CLHEP::mm, 0, 0, 0})
 
DerivedPtr SetPhysTransform (const UnitlessG4Transform3D &new_transform)
 
G4Transform3D GetPhysTransform () const final
 
DerivedPtr OverridePlacementName (const G4String &pName)
 
DerivedPtr SetCopyNo (G4int pCopyNo)
 
DerivedPtr SetSurfaceCheck (G4bool pSurfChk)
 
DerivedPtr SetMother (const BuilderView &mother)
 
DerivedPtr SetAutoPlacementNaming (bool set)
 
DerivedPtr SetAutoCopyNo (bool set)
 

Detailed Description

Placement Configuration Setters These all return the builder for fluent interface.

Function Documentation

◆ GetPhysTransform() [1/2]

template<typename U >
G4Transform3D GetPhysTransform ( ) const
inline

A helper to get the Physical Volume transform with units applied This is built from rotation and translatin if they were provided, or from a transform if it was provided, with units applied as specified.

Basically allows you to get the unit-multiplied version for use in direct Geant calls.

Returns
The Physical volume G4Transform3D with units applied.

Definition at line 290 of file StructureBuilder.hh.

290 {
291 return {placement_configs_->rotation, placement_configs_->translation};
292 }

◆ GetPhysTransform() [2/2]

template<typename U >
G4Transform3D GetPhysTransform ( ) const
inlinefinalvirtual

A helper to get the Physical Volume transform with units applied This is built from rotation and translatin if they were provided, or from a transform if it was provided, with units applied as specified.

Basically allows you to get the unit-multiplied version for use in direct Geant calls.

Returns
The Physical volume G4Transform3D with units applied.

Implements IVolumeBuilder.

Definition at line 383 of file VolumeBuilder.hh.

383 {
384 return {placement_configs_->rotation, placement_configs_->translation};
385 }

◆ OverridePlacementName() [1/2]

template<typename U >
DerivedPtr OverridePlacementName ( const G4String &  pName)

Set the placement name for the volume.


Parameters
pNameName for the placement.
Returns
This builder for chaining.

◆ OverridePlacementName() [2/2]

template<typename U >
VolumeBuilder< U >::DerivedPtr OverridePlacementName ( const G4String &  pName)

Set the placement name for the volume.


Parameters
pNameName for the placement.
Returns
This builder for chaining.

Definition at line 622 of file VolumeBuilder.hpp.

622 {
623 explicit_physical_copy_name_set_ = static_cast<bool>(pName);
624 this->placement_name_override_ = pName;
625 return this->shared_from_this();
626 }

◆ PlaceAndFork() [1/2]

template<typename U >
DerivedPtr PlaceAndFork ( )

An alias for MakePlacement and ClonePlacement Used for one or many unaltered placments in sequence, usually with auto naming and/or numbering.

Returns
The builder

◆ PlaceAndFork() [2/2]

template<typename U >
DerivedPtr PlaceAndFork ( )
inline

An alias for MakePlacement and ForkForPlacement Used for one or many unaltered placments in sequence, usually with auto naming and/or numbering.

Returns
The builder

Definition at line 109 of file VolumeBuilder.hh.

109 {
110 this->MakePlacement();
111 auto clone = this->ForkForPlacement(); // default/preset options
112 return clone;
113 }
DerivedPtr MakePlacement()
Make a placed physical volume.
DerivedPtr ForkForPlacement(std::optional< int > copy_no=std::nullopt, const G4String &name_override="", bool parent_name_was_set=false)
Calls MakeLogicalVolume() and creates a new builder instance with a copy of all placement-related con...

◆ SetAutoCopyNo() [1/2]

template<typename U >
DerivedPtr SetAutoCopyNo ( bool  set)

Enable (disable for false) auto Physical Volume numbering, on by default.


Adds a copy number to every name. By default copy numbers auto increment. Or you can set explicit names and numbers in ClonePlacement.

Parameters
setTrue before setting.
Returns

◆ SetAutoCopyNo() [2/2]

template<typename U >
VolumeBuilder< U >::DerivedPtr SetAutoCopyNo ( bool  set)

Enable (disable for false) auto Physical Volume numbering, on by default.


Adds a copy number to every name. By default copy numbers auto increment. Or you can set explicit names and numbers in ClonePlacement.

Parameters
setTrue before setting.
Returns

Definition at line 736 of file VolumeBuilder.hpp.

736 {
737 placement_configs_->auto_copyno = set;
738 if (set) {
739 placement_configs_->auto_copy_name = false;
740 }
741 return this->shared_from_this();
742 }

◆ SetAutoPlacementNaming() [1/2]

template<typename U >
DerivedPtr SetAutoPlacementNaming ( bool  set)

Enable auto Physical Volume naming.


Adds a copy number to every name. By default copy numbers auto increment.
This will turn that off. Both makes no sense.
Or you can set explicit names and numbers in ClonePlacement.

Parameters
setFalse before setting.
Returns

◆ SetAutoPlacementNaming() [2/2]

template<typename U >
VolumeBuilder< U >::DerivedPtr SetAutoPlacementNaming ( bool  set)

Enable auto Physical Volume naming.


Adds a copy number to every name. By default copy numbers auto increment.
This will turn that off. Both makes no sense.
Or you can set explicit names and numbers in ClonePlacement.

Parameters
setFalse before setting.
Returns

Definition at line 727 of file VolumeBuilder.hpp.

727 {
728 placement_configs_->auto_copy_name = set;
729 if (set) {
730 placement_configs_->auto_copyno = false;
731 }
732 return this->shared_from_this();
733 }

◆ SetBooleanName()

template<typename U >
VolumeBuilder< U >::DerivedPtr SetBooleanName ( const G4String &  name)

Pre-set base name for logical and physical volumes.

_L and _P will be appended, respectively.

If not set, the builder will take it from the builder name. But this is useful for unions where the starting solid name may be more specific.

Parameters
name

Definition at line 159 of file VolumeBuilder.hpp.

159 {
160 this->boolean_configs_->boolean_name = name;
161 return this->shared_from_this();
162 }

◆ SetCopyNo() [1/2]

template<typename U >
DerivedPtr SetCopyNo ( G4int  pCopyNo)

Set the copy number for the placement.


Parameters
pCopyNoCopy number.
Returns
This builder for chaining.

◆ SetCopyNo() [2/2]

template<typename U >
VolumeBuilder< U >::DerivedPtr SetCopyNo ( G4int  pCopyNo)

Set the copy number for the placement.


Parameters
pCopyNoCopy number.
Returns
This builder for chaining.

Definition at line 630 of file VolumeBuilder.hpp.

630 {
631 explicit_copyno_set_ = static_cast<bool>(pCopyNo);
632 this->placement_configs_->copy_no = pCopyNo;
633 return this->shared_from_this();
634 }

◆ SetLogicalVolume()

template<typename U >
VolumeBuilder< U >::DerivedPtr SetLogicalVolume ( G4LogicalVolume *  logical_volume)

Directly Provide a Logical Volume Instead of using the builder.

Parameters
logical_volume

Definition at line 192 of file VolumeBuilder.hpp.

192 {
193 SetLogicalVolume_impl(logical_volume);
194 return this->shared_from_this();
195 }

◆ SetMother() [1/2]

template<typename U >
DerivedPtr SetMother ( const BuilderView mother)

Set the mother volume with a builder, or G4VPhysicalVolume or G4VLogicalVolume through implicit conversion.


This does NOT immediately force a build the mother builder, just pre-sets the relationship.

Parameters
motherolumeReferencePtrparameter accepts a builder or a G4VSolid through implicit ctor
Returns
This builder for chaining.

◆ SetMother() [2/2]

template<typename U >
VolumeBuilder< U >::DerivedPtr SetMother ( const BuilderView mother)

Set the mother volume with a builder, or G4VPhysicalVolume or G4VLogicalVolume through implicit conversion.


This does NOT immediately force a build the mother builder, just pre-sets the relationship.

Parameters
motherolumeReferencePtrparameter accepts a builder or a G4VSolid through implicit ctor
Returns
This builder for chaining.

Definition at line 645 of file VolumeBuilder.hpp.

645 {
646 if (!mother) {
647 throw std::runtime_error("Error in VolumeBuilder::SetMother,"
648 "for builder named: \"" + builder_configs_->name + "\"\n"
649 " no valid mother physical volume provided");
650 // We cannot actually fully check this yet because we allow this to be a forward association
651 // The logical volume is not required to be constructable before we make a placement.
652 }
653 this->placement_configs_->mother = mother;
654 return this->shared_from_this();
655 }

◆ SetPhysOffset() [1/2]

template<typename U >
DerivedPtr SetPhysOffset ( const Unit3Vec offset = {CLHEP::mm, 0, 0, 0})

Set the translation vector for placement.

Using Set, rotation applies before translation, regardless of order set, just as in G4PVPlacement() You can pass (unit, x, y, z) or use the default unit with (x, y, z).

Examples: SetPhysOffset({CLHEP::cm, 1, 2, 3}) // 1cm, 2cm, 3cm SetPhysOffset({1, 2, 3}) // Uses default default unit (usually mm) SetDefaultUnit(CLHEP::cm); SetPhysOffset({1, 2, 3}) // 1cm, 2cm, 3cm SetDefaultUnit(1); SetPhysOffset({10*CLHEP::mm, 20*CLHEP::mm, 30*CLHEP::mm}) // Values already have units

Parameters
offsetTranslation vector. See method description for details.
Returns
This builder for chaining.

◆ SetPhysOffset() [2/2]

template<typename U >
VolumeBuilder< U >::DerivedPtr SetPhysOffset ( const Unit3Vec offset = {CLHEP::mm, 0, 0, 0})

Set the translation vector for placement.

Using Set, rotation applies before translation, regardless of order set, just as in G4PVPlacement() You can pass (unit, x, y, z) or use the default unit with (x, y, z).

Examples: SetPhysOffset({CLHEP::cm, 1, 2, 3}) // 1cm, 2cm, 3cm SetPhysOffset({1, 2, 3}) // Uses default default unit (usually mm) SetDefaultUnit(CLHEP::cm); SetPhysOffset({1, 2, 3}) // 1cm, 2cm, 3cm SetDefaultUnit(1); SetPhysOffset({10*CLHEP::mm, 20*CLHEP::mm, 30*CLHEP::mm}) // Values already have units

Parameters
offsetTranslation vector. See method description for details.
Returns
This builder for chaining.

Definition at line 561 of file VolumeBuilder.hpp.

561 {
562 const auto &offset = ProvisionUnits(new_offset);
563 placement_configs_->translation = offset;
564 PropagateTransform();
565 return this->shared_from_this();
566 }

◆ SetPhysRotation() [1/2]

template<typename U >
DerivedPtr SetPhysRotation ( const G4RotationMatrix &  rot)

Set the rotation matrix for placement.

Using Set, rotation applies before translation, regardless of order set, just as in G4PVPlacement()

Parameters
rotPointer to the rotation matrix.
Returns
This builder for chaining.

◆ SetPhysRotation() [2/2]

template<typename U >
VolumeBuilder< U >::DerivedPtr SetPhysRotation ( const G4RotationMatrix &  rot)

Set the rotation matrix for placement.

Using Set, rotation applies before translation, regardless of order set, just as in G4PVPlacement()

Parameters
rotPointer to the rotation matrix.
Returns
This builder for chaining.

Definition at line 538 of file VolumeBuilder.hpp.

538 {
539 G4RotationMatrix nullrot;
540 this->placement_configs_->rotation = rot;
541 PropagateTransform();
542 return this->shared_from_this();
543 }

◆ SetPhysTransform() [1/2]

template<typename U >
DerivedPtr SetPhysTransform ( const UnitlessG4Transform3D new_transform)

Set the G4Transform3D for placment The tranformation provided is meant to be UNITLESS unless you SetDefaultUnit(1).

Otherwise ex: SetDefaultUnit(CLHEP::cm) and proivde a UNITLESS transform. To supply units for each G4Tranform3D separately, just call SetDefaultUnit(unit) before each call. Will overwite/replace rotation and translation.

Parameters
new_transformTranslation vector.
Returns
This builder for chaining.

◆ SetPhysTransform() [2/2]

template<typename U >
VolumeBuilder< U >::DerivedPtr SetPhysTransform ( const UnitlessG4Transform3D new_transform)

Set the G4Transform3D for placment The tranformation provided is meant to be UNITLESS unless you SetDefaultUnit(1).

Otherwise ex: SetDefaultUnit(CLHEP::cm) and proivde a UNITLESS transform. To supply units for each G4Tranform3D separately, just call SetDefaultUnit(unit) before each call. Will overwite/replace rotation and translation.

Parameters
new_transformTranslation vector.
Returns
This builder for chaining.

Definition at line 578 of file VolumeBuilder.hpp.

578 {
579 SetPhysRotation(new_transform.getRotation()); // gets a copy on stack
580 SetPhysOffset({GetEffectiveDefaultUnit(), new_transform.getTranslation()});
581 PropagateTransform();
582 return this->shared_from_this();
583 }
DerivedPtr SetPhysOffset(const Unit3Vec &offset={CLHEP::mm, 0, 0, 0})
Set the translation vector for placement.
DerivedPtr SetPhysRotation(const G4RotationMatrix &rot)
Set the rotation matrix for placement.
G4double GetEffectiveDefaultUnit() const
Get the builder default unit or global if not set.

◆ SetSurfaceCheck() [1/2]

template<typename U >
DerivedPtr SetSurfaceCheck ( G4bool  pSurfChk)

Set the surface check flag for the placement.


Parameters
pSurfChkBoolean flag for surface check.
Returns
This builder for chaining.

◆ SetSurfaceCheck() [2/2]

template<typename U >
VolumeBuilder< U >::DerivedPtr SetSurfaceCheck ( G4bool  pSurfChk)

Set the surface check flag for the placement.


Parameters
pSurfChkBoolean flag for surface check.
Returns
This builder for chaining.

Definition at line 638 of file VolumeBuilder.hpp.

638 {
639 this->placement_configs_->surface_check = pSurfChk;
640 return this->shared_from_this();
641 }