SND@LHC Software
Loading...
Searching...
No Matches
getGeoInformation Namespace Reference

Functions

 local2Global (n)
 
 print_info (path, node, level, currentlevel, print_sub_det_info=False)
 

Variables

 parser = ArgumentParser()
 
 dest
 
 help
 
 required
 
 default
 
 options = parser.parse_args()
 
 fname = options.geometry
 
 fgeom = ROOT.TFile.Open(fname)
 
 fGeo = fgeom.FAIRGeom
 
 top = fGeo.GetTopVolume()
 
int currentlevel = 0
 

Function Documentation

◆ local2Global()

getGeoInformation.local2Global (   n)

Definition at line 13 of file getGeoInformation.py.

13def local2Global(n):
14 Info={}
15 nav = ROOT.gGeoManager.GetCurrentNavigator()
16 nav.cd(n)
17 Info['node'] = nav.GetCurrentNode()
18 Info['path'] = n
19 tmp = Info['node'].GetVolume().GetShape()
20 Info['material'] = Info['node'].GetVolume().GetMaterial().GetName()
21 if options.moreInfo:
22 x = ROOT.gGeoManager.GetVerboseLevel()
23 ROOT.gGeoManager.SetVerboseLevel(0)
24 Info['weight']=Info['node'].GetVolume().Weight() # kg
25 Info['cubicmeter']=Info['node'].GetVolume().Capacity()/1000000. #
26 ROOT.gGeoManager.SetVerboseLevel(x)
27 o = [tmp.GetOrigin()[0],tmp.GetOrigin()[1],tmp.GetOrigin()[2]]
28 Info['locorign'] = o
29 local = array('d',o)
30 globOrigin = array('d',[0,0,0])
31 nav.LocalToMaster(local,globOrigin)
32 Info['origin'] = globOrigin
33 shifts = [ [-tmp.GetDX()+o[0],o[1],o[2]],
34 [tmp.GetDX()+o[0],o[1],o[2]],
35 [o[0],-tmp.GetDY()+o[1],o[2]],
36 [o[0],tmp.GetDY()+o[1],o[2]],
37 [o[0],o[1],-tmp.GetDZ()+o[2]],[o[0],o[1],tmp.GetDZ()+o[2]]
38 ]
39 shifted = []
40 for s in shifts:
41 local = array('d',s)
42 glob = array('d',[0,0,0])
43 nav.LocalToMaster(local,glob)
44 shifted.append([glob[0],glob[1],glob[2]])
45 Info['boundingbox']={}
46 for j in range(3):
47 jmin = 1E30
48 jmax = -1E30
49 for s in shifted:
50 if s[j]<jmin: jmin = s[j]
51 if s[j]>jmax: jmax = s[j]
52 Info['boundingbox'][j]=[jmin,jmax]
53 return Info
54

◆ print_info()

getGeoInformation.print_info (   path,
  node,
  level,
  currentlevel,
  print_sub_det_info = False 
)

Definition at line 55 of file getGeoInformation.py.

55def print_info(path, node, level, currentlevel, print_sub_det_info=False):
56 sub_nodes = {}
57 fullInfo = {}
58 for subnode in node.GetNodes():
59 name = subnode.GetName()
60 fullInfo[name] = local2Global(path + '/' + name)
61 sub_nodes[name] = fullInfo[name]['origin'][2]
62
63 for name, _ in sorted(list(sub_nodes.items()), key=operator.itemgetter(1)):
64 boundingbox = fullInfo[name]['boundingbox']
65
66 format_string = "{:<28s}: z={:10.4F}cm dZ={:10.4F}cm [{:10.4F} {:10.4F}]"+\
67 " dx={:10.4F}cm [{:10.4F} {:10.4F}] dy={:10.4F}cm [{:10.4F} {:10.4F}] {:>20s}"
68
69 format_variable = [" " * int(currentlevel) + name, fullInfo[name]['origin'][2],
70 abs(boundingbox[2][0]-boundingbox[2][1])/2., boundingbox[2][0],boundingbox[2][1],
71 abs(boundingbox[0][0]-boundingbox[0][1])/2., boundingbox[0][0],boundingbox[0][1],
72 abs(boundingbox[1][0]-boundingbox[1][1])/2., boundingbox[1][0],boundingbox[1][1],
73 fullInfo[name]['material']]
74
75 if options.moreInfo:
76 cubicmeter = fullInfo[name]['cubicmeter']
77 weight = fullInfo[name]['weight']
78 format_string += " {:10.1F}kg {:10.1F}m3"
79 format_variable.extend([weight, cubicmeter])
80
81 print (format_string.format(*format_variable))
82
83 if options.volume in ["", name]:
84 print_sub_det_info = True
85
86 if print_sub_det_info and currentlevel < level and fullInfo[name]['node'].GetNodes():
87 print_info(fullInfo[name]['path'], fullInfo[name]['node'], level, currentlevel + 1,
88 print_sub_det_info)
89
90 if currentlevel == 0:
91 print_sub_det_info = False
92
93

Variable Documentation

◆ currentlevel

int getGeoInformation.currentlevel = 0

Definition at line 117 of file getGeoInformation.py.

◆ default

getGeoInformation.default

Definition at line 97 of file getGeoInformation.py.

◆ dest

getGeoInformation.dest

Definition at line 95 of file getGeoInformation.py.

◆ fGeo

getGeoInformation.fGeo = fgeom.FAIRGeom

Definition at line 106 of file getGeoInformation.py.

◆ fgeom

getGeoInformation.fgeom = ROOT.TFile.Open(fname)

Definition at line 105 of file getGeoInformation.py.

◆ fname

getGeoInformation.fname = options.geometry

Definition at line 102 of file getGeoInformation.py.

◆ help

getGeoInformation.help

Definition at line 95 of file getGeoInformation.py.

◆ options

getGeoInformation.options = parser.parse_args()

Definition at line 101 of file getGeoInformation.py.

◆ parser

getGeoInformation.parser = ArgumentParser()

Definition at line 94 of file getGeoInformation.py.

◆ required

getGeoInformation.required

Definition at line 96 of file getGeoInformation.py.

◆ top

getGeoInformation.top = fGeo.GetTopVolume()

Definition at line 107 of file getGeoInformation.py.