legend-pygeom-hades 0.1.0a0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (85) hide show
  1. legend_pygeom_hades-0.1.0a0.dist-info/METADATA +62 -0
  2. legend_pygeom_hades-0.1.0a0.dist-info/RECORD +85 -0
  3. legend_pygeom_hades-0.1.0a0.dist-info/WHEEL +5 -0
  4. legend_pygeom_hades-0.1.0a0.dist-info/entry_points.txt +2 -0
  5. legend_pygeom_hades-0.1.0a0.dist-info/licenses/LICENSE +674 -0
  6. legend_pygeom_hades-0.1.0a0.dist-info/top_level.txt +1 -0
  7. pygeomhades/__init__.py +6 -0
  8. pygeomhades/_version.py +34 -0
  9. pygeomhades/cli.py +169 -0
  10. pygeomhades/configs/dummy_geom/B99000A.yaml +25 -0
  11. pygeomhades/configs/dummy_geom/C99000A.yaml +31 -0
  12. pygeomhades/configs/dummy_geom/P99000A.yaml +20 -0
  13. pygeomhades/configs/dummy_geom/V99000A.yaml +31 -0
  14. pygeomhades/configs/holder_wrap/B00000B.yaml +37 -0
  15. pygeomhades/configs/holder_wrap/B00000D.yaml +37 -0
  16. pygeomhades/configs/holder_wrap/B00002C.yaml +37 -0
  17. pygeomhades/configs/holder_wrap/B00032B.yaml +37 -0
  18. pygeomhades/configs/holder_wrap/B00035A.yaml +37 -0
  19. pygeomhades/configs/holder_wrap/B00035B.yaml +37 -0
  20. pygeomhades/configs/holder_wrap/B00061C.yaml +37 -0
  21. pygeomhades/configs/holder_wrap/B00076C.yaml +37 -0
  22. pygeomhades/configs/holder_wrap/B00091B.yaml +37 -0
  23. pygeomhades/configs/holder_wrap/V00048B.yaml +37 -0
  24. pygeomhades/configs/holder_wrap/V02160A.yaml +37 -0
  25. pygeomhades/configs/holder_wrap/V02160B.yaml +37 -0
  26. pygeomhades/configs/holder_wrap/V02162B.yaml +37 -0
  27. pygeomhades/configs/holder_wrap/V02166B.yaml +37 -0
  28. pygeomhades/configs/holder_wrap/V03421A.yaml +37 -0
  29. pygeomhades/configs/holder_wrap/V03422A.yaml +37 -0
  30. pygeomhades/configs/holder_wrap/V04199A.yaml +37 -0
  31. pygeomhades/configs/holder_wrap/V04545A.yaml +37 -0
  32. pygeomhades/configs/holder_wrap/V04549A.yaml +37 -0
  33. pygeomhades/configs/holder_wrap/V04549B.yaml +37 -0
  34. pygeomhades/configs/holder_wrap/V05261A.yaml +37 -0
  35. pygeomhades/configs/holder_wrap/V05261B.yaml +37 -0
  36. pygeomhades/configs/holder_wrap/V05266A.yaml +37 -0
  37. pygeomhades/configs/holder_wrap/V05266B.yaml +37 -0
  38. pygeomhades/configs/holder_wrap/V05267A.yaml +37 -0
  39. pygeomhades/configs/holder_wrap/V05267B.yaml +37 -0
  40. pygeomhades/configs/holder_wrap/V05268A.yaml +37 -0
  41. pygeomhades/configs/holder_wrap/V05268B.yaml +37 -0
  42. pygeomhades/configs/holder_wrap/V05612A.yaml +37 -0
  43. pygeomhades/configs/holder_wrap/V05612B.yaml +37 -0
  44. pygeomhades/configs/holder_wrap/V06643A.yaml +29 -0
  45. pygeomhades/configs/holder_wrap/V06649A.yaml +29 -0
  46. pygeomhades/configs/holder_wrap/V06659A.yaml +29 -0
  47. pygeomhades/configs/holder_wrap/V07298B.yaml +37 -0
  48. pygeomhades/configs/holder_wrap/V07302A.yaml +37 -0
  49. pygeomhades/configs/holder_wrap/V07302B.yaml +37 -0
  50. pygeomhades/configs/holder_wrap/V07646A.yaml +37 -0
  51. pygeomhades/configs/holder_wrap/V07647A.yaml +37 -0
  52. pygeomhades/configs/holder_wrap/V07647B.yaml +37 -0
  53. pygeomhades/configs/holder_wrap/V08682A.yaml +37 -0
  54. pygeomhades/configs/holder_wrap/V08682B.yaml +37 -0
  55. pygeomhades/configs/holder_wrap/V09372A.yaml +37 -0
  56. pygeomhades/configs/holder_wrap/V09374A.yaml +37 -0
  57. pygeomhades/configs/holder_wrap/V09724A.yaml +37 -0
  58. pygeomhades/configs/holder_wrap/V10437B.yaml +37 -0
  59. pygeomhades/configs/holder_wrap/V10447B.yaml +37 -0
  60. pygeomhades/configs/holder_wrap/V11924A.yaml +37 -0
  61. pygeomhades/configs/holder_wrap/V11925A.yaml +37 -0
  62. pygeomhades/configs/holder_wrap/V11947B.yaml +37 -0
  63. pygeomhades/configs/holder_wrap/V14673A.yaml +37 -0
  64. pygeomhades/configs/vis-scene.yaml +0 -0
  65. pygeomhades/core.py +275 -0
  66. pygeomhades/create_volumes.py +571 -0
  67. pygeomhades/dimensions.py +283 -0
  68. pygeomhades/metadata.py +28 -0
  69. pygeomhades/models/dummy/bottom_plate_dummy.gdml +44 -0
  70. pygeomhades/models/dummy/cryostat_dummy.gdml +57 -0
  71. pygeomhades/models/dummy/holder_bege_dummy.gdml +61 -0
  72. pygeomhades/models/dummy/holder_icpc_dummy.gdml +78 -0
  73. pygeomhades/models/dummy/lead_castle_table1_dummy.gdml +71 -0
  74. pygeomhades/models/dummy/lead_castle_table2_dummy.gdml +73 -0
  75. pygeomhades/models/dummy/source_am_collimated_dummy.gdml +97 -0
  76. pygeomhades/models/dummy/source_am_dummy.gdml +64 -0
  77. pygeomhades/models/dummy/source_ba_dummy.gdml +72 -0
  78. pygeomhades/models/dummy/source_co_dummy.gdml +71 -0
  79. pygeomhades/models/dummy/source_holder_am_dummy.gdml +73 -0
  80. pygeomhades/models/dummy/source_holder_dummy.gdml +61 -0
  81. pygeomhades/models/dummy/source_holder_th_lat_dummy.gdml +54 -0
  82. pygeomhades/models/dummy/source_th_dummy.gdml +134 -0
  83. pygeomhades/models/dummy/source_th_plates_dummy.gdml +36 -0
  84. pygeomhades/models/dummy/wrap_dummy.gdml +50 -0
  85. pygeomhades/utils.py +101 -0
@@ -0,0 +1,134 @@
1
+ <?xml version="1.0" ?>
2
+ <gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
3
+
4
+ <define>
5
+ <constant name="TWOPI" value="2.*pi"/>
6
+ <quantity name="source_z" type="length" value="source_height" unit="mm"/>
7
+ <quantity name="source_radius" type="length" value="source_width/2" unit="mm"/>
8
+ <quantity name="source_capsule_z" type="length" value="source_capsule_height" unit="mm"/>
9
+ <quantity name="source_capsule_radius" type="length" value="source_capsule_width/2" unit="mm"/>
10
+ <quantity name="source_epoxy_z" type="length" value="source_epoxy_height" unit="mm"/>
11
+ <quantity name="source_epoxy_radius" type="length" value="source_epoxy_width/2" unit="mm"/>
12
+ <quantity name="CuSource_holder_z" type="length" value="CuSource_holder_height" unit="mm"/>
13
+ <quantity name="CuSource_holder_radius" type="length" value="CuSource_holder_width/2" unit="mm"/>
14
+ <quantity name="CuSource_holder_cavity_radius" type="length" value="CuSource_holder_cavity_width/2" unit="mm"/>
15
+ <quantity name="CuSource_holder_bottom_z" type="length" value="CuSource_holder_bottom_height" unit="mm"/>
16
+ <quantity name="CuSource_holder_bottom_radius" type="length" value="CuSource_holder_bottom_width/2" unit="mm"/>
17
+ <quantity name="CuSource_holder_all_z" type="length" value="CuSource_holder_height+CuSource_holder_bottom_height" unit="mm"/>
18
+ <quantity name="source_offset_z" type="length" value="source_offset_height" unit="mm" />
19
+ <position name="pos_source_capsule" z="0"/>
20
+ <position name="pos_source_epoxy" z="(source_capsule_z-source_epoxy_z)/2"/>
21
+ <position name="pos_source_encapsulated" z="CuSource_holder_all_z-source_capsule_z/2-source_offset_z"/>
22
+ <position name="pos_CuSource_holder_cavity" z="0"/>
23
+ </define>
24
+
25
+ <materials>
26
+ <element Z="1" formula="H" name="Hydrogen" >
27
+ <atom value="1" />
28
+ </element>
29
+ <element Z="6" formula="C" name="Carbon" >
30
+ <atom value="12.01" />
31
+ </element>
32
+ <element Z="7" formula="N" name="Nitrogen" >
33
+ <atom value="14.01" />
34
+ </element>
35
+ <element Z="8" formula="O" name="Oxygen" >
36
+ <atom value="16" />
37
+ </element>
38
+ <element Z="14" formula="Si" name="Silicon" >
39
+ <atom value="28.09" />
40
+ </element>
41
+ <element Z="24" formula="Cr" name="Chromium" >
42
+ <atom value="51.9961" />
43
+ </element>
44
+ <element Z="25" formula="Mn" name="Manganese" >
45
+ <atom value="54.93805" />
46
+ </element>
47
+ <element Z="26" formula="Fe" name="Iron" >
48
+ <atom value="55.845" />
49
+ </element>
50
+ <element Z="28" formula="Ni" name="Nickel" >
51
+ <atom value="58.9332" />
52
+ </element>
53
+ <material name="epoxy_mod" >
54
+ <D value="1.129" unit="g/cm3"/>
55
+ <composite n="41" ref="Carbon" />
56
+ <composite n="49" ref="Hydrogen" />
57
+ <composite n="7" ref="Oxygen" />
58
+ <composite n="3" ref="Nitrogen" />
59
+ </material>
60
+ <material name="Ssteel" >
61
+ <D value="7.9" unit="g/cm3" />
62
+ <fraction n="0.01" ref="Silicon" />
63
+ <fraction n="0.2" ref="Chromium" />
64
+ <fraction n="0.02" ref="Manganese" />
65
+ <fraction n="0.67" ref="Iron" />
66
+ <fraction n="0.10" ref="Nickel" />
67
+ </material>
68
+ <material name="SiliconDioxide" >
69
+ <D value="2.32" unit="g/cm3" />
70
+ <composite n="1" ref="Silicon" />
71
+ <composite n="2" ref="Oxygen" />
72
+ </material>
73
+ </materials>
74
+
75
+ <solids>
76
+ <tube name="source" rmax="source_radius" z="source_z" startphi="0" deltaphi="TWOPI" aunit="rad" />
77
+ <tube name="source_capsule" rmax="source_capsule_radius" z="source_capsule_z" startphi="0" deltaphi="TWOPI" aunit="rad" />
78
+ <tube name="source_epoxy" rmax="source_epoxy_radius" z="source_epoxy_z" startphi="0" deltaphi="TWOPI" aunit="rad" />
79
+ <polycone name="CuSource_holder_cavity" startphi="0" deltaphi="TWOPI" aunit="rad">
80
+ <zplane rmin="0" rmax="CuSource_holder_cavity_radius" z="0" />
81
+ <zplane rmin="0" rmax="CuSource_holder_cavity_radius" z="CuSource_holder_all_z" />
82
+ </polycone>
83
+ <polycone name="CuSource_holder" startphi="0" deltaphi="TWOPI" aunit="rad">
84
+ <zplane rmin="0" rmax="CuSource_holder_radius" z="0" />
85
+ <zplane rmin="0" rmax="CuSource_holder_radius" z="CuSource_holder_z" />
86
+ <zplane rmin="0" rmax="CuSource_holder_bottom_radius" z="CuSource_holder_z" />
87
+ <zplane rmin="0" rmax="CuSource_holder_bottom_radius" z="CuSource_holder_all_z" />
88
+ </polycone>
89
+ </solids>
90
+
91
+ <structure>
92
+ <volume name="Source">
93
+ <materialref ref="SiliconDioxide"/>
94
+ <solidref ref="source"/>
95
+ </volume>
96
+ <volume name="Source_Epoxy">
97
+ <materialref ref="epoxy_mod"/>
98
+ <solidref ref="source_epoxy"/>
99
+ </volume>
100
+ <volume name="Source_Encapsulated">
101
+ <materialref ref="Ssteel"/>
102
+ <solidref ref="source_capsule"/>
103
+ <physvol>
104
+ <volumeref ref="Source"/>
105
+ <positionref ref="pos_source_capsule"/>
106
+ </physvol>
107
+ <physvol>
108
+ <volumeref ref="Source_Epoxy"/>
109
+ <positionref ref="pos_source_epoxy"/>
110
+ </physvol>
111
+ </volume>
112
+ <volume name="CuSource_Holder_Cavity">
113
+ <materialref ref="G4_AIR"/>
114
+ <solidref ref="CuSource_holder_cavity"/>
115
+ <physvol>
116
+ <volumeref ref="Source_Encapsulated"/>
117
+ <positionref ref="pos_source_encapsulated"/>
118
+ </physvol>
119
+ </volume>
120
+ <volume name="CuSource_Holder">
121
+ <materialref ref="G4_Cu"/>
122
+ <solidref ref="CuSource_holder"/>
123
+ <physvol>
124
+ <volumeref ref="CuSource_Holder_Cavity"/>
125
+ <positionref ref="pos_CuSource_holder_cavity"/>
126
+ </physvol>
127
+ </volume>
128
+ </structure>
129
+
130
+ <setup name="Default" version="1.0">
131
+ <world ref="CuSource_Holder"/>
132
+ </setup>
133
+
134
+ </gdml>
@@ -0,0 +1,36 @@
1
+ <?xml version="1.0" ?>
2
+ <gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
3
+
4
+ <define>
5
+ <constant name="TWOPI" value="2.*pi"/>
6
+ <quantity name="source_plates_z" type="length" value="source_plates_height" unit="mm"/>
7
+ <quantity name="source_plates_radius" type="length" value="source_plates_width/2" unit="mm"/>
8
+ <quantity name="source_plates_cavity_radius" type="length" value="source_plates_cavity_width/2" unit="mm"/>
9
+ </define>
10
+
11
+ <materials>
12
+ <element Z="82" formula="Pb" name="Lead" >
13
+ <atom value="207.2" />
14
+ </element>
15
+ <material name="Pb" formula="Pb" >
16
+ <D value="2.84" unit="g/cm3" />
17
+ <fraction n="1" ref="Lead"/>
18
+ </material>
19
+ </materials>
20
+
21
+ <solids>
22
+ <tube name="source_plates" rmin="source_plates_cavity_radius" rmax="source_plates_radius" z="source_plates_z" startphi="0" deltaphi="TWOPI" aunit="rad" />
23
+ </solids>
24
+
25
+ <structure>
26
+ <volume name="Source_Plates">
27
+ <materialref ref="G4_Pb"/>
28
+ <solidref ref="source_plates"/>
29
+ </volume>
30
+ </structure>
31
+
32
+ <setup name="Default" version="1.0">
33
+ <world ref="Source_Plates"/>
34
+ </setup>
35
+
36
+ </gdml>
@@ -0,0 +1,50 @@
1
+ <?xml version="1.0" ?>
2
+ <gdml xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://service-spi.web.cern.ch/service-spi/app/releases/GDML/schema/gdml.xsd">
3
+
4
+
5
+ <define>
6
+ <constant name="TWOPI" value="2.*pi"/>
7
+
8
+ <quantity name="wrap_z" type="length" value="wrap_outer_height_in_mm" unit="mm"/>
9
+ <quantity name="wrap_radius" type="length" value="wrap_outer_radius_in_mm" unit="mm"/>
10
+
11
+ <quantity name="wrap_cavity_radius" type="length" value="wrap_inner_radius_in_mm" unit="mm"/>
12
+ <quantity name="wrap_top_thickness" type="length" value="wrap_top_thickness_in_mm" unit="mm" />
13
+ </define>
14
+
15
+
16
+ <materials>
17
+ <element Z="1" formula="H" name="Hydrogen" >
18
+ <atom value="1" />
19
+ </element>
20
+ <element Z="6" formula="C" name="Carbon" >
21
+ <atom value="12.01" />
22
+ </element>
23
+ <material name="HD1000" >
24
+ <D value="0.93" unit="g/cm3" />
25
+ <composite n="4" ref="Hydrogen" />
26
+ <composite n="2" ref="Carbon" />
27
+ </material>
28
+ </materials>
29
+
30
+ <solids>
31
+ <polycone name="wrap" startphi="0" deltaphi="TWOPI" aunit="rad">
32
+ <zplane rmin="0" rmax="wrap_radius" z="0" />
33
+ <zplane rmin="0" rmax="wrap_radius" z="wrap_top_thickness" />
34
+ <zplane rmin="wrap_cavity_radius" rmax="wrap_radius" z="wrap_top_thickness" />
35
+ <zplane rmin="wrap_cavity_radius" rmax="wrap_radius" z="wrap_z" />
36
+ </polycone>
37
+ </solids>
38
+
39
+ <structure>
40
+ <volume name="Wrap">
41
+ <materialref ref="HD1000"/>
42
+ <solidref ref="wrap"/>
43
+ </volume>
44
+ </structure>
45
+
46
+ <setup name="Default" version="1.0">
47
+ <world ref="Wrap"/>
48
+ </setup>
49
+
50
+ </gdml>
pygeomhades/utils.py ADDED
@@ -0,0 +1,101 @@
1
+ from __future__ import annotations
2
+
3
+ import logging
4
+ import tempfile
5
+ from collections.abc import Mapping
6
+ from pathlib import Path
7
+
8
+ from dbetto import AttrsDict
9
+ from pyg4ometry import gdml, geant4
10
+
11
+ log = logging.getLogger(__name__)
12
+
13
+
14
+ def parse_measurement(measurement: str) -> AttrsDict:
15
+ """Parse a measurement string into its components.
16
+
17
+ The measurement string is expected to be in the format
18
+ `{source}_{HSX}_{position}_{ID}` eg. "am_HS1_top_dlt".
19
+
20
+ For more details see [link](https://legend-exp.atlassian.net/wiki/spaces/LEGEND/pages/1826750480/Analysis+of+characterization+data+WIP).
21
+
22
+
23
+ .. warning::
24
+
25
+ In the case of the "source" being "am", for compatibility
26
+ with the rest of the codebase if the source is colimated (HS1) the source name is
27
+ "am_collimated".
28
+
29
+ Parameters
30
+ ----------
31
+ measurement
32
+ The measurement string, e.g., "am_HS1_top_dlt".
33
+
34
+ """
35
+
36
+ split = measurement.split("_")
37
+
38
+ if len(split) != 4:
39
+ msg = f"Measurement string '{measurement}' is not in the expected format '{{source}}_{{HSX}}_{{position}}_{{ID}}'."
40
+ raise ValueError(msg)
41
+
42
+ out = AttrsDict({"source": split[0], "holder": split[1], "position": split[2], "id": split[3]})
43
+
44
+ if out.source == "am" and out.holder == "HS1":
45
+ out.source = "am_collimated"
46
+
47
+ return out
48
+
49
+
50
+ def merge_configs(diode_meta: AttrsDict, extra_meta: Mapping, *, extra_name: str = "hades") -> AttrsDict:
51
+ """Merge the configs from `diode_meta` to the extra information
52
+ provided in `extra_meta`.
53
+
54
+ This also adds the needed `enrichment` value if this is not present.
55
+
56
+ Parameters
57
+ ----------
58
+ diode_meta
59
+ The standard metadata for the diode.
60
+ extra_meta
61
+ Extra metadata to add.
62
+ extra_name
63
+ name of the subdictionary to add the extra metadata to.
64
+ """
65
+ # make sure there is an enrichment value
66
+ if diode_meta["production"]["enrichment"]["val"] is None:
67
+ diode_meta["production"]["enrichment"]["val"] = 0.9 # reasonable value
68
+
69
+ diode_meta[extra_name] = extra_meta
70
+
71
+ return diode_meta
72
+
73
+
74
+ def read_gdml_with_replacements(
75
+ dummy_gdml_path: Path, replacements: Mapping, vol_name: str | None = None
76
+ ) -> geant4.LogicalVolume | dict[str, geant4.LogicalVolume]:
77
+ """Read a GDML file including replacements.
78
+
79
+ Parameters
80
+ ----------
81
+ dummy_gdml_path
82
+ path to the GDML template.
83
+ replacements
84
+ Constants in the GDML file to replace.
85
+ """
86
+
87
+ gdml_text = dummy_gdml_path.read_text()
88
+
89
+ for key, val in replacements.items():
90
+ gdml_text = gdml_text.replace(key, f"{val:.1f}")
91
+
92
+ with tempfile.NamedTemporaryFile("w+", suffix=".gdml") as f:
93
+ f.write(gdml_text)
94
+ f.flush()
95
+ reader = gdml.Reader(f.name)
96
+
97
+ reg_tmp = reader.getRegistry()
98
+
99
+ if len(reg_tmp.logicalVolumeList) == 1:
100
+ return next(iter(reg_tmp.logicalVolumeDict.values()))
101
+ return reg_tmp.logicalVolumeDict[vol_name]