Logo ROOT   6.16/01
Reference Guide
ROOTwriter.py
Go to the documentation of this file.
1# @(#)root/gdml:$Id$
2# Author: Witold Pokorski 05/06/2006
3
4from math import *
5
6import libPyROOT
7import ROOT
8import math
9import re
10
11# This class provides ROOT binding for the 'writer' class. It implements specific
12# methods for all the supported TGeo classes which call the appropriate 'add-element'
13# methods from the 'writer' class.
14
15# The list of presently supported classes is the following:
16
17# Materials:
18# TGeoElement
19# TGeoMaterial
20# GeoMixture
21
22# Solids:
23# TGeoBBox
24# TGeoArb8
25# TGeoTubeSeg
26# TGeoConeSeg
27# TGeoCtub
28# TGeoPcon
29# TGeoTrap
30# TGeoGtra
31# TGeoTrd2
32# TGeoSphere
33# TGeoPara
34# TGeoTorus
35# TGeoHype
36# TGeoPgon
37# TGeoXtru
38# TGeoEltu
39# TGeoParaboloid
40# TGeoCompositeShape (subtraction, union, intersection)
41
42# Geometry:
43# TGeoVolume
44
45# In addition the class contains three methods 'dumpMaterials', 'dumpSolids' and 'examineVol'
46# which retrieve from the memory the materials, the solids and the geometry tree
47# respectively. The user should instanciate this class passing and instance of 'writer'
48# class as argument. In order to export the geometry in the form of a GDML file,
49# the three methods (dumpMaterials, dumpSolids and examineVol) should be called.
50# The argument of 'dumpMaterials' method should be the list of materials,
51# the argument of the 'dumpSolids' method should be the list of solids and
52# the argument of the 'examineVol' method should be the top volume of
53# the geometry tree.
54
55# For any question or remarks concerning this code, please send an email to
56# Witold.Pokorski@cern.ch.
57
58class ROOTwriter(object):
59
60 def __init__(self, writer):
61 self.writerwriter = writer
62 self.elementselements = []
63 self.volumeCountvolumeCount = 0
64 self.nodeCountnodeCount = 0
65 self.shapesCountshapesCount = 0
66 self.bvolsbvols = []
67 self.volsvols = []
68 self.volsUseCountvolsUseCount = {}
69 self.sortedVolssortedVols = []
70 self.nodesnodes = []
71 self.bnodesbnodes = []
72 self.solListsolList = []
73 self.geomgrgeomgr = ROOT.gGeoManager
74 self.geomgrgeomgr.SetAllIndex()
75 pass
76
77
78
79 def genName(self, name):
80
81 re.sub('$', '', name)
82
83 return name
84
85
86 def rotXYZ(self, r):
87
88 rad = 180/acos(-1)
89
90 cosb = math.sqrt( r[0]*r[0] + r[1]*r[1] )
91 if cosb > 0.00001 : #I didn't find a proper constant to use here, so I just put a value that works with all the examples on a linux machine (P4)
92 a = atan2( r[5], r[8] ) * rad
93 b = atan2( -r[2], cosb ) * rad
94 c = atan2( r[1], r[0] ) * rad
95 else:
96 a = atan2( -r[7], r[4] ) * rad
97 b = atan2( -r[2], cosb ) * rad
98 c = 0.
99 return (a, b, c)
100
101 def TGeoBBox(self, solid):
102 self.writerwriter.addBox(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), 2*solid.GetDX(), 2*solid.GetDY(), 2*solid.GetDZ())
103
104 def TGeoParaboloid(self, solid):
105 self.writerwriter.addParaboloid(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetRlo(), solid.GetRhi(), solid.GetDz())
106
107 def TGeoSphere(self, solid):
108 self.writerwriter.addSphere(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetRmin(), solid.GetRmax(),
109 solid.GetPhi1(), solid.GetPhi2() - solid.GetPhi1(),
110 solid.GetTheta1(), solid.GetTheta2() - solid.GetTheta1())
111
112 def TGeoArb8(self, solid):
113 self.writerwriter.addArb8(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]),
114 solid.GetVertices()[0],
115 solid.GetVertices()[1],
116 solid.GetVertices()[2],
117 solid.GetVertices()[3],
118 solid.GetVertices()[4],
119 solid.GetVertices()[5],
120 solid.GetVertices()[6],
121 solid.GetVertices()[7],
122 solid.GetVertices()[8],
123 solid.GetVertices()[9],
124 solid.GetVertices()[10],
125 solid.GetVertices()[11],
126 solid.GetVertices()[12],
127 solid.GetVertices()[13],
128 solid.GetVertices()[14],
129 solid.GetVertices()[15],
130 solid.GetDz())
131
132 def TGeoConeSeg(self, solid):
133 self.writerwriter.addCone(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), 2*solid.GetDz(), solid.GetRmin1(), solid.GetRmin2(),
134 solid.GetRmax1(), solid.GetRmax2(), solid.GetPhi1(), solid.GetPhi2() - solid.GetPhi1())
135
136 def TGeoCone(self, solid):
137 self.writerwriter.addCone(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), 2*solid.GetDz(), solid.GetRmin1(), solid.GetRmin2(),
138 solid.GetRmax1(), solid.GetRmax2(), 0, 360)
139
140 def TGeoPara(self, solid):
141 self.writerwriter.addPara(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetX(), solid.GetY(), solid.GetZ(),
142 solid.GetAlpha(), solid.GetTheta(), solid.GetPhi())
143
144 def TGeoTrap(self, solid):
145 self.writerwriter.addTrap(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), 2*solid.GetDz(), solid.GetTheta(), solid.GetPhi(),
146 2*solid.GetH1(), 2*solid.GetBl1(), 2*solid.GetTl1(), solid.GetAlpha1(),
147 2*solid.GetH2(), 2*solid.GetBl2(), 2*solid.GetTl2(), solid.GetAlpha2())
148
149 def TGeoGtra(self, solid):
150 self.writerwriter.addTwistedTrap(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), 2*solid.GetDz(), solid.GetTheta(), solid.GetPhi(),
151 2*solid.GetH1(), 2*solid.GetBl1(), 2*solid.GetTl1(), solid.GetAlpha1(),
152 2*solid.GetH2(), 2*solid.GetBl2(), 2*solid.GetTl2(), solid.GetAlpha2(), solid.GetTwistAngle())
153
154 def TGeoTrd1(self, solid):
155 self.writerwriter.addTrd(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), 2*solid.GetDx1(), 2*solid.GetDx2(), 2*solid.GetDy(),
156 2*solid.GetDy(), 2*solid.GetDz())
157
158 def TGeoTrd2(self, solid):
159 self.writerwriter.addTrd(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), 2*solid.GetDx1(), 2*solid.GetDx2(), 2*solid.GetDy1(),
160 2*solid.GetDy2(), 2*solid.GetDz())
161
162 def TGeoTubeSeg(self, solid):
163 self.writerwriter.addTube(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetRmin(), solid.GetRmax(),
164 2*solid.GetDz(), solid.GetPhi1(), solid.GetPhi2()-solid.GetPhi1())
165
166 def TGeoCtub(self, solid):
167 self.writerwriter.addCutTube(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetRmin(), solid.GetRmax(),
168 2*solid.GetDz(), solid.GetPhi1(), solid.GetPhi2()-solid.GetPhi1(),
169 solid.GetNlow()[0],
170 solid.GetNlow()[1],
171 solid.GetNlow()[2],
172 solid.GetNhigh()[0],
173 solid.GetNhigh()[1],
174 solid.GetNhigh()[2])
175
176 def TGeoTube(self, solid):
177 self.writerwriter.addTube(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetRmin(), solid.GetRmax(),
178 2*solid.GetDz(), 0, 360)
179
180 def TGeoPcon(self, solid):
181 zplanes = []
182 for i in range(solid.GetNz()):
183 zplanes.append( (solid.GetZ(i), solid.GetRmin(i), solid.GetRmax(i)) )
184 self.writerwriter.addPolycone(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetPhi1(), solid.GetDphi(), zplanes)
185
186 def TGeoTorus(self, solid):
187 self.writerwriter.addTorus(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetR(), solid.GetRmin(), solid.GetRmax(),
188 solid.GetPhi1(), solid.GetDphi())
189
190 def TGeoPgon(self, solid):
191 zplanes = []
192 for i in range(solid.GetNz()):
193 zplanes.append( (solid.GetZ(i), solid.GetRmin(i), solid.GetRmax(i)) )
194 self.writerwriter.addPolyhedra(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetPhi1(), solid.GetDphi(),
195 solid.GetNedges(), zplanes)
196
197 def TGeoXtru(self, solid):
198 vertices = []
199 sections = []
200 for i in range(solid.GetNvert()):
201 vertices.append( (solid.GetX(i), solid.GetY(i)) )
202 for i in range(solid.GetNz()):
203 sections.append( (i, solid.GetZ(i), solid.GetXOffset(i), solid.GetYOffset(i), solid.GetScale(i)) )
204 self.writerwriter.addXtrusion(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), vertices, sections)
205
206 def TGeoEltu(self, solid):
207 self.writerwriter.addEltube(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetA(), solid.GetB(), solid.GetDz())
208
209 def TGeoHype(self, solid):
210 self.writerwriter.addHype(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetRmin(), solid.GetRmax(),
211 solid.GetStIn(), solid.GetStOut(), 2*solid.GetDz())
212
213 def TGeoUnion(self, solid):
214 lrot = self.rotXYZrotXYZ(solid.GetBoolNode().GetLeftMatrix().Inverse().GetRotationMatrix())
215 rrot = self.rotXYZrotXYZ(solid.GetBoolNode().GetRightMatrix().Inverse().GetRotationMatrix())
216
217 if ([solid.GetBoolNode().GetLeftShape(), 0]) in self.solListsolList:
218 self.solListsolList[self.solListsolList.index([solid.GetBoolNode().GetLeftShape(), 0])][1] = 1
219 eval('self.'+solid.GetBoolNode().GetLeftShape().__class__.__name__)(solid.GetBoolNode().GetLeftShape())
220 self.shapesCountshapesCount = self.shapesCountshapesCount + 1
221 if ([solid.GetBoolNode().GetRightShape(), 0]) in self.solListsolList:
222 self.solListsolList[self.solListsolList.index([solid.GetBoolNode().GetRightShape(), 0])][1] = 1
223 eval('self.'+solid.GetBoolNode().GetRightShape().__class__.__name__)(solid.GetBoolNode().GetRightShape())
224 self.shapesCountshapesCount = self.shapesCountshapesCount + 1
225
226 self.writerwriter.addUnion(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]),
227 solid.GetBoolNode().GetLeftShape().GetName()+'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetLeftShape())[0]),
228 solid.GetBoolNode().GetLeftMatrix().GetTranslation(),
229 lrot,
230 solid.GetBoolNode().GetRightShape().GetName()+'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetRightShape())[0]),
231 solid.GetBoolNode().GetRightMatrix().GetTranslation(),
232 rrot)
233
234 def TGeoIntersection(self, solid):
235 lrot = self.rotXYZrotXYZ(solid.GetBoolNode().GetLeftMatrix().Inverse().GetRotationMatrix())
236 rrot = self.rotXYZrotXYZ(solid.GetBoolNode().GetRightMatrix().Inverse().GetRotationMatrix())
237
238 if ([solid.GetBoolNode().GetLeftShape(), 0]) in self.solListsolList:
239 self.solListsolList[self.solListsolList.index([solid.GetBoolNode().GetLeftShape(), 0])][1] = 1
240 eval('self.'+solid.GetBoolNode().GetLeftShape().__class__.__name__)(solid.GetBoolNode().GetLeftShape())
241 self.shapesCountshapesCount = self.shapesCountshapesCount + 1
242 if ([solid.GetBoolNode().GetRightShape(), 0]) in self.solListsolList:
243 self.solListsolList[self.solListsolList.index([solid.GetBoolNode().GetRightShape(), 0])][1] = 1
244 eval('self.'+solid.GetBoolNode().GetRightShape().__class__.__name__)(solid.GetBoolNode().GetRightShape())
245 self.shapesCountshapesCount = self.shapesCountshapesCount + 1
246
247 self.writerwriter.addIntersection(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]),
248 solid.GetBoolNode().GetLeftShape().GetName()+'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetLeftShape())[0]),
249 solid.GetBoolNode().GetLeftMatrix().GetTranslation(),
250 lrot,
251 solid.GetBoolNode().GetRightShape().GetName()+'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetRightShape())[0]),
252 solid.GetBoolNode().GetRightMatrix().GetTranslation(),
253 rrot)
254
255 def TGeoSubtraction(self, solid):
256 lrot = self.rotXYZrotXYZ(solid.GetBoolNode().GetLeftMatrix().Inverse().GetRotationMatrix())
257 rrot = self.rotXYZrotXYZ(solid.GetBoolNode().GetRightMatrix().Inverse().GetRotationMatrix())
258
259 if ([solid.GetBoolNode().GetLeftShape(), 0]) in self.solListsolList:
260 self.solListsolList[self.solListsolList.index([solid.GetBoolNode().GetLeftShape(), 0])][1] = 1
261 eval('self.'+solid.GetBoolNode().GetLeftShape().__class__.__name__)(solid.GetBoolNode().GetLeftShape())
262 self.shapesCountshapesCount = self.shapesCountshapesCount + 1
263 if ([solid.GetBoolNode().GetRightShape(), 0]) in self.solListsolList:
264 self.solListsolList[self.solListsolList.index([solid.GetBoolNode().GetRightShape(), 0])][1] = 1
265 eval('self.'+solid.GetBoolNode().GetRightShape().__class__.__name__)(solid.GetBoolNode().GetRightShape())
266 self.shapesCountshapesCount = self.shapesCountshapesCount + 1
267
268 self.writerwriter.addSubtraction(self.genNamegenName(solid.GetName())+'_'+str(libPyROOT.AddressOf(solid)[0]),
269 solid.GetBoolNode().GetLeftShape().GetName()+'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetLeftShape())[0]),
270 solid.GetBoolNode().GetLeftMatrix().GetTranslation(),
271 lrot,
272 solid.GetBoolNode().GetRightShape().GetName()+'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetRightShape())[0]),
273 solid.GetBoolNode().GetRightMatrix().GetTranslation(),
274 rrot)
275
276 def TGeoCompositeShape(self, solid):
277 eval('self.'+solid.GetBoolNode().__class__.__name__)(solid)
278
279 def dumpMaterials(self, matlist):
280 print 'Info in <TPython::Exec>: Found ', matlist.GetSize(),' materials'
281 for mat in matlist:
282 if not mat.IsMixture():
283 self.writerwriter.addMaterial(self.genNamegenName(mat.GetName()), mat.GetA(), mat.GetZ(), mat.GetDensity())
284 else:
285 elems = {}
286 for index in range(mat.GetNelements()):
287 elems[mat.GetElement(index).GetName()] = mat.GetWmixt()[index]
288 el = mat.GetElement(index)
289 if el not in self.elementselements:
290 self.elementselements.append(el)
291 self.writerwriter.addElement(mat.GetElement(index).GetTitle(), mat.GetElement(index).GetName(), mat.GetZmixt()[index], mat.GetAmixt()[index])
292
293 self.writerwriter.addMixture(self.genNamegenName(mat.GetName()), mat.GetDensity(), elems)
294
295 def dumpSolids(self, shapelist):
296 print 'Info in <TPython::Exec>: Found ', shapelist.GetEntries(), ' shapes'
297 for shape in shapelist:
298 self.solListsolList.append([shape, 0])
299 for sol in self.solListsolList:
300 if sol[1] == 0:
301 sol[1] = 1
302 #print eval('self.'+sol[0].__class__.__name__)(sol[0])
303 eval('self.'+sol[0].__class__.__name__)(sol[0])
304 self.shapesCountshapesCount = self.shapesCountshapesCount + 1
305 print 'Info in <TPython::Exec>: Dumped ', self.shapesCountshapesCount, ' shapes'
306
307
308 def orderVolumes(self, volume):
309 index = str(volume.GetNumber())+"_"+str(libPyROOT.AddressOf(volume)[0])
310 daughters = volume.GetNodes()
311 if len(self.sortedVolssortedVols)<len(self.volsvols) and self.volsUseCountvolsUseCount[index]>0:
312 self.volsUseCountvolsUseCount[index] = self.volsUseCountvolsUseCount[index]-1
313 if self.volsUseCountvolsUseCount[index]==0:
314 self.sortedVolssortedVols.append(volume)
315 if daughters:
316 for node in daughters:
317 self.orderVolumesorderVolumes(node.GetVolume())
318 self.nodeCountnodeCount = self.nodeCountnodeCount+1
319 if self.nodeCountnodeCount%10000==0:
320 print '[FIRST STAGE] Node count: ', self.nodeCountnodeCount
321 elif len(self.sortedVolssortedVols)<len(self.volsUseCountvolsUseCount) and self.volsUseCountvolsUseCount[index]==0:
322 self.sortedVolssortedVols.append(volume)
323 if daughters:
324 for node in daughters:
325 self.orderVolumesorderVolumes(node.GetVolume())
326 self.nodeCountnodeCount = self.nodeCountnodeCount+1
327 if self.nodeCountnodeCount%10000==0:
328 print '[FIRST STAGE] Node count: ', self.nodeCountnodeCount
329
330 def getNodes(self, volume):
331 nd = volume.GetNdaughters()
332 if nd:
333 for i in range(nd):
334 currentNode = volume.GetNode(i)
335 nextVol = currentNode.GetVolume()
336 index = str(nextVol.GetNumber())+"_"+str(libPyROOT.AddressOf(nextVol)[0])
337 self.volsUseCountvolsUseCount[index] = self.volsUseCountvolsUseCount[index]+1
338 self.nodesnodes.append(currentNode)
339 self.getNodesgetNodes(nextVol)
340 self.nodeCountnodeCount = self.nodeCountnodeCount+1
341 if self.nodeCountnodeCount%10000==0:
342 print '[ZEROTH STAGE] Analysing node: ', self.nodeCountnodeCount
343
344 def examineVol2(self, volume): #use with geometries containing many volumes
345 print ''
346 print '[RETRIEVING VOLUME LIST]'
347
348 self.bvolsbvols = geomgr.GetListOfVolumes()
349 print ''
350 print '[INITIALISING VOLUME USE COUNT]'
351 for vol in self.bvolsbvols:
352 self.volsvols.append(vol)
353 self.volsUseCountvolsUseCount[str(vol.GetNumber())+"_"+str(libPyROOT.AddressOf(vol)[0])]=0
354 print ''
355 print '[CALCULATING VOLUME USE COUNT]'
356 self.nodeCountnodeCount = 0
357 self.getNodesgetNodes(volume)
358 print ''
359 print '[ORDERING VOLUMES]'
360 self.nodeCountnodeCount = 0
361 self.orderVolumesorderVolumes(volume)
362 print ''
363 print '[DUMPING GEOMETRY TREE]'
364 self.sortedVolssortedVols.reverse()
365 self.nodeCountnodeCount = 0
366 self.dumpGeoTreedumpGeoTree()
367 print ''
368 print '[FINISHED!]'
369 print ''
370
371 def examineVol(self, volume): #use with geometries containing very few volumes and many nodes
372 daughters = []
373 if volume.GetNodes():
374 for node in volume.GetNodes():
375 subvol = node.GetVolume()
376
377 #if bit not set, set and save primitive
378 if not subvol.TestAttBit(524288): #value referring to TGeoAtt::kSavePrimitiveAtt (1 << 19)
379 subvol.SetAttBit(524288)
380 self.volsvols.append(subvol)
381 self.examineVolexamineVol(subvol)
382 name = node.GetName()+str(libPyROOT.AddressOf(subvol)[0])+'in'+volume.GetName()+str(libPyROOT.AddressOf(volume)[0])
383 pos = node.GetMatrix().GetTranslation()
384 self.writerwriter.addPosition(name+'pos', pos[0], pos[1], pos[2])
385 r = self.rotXYZrotXYZ(node.GetMatrix().GetRotationMatrix())
386 rotname = ''
387 if r[0]!=0.0 or r[1]!=0.0 or r[2]!=0.0:
388 self.writerwriter.addRotation(name+'rot', r[0], r[1], r[2])
389 rotname = name+'rot'
390
391 reflection = node.GetMatrix().IsReflection()#check if this daughter has a reflection matrix
392
393 if reflection:
394 rotmat = node.GetMatrix().GetRotationMatrix()
395
396 #add new 'reflectedSolid' shape to solids
397 self.writerwriter.addReflSolid('refl_'+node.GetVolume().GetShape().GetName()+'_'+str(libPyROOT.AddressOf(node.GetVolume().GetShape())[0]), node.GetVolume().GetShape().GetName()+'_'+str(libPyROOT.AddressOf(node.GetVolume().GetShape())[0]), 0, 0, 0, rotmat[0], rotmat[4], rotmat[8], 0, 0, 0)
398
399 #add new volume with correct solidref to the new reflectedSolid
400 emptyd = []
401 self.writerwriter.addVolume('refl_'+node.GetVolume().GetName()+'_'+str(libPyROOT.AddressOf(node.GetVolume())[0]), 'refl_'+node.GetVolume().GetShape().GetName()+'_'+str(libPyROOT.AddressOf(node.GetVolume().GetShape())[0]), self.genNamegenName(node.GetVolume().GetMaterial().GetName()), emptyd)
402
403 #add new volume as volumeref to this physvol
404 daughters.append( ('refl_'+node.GetVolume().GetName()+'_'+str(libPyROOT.AddressOf(node.GetVolume())[0]), name+'pos', rotname) )
405
406 else:
407 daughters.append( (node.GetVolume().GetName()+'_'+str(libPyROOT.AddressOf(node.GetVolume())[0]), name+'pos', rotname) )
408
409 if volume.IsTopVolume():
410 if not volume.IsAssembly():
411 self.writerwriter.addVolume(volume.GetName(), volume.GetShape().GetName()+'_'+str(libPyROOT.AddressOf(volume.GetShape())[0]), self.genNamegenName(volume.GetMaterial().GetName()), daughters)
412 else:
413 self.writerwriter.addAssembly(volume.GetName(), daughters)
414 else:
415 if not volume.IsAssembly():
416 self.writerwriter.addVolume(volume.GetName()+'_'+str(libPyROOT.AddressOf(volume)[0]), volume.GetShape().GetName()+'_'+str(libPyROOT.AddressOf(volume.GetShape())[0]), self.genNamegenName(volume.GetMaterial().GetName()), daughters)
417 else:
418 self.writerwriter.addAssembly(volume.GetName()+'_'+str(libPyROOT.AddressOf(volume)[0]), daughters)
419
420 def dumpGeoTree(self):
421 for volume in self.sortedVolssortedVols:
422 nd = volume.GetNdaughters()
423 daughters = []
424 if nd:
425 for i in range(nd):
426 node = volume.GetNode(i)
427 name = node.GetName()+'in'+volume.GetName()
428 pos = node.GetMatrix().GetTranslation()
429 self.writerwriter.addPosition(name+'pos', pos[0], pos[1], pos[2])
430 r = self.rotXYZrotXYZ(node.GetMatrix().GetRotationMatrix())
431 rotname = ''
432 if r[0]!=0.0 or r[1]!=0.0 or r[2]!=0.0:
433 self.writerwriter.addRotation(name+'rot', r[0], r[1], r[2])
434 rotname = name+'rot'
435 daughters.append( (node.GetVolume().GetName()+'_'+str(libPyROOT.AddressOf(node.GetVolume())[0]), name+'pos', rotname) )
436 self.nodeCountnodeCount = self.nodeCountnodeCount+1
437 if self.nodeCountnodeCount%100==0:
438 print '[SECOND STAGE] Volume Count: ', self.nodeCountnodeCount, node.GetVolume().GetName()+'_'+str(libPyROOT.AddressOf(node.GetVolume())[0])
439
440 if volume.IsTopVolume():
441 if not volume.IsAssembly():
442 self.writerwriter.addVolume(volume.GetName(), volume.GetShape().GetName()+'_'+str(libPyROOT.AddressOf(volume.GetShape())[0]), self.genNamegenName(volume.GetMaterial().GetName()), daughters)
443 else:
444 self.writerwriter.addAssembly(volume.GetName(), daughters)
445 else:
446 if not volume.IsAssembly():
447 self.writerwriter.addVolume(volume.GetName()+'_'+str(libPyROOT.AddressOf(volume)[0]), volume.GetShape().GetName()+'_'+str(libPyROOT.AddressOf(volume.GetShape())[0]), self.genNamegenName(volume.GetMaterial().GetName()), daughters)
448 else:
449 self.writerwriter.addAssembly(volume.GetName()+'_'+str(libPyROOT.AddressOf(volume)[0]), daughters)
450
double atan2(double, double)
double acos(double)
def TGeoPgon(self, solid)
Definition: ROOTwriter.py:190
def TGeoPcon(self, solid)
Definition: ROOTwriter.py:180
def dumpMaterials(self, matlist)
Definition: ROOTwriter.py:279
def genName(self, name)
Definition: ROOTwriter.py:79
def TGeoTrd2(self, solid)
Definition: ROOTwriter.py:158
def TGeoUnion(self, solid)
Definition: ROOTwriter.py:213
def getNodes(self, volume)
Definition: ROOTwriter.py:330
def TGeoSphere(self, solid)
Definition: ROOTwriter.py:107
def dumpSolids(self, shapelist)
Definition: ROOTwriter.py:295
def TGeoTrd1(self, solid)
Definition: ROOTwriter.py:154
def TGeoSubtraction(self, solid)
Definition: ROOTwriter.py:255
def TGeoArb8(self, solid)
Definition: ROOTwriter.py:112
def rotXYZ(self, r)
Definition: ROOTwriter.py:86
def TGeoCtub(self, solid)
Definition: ROOTwriter.py:166
def TGeoPara(self, solid)
Definition: ROOTwriter.py:140
def TGeoXtru(self, solid)
Definition: ROOTwriter.py:197
def TGeoHype(self, solid)
Definition: ROOTwriter.py:209
def TGeoCompositeShape(self, solid)
Definition: ROOTwriter.py:276
def TGeoTubeSeg(self, solid)
Definition: ROOTwriter.py:162
def TGeoTorus(self, solid)
Definition: ROOTwriter.py:186
def TGeoBBox(self, solid)
Definition: ROOTwriter.py:101
def TGeoIntersection(self, solid)
Definition: ROOTwriter.py:234
def TGeoGtra(self, solid)
Definition: ROOTwriter.py:149
def TGeoParaboloid(self, solid)
Definition: ROOTwriter.py:104
def TGeoEltu(self, solid)
Definition: ROOTwriter.py:206
def examineVol(self, volume)
Definition: ROOTwriter.py:371
def TGeoCone(self, solid)
Definition: ROOTwriter.py:136
def TGeoTube(self, solid)
Definition: ROOTwriter.py:176
def __init__(self, writer)
Definition: ROOTwriter.py:60
def TGeoTrap(self, solid)
Definition: ROOTwriter.py:144
def orderVolumes(self, volume)
Definition: ROOTwriter.py:308
def examineVol2(self, volume)
Definition: ROOTwriter.py:344
def TGeoConeSeg(self, solid)
Definition: ROOTwriter.py:132
std::string GetName(const std::string &scope_name)
Definition: Cppyy.cxx:146
ABObj< sym, MatrixInverse< sym, ABObj< sym, LASymMatrix, double >, double >, double > Inverse(const ABObj< sym, LASymMatrix, double > &obj)
LAPACK Algebra functions specialize the Invert function for LASymMatrix.
Definition: LaInverse.h:27