pygeomhades package

Submodules

pygeomhades.cli module

pygeomhades.cli._parse_cli_args(argv=None)
Parameters:

argv (list[str] | None)

Return type:

Namespace

pygeomhades.cli.dump_gdml_cli(argv=None)
Parameters:

argv (list[str] | None)

Return type:

None

pygeomhades.core module

pygeomhades.core._place_pv(lv, name, mother_lv, reg, *, x_in_mm=0, y_in_mm=0, z_in_mm=0, x_rot=0, invert_z_axes=False)

Wrapper to place the physical volume more concisely.

Parameters:
Return type:

PhysicalVolume

pygeomhades.core.construct(config, public_geometry=False, plot_profiles=False)

Construct the HADES geometry.

Returns the registry containing the world volume.

Parameters:
  • config (AttrsDict) –

    configuration dictionary defining the geometry, e.g.,

    detector: V13049A
    daq_settings:
      flashcam:
        card_interface: efb2
    run: run0001
    measurement: th_HS2_top_psa
    source_position:
      phi_in_deg: 0.0
      r_in_mm: 0.0
      z_in_mm: 38.0
    

  • public_geometry (bool) – if true, uses the public geometry metadata instead of the LEGEND-internal legend-metadata.

  • plot_profiles (bool) – if true, plots the profiles of the volumes in the geometry using matplotlib.

Return type:

Registry

pygeomhades.core.translate_to_detector_frame(phi, r, z, source_type)

Translate the source position from metadata to detector frame.

In most cases this is purely a translation from cylindrical to Cartesian coordinates, but for the am_HS1 source there is an extra offset in r that is not well known.

Parameters:
  • phi (float) – the phi position of the source in degrees, as given in the metadata

  • r (float) – the r position of the source in mm, as given in the metadata

  • z (float) – the z position of the source in mm, as given in the metadata

  • source_type (str) – the type of source, as given in the metadata, e.g., “am_HS1”

Returns:

  • x_position – the x position of the source in mm in the detector frame

  • y_position – the y position of the source in mm in the detector frame

  • z_position – the z position of the source in mm in the detector frame

Return type:

list[float, float, float]

pygeomhades.create_volumes module

pygeomhades.create_volumes.create_bottom_plate(plate_metadata, from_gdml=True)

Create the bottom plate.

Parameters:
  • plate_metadata (AttrsDict) –

    Metadata describing the position of the bottom plate. This should have the format:

    width: 100
    depth: 200
    height: 300
    cavity:
        width: 100
        depth: 200
        height: 200
    

  • from_gdml (bool) – Whether to construct from a GDML file

Return type:

Registry

pygeomhades.create_volumes.create_cryostat(cryostat_meta, from_gdml=True)

Create the cryostat logical volume.

Parameters:
  • cryostat_meta (AttrsDict) – Metadata describing the cryostat geometry (see create_wrap()) for details.

  • from_gdml (bool) – Whether to construct from a GDML file

Return type:

LogicalVolume

pygeomhades.create_volumes.create_holder(holder_meta, det_type, order, from_gdml=True)

Construct the holder geometry

Parameters:
  • holder_meta (AttrsDict) –

    The metadata describing the holder geometry, should be of the format:

    cylinder:
        inner:
            height_in_mm: 100
            radius_in_mm: 100
        outer:
            height_in_mm: 104
            radius_in_mm: 104
    bottom_cyl:
        inner:
            height_in_mm: 100
            radius_in_mm: 100
        outer:
            height_in_mm: 104
            radius_in_mm: 104
    rings:
        position_top_ring_in_mm: 20
        position_bottom_ring_in_mm: 30
        radius_in_mm: 150
        height_in_mm: 10
    edge:
        height_in_mm: 1000
    

  • order (int) – The detector batch number.

  • det_type (str) – Detector type.

  • from_gdml (bool) – Whether to construct from a GDML file

Return type:

LogicalVolume

pygeomhades.create_volumes.create_lead_castle(table_num, castle_dimensions, from_gdml=True)

Create the lead castle.

Parameters:
  • table_num (int) – Which table the measurements were taken on (1 or 2).

  • castle_dimensions (AttrsDict) –

    The metadata describing the lead castle dimensions. This should have the fields “base”, “inner_cavity”, “cavity”, “top”, “front” and “copper_plate”.

    Each should have a subdictionary with this format:

    base:
        height: 100
        depth: 100
        width: 100
    

  • volume_name – Which volume to extract, defaults to “Lead_castle”.

  • from_gdml (bool) – Whether to construct from a GDML file

Return type:

LogicalVolume

pygeomhades.create_volumes.create_source(source_type, source_dims, holder_dims, from_gdml=False)

Create the geometry of the source.

Parameters:
  • source_type (str) – The type of source (am_collimated, am, ba, co or th)

  • source_dims (AttrsDict) –

    Metadata describing the source geometry. Should be of the following format:

    height: 0.0
    width: 0.0
    
    foil:
        height: 0.0
        width: 0.0
    
    al_ring:
        height: 0.0
        width_max: 0.0
        width_min: 0.0
    
    capsule:
        width: 0.0
        depth: 0.0
        height: 0.0
    
    collimator:
        width: 0.0
        depth: 0.0
        height: 0.0
        beam_width: 0.0
        beam_height: 0.0
        window: 0.0
    
    epoxy:
        height: 0.0
        width: 0.0
    
    plates:
        height: 0.0
        width: 0.0
        cavity_width: 0.0
    
    offset_height: 0.0
    

  • holder_dims (AttrsDict | None) – Dimensions of the source holder (see get_source_holder()).

  • from_gdml (bool) – Whether to construct from a GDML file

Return type:

LogicalVolume

pygeomhades.create_volumes.create_source_holder(source_type, holder_dims, source_z, meas_type='lat', from_gdml=True)

Get the source holder geometry.

Parameters:
  • source_type (str) – The type of source (am_collimated, am, ba, co or th)

  • holder_dims (AttrsDict) –

    The dimensions of the source holder, should be of the format:

    source:
        top_plate_height: 10.0
        top_plate_width: 10.0
        top_height: 2.0
        top_inner_width: 2.0
        top_bottom_height: 2.0
        bottom_inner_width: 2.0
    outer_width: 100.0
    inner_width: 10.0
    

  • source_z (float)

  • meas_type (str)

  • from_gdml (bool)

Return type:

LogicalVolume

meas_type

The measurement type (for th only) either lat or top.

source_z

The z position of the source from the cryostat bottom.

from_gdml

Whether to construct from a GDML file

pygeomhades.create_volumes.create_th_plate(source_dims, from_gdml=False)

Construct the plate for the Th source

Parameters:
Return type:

LogicalVolume

pygeomhades.create_volumes.create_vacuum_cavity(cryostat_metadata, registry)

Construct the vacuum cavity.

Parameters:
  • cryostat_metadata (AttrsDict) –

    The dimensions of the various parts of the cryostat, should have the following format

    cryostat:
        width: 200
        thickness: 2
        height: 200
        position_cavity_from_top: 10
        position_cavity_from_bottom: 20,
        position_from_bottom: 100
    

  • registry (Registry) – The registry to add the geometry to.

Return type:

The logical volume for the cavity.

pygeomhades.create_volumes.create_wrap(wrap_metadata, from_gdml=False)

Create the mylar wrap.

Warning

The returned logical volume belongs to its own registry, it is necessary to call reg.addVolumeRecursive() on the produced PhysicalVolume to get a sane registry.

Parameters:
  • wrap_metadata (AttrsDict) –

    The information on the dimensions of the mylar wrap, should be of the format:

    outer:
        height_in_mm: 100
        radius_in_mm: 100
    inner:
        height_in_mm: 99
        radius_in_mm: 99
    

  • from_gdml (bool) – whether to read the geometry from GDML or construct it directly.

Return type:

LogicalVolume

pygeomhades.dimensions module

pygeomhades.dimensions.get_bottom_plate_metadata()

Extract the metadata describing the bottom plate.

Return type:

AttrsDict

pygeomhades.dimensions.get_castle_dimensions(table_num)

Extract the lead castle dimensions for a given table.

Parameters:

table_num (int) – The number of the table to use, can be 1 or 2.

Return type:

AttrsDict

pygeomhades.dimensions.get_cryostat_metadata(det_type, order, xtal_slice)

Extract the metadata corresponding to the cryostat

In future this will be moved into external metadata.

Parameters:
  • det_type (str) – The detector type (should be icpc or bege).

  • order (int) – The order number.

  • xtal_slice (str) – The slice of the crystal (typically A or B).

Return type:

AttrsDict

pygeomhades.dimensions.get_source_holder_metadata(source_type, meas_type='lat')

Get the dimensions of the source holder.

Parameters:
  • source_type (str) – The type of source (am_HS1, am_HS6, ba_HS4, co_HS5 or th_HS2)

  • meas_type (str) – The measurement (for th only) either lat or top.

Return type:

AttrsDict

pygeomhades.dimensions.get_source_metadata(source_type, meas_type='')

Get the dimensions of the source and collimator.

Parameters:
  • source_type (str) – The type of source (am_HS1, am_HS6, ba_HS4, co_HS5 or th_HS2)

  • meas_type (str) – The measurement (for th_HS2 only) either lat or top.

Return type:

AttrsDict

pygeomhades.metadata module

class pygeomhades.metadata.PublicHadesMetadataProxy

Bases: object

class pygeomhades.metadata.PublicLegendMetadataProxy

Bases: object

class pygeomhades.metadata._CryostatProxy(dummy_cryostats)

Bases: object

Parameters:

dummy_cryostats (TextDB)

keys()
class pygeomhades.metadata._DiodeProxy(dummy_detectors)

Bases: object

Parameters:

dummy_detectors (TextDB)

keys()

pygeomhades.plot module

pygeomhades.plot.plot_profiles(profiles, title='', show=False)

Plot the profiles of the volumes in the geometry using matplotlib.

Parameters:
  • profiles (dict) – A dictionary mapping volume names to their profiles, where each profile is a dictionary with 3 fields r, z and offset. The r and z fields are lists of the same length, containing the radius and z coordinates of the profile, respectively. The offset field is a single number representing the offset of the profile from the center of the geometry.

  • title (str)

  • show (bool)

Return type:

tuple[Figure, Axes]

pygeomhades.utils module

pygeomhades.utils.get_profile(solid, flip=False)

Get the (r,z) pairs making up the profile of a solid. Only works for polycones.

Parameters:
  • solid (GenericPolycone | Polycone) – The solid to get the profile of.

  • flip (bool) – Whether to flip the z. This is needed for the detector, which is placed with inverted axes in the cryostat.

Return type:

dict[str, list[float]]

pygeomhades.utils.merge_configs(diode_meta, extra_meta, *, extra_name='hades')

Merge the configs from diode_meta to the extra information provided in extra_meta.

This also adds the needed enrichment value if this is not present.

Parameters:
  • diode_meta (AttrsDict) – The standard metadata for the diode.

  • extra_meta (Mapping) – Extra metadata to add.

  • extra_name (str) – name of the subdictionary to add the extra metadata to.

Return type:

AttrsDict

pygeomhades.utils.parse_measurement(measurement)

Parse a measurement string into its components.

The measurement string is expected to be in the format {source}_{HSX}_{position}_{ID}, e.g. “am_HS1_top_dlt”.

For more details see [link](https://legend-exp.atlassian.net/wiki/spaces/LEGEND/pages/1826750480/Analysis+of+characterization+data+WIP).

Parameters:

measurement (str) – The measurement string, e.g., “am_HS1_top_dlt”.

Returns:

A dictionary with keys “source”, “position”, and “id” containing the parsed components of the measurement string. For example, for “am_HS1_top_dlt”, the returned dictionary would be {"source": "am_HS1", "position": "top", "id": "dlt"}.

Return type:

AttrsDict

pygeomhades.utils.read_gdml_with_replacements(dummy_gdml_path, replacements)

Read a GDML file including replacements.

Parameters:
  • dummy_gdml_path (Path) – path to the GDML template.

  • replacements (Mapping) – Constants in the GDML file to replace.

Return type:

LogicalVolume | dict[str, LogicalVolume]