pyg4ometry.geant4.Registry¶
Classes¶
Object to store geometry for input and output. |
|
Functions¶
|
|
|
|
|
Analyse a geometry tree starting from a logical volume. |
|
|
|
Produce a pandas dataframe representing the structure of the geometry. |
|
Module Contents¶
- pyg4ometry.geant4.Registry.solidName(var)¶
- pyg4ometry.geant4.Registry.removeprefix(string, prefix, /)¶
- class pyg4ometry.geant4.Registry.Registry¶
Object to store geometry for input and output. All of the pyg4ometry classes can be used without storing them in the Registry. The registry is used to write the GDML output file. A registry needs to be used in conjunction with GDML Define objects for evaluation of expressions.
- materialList = []¶
- defineDict¶
- materialDict¶
- solidDict¶
- logicalVolumeDict¶
- assemblyVolumeDict¶
- physicalVolumeDict¶
- surfaceDict¶
- loopDict¶
- logicalVolumeList = []¶
- solidUsageCountDict¶
- volumeTypeCountDict¶
- physicalVolumeCountDict¶
- surfaceTypeCountDict¶
- logicalVolumeMeshSkip = []¶
- userInfo = []¶
- defineNameCount¶
- materialNameCount¶
- materialUsageCount¶
- solidNameCount¶
- logicalVolumeNameCount¶
- assemblyVolumeNameCount¶
- physicalVolumeNameCount¶
- surfaceNameCount¶
- solidTypeCountDict¶
- logicalVolumeUsageCountDict¶
- editedSolids = []¶
- expressionParser = None¶
- clear()¶
Empty all internal structures
- getExpressionParser()¶
- registerSolidEdit(solid)¶
- addMaterial(material, dontWarnIfAlreadyAdded=False)¶
Register a material with this registry.
- Parameters:
material (Material) – Material object for storage
- transferMaterial(material, incrementRenameDict={}, userRenameDict=None)¶
Transfer a material to this registry. This can operate on a Material, an Isotope and an Element instance.
- addSolid(solid)¶
Register a solid with this registry.
- Parameters:
solid (One of the geant4 solids) – Solid object for storage
- transferSolid(solid, incrementRenameDict={}, userRenameDict=None)¶
Transfer a solid to this registry. Doesn’t handle any members’ transferal - only the solid itself.
- Parameters:
solid (One of the geant4 solids) – Solid object for storage
- addLogicalVolume(volume)¶
Register a logical volume with this registry. Also accepts Assembly Volumes.
- Parameters:
volume (LogicalVolume) – LogicalVolume object for storage
- transferLogicalVolume(volume, incrementRenameDict={}, userRenameDict=None)¶
Transfer a logical volume to this registry. Doesn’t handle any members’ transferal - only the logical volume itself.
- addPhysicalVolume(volume)¶
Registry a physical volume with this registry.
- Parameters:
volume (PhysicalVolume) – PhysicalVolume object for storage
- transferPhysicalVolume(volume, incrementRenameDict={}, userRenameDict=None)¶
Transfer a physical volume to this registry. Doesn’t handle any members’ transferal - only the physical volume itself.
- addSurface(surface)¶
Register a surface with this registry.
- Parameters:
surface (pyg4ometry.geant4.BorderSurface or pyg4ometry.geant4.SkinSurface) – Surface
- transferSurface(surface, incrementRenameDict={}, userRenameDict=None)¶
Transfer a surface to this registry.
- addAuxiliary(auxiliary)¶
- addDefine(define)¶
Register a define with this registry.
- transferDefine(define, incrementRenameDict={}, userRenameDict=None)¶
Transfer a single define from another registry to this one. No checking on previous registry or not.
- transferDefines(var, otherRegistry, incrementRenameDict={}, userRenameDict=None)¶
This function tolerates all types of defines including vector ones.
Transfer defines from one registry to another recursively. A define may not be part of the old registry so won’t be added to this one. A define may be a vector or composite and its ‘bits’ may be in the (old) registry so each part should be checked.
In “3x + 2”, “x” would be a variable”. In “3.5*2” there would be no variables.
- setWorld(worldIn)¶
The argument can either be the name of logical volume of the world or the pyg4ometry.geant4.LogicalVolume instance of the world volume. The term world is used to refer to the outermost volume of the hierarchy.
- setWorldVolume(worldIn)¶
An alias for some of us who can’t remember.
- _orderMaterialList(materials, materials_ordered=[])¶
- orderMaterials()¶
Need to have a ordered list of all material entities for writing to GDML. GDML needs to have the isotopes/elements/materials defined in use order
- orderLogicalVolumes(lvName, first=True)¶
Need to have an ordered list from most basic (solid) object upto physical/logical volumes for writing to GDML. GDML needs to have the solids/booleans/volumes defined in order
- addVolumeRecursive(volume, collapseAssemblies=False, incrementRenameDict=None, userRenameDict=None)¶
Transfer a volume hierarchy to this registry. Any objects that had a registry set to another will be set to this one and will be owned by it effectively. :param volume: PhysicalVolume or LogicalVolume or AssemblyVolume. :type volume: pyg4ometry.geant4.PhysicalVolume, pyg4ometry.geant4.LogicalVolume, pyg4ometry.geant4.AssemblyVolume. :param collapseAssemblies: if True, daughters of AssemblyVolume’s will be attached directly to the mother of the assembly and the AssemblyVolume itself will be eliminated from the geometry tree :param incrementRenameDict: ignore - dictionary used internally for potentially incrementing names :param userRenameDict: a dictionary of find/replace regex strings to be used to rename volumes/materials/etc.
In the case where some object or variable has a name (e.g. ‘X’) that already exists in this registry, it will be incremented to ‘X_1’.
- addAndCollapseAssemblyVolumeRecursive(assemblyPV, motherVol, positions, rotations, scales, names, incrementRenameDict, userRenameDict)¶
Transfer and collapse an AssemblyVolume hierarchy to this registry. Daughter volumes are copied, renamed, and attached to the supplied mother LogicalVolume with the correct position/rotation. Any objects that had a registry set to another will be set to this one and will be owned by it effectively. :param assemblyPV: the PhysicalVolume that places an AssemblyVolume :param motherVol: the LogicalVolume to which all daughters of the AssemblyVolume (including any daughters of nested AssemblyVolume’s) should be attached :param positions: a list (initially empty) to hold position objects for each AssemblyVolume in a hierarchy of nested assemblies (used to correctly set the transformation of daughters within the motherVol) :param rotations: a list (initially empty) to hold rotation objects for each AssemblyVolume in a hierarchy of nested assemblies (used to correctly set the transformation of daughters within the motherVol) :param scales: a list (initially empty) to hold scale objects for each AssemblyVolume in a hierarchy of nested assemblies (used to correctly set the transformation of daughters within the motherVol) :param names: a list (initially empty) to hold the names of each AssemblyVolume in a hierarchy of nested assemblies (used to set unique names for the daughters within the motherVol) :param incrementRenameDict: ignore - dictionary used internally for potentially incrementing names :param userRenameDict: a dictionary of find/replace regex strings to be used to rename volumes/materials/etc.
- transferSolidDefines(solid, incrementRenameDict={}, userRenameDict=None)¶
For each parameter in a given solid (unique to each) check if it’s a define and transfer that over.
- volumeTree(lvName)¶
Not sure what this method is used for
- solidTree(solidName)¶
Not sure what this method is used for
- getWorldVolume()¶
- printStats()¶
- structureAnalysis(lv_name=None, debug=False, level=0, df=None)¶
- _findDictByName(dic, nameFragment)¶
Find a object which name matches (or partially matches) nameFragment, returns a list of objects
- findSolidByName(nameFragment='box')¶
Find a solid which name matches (or partially matches) nameFragment, returns a list of solids
- findMaterialByName(nameFragment='G4_AIR')¶
Find a material which name matches (or partially matches) nameFragment, returns a list of materials
- findLogicalVolumeByName(nameFragment='World')¶
Find a logical volume which name matches (or partially matches) nameFragment, returns a list of LogicalVolumes
- findPhysicalVolumeByName(nameFragment)¶
Find a physical volume which name matches (or partially matches) nameFragment, returns a list of LogicalVolumes
- class pyg4ometry.geant4.Registry.GeometryComplexityInformation¶
- solids¶
- nDaughtersPerLV¶
- nDaughters¶
- booleanDepthCount¶
- booleanDepth¶
- printSummary(boolDepthLimit=3)¶
- pyg4ometry.geant4.Registry.AnalyseGeometryComplexity(logicalVolume)¶
Analyse a geometry tree starting from a logical volume. Produces an instance of
GeometryComplexityInformationwith summary information. Provides:count per solid type
number of daughters per logical volume
dictionary of N daughters for each logical volume name
depth count of Boolean solids
ie a Boolean of a Boolean returns 2, a Boolean of two primitives returns 1
a dictionary of boolean depth for each logical volume name
Example:
info = AnalyseGeometryComplexity(lv) info.printSummary()
- pyg4ometry.geant4.Registry._UpdateComplexity(lv, info)¶
- pyg4ometry.geant4.Registry.AnalyseGeometryStructure(registry, lv_name=None, debug=False, level=0, df=None)¶
Produce a pandas dataframe representing the structure of the geometry.
- pyg4ometry.geant4.Registry.DumpGeometryStructureTree(lv, depth=0)¶