forked from lbl-neutrino/GeoMergeFor2x2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
geomerge_v3.py
executable file
·75 lines (57 loc) · 2.47 KB
/
geomerge_v3.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#!/usr/bin/env python3
from math import pi
import pyg4ometry
def add_sens_to_file(inFile, outFile):
r1 = pyg4ometry.gdml.Reader(inFile)
reg1 = r1.getRegistry()
print("Looping over volumes")
for volname, volume in reg1.logicalVolumeDict.items():
aux_tag = pyg4ometry.gdml.Auxiliary("SensDet", volname)
volume .addAuxiliaryInfo(aux_tag)
# gdml output
w = pyg4ometry.gdml.Writer()
w.addDetector(reg1)
w.write(outFile)
def merge_files(inFileHall, inFileArC, inFileMin, outFile):
r0 = pyg4ometry.gdml.Reader(inFileHall)
reg0 = r0.getRegistry()
r1 = pyg4ometry.gdml.Reader(inFileArC)
reg1 = r1.getRegistry()
r2 = pyg4ometry.gdml.Reader(inFileMin)
reg2 = r2.getRegistry()
## Want to loop over the logical volumes, and add an auxiliary field to them
print("Looping over ArC volumes")
for volname, volume in reg1.logicalVolumeDict.items():
if volname == 'volLArActive':
aux_tag = pyg4ometry.gdml.Auxiliary("SensDet", volname)
volume .addAuxiliaryInfo(aux_tag)
print("Looping over MINERvA volumes")
for volname, volume in reg2.logicalVolumeDict.items():
if "AssemblyVolume" in str(type(volume)): continue
if "Fiber" in volname: continue
aux_tag = pyg4ometry.gdml.Auxiliary("SensDet", volname)
volume .addAuxiliaryInfo(aux_tag)
print("Merging volumes")
lvHall = reg0.logicalVolumeDict["volMinosNDHall"]
lvArC = reg1.logicalVolumeDict["volArgonCubeDetector"]
lvMin = reg2.logicalVolumeDict["MINERvA_components"]
yoffset = -3100
zoffset = -13000
pvArC = pyg4ometry.geant4.PhysicalVolume([-pi/2, pi, 0],
[0, yoffset, zoffset],
lvArC, "TheArgonCube", lvHall, reg0)
pvMin = pyg4ometry.geant4.PhysicalVolume([0, pi, 0],
[0, yoffset + 420, 6548.65 + zoffset],
lvMin, "MINERvA", lvHall, reg0)
reg0.addVolumeRecursive(pvArC)
reg0.addVolumeRecursive(pvMin)
# gdml output
w = pyg4ometry.gdml.Writer()
w.addDetector(reg0)
w.write(outFile)
if __name__ == "__main__":
inFileHall = "input/New_2x2_Hall_newRock_clean.gdml"
inFileArC = "input/arc2x2.gdml"
inFileMin = "input/minerva_hacked.gdml"
outFile = "output/Merged2x2MINERvA_v3.gdml"
merge_files(inFileHall, inFileArC, inFileMin, outFile)