Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ repos:
- id: trailing-whitespace

- repo: https://github.com/psf/black-pre-commit-mirror
rev: "25.9.0"
rev: "26.3.1"
hooks:
- id: black-jupyter
args: ["--line-length", "100"]
Expand All @@ -34,19 +34,19 @@ repos:
additional_dependencies: [black==23.3.0]

- repo: https://github.com/astral-sh/ruff-pre-commit
rev: "v0.13.3"
rev: "v0.15.12"
hooks:
- id: ruff
args: ["--fix", "--show-fixes"]

- repo: https://github.com/mgedmin/check-manifest
rev: "0.50"
rev: "0.51"
hooks:
- id: check-manifest
stages: [manual]

- repo: https://github.com/codespell-project/codespell
rev: "v2.4.1"
rev: "v2.4.2"
hooks:
- id: codespell
args: ["-L", "commun,precess"]
Expand Down Expand Up @@ -76,7 +76,7 @@ repos:
types_or: [yaml, markdown, html, css, scss, javascript, json]

- repo: https://github.com/kynan/nbstripout
rev: "0.8.1"
rev: "0.9.1"
hooks:
- id: nbstripout
args:
Expand All @@ -87,7 +87,7 @@ repos:
]

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: "v21.1.2"
rev: "v22.1.4"
hooks:
- id: clang-format
types_or: [c++, c, cuda]
20 changes: 17 additions & 3 deletions examples/cbpm.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ def Test(vis=False, interactive=False, gdml=True, fluka=False):
"wg_sub3", wg_sub2, wg_cut_solid, [[0, 0, _np.pi], [-wg_centre, 0, 0]], reg
)
wg_sub4 = _g4.solid.Subtraction(
"wg_sub4", wg_sub3, wg_cut_solid, [[0, 0, 3.0 / 2.0 * _np.pi], [0, -wg_centre, 0]], reg
"wg_sub4",
wg_sub3,
wg_cut_solid,
[[0, 0, 3.0 / 2.0 * _np.pi], [0, -wg_centre, 0]],
reg,
)

wg_sub5 = _g4.solid.Subtraction(
Expand All @@ -86,7 +90,12 @@ def Test(vis=False, interactive=False, gdml=True, fluka=False):

wg_logical = _g4.LogicalVolume(wg_sub8, "G4_Cu", "wg_logical", reg)
wg_physical = _g4.PhysicalVolume(
[0, 0, 0], [0, 0, -wg_length / 2.0], wg_logical, "wg_physical", world_logical, reg
[0, 0, 0],
[0, 0, -wg_length / 2.0],
wg_logical,
"wg_physical",
world_logical,
reg,
)

################################
Expand Down Expand Up @@ -121,7 +130,12 @@ def Test(vis=False, interactive=False, gdml=True, fluka=False):
ca_solid = _g4.solid.Tubs("ca_solid", ca_innerr, wg_outerr, ca_length, 0, 2 * _np.pi, reg)
ca_logical = _g4.LogicalVolume(ca_solid, "G4_Cu", "ca_logical", reg)
ca_physical = _g4.PhysicalVolume(
[0, 0, 0], [0, 0, ca_length / 2.0 + safety], ca_logical, "ca_physical", world_logical, reg
[0, 0, 0],
[0, 0, ca_length / 2.0 + safety],
ca_logical,
"ca_physical",
world_logical,
reg,
)

################################
Expand Down
119 changes: 103 additions & 16 deletions examples/hep_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,12 @@ def HepDetector(siBarrel=True, siEndcaps=True, ecalBarrel=True, solenoid=True):
for i in range(4):
zOffset = 0.5 * siBarrelLength * 1.02 + (i * endcapLayerSeparation)
pyg4ometry.geant4.PhysicalVolume(
[0, 0, 0], [0, 0, zOffset], endcapLV, "endcap_" + str(i) + "_left_pv", worldLV, reg
[0, 0, 0],
[0, 0, zOffset],
endcapLV,
"endcap_" + str(i) + "_left_pv",
worldLV,
reg,
)
pyg4ometry.geant4.PhysicalVolume(
[0, 0, 0],
Expand Down Expand Up @@ -113,7 +118,12 @@ def SiBarrelTracker(reg=None):
name="barrelAv1", moduleAv=siTrackerModuleAv, radius=0.15, nAzimuth=15, reg=reg
)
siTrackerLayer1Pv = pyg4ometry.geant4.PhysicalVolume(
[_np.pi / 2.0, 0, 0], [0, 0, 0], siTrackerLayer1Av, "siTrackerLayer1Pv", siTrackerLv, reg
[_np.pi / 2.0, 0, 0],
[0, 0, 0],
siTrackerLayer1Av,
"siTrackerLayer1Pv",
siTrackerLv,
reg,
)

siTrackerLayer2Av = SiTrackerBarrelLayer(
Expand All @@ -124,7 +134,12 @@ def SiBarrelTracker(reg=None):
reg=reg,
)
siTrackerLayer2Pv = pyg4ometry.geant4.PhysicalVolume(
[_np.pi / 2.0, 0, 0], [0, 0, 0], siTrackerLayer2Av, "siTrackerLayer2Pv", siTrackerLv, reg
[_np.pi / 2.0, 0, 0],
[0, 0, 0],
siTrackerLayer2Av,
"siTrackerLayer2Pv",
siTrackerLv,
reg,
)

siTrackerLayer3Av = SiTrackerBarrelLayer(
Expand All @@ -135,7 +150,12 @@ def SiBarrelTracker(reg=None):
reg=reg,
)
siTrackerLayer3Pv = pyg4ometry.geant4.PhysicalVolume(
[_np.pi / 2.0, 0, 0], [0, 0, 0], siTrackerLayer3Av, "siTrackerLayer3Pv", siTrackerLv, reg
[_np.pi / 2.0, 0, 0],
[0, 0, 0],
siTrackerLayer3Av,
"siTrackerLayer3Pv",
siTrackerLv,
reg,
)

return siTrackerLv
Expand Down Expand Up @@ -180,7 +200,12 @@ def SiTrackerBarrelLayer(


def SiTrackerBarrelModule(
sensorSize=0.08, sensorGap=3e-3, pcbLength=0.015, pcbGap=0.005, tiltAngleDeg=5, reg=None
sensorSize=0.08,
sensorGap=3e-3,
pcbLength=0.015,
pcbGap=0.005,
tiltAngleDeg=5,
reg=None,
):
reg = pyg4ometry.geant4.Registry() if reg is None else reg

Expand Down Expand Up @@ -272,7 +297,15 @@ def SiTrackerEndcapLayer(
dAzimuth = 2 * _np.pi / nAzimuth

siTrackerECTubs = pyg4ometry.geant4.solid.Tubs(
name + "_siTrackerECTubs", innerRadius, outerRadius, 0.025, 0, 2 * _np.pi, reg, "m", "rad"
name + "_siTrackerECTubs",
innerRadius,
outerRadius,
0.025,
0,
2 * _np.pi,
reg,
"m",
"rad",
)
siTrackerECLv = pyg4ometry.geant4.LogicalVolume(
siTrackerECTubs, "G4_Galactic", "siTrackerECLv", reg
Expand Down Expand Up @@ -310,10 +343,20 @@ def SiTrackerEndcapModule(
)

sensorPv1 = pyg4ometry.geant4.PhysicalVolume(
[0, 0, 0], [0, sensorGap / 2, 0, "m"], sensorLv, "sensorEndcapPv1", moduleAv, reg
[0, 0, 0],
[0, sensorGap / 2, 0, "m"],
sensorLv,
"sensorEndcapPv1",
moduleAv,
reg,
)
sensorPv2 = pyg4ometry.geant4.PhysicalVolume(
[0, 0, 0], [0, -sensorGap / 2, 0, "m"], sensorLv, "sensorEndcapPv2", moduleAv, reg
[0, 0, 0],
[0, -sensorGap / 2, 0, "m"],
sensorLv,
"sensorEndcapPv2",
moduleAv,
reg,
)

return moduleAv
Expand Down Expand Up @@ -346,7 +389,13 @@ def Solenoid(innerRadius, thickness, length, constants, reg=None):
"""
reg = pyg4ometry.geant4.Registry() if reg is None else reg
solenoidSolid = pyg4ometry.geant4.solid.Tubs(
"solenoid_solid", innerRadius, innerRadius + thickness, length, 0, constants["twopi"], reg
"solenoid_solid",
innerRadius,
innerRadius + thickness,
length,
0,
constants["twopi"],
reg,
)
aluminium = pyg4ometry.geant4.MaterialPredefined("G4_Al")
solenoidLV = pyg4ometry.geant4.LogicalVolume(solenoidSolid, aluminium, "solenoid_lv", reg)
Expand All @@ -358,7 +407,13 @@ def Solenoid(innerRadius, thickness, length, constants, reg=None):
nCoils = int(length.eval() / (2 * coilLengthZ.eval()))
nCoilsEven = nCoils if (nCoils % 2 == 0) else nCoils - 1
coilSolid = pyg4ometry.geant4.solid.Tubs(
"coil_solid", coilInnerRadius, coilOuterRadius, coilLengthZ, 0, constants["twopi"], reg
"coil_solid",
coilInnerRadius,
coilOuterRadius,
coilLengthZ,
0,
constants["twopi"],
reg,
)
nbti = pyg4ometry.geant4.MaterialCompound("nbti", 5.7, 2, reg)
nbti.set_state("solid")
Expand All @@ -377,11 +432,21 @@ def Solenoid(innerRadius, thickness, length, constants, reg=None):
zOffset = i * 2 * coilLengthZ
iCoil += 1
pyg4ometry.geant4.PhysicalVolume(
[0, 0, 0], [0, 0, zOffset], coilLV, "coil_" + str(iCoil) + "_pv", solenoidLV, reg
[0, 0, 0],
[0, 0, zOffset],
coilLV,
"coil_" + str(iCoil) + "_pv",
solenoidLV,
reg,
)
iCoil += 1
pyg4ometry.geant4.PhysicalVolume(
[0, 0, 0], [0, 0, -zOffset], coilLV, "coil_" + str(iCoil) + "_pv", solenoidLV, reg
[0, 0, 0],
[0, 0, -zOffset],
coilLV,
"coil_" + str(iCoil) + "_pv",
solenoidLV,
reg,
)

return solenoidLV
Expand All @@ -390,7 +455,13 @@ def Solenoid(innerRadius, thickness, length, constants, reg=None):
def ECALBarrel(innerRadius, outerRadius, length, nModulesPhi, nModulesZ, constants, reg):
# container LV
ecalBarrelSolid = pyg4ometry.geant4.solid.Tubs(
"ecal_barrel_solid", innerRadius, outerRadius, length, 0, constants["twopi"], reg
"ecal_barrel_solid",
innerRadius,
outerRadius,
length,
0,
constants["twopi"],
reg,
)
air = pyg4ometry.geant4.MaterialPredefined("G4_AIR")
ecalBarrelLV = pyg4ometry.geant4.LogicalVolume(ecalBarrelSolid, air, "ecal_barrel_lv", reg)
Expand Down Expand Up @@ -439,21 +510,37 @@ def ECALBarrel(innerRadius, outerRadius, length, nModulesPhi, nModulesZ, constan
for i in range(nModulesZ):
iModuleName = "ecal_mod_" + str(i)
iModule = pyg4ometry.geant4.solid.Tubs(
iModuleName + "_solid", innerR2, outerR2, 0.95 * dz, startAngle, sweepAngle, reg
iModuleName + "_solid",
innerR2,
outerR2,
0.95 * dz,
startAngle,
sweepAngle,
reg,
)
iModuleLV = pyg4ometry.geant4.LogicalVolume(
iModule, leadTungstate, iModuleName + "_lv", reg
)
pyg4ometry.geant4.PhysicalVolume(
[0, 0, 0], [0, 0, iz + 0.5 * dz], iModuleLV, iModuleName + "_pv", segmentLV, reg
[0, 0, 0],
[0, 0, iz + 0.5 * dz],
iModuleLV,
iModuleName + "_pv",
segmentLV,
reg,
)
iz += dz

# nModulesPhi = 1
for i in range(nModulesPhi):
angle = i * segmentAngle
pyg4ometry.geant4.PhysicalVolume(
[0, 0, angle], [0, 0, 0], segmentLV, "ecal_segment_" + str(i) + "_pv", ecalBarrelLV, reg
[0, 0, angle],
[0, 0, 0],
segmentLV,
"ecal_segment_" + str(i) + "_pv",
ecalBarrelLV,
reg,
)
return ecalBarrelLV

Expand Down
Loading
Loading