Geometry IVGeometry IV
Makoto Asai (SLAC)Makoto Asai (SLAC)
Geant4 Tutorial CourseGeant4 Tutorial Course
Geant4 v8.2p01
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 22
ContentsContents
Magnetic fieldMagnetic field
Electric fieldElectric field
Advanced ways of placementAdvanced ways of placement
Nested parameterizationNested parameterization
Reflected volumeReflected volume
Assembly volumeAssembly volume
Geometry optimizationGeometry optimization
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 44
Magnetic field (1)Magnetic field (1) Create your Magnetic field classCreate your Magnetic field class
Uniform field : Uniform field :
Use an object of the G4UniformMagField classUse an object of the G4UniformMagField class
G4MagneticField* magField = G4MagneticField* magField =
new G4UniformMagField(G4ThreeVector(1.*Tesla,0.,0.);new G4UniformMagField(G4ThreeVector(1.*Tesla,0.,0.);
Non-uniform field :Non-uniform field :
Create your own concrete class derived from G4MagneticField Create your own concrete class derived from G4MagneticField
and implement and implement GetFieldValueGetFieldValue method. method.
void MyField::GetFieldValue(void MyField::GetFieldValue(
const double Point[4], double *field) constconst double Point[4], double *field) const
Point[0..2] are Point[0..2] are position in global coordinate systemposition in global coordinate system, Point[3] is , Point[3] is
timetime
field[0..2] are returning magnetic fieldfield[0..2] are returning magnetic field
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 55
Magnetic field (2)Magnetic field (2) Tell Geant4 to use your field Tell Geant4 to use your field
1.1. Find the global Field ManagerFind the global Field Manager
G4FieldManager* globalFieldMgr = G4FieldManager* globalFieldMgr =
G4TransportationManager::GetTransportationManager()G4TransportationManager::GetTransportationManager()
->GetFieldManager();->GetFieldManager();
2.2. Set the field for this FieldManager,Set the field for this FieldManager,
globalFieldMgr->SetDetectorField(magField);globalFieldMgr->SetDetectorField(magField);
3.3. and create a Chord Finder.and create a Chord Finder.
globalFieldMgr->CreateChordFinder(magField);globalFieldMgr->CreateChordFinder(magField);
/example/novice/N04/ExN04 is a good starting point/example/novice/N04/ExN04 is a good starting point
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 66
Global and local fieldsGlobal and local fields One field manager is associated with the ‘world’ and it is set in One field manager is associated with the ‘world’ and it is set in
G4TransportationManagerG4TransportationManager Other volumes can override thisOther volumes can override this
An alternative field manager can be associated with any logical An alternative field manager can be associated with any logical
volumevolume The field must accept The field must accept position in global coordinatesposition in global coordinates and return and return
field in global coordinatesfield in global coordinates By default this is propagated to all its daughter volumesBy default this is propagated to all its daughter volumes
G4FieldManager* localFieldMgr G4FieldManager* localFieldMgr
= new G4FieldManager(magField);= new G4FieldManager(magField);
logVolume->setFieldManager(localFieldMgr, true);logVolume->setFieldManager(localFieldMgr, true);
where where ‘‘truetrue’’ makes it push the field to all the volumes it contains, makes it push the field to all the volumes it contains,
unless a daughter has its own field manager.unless a daughter has its own field manager. Customizing the field propagation classesCustomizing the field propagation classes
Choosing an appropriate stepper for your fieldChoosing an appropriate stepper for your field Setting precision parametersSetting precision parameters
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 77
Field integrationField integration In order to propagate a particle inside a field (e.g. magnetic, electric In order to propagate a particle inside a field (e.g. magnetic, electric
or both), we solve or both), we solve the equation of motionthe equation of motion of the particle in the field. of the particle in the field. We use a Runge-Kutta method for the integration of the ordinary We use a Runge-Kutta method for the integration of the ordinary
differential equations of motion. differential equations of motion. Several Runge-Kutta ‘steppers’ are available.Several Runge-Kutta ‘steppers’ are available.
In specific cases other solvers can also be used: In specific cases other solvers can also be used: In a uniform field, using the analytical solution.In a uniform field, using the analytical solution. In a smooth but varying field, with RK+helix.In a smooth but varying field, with RK+helix.
Using the method to calculate the track's motion in a field, Geant4 Using the method to calculate the track's motion in a field, Geant4
breaks up this curved path into linear chord segments. breaks up this curved path into linear chord segments. We determine the chord segments so that they closely We determine the chord segments so that they closely
approximate the curved path.approximate the curved path.
‘Tracking’ StepChords
Real Trajectory
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 88
Tracking in fieldTracking in field We use the chords to interrogate the We use the chords to interrogate the G4NavigatorG4Navigator, to see whether the , to see whether the
track has crossed a volume boundary.track has crossed a volume boundary. One physics/tracking step can create several chords.One physics/tracking step can create several chords.
In some cases, one step consists of several helix turns.In some cases, one step consists of several helix turns. User can set the accuracy of the volume intersection, User can set the accuracy of the volume intersection,
By setting a parameter called the By setting a parameter called the “miss distance”“miss distance” It is a measure of the error in whether the approximate track It is a measure of the error in whether the approximate track
intersects a volume. intersects a volume. It is quite expensive in CPU performance to set too small “miss It is quite expensive in CPU performance to set too small “miss
distance”.distance”.
"miss distance"
‘Tracking’ StepChords
Real Trajectory
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 99
Tunable parametersTunable parameters In addition to the In addition to the “miss distance”“miss distance” there are two there are two
more parameters which the user can set in order to more parameters which the user can set in order to
adjust the accuracy (and performance) of tracking adjust the accuracy (and performance) of tracking
in a field. in a field.
These parameters govern the accuracy of the These parameters govern the accuracy of the
intersection with a volume boundary and the intersection with a volume boundary and the
accuracy of the integration of other steps. accuracy of the integration of other steps.
The The “delta intersection”“delta intersection” parameter is the accuracy parameter is the accuracy
to which an intersection with a volume boundary is to which an intersection with a volume boundary is
calculated. This parameter is especially important calculated. This parameter is especially important
because it is used to limit a bias that our algorithm because it is used to limit a bias that our algorithm
(for boundary crossing in a field) exhibits. The (for boundary crossing in a field) exhibits. The
intersection point is always on the 'inside' of the intersection point is always on the 'inside' of the
curve. By setting a value for this parameter that is curve. By setting a value for this parameter that is
much smaller than some acceptable error, the user much smaller than some acceptable error, the user
can limit the effect of this bias. can limit the effect of this bias.
boundary
realtrajectory
Chord
estimated intersection correct
intersection
““delta delta intersectiointersection”n”
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 1010
Tunable parametersTunable parameters The The “delta one step”“delta one step” parameter is the accuracy for the endpoint of parameter is the accuracy for the endpoint of
'ordinary' integration steps, those which do not intersect a volume 'ordinary' integration steps, those which do not intersect a volume
boundary. This parameter is a limit on the estimation error of the boundary. This parameter is a limit on the estimation error of the
endpoint of each physics step.endpoint of each physics step. ““delta intersection”delta intersection” and and “delta one step”“delta one step” are strongly coupled. These are strongly coupled. These
values must be reasonably close to each other. values must be reasonably close to each other. At most within one order of magnitudeAt most within one order of magnitude
These tunable parameters can be set byThese tunable parameters can be set by
theChordFinder->SetDeltaChordtheChordFinder->SetDeltaChord( ( miss_distancemiss_distance ); );
theFieldManager->SetDeltaIntersectiontheFieldManager->SetDeltaIntersection( delta_intersection );( delta_intersection );
theFieldManager->SetDeltaOneSteptheFieldManager->SetDeltaOneStep( delta_one_step );( delta_one_step );
Further details are described in Further details are described in Section 4.3 (Electromagnetic Field) of Section 4.3 (Electromagnetic Field) of
the Application Developers Manualthe Application Developers Manual..
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 1212
Customizing field integration Customizing field integration Runge-Kutta integration is used to compute the motion of a charged Runge-Kutta integration is used to compute the motion of a charged
track in a general field. There are many general steppers from which track in a general field. There are many general steppers from which to choose, of low and high order, and specialized steppers for pure to choose, of low and high order, and specialized steppers for pure magnetic fields. magnetic fields.
By default, Geant4 uses the classical fourth-order Runge-Kutta stepper By default, Geant4 uses the classical fourth-order Runge-Kutta stepper ((G4ClassicalRK4G4ClassicalRK4), which is general purpose and robust. ), which is general purpose and robust. If the field is known to have specific properties, lower or higher If the field is known to have specific properties, lower or higher
order steppers can be used to obtain the results of same quality order steppers can be used to obtain the results of same quality using fewer computing cycles. using fewer computing cycles.
In particular, if the field is calculated from a field map, a lower order In particular, if the field is calculated from a field map, a lower order stepper is recommended. The less smooth the field is, the lower the stepper is recommended. The less smooth the field is, the lower the order of the stepper that should be used. order of the stepper that should be used. The choice of lower order steppers includes the third order stepper The choice of lower order steppers includes the third order stepper
G4SimpleHeumG4SimpleHeum, the second order , the second order G4ImplicitEulerG4ImplicitEuler and and G4SimpleRungeG4SimpleRunge, and the first order , and the first order G4ExplicitEulerG4ExplicitEuler. A first order . A first order stepper would be useful only for very rough fields. stepper would be useful only for very rough fields.
For somewhat smooth fields (intermediate), the choice between For somewhat smooth fields (intermediate), the choice between second and third order steppers should be made by trial and error. second and third order steppers should be made by trial and error.
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 1313
Customizing field integration Customizing field integration Trying a few different types of steppers for a particular field or Trying a few different types of steppers for a particular field or
application is suggested if maximum performance is a goal. application is suggested if maximum performance is a goal.
Specialized steppers for pure magnetic fields are also available. They Specialized steppers for pure magnetic fields are also available. They
take into account the fact that a local trajectory in a slowly varying take into account the fact that a local trajectory in a slowly varying
field will not vary significantly from a helix. field will not vary significantly from a helix.
Combining this in with a variation, the Runge-Kutta method can Combining this in with a variation, the Runge-Kutta method can
provide higher accuracy at lower computational cost when large provide higher accuracy at lower computational cost when large
steps are possible. steps are possible.
To change the stepper To change the stepper
theChordFindertheChordFinder
->GetIntegrationDriver() ->GetIntegrationDriver()
->RenewStepperAndAdjust( newStepper ); ->RenewStepperAndAdjust( newStepper );
Further details are described in Further details are described in Section 4.3 (Electromagnetic Field) of Section 4.3 (Electromagnetic Field) of
the Application Developers Manualthe Application Developers Manual..
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 1414
Other types of fieldOther types of field The user can create their own type of field, inheriting from The user can create their own type of field, inheriting from G4VFieldG4VField, and an , and an
associated associated Equation of MotionEquation of Motion class (inheriting from class (inheriting from G4EqRhsG4EqRhs) to simulate other ) to simulate other types of fields. Field can be time-dependent.types of fields. Field can be time-dependent.
For pure electric field, Geant4 has For pure electric field, Geant4 has G4ElectricFieldG4ElectricField and and G4UniformElectricFieldG4UniformElectricField classes. For combined electromagnetic field, Geant4 has classes. For combined electromagnetic field, Geant4 has G4ElectroMagneticFieldG4ElectroMagneticField class. class.
Equation of Motion class for electromagnetic field is Equation of Motion class for electromagnetic field is G4MagElectricFieldG4MagElectricField..
G4ElectricFieldG4ElectricField* fEMfield* fEMfield
= new G4UniformElectricField( G4ThreeVector(0., 100000.*kilovolt/cm, 0.) ); = new G4UniformElectricField( G4ThreeVector(0., 100000.*kilovolt/cm, 0.) );
G4EqMagElectricFieldG4EqMagElectricField* fEquation = new G4EqMagElectricField(fEMfield); * fEquation = new G4EqMagElectricField(fEMfield);
G4MagIntegratorStepperG4MagIntegratorStepper* fStepper = new G4ClassicalRK4( fEquation, nvar ); * fStepper = new G4ClassicalRK4( fEquation, nvar );
G4FieldManager* fFieldMgrG4FieldManager* fFieldMgr
= G4TransportationManager::GetTransportationManager()-> = G4TransportationManager::GetTransportationManager()-> GetFieldManager(); GetFieldManager();
fFieldManager->fFieldManager->SetDetectorFieldSetDetectorField( fEMfield );( fEMfield );
G4MagInt_DriverG4MagInt_Driver* fIntgrDriver * fIntgrDriver
= new G4MagInt_Driver(fMinStep, fStepper,= new G4MagInt_Driver(fMinStep, fStepper,
fStepper->GetNumberOfVariables() );fStepper->GetNumberOfVariables() );
G4ChordFinderG4ChordFinder* fChordFinder = new G4ChordFinder(fIntgrDriver); * fChordFinder = new G4ChordFinder(fIntgrDriver);
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 1616
Nested parameterizationNested parameterization Suppose your geometry has three-dimensional regular reputation of
same shape and size of volumes without gap between volumes. And material of such volumes are changing according to the position.
E.g. voxels made by CT Scan data (DICOM) Instead of direct three-dimensional parameterized volume,
use replicas for the first and second axes sequentially, and then use one-dimensional parameterization along the third axis.
It requires much less memory for geometry optimization and gives much faster navigation for ultra-large number of voxels.
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 1717
Nested parameterizationNested parameterization
0
1
2
01
20 1 2 3
Given geometry is defined as two sequential replicas and then one-dimensional parameterization,
Material of a voxel must be parameterized not only by the copy number of the voxel, but also by the copy numbers of ancestors.
Material is indexed by three indices. G4VNestedParameterisation is a special parameterization class
derived from G4VPVParameterisation base class. ComputeMaterial() method of G4VNestedParameterisation has a
touchable object of the parent physical volume, in addition to the copy number of the voxel.
Index of first axis = theTouchable->GetCopyNumber(1); Index of second axis = theTouchable->GetCopyNumber(0); Index of third axis = copy number
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 1818
G4VNestedParameterisationG4VNestedParameterisation G4VNestedParameterisation is derived from G4VNestedParameterisation is derived from
G4VPVParameterization.G4VPVParameterization. G4VNestedParameterisation class has three G4VNestedParameterisation class has three pure virtualpure virtual methods methods
you have to implement, you have to implement, in addition to ComputeTransformation() method, which is in addition to ComputeTransformation() method, which is
mandatory for all G4VPVParameterization classes.mandatory for all G4VPVParameterization classes.
virtual G4Material* virtual G4Material* ComputeMaterialComputeMaterial(G4VPhysicalVolume (G4VPhysicalVolume *currentVol,*currentVol,const G4int repNo, const G4VTouchable *parentTouch=0)=0;const G4int repNo, const G4VTouchable *parentTouch=0)=0;
Return a material pointer w.r.t. copy numbers of itself and Return a material pointer w.r.t. copy numbers of itself and ancestors.ancestors.
Must cope with parentTouch=0 for navigator's sake. Typically, Must cope with parentTouch=0 for navigator's sake. Typically, return a default material if parentTouch=0.return a default material if parentTouch=0.
virtual G4int virtual G4int GetNumberOfMaterialsGetNumberOfMaterials() const=0;() const=0; Return total number of materials which may appear as the return Return total number of materials which may appear as the return
value of ComputeMaterial() method.value of ComputeMaterial() method.
virtual G4Material* virtual G4Material* GetMaterialGetMaterial(G4int idx) const=0;(G4int idx) const=0; Return idx-th material.Return idx-th material. ““idx” is not a copy number. idx = [0, nMaterial-1]idx” is not a copy number. idx = [0, nMaterial-1]
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 1919
G4VNestedParameterisationG4VNestedParameterisation G4VNestedParameterisation is a kind of G4VNestedParameterisation is a kind of
G4VPVParameterization.G4VPVParameterization. It can be used as an argument of G4PVParameterised.It can be used as an argument of G4PVParameterised. All other arguments of G4PVParameterised are unaffected.All other arguments of G4PVParameterised are unaffected.
Nested parameterization of placement volume is Nested parameterization of placement volume is notnot
supported. supported. All levels used as indices of material must be All levels used as indices of material must be repeated repeated
volumevolume. There cannot be a level of placement volume in . There cannot be a level of placement volume in
between.between.
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 2121
Grouping volumesGrouping volumes To represent a regular pattern of positioned volumes, composing a To represent a regular pattern of positioned volumes, composing a
more or less complex structuremore or less complex structure structures which are hard to describe with simple replicas or structures which are hard to describe with simple replicas or
parameterised volumesparameterised volumes structures which may consist of different shapesstructures which may consist of different shapes Too densely positioned to utilize a mother volume Too densely positioned to utilize a mother volume
Assembly volumeAssembly volume acts as an acts as an envelopeenvelope for its daughter volumes for its daughter volumes its role is over once its logical volume has been placedits role is over once its logical volume has been placed daughter physical volumes become independent copies in the daughter physical volumes become independent copies in the
final structurefinal structure Participating daughter logical volumes are treated as tripletsParticipating daughter logical volumes are treated as triplets
logical volumelogical volume translation w.r.t. enveloptranslation w.r.t. envelop rotation w.r.t. enveloprotation w.r.t. envelop
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 2222
G4AssemblyVolumeG4AssemblyVolumeG4AssemblyVolume::AddPlacedVolumeG4AssemblyVolume::AddPlacedVolume
( G4LogicalVolume* volume,( G4LogicalVolume* volume,
G4ThreeVector& translation,G4ThreeVector& translation,
G4RotationMatrix* rotation );G4RotationMatrix* rotation );
Helper class to combine daughter logical volumes in arbitrary wayHelper class to combine daughter logical volumes in arbitrary way Imprints of the assembly volume are made inside a mother Imprints of the assembly volume are made inside a mother
logical volume through logical volume through G4AssemblyVolume::MakeImprintG4AssemblyVolume::MakeImprint(…)(…)
Each physical volume name is generated automaticallyEach physical volume name is generated automatically Format: Format: avav_WWW__WWW_imprimpr_XXX_YYY_ZZZ_XXX_YYY_ZZZ
WWWWWW – assembly volume instance number – assembly volume instance number XXXXXX – assembly volume imprint number – assembly volume imprint number YYYYYY – name of the placed logical volume in the – name of the placed logical volume in the
assemblyassembly ZZZZZZ – index of the associated logical volume – index of the associated logical volume
Generated physical volumes (and related transformations) are Generated physical volumes (and related transformations) are
automatically managed (creation and destruction)automatically managed (creation and destruction)
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 2323
G4AssemblyVolume : exampleG4AssemblyVolume : exampleG4AssemblyVolume* assembly = new G4AssemblyVolume* assembly = new G4AssemblyVolumeG4AssemblyVolume();();
G4RotationMatrix Ra; G4RotationMatrix Ra;
G4ThreeVector Ta;G4ThreeVector Ta;
Ta.setX(…); Ta.setY(…); Ta.setZ(…);Ta.setX(…); Ta.setY(…); Ta.setZ(…);
assembly->assembly->AddPlacedVolumeAddPlacedVolume( plateLV, Ta, Ra );( plateLV, Ta, Ra );
… … // repeat placement for each daughter// repeat placement for each daughter
for( unsigned int i = 0; i < layers; i++ ) {for( unsigned int i = 0; i < layers; i++ ) {
G4RotationMatrix Rm(…);G4RotationMatrix Rm(…);
G4ThreeVector Tm(…);G4ThreeVector Tm(…);
assembly->assembly->MakeImprintMakeImprint( worldLV, Tm, Rm );( worldLV, Tm, Rm );
}}
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 2525
Reflecting solidsReflecting solids
G4ReflectedSolidG4ReflectedSolid (derived from G4VSolid) (derived from G4VSolid) Utility class representing a solid shifted from its original reference Utility class representing a solid shifted from its original reference
frame to a new frame to a new mirror symmetricmirror symmetric one one The reflection (G4Reflect[X/Y/Z]3D) is applied as a decomposition The reflection (G4Reflect[X/Y/Z]3D) is applied as a decomposition
into rotation and translationinto rotation and translation G4ReflectionFactoryG4ReflectionFactory
Singleton object using G4ReflectedSolid for generating Singleton object using G4ReflectedSolid for generating placements of reflected volumesplacements of reflected volumes
Reflections are currently limited to simple CSG solids.Reflections are currently limited to simple CSG solids. will be extended soon to all solidswill be extended soon to all solids
Let's take an example of a pair Let's take an example of a pair of mirror symmetric volumes.of mirror symmetric volumes.
Such geometry cannot be Such geometry cannot be made by parallel made by parallel transformation transformation
or 180 degree rotation.or 180 degree rotation.
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 2626
Reflecting hierarchies of volumes - 1Reflecting hierarchies of volumes - 1G4PhysicalVolumesPair G4ReflectionFactory::PlaceG4PhysicalVolumesPair G4ReflectionFactory::Place
(const G4Transform3D& transform3D, // the transformation(const G4Transform3D& transform3D, // the transformation
const G4String& name, // the nameconst G4String& name, // the name
G4LogicalVolume* LV, // the logical volumeG4LogicalVolume* LV, // the logical volume
G4LogicalVolume* motherLV, // the mother volumeG4LogicalVolume* motherLV, // the mother volume
G4bool noBool, // currently unusedG4bool noBool, // currently unused
G4int copyNo) // optional copy numberG4int copyNo) // optional copy number
Used for normal placements:Used for normal placements:
i.i. Performs the transformation decompositionPerforms the transformation decomposition
ii.ii. Generates a new reflected solid and logical volumeGenerates a new reflected solid and logical volume Retrieves it from a map if the reflected object is already createdRetrieves it from a map if the reflected object is already created
iii.iii. Transforms any daughter and places them in the given motherTransforms any daughter and places them in the given mother
iv.iv. Returns a pair of physical volumes, the second being a placement Returns a pair of physical volumes, the second being a placement in the reflected motherin the reflected mother
G4PhysicalVolumesPairG4PhysicalVolumesPair is is std::map<G4VPhysicalVolume*,G4VPhysicalVolume*>std::map<G4VPhysicalVolume*,G4VPhysicalVolume*>
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 2727
Reflecting hierarchies of volumes - 2Reflecting hierarchies of volumes - 2G4PhysicalVolumesPair G4ReflectionFactory::ReplicateG4PhysicalVolumesPair G4ReflectionFactory::Replicate
(const G4String& name, // the actual name(const G4String& name, // the actual name
G4LogicalVolume* LV, // the logical volumeG4LogicalVolume* LV, // the logical volume
G4LogicalVolume* motherLV, // the mother volumeG4LogicalVolume* motherLV, // the mother volume
Eaxis axis // axis of replicationEaxis axis // axis of replication
G4int replicaNo // number of replicasG4int replicaNo // number of replicas
G4int width, // width of single replicaG4int width, // width of single replica
G4int offset=0) // optional mother offsetG4int offset=0) // optional mother offset
Creates replicas in the given mother volumeCreates replicas in the given mother volume
Returns a pair of physical volumes, the second being a replica in the Returns a pair of physical volumes, the second being a replica in the
reflected motherreflected mother
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 2929
Smart voxelizationSmart voxelization In case of Geant 3.21, the user had to carefully implement his/her In case of Geant 3.21, the user had to carefully implement his/her
geometry to maximize the performance of geometrical navigation.geometry to maximize the performance of geometrical navigation.
While in Geant4, user’s geometry is automatically optimized to most While in Geant4, user’s geometry is automatically optimized to most
suitable to the navigation. - "Voxelization"suitable to the navigation. - "Voxelization"
For each mother volume, one-dimensional virtual division is performed.For each mother volume, one-dimensional virtual division is performed.
Subdivisions (slices) containing same volumes are gathered into one.Subdivisions (slices) containing same volumes are gathered into one.
Additional division again using second and/or third Cartesian axes, if Additional division again using second and/or third Cartesian axes, if
needed.needed.
"Smart voxels""Smart voxels" are computed at initialisation time are computed at initialisation time
When the detector geometry is When the detector geometry is closedclosed
Does not require large memory or computing resourcesDoes not require large memory or computing resources
At tracking time, searching is done in a hierarchy of virtual divisionsAt tracking time, searching is done in a hierarchy of virtual divisions
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 3030
Detector description tuningDetector description tuning Some geometry topologies may require ‘special’ tuning for ideal and Some geometry topologies may require ‘special’ tuning for ideal and
efficient optimisationefficient optimisation for example: a dense nucleus of volumes included in very large for example: a dense nucleus of volumes included in very large
mother volumemother volume Granularity of voxelisation can be explicitly setGranularity of voxelisation can be explicitly set
MethodsMethods Set/GetSmartless()Set/GetSmartless() from from G4LogicalVolumeG4LogicalVolume
Critical regions for optimisation can be detectedCritical regions for optimisation can be detected Helper class Helper class G4SmartVoxelStatG4SmartVoxelStat for monitoring time spent in for monitoring time spent in
detector geometry optimisationdetector geometry optimisation Automatically activated if Automatically activated if /run/verbose/run/verbose greater than greater than 11
Percent Memory Heads Nodes Pointers Total CPU VolumePercent Memory Heads Nodes Pointers Total CPU Volume
------- ------ ----- ----- -------- --------- ------------------ ------ ----- ----- -------- --------- -----------
91.70 1k 1 50 50 0.00 Calorimeter91.70 1k 1 50 50 0.00 Calorimeter
8.30 0k 1 3 4 0.00 Layer8.30 0k 1 3 4 0.00 Layer
Geometry IV - M.Asai (SLAC)Geometry IV - M.Asai (SLAC) 3131
Visualising voxel structureVisualising voxel structure
The computed voxel structure can be visualized with the final detector The computed voxel structure can be visualized with the final detector
geometrygeometry
Helper class Helper class G4DrawVoxelsG4DrawVoxels
Visualize voxels given a logical volumeVisualize voxels given a logical volume
G4DrawVoxels::DrawVoxels(const G4LogicalVolume*)G4DrawVoxels::DrawVoxels(const G4LogicalVolume*)
Allows setting of visualization attributes for voxelsAllows setting of visualization attributes for voxels
G4DrawVoxels::SetVoxelsVisAttributes(…)G4DrawVoxels::SetVoxelsVisAttributes(…)
useful for debugging purposesuseful for debugging purposes