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 DLG4::VolumeBuilders::ThreeVecDimensioner &offset={0, 0, 0, VB::Length::mm})
 
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 VolumeBuilder &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 DLG4::VolumeBuilders::ThreeVecDimensioner &offset={0, 0, 0, VB::Length::mm})
 
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 VolumeBuilder &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 294 of file StructureBuilderBase.hh.

294 {
295 return {placement_configs_->rotation, placement_configs_->translation};
296 }

◆ 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 387 of file VolumeBuilderBase.hh.

387 {
388 return {placement_configs_->rotation, placement_configs_->translation};
389 }

◆ 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 >
VolumeBuilderBase< 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 619 of file VolumeBuilderBase.hpp.

619 {
620 explicit_physical_copy_name_set_ = static_cast<bool>(pName);
621 this->placement_name_override_ = pName;
622 return this->shared_from_this();
623 }

◆ 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 112 of file VolumeBuilderBase.hh.

112 {
113 this->MakePlacement();
114 auto clone = this->ForkForPlacement(); // default/preset options
115 return clone;
116 }
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 >
VolumeBuilderBase< 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 733 of file VolumeBuilderBase.hpp.

733 {
734 placement_configs_->auto_copyno = set;
735 if (set) {
736 placement_configs_->auto_copy_name = false;
737 }
738 return this->shared_from_this();
739 }

◆ 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 >
VolumeBuilderBase< 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 724 of file VolumeBuilderBase.hpp.

724 {
725 placement_configs_->auto_copy_name = set;
726 if (set) {
727 placement_configs_->auto_copyno = false;
728 }
729 return this->shared_from_this();
730 }

◆ SetBooleanName()

template<typename U >
VolumeBuilderBase< 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 156 of file VolumeBuilderBase.hpp.

156 {
157 this->boolean_configs_->boolean_name = name;
158 return this->shared_from_this();
159 }

◆ 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 >
VolumeBuilderBase< U >::DerivedPtr SetCopyNo ( G4int  pCopyNo)

Set the copy number for the placement.


Parameters
pCopyNoCopy number.
Returns
This builder for chaining.

Definition at line 627 of file VolumeBuilderBase.hpp.

627 {
628 explicit_copyno_set_ = static_cast<bool>(pCopyNo);
629 this->placement_configs_->copy_no = pCopyNo;
630 return this->shared_from_this();
631 }

◆ SetLogicalVolume()

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

Directly Provide a Logical Volume Instead of using the builder.

Parameters
logical_volume

Definition at line 189 of file VolumeBuilderBase.hpp.

189 {
190 SetLogicalVolume_impl(logical_volume);
191 return this->shared_from_this();
192 }

◆ SetMother() [1/2]

template<typename U >
DerivedPtr SetMother ( const VolumeBuilder 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
motherBuilderView parameter accepts a builder or a G4VSolid through implicit ctor
Returns
This builder for chaining.

◆ SetMother() [2/2]

template<typename U >
VolumeBuilderBase< U >::DerivedPtr SetMother ( const VolumeBuilder 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
motherBuilderVew parameter accepts a builder or a G4VSolid through implicit ctor
Returns
This builder for chaining.

Definition at line 642 of file VolumeBuilderBase.hpp.

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

◆ SetPhysOffset() [1/2]

template<typename U >
DerivedPtr SetPhysOffset ( const DLG4::VolumeBuilders::ThreeVecDimensioner offset = {0, 0, 0, VB::Length::mm})

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({ 1, 2, 3, VB::cm}) // 1cm, 2cm, 3cm SetPhysOffset({1, 2, 3}) // Uses default default unit (usually mm) SetDefaultUnit(VB::cm); SetPhysOffset({1, 2, 3}) // 1cm, 2cm, 3cm // or work with raw geant values, must use CLHEP units, not VB: SetDefaultUnit(VB::native); SetPhysOffset({10*CLHEP::mm, 20*CLHEP::mm, 30*CLHEP::mm})

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

◆ SetPhysOffset() [2/2]

template<typename U >
VolumeBuilderBase< U >::DerivedPtr SetPhysOffset ( const DLG4::VolumeBuilders::ThreeVecDimensioner offset = {0, 0, 0, VB::Length::mm})

Set the translation vector for placement.

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

Examples: SetPhysOffset({ 1, 2, 3, VB::cm}) // 1cm, 2cm, 3cm SetPhysOffset({1, 2, 3}) // Uses default default unit (usually mm) SetDefaultUnit(VB::cm); SetPhysOffset({1, 2, 3}) // 1cm, 2cm, 3cm // or work with raw geant values, must use CLHEP units, not VB: SetDefaultUnit(VB::native); SetPhysOffset({10*CLHEP::mm, 20*CLHEP::mm, 30*CLHEP::mm})

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

Definition at line 558 of file VolumeBuilderBase.hpp.

558 {
559 const auto &offset = ProvisionUnits(new_offset);
560 placement_configs_->translation = offset;
561 PropagateTransform();
562 return this->shared_from_this();
563 }

◆ 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 >
VolumeBuilderBase< 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 535 of file VolumeBuilderBase.hpp.

535 {
536 G4RotationMatrix nullrot;
537 this->placement_configs_->rotation = rot;
538 PropagateTransform();
539 return this->shared_from_this();
540 }

◆ 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(VB::Length::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 >
VolumeBuilderBase< U >::DerivedPtr SetPhysTransform ( const UnitlessG4Transform3D new_transform)

Set the G4Transform3D for placment.

The tranformation provided is meant to be in UNITLESS values. Ie the unit is already pre-configured but not included in the values. So passing 5 means 5cm if SetDefault(VB::Length::cm) was set. Otherwise you SetDefaultUnit(VB::roaw), and pass a value that was already multipled by units. To supply different units for each G4Tranform3D separately, just call SetDefaultUnit(unit) before each call. The call will overwite/replace rotation and translation.

Parameters
new_transformTranslation vector.
Returns
This builder for chaining.

Definition at line 575 of file VolumeBuilderBase.hpp.

575 {
576 SetPhysRotation(new_transform.getRotation()); // gets a copy on stack
577 SetPhysOffset({ (G4ThreeVector)new_transform.getTranslation(), GetEffectiveDefaultUnit()});
578 PropagateTransform();
579 return this->shared_from_this();
580 }
DerivedPtr SetPhysRotation(const G4RotationMatrix &rot)
Set the rotation matrix for placement.
DerivedPtr SetPhysOffset(const DLG4::VolumeBuilders::ThreeVecDimensioner &offset={0, 0, 0, VB::Length::mm})
Set the translation vector for placement.
Length 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 >
VolumeBuilderBase< 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 635 of file VolumeBuilderBase.hpp.

635 {
636 this->placement_configs_->surface_check = pSurfChk;
637 return this->shared_from_this();
638 }