Analysing Geometry
Finding volumes
Before editing geometry it is useful to find a logical volume. The registry contains all the logical volumes
using the GDML in pyg4ometry/test/gdmlG4examples/ChargeExchangeMC/
1import pyg4ometry
2r = pyg4ometry.gdml.Reader("lht.gdml")
3reg = r.getRegistry()
The registry
instance reg
has a member variable called logicalVolumeDict
so calling
reg.logicalVolumeDict.keys()
should print
In [4]: reg.logicalVolumeDict.keys()
Out[4]: odict_keys(['vMonitor', 'vMonitorBack', 'vTarget', 'vTargetInnerCover', 'vTargetColumn', 'vTargetInnerColumn',
'vTargetVacuumSpace', 'vTargetOuterCover', 'vCrystal', 'vCrystalRow', 'vCalorimeter', 'vVetoCounter',
'vOuterFerrumRing', 'vInnerFerrumRing', 'vInnerCuprumRing', 'vTargetWindow', 'vTargetWindowCap',
'vTargetWindowMylarCover', 'vTargetWindowAluminiumCover', 'vWorldVisible', 'World'])
then the LogicalVolume can be obtained simply from the dictionary
lv = reg.logicalVolumeDict['vTargetInnerColumn']
This lv
can be used for manipulating geometry, passing to visualisers etc.
Geometry Complexity Analysis
For a given logical volume we can get some statistics on the complexity of the geometry. A simple class called GeometryComplexityInformation is returned that has a serious of dictionaries with information.
cd pyg4ometry/test/gdmlCompoundExamples/bdsim_2
ipython
>>> import pyg4ometry
>>> r = pyg4ometry.gdml.Reader("22-size-variation-facetcrop-quad.gdml")
>>> info = pyg4ometry.geant4.AnalyseGeometryComplexity(r.getRegistry().getWorldVolume())
>>> info.printSummary()
Types of solids
ExtrudedSolid : 96
Tubs : 51
Intersection : 24
Polyhedra : 12
Subtraction : 6
Box : 1
# of daughters count
0 : 152
2 : 19
4 : 12
13 : 6
25 : 1
Depth of booleans count
1 : 30
Booleans width depth over 3
Solid name : n Booleans
>>> info. <tab>
comp.booleanDepth comp.nDaughtersPerLV
comp.booleanDepthCount comp.printSummary
comp.nDaughters comp.solids