90 cosb = math.sqrt( r[0]*r[0] + r[1]*r[1] )
92 a =
atan2( r[5], r[8] ) * rad
93 b =
atan2( -r[2], cosb ) * rad
94 c =
atan2( r[1], r[0] ) * rad
96 a =
atan2( -r[7], r[4] ) * rad
97 b =
atan2( -r[2], cosb ) * rad
102 self.
writer.addBox(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), 2*solid.GetDX(), 2*solid.GetDY(), 2*solid.GetDZ())
105 self.
writer.addParaboloid(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetRlo(), solid.GetRhi(), solid.GetDz())
108 self.
writer.addSphere(self.
genName(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())
113 self.
writer.addArb8(self.
genName(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],
133 self.
writer.addCone(self.
genName(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())
137 self.
writer.addCone(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), 2*solid.GetDz(), solid.GetRmin1(), solid.GetRmin2(),
138 solid.GetRmax1(), solid.GetRmax2(), 0, 360)
141 self.
writer.addPara(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetX(), solid.GetY(), solid.GetZ(),
142 solid.GetAlpha(), solid.GetTheta(), solid.GetPhi())
145 self.
writer.addTrap(self.
genName(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())
150 self.
writer.addTwistedTrap(self.
genName(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())
155 self.
writer.addTrd(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), 2*solid.GetDx1(), 2*solid.GetDx2(), 2*solid.GetDy(),
156 2*solid.GetDy(), 2*solid.GetDz())
159 self.
writer.addTrd(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), 2*solid.GetDx1(), 2*solid.GetDx2(), 2*solid.GetDy1(),
160 2*solid.GetDy2(), 2*solid.GetDz())
163 self.
writer.addTube(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetRmin(), solid.GetRmax(),
164 2*solid.GetDz(), solid.GetPhi1(), solid.GetPhi2()-solid.GetPhi1())
167 self.
writer.addCutTube(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetRmin(), solid.GetRmax(),
168 2*solid.GetDz(), solid.GetPhi1(), solid.GetPhi2()-solid.GetPhi1(),
177 self.
writer.addTube(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetRmin(), solid.GetRmax(),
178 2*solid.GetDz(), 0, 360)
182 for i
in range(solid.GetNz()):
183 zplanes.append( (solid.GetZ(i), solid.GetRmin(i), solid.GetRmax(i)) )
184 self.
writer.addPolycone(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetPhi1(), solid.GetDphi(), zplanes)
187 self.
writer.addTorus(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetR(), solid.GetRmin(), solid.GetRmax(),
188 solid.GetPhi1(), solid.GetDphi())
192 for i
in range(solid.GetNz()):
193 zplanes.append( (solid.GetZ(i), solid.GetRmin(i), solid.GetRmax(i)) )
194 self.
writer.addPolyhedra(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetPhi1(), solid.GetDphi(),
195 solid.GetNedges(), zplanes)
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.
writer.addXtrusion(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), vertices, sections)
207 self.
writer.addEltube(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetA(), solid.GetB(), solid.GetDz())
210 self.
writer.addHype(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]), solid.GetRmin(), solid.GetRmax(),
211 solid.GetStIn(), solid.GetStOut(), 2*solid.GetDz())
214 lrot = self.
rotXYZ(solid.GetBoolNode().GetLeftMatrix().
Inverse().GetRotationMatrix())
215 rrot = self.
rotXYZ(solid.GetBoolNode().GetRightMatrix().
Inverse().GetRotationMatrix())
217 if ([solid.GetBoolNode().GetLeftShape(), 0])
in self.
solList:
219 eval(
'self.'+solid.GetBoolNode().GetLeftShape().__class__.__name__)(solid.GetBoolNode().GetLeftShape())
221 if ([solid.GetBoolNode().GetRightShape(), 0])
in self.
solList:
223 eval(
'self.'+solid.GetBoolNode().GetRightShape().__class__.__name__)(solid.GetBoolNode().GetRightShape())
226 self.
writer.addUnion(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]),
227 solid.GetBoolNode().GetLeftShape().GetName()+
'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetLeftShape())[0]),
228 solid.GetBoolNode().GetLeftMatrix().GetTranslation(),
230 solid.GetBoolNode().GetRightShape().GetName()+
'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetRightShape())[0]),
231 solid.GetBoolNode().GetRightMatrix().GetTranslation(),
235 lrot = self.
rotXYZ(solid.GetBoolNode().GetLeftMatrix().
Inverse().GetRotationMatrix())
236 rrot = self.
rotXYZ(solid.GetBoolNode().GetRightMatrix().
Inverse().GetRotationMatrix())
238 if ([solid.GetBoolNode().GetLeftShape(), 0])
in self.
solList:
240 eval(
'self.'+solid.GetBoolNode().GetLeftShape().__class__.__name__)(solid.GetBoolNode().GetLeftShape())
242 if ([solid.GetBoolNode().GetRightShape(), 0])
in self.
solList:
244 eval(
'self.'+solid.GetBoolNode().GetRightShape().__class__.__name__)(solid.GetBoolNode().GetRightShape())
247 self.
writer.addIntersection(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]),
248 solid.GetBoolNode().GetLeftShape().GetName()+
'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetLeftShape())[0]),
249 solid.GetBoolNode().GetLeftMatrix().GetTranslation(),
251 solid.GetBoolNode().GetRightShape().GetName()+
'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetRightShape())[0]),
252 solid.GetBoolNode().GetRightMatrix().GetTranslation(),
256 lrot = self.
rotXYZ(solid.GetBoolNode().GetLeftMatrix().
Inverse().GetRotationMatrix())
257 rrot = self.
rotXYZ(solid.GetBoolNode().GetRightMatrix().
Inverse().GetRotationMatrix())
259 if ([solid.GetBoolNode().GetLeftShape(), 0])
in self.
solList:
261 eval(
'self.'+solid.GetBoolNode().GetLeftShape().__class__.__name__)(solid.GetBoolNode().GetLeftShape())
263 if ([solid.GetBoolNode().GetRightShape(), 0])
in self.
solList:
265 eval(
'self.'+solid.GetBoolNode().GetRightShape().__class__.__name__)(solid.GetBoolNode().GetRightShape())
268 self.
writer.addSubtraction(self.
genName(solid.GetName())+
'_'+str(libPyROOT.AddressOf(solid)[0]),
269 solid.GetBoolNode().GetLeftShape().GetName()+
'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetLeftShape())[0]),
270 solid.GetBoolNode().GetLeftMatrix().GetTranslation(),
272 solid.GetBoolNode().GetRightShape().GetName()+
'_'+str(libPyROOT.AddressOf(solid.GetBoolNode().GetRightShape())[0]),
273 solid.GetBoolNode().GetRightMatrix().GetTranslation(),
277 eval(
'self.'+solid.GetBoolNode().__class__.__name__)(solid)
280 print 'Info in <TPython::Exec>: Found ', matlist.GetSize(),
' materials'
282 if not mat.IsMixture():
283 self.
writer.addMaterial(self.
genName(mat.GetName()), mat.GetA(), mat.GetZ(), mat.GetDensity())
286 for index
in range(mat.GetNelements()):
287 elems[mat.GetElement(index).GetName()] = mat.GetWmixt()[index]
288 el = mat.GetElement(index)
291 self.
writer.addElement(mat.GetElement(index).GetTitle(), mat.GetElement(index).GetName(), mat.GetZmixt()[index], mat.GetAmixt()[index])
293 self.
writer.addMixture(self.
genName(mat.GetName()), mat.GetDensity(), elems)
296 print 'Info in <TPython::Exec>: Found ', shapelist.GetEntries(),
' shapes'
297 for shape
in shapelist:
298 self.
solList.append([shape, 0])
303 eval(
'self.'+sol[0].__class__.__name__)(sol[0])
305 print 'Info in <TPython::Exec>: Dumped ', self.
shapesCount,
' shapes'
309 index = str(volume.GetNumber())+
"_"+str(libPyROOT.AddressOf(volume)[0])
310 daughters = volume.GetNodes()
316 for node
in daughters:
320 print '[FIRST STAGE] Node count: ', self.
nodeCount
324 for node
in daughters:
328 print '[FIRST STAGE] Node count: ', self.
nodeCount
331 nd = volume.GetNdaughters()
334 currentNode = volume.GetNode(i)
335 nextVol = currentNode.GetVolume()
336 index = str(nextVol.GetNumber())+
"_"+str(libPyROOT.AddressOf(nextVol)[0])
338 self.
nodes.append(currentNode)
342 print '[ZEROTH STAGE] Analysing node: ', self.
nodeCount
346 print '[RETRIEVING VOLUME LIST]'
348 self.
bvols = geomgr.GetListOfVolumes()
350 print '[INITIALISING VOLUME USE COUNT]'
351 for vol
in self.
bvols:
352 self.
vols.append(vol)
353 self.
volsUseCount[str(vol.GetNumber())+
"_"+str(libPyROOT.AddressOf(vol)[0])]=0
355 print '[CALCULATING VOLUME USE COUNT]'
359 print '[ORDERING VOLUMES]'
363 print '[DUMPING GEOMETRY TREE]'
373 if volume.GetNodes():
374 for node
in volume.GetNodes():
375 subvol = node.GetVolume()
378 if not subvol.TestAttBit(524288):
379 subvol.SetAttBit(524288)
380 self.
vols.append(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.
writer.addPosition(name+
'pos', pos[0], pos[1], pos[2])
385 r = self.
rotXYZ(node.GetMatrix().GetRotationMatrix())
387 if r[0]!=0.0
or r[1]!=0.0
or r[2]!=0.0:
388 self.
writer.addRotation(name+
'rot', r[0], r[1], r[2])
391 reflection = node.GetMatrix().IsReflection()
394 rotmat = node.GetMatrix().GetRotationMatrix()
397 self.
writer.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)
401 self.
writer.addVolume(
'refl_'+node.GetVolume().GetName()+
'_'+str(libPyROOT.AddressOf(node.GetVolume())[0]),
'refl_'+node.GetVolume().GetShape().GetName()+
'_'+str(libPyROOT.AddressOf(node.GetVolume().GetShape())[0]), self.
genName(node.GetVolume().GetMaterial().GetName()), emptyd)
404 daughters.append( (
'refl_'+node.GetVolume().GetName()+
'_'+str(libPyROOT.AddressOf(node.GetVolume())[0]), name+
'pos', rotname) )
407 daughters.append( (node.GetVolume().GetName()+
'_'+str(libPyROOT.AddressOf(node.GetVolume())[0]), name+
'pos', rotname) )
409 if volume.IsTopVolume():
410 if not volume.IsAssembly():
411 self.
writer.addVolume(volume.GetName(), volume.GetShape().GetName()+
'_'+str(libPyROOT.AddressOf(volume.GetShape())[0]), self.
genName(volume.GetMaterial().GetName()), daughters)
413 self.
writer.addAssembly(volume.GetName(), daughters)
415 if not volume.IsAssembly():
416 self.
writer.addVolume(volume.GetName()+
'_'+str(libPyROOT.AddressOf(volume)[0]), volume.GetShape().GetName()+
'_'+str(libPyROOT.AddressOf(volume.GetShape())[0]), self.
genName(volume.GetMaterial().GetName()), daughters)
418 self.
writer.addAssembly(volume.GetName()+
'_'+str(libPyROOT.AddressOf(volume)[0]), daughters)
422 nd = volume.GetNdaughters()
426 node = volume.GetNode(i)
427 name = node.GetName()+
'in'+volume.GetName()
428 pos = node.GetMatrix().GetTranslation()
429 self.
writer.addPosition(name+
'pos', pos[0], pos[1], pos[2])
430 r = self.
rotXYZ(node.GetMatrix().GetRotationMatrix())
432 if r[0]!=0.0
or r[1]!=0.0
or r[2]!=0.0:
433 self.
writer.addRotation(name+
'rot', r[0], r[1], r[2])
435 daughters.append( (node.GetVolume().GetName()+
'_'+str(libPyROOT.AddressOf(node.GetVolume())[0]), name+
'pos', rotname) )
438 print '[SECOND STAGE] Volume Count: ', self.
nodeCount, node.GetVolume().GetName()+
'_'+str(libPyROOT.AddressOf(node.GetVolume())[0])
440 if volume.IsTopVolume():
441 if not volume.IsAssembly():
442 self.
writer.addVolume(volume.GetName(), volume.GetShape().GetName()+
'_'+str(libPyROOT.AddressOf(volume.GetShape())[0]), self.
genName(volume.GetMaterial().GetName()), daughters)
444 self.
writer.addAssembly(volume.GetName(), daughters)
446 if not volume.IsAssembly():
447 self.
writer.addVolume(volume.GetName()+
'_'+str(libPyROOT.AddressOf(volume)[0]), volume.GetShape().GetName()+
'_'+str(libPyROOT.AddressOf(volume.GetShape())[0]), self.
genName(volume.GetMaterial().GetName()), daughters)
449 self.
writer.addAssembly(volume.GetName()+
'_'+str(libPyROOT.AddressOf(volume)[0]), daughters)
double atan2(double, double)
def TGeoPgon(self, solid)
def TGeoPcon(self, solid)
def dumpMaterials(self, matlist)
def TGeoTrd2(self, solid)
def TGeoUnion(self, solid)
def getNodes(self, volume)
def TGeoSphere(self, solid)
def dumpSolids(self, shapelist)
def TGeoTrd1(self, solid)
def TGeoSubtraction(self, solid)
def TGeoArb8(self, solid)
def TGeoCtub(self, solid)
def TGeoPara(self, solid)
def TGeoXtru(self, solid)
def TGeoHype(self, solid)
def TGeoCompositeShape(self, solid)
def TGeoTubeSeg(self, solid)
def TGeoTorus(self, solid)
def TGeoBBox(self, solid)
def TGeoIntersection(self, solid)
def TGeoGtra(self, solid)
def TGeoParaboloid(self, solid)
def TGeoEltu(self, solid)
def examineVol(self, volume)
def TGeoCone(self, solid)
def TGeoTube(self, solid)
def __init__(self, writer)
def TGeoTrap(self, solid)
def orderVolumes(self, volume)
def examineVol2(self, volume)
def TGeoConeSeg(self, solid)
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.