| 1 | # $Id: variableGeometry.py,v 1.2 2003/06/16 17:06:45 dressel Exp $
|
|---|
| 2 | # -------------------------------------------------------------------
|
|---|
| 3 | # GEANT4 tag $Name: $
|
|---|
| 4 | # -------------------------------------------------------------------
|
|---|
| 5 | #
|
|---|
| 6 | import G4Kernel
|
|---|
| 7 | import parallelHall
|
|---|
| 8 | import posLog
|
|---|
| 9 |
|
|---|
| 10 | class VariableSlobedGeometry(object):
|
|---|
| 11 | def __init__(self,\
|
|---|
| 12 | tiaraSpecs,
|
|---|
| 13 | cellSizeImportanceList,
|
|---|
| 14 | parallelGeo):
|
|---|
| 15 | self.arrPosLogVol = []
|
|---|
| 16 | self.normalCellSolids = []
|
|---|
| 17 | self.logNormCells = []
|
|---|
| 18 | self.lastCellSolid = None
|
|---|
| 19 | self.logLastCell = None
|
|---|
| 20 | self.createCells(tiaraSpecs,
|
|---|
| 21 | cellSizeImportanceList, parallelGeo)
|
|---|
| 22 |
|
|---|
| 23 | def createCells(self, tiaraSpecs,
|
|---|
| 24 | cellSizeImportanceList, parallelGeo):
|
|---|
| 25 | nImps = len(cellSizeImportanceList)
|
|---|
| 26 | zCellStart = tiaraSpecs.dimensions.targetPosZ + \
|
|---|
| 27 | tiaraSpecs.dimensions.distTargetExperiment + \
|
|---|
| 28 | tiaraSpecs.experiment.colWidth
|
|---|
| 29 | zCellRegion = parallelGeo.halfLength - zCellStart
|
|---|
| 30 | print "zCellStart", zCellStart, "zCellRegion", zCellRegion
|
|---|
| 31 | vacuum = tiaraSpecs.materials.GetMaterial("vacuum")
|
|---|
| 32 | for i in range(nImps):
|
|---|
| 33 | ncsName = "cellBox_%(i)d" % vars()
|
|---|
| 34 | print "i", i, "cswidth", cellSizeImportanceList[i]["width"]
|
|---|
| 35 | ncs = G4Kernel.G4Box(ncsName,
|
|---|
| 36 | parallelGeo.halfWidth,
|
|---|
| 37 | parallelGeo.halfWidth,
|
|---|
| 38 | 0.5 * cellSizeImportanceList[i]["width"])
|
|---|
| 39 | self.normalCellSolids.append(ncs)
|
|---|
| 40 | nclName = "cellLog_%(i)d" % vars()
|
|---|
| 41 | ncl = G4Kernel.G4LogicalVolume(ncs,
|
|---|
| 42 | vacuum,
|
|---|
| 43 | nclName)
|
|---|
| 44 | self.logNormCells.append(ncl)
|
|---|
| 45 |
|
|---|
| 46 | zPos = zCellStart
|
|---|
| 47 | for i in range(nImps):
|
|---|
| 48 | zPos += 0.5 * cellSizeImportanceList[i]["width"]
|
|---|
| 49 | print "zPos", zPos, "cellNum", i
|
|---|
| 50 | self.arrPosLogVol.append(posLog.PosLog(zPos, self.logNormCells[i]))
|
|---|
| 51 | zPos += 0.5 * cellSizeImportanceList[i]["width"]
|
|---|
| 52 |
|
|---|
| 53 |
|
|---|
| 54 | allCellWidth = 0.0
|
|---|
| 55 | for i in range(nImps):
|
|---|
| 56 | allCellWidth+=cellSizeImportanceList[i]["width"]
|
|---|
| 57 | print "allCellWidth", allCellWidth
|
|---|
| 58 | lengthLastCell = zCellRegion - allCellWidth
|
|---|
| 59 |
|
|---|
| 60 | self.lastCellSolid = G4Kernel.G4Box("lastCellBox",
|
|---|
| 61 | parallelGeo.halfWidth,
|
|---|
| 62 | parallelGeo.halfWidth,
|
|---|
| 63 | lengthLastCell/2)
|
|---|
| 64 | self.logLastCell = G4Kernel.G4LogicalVolume(self.lastCellSolid,
|
|---|
| 65 | vacuum,
|
|---|
| 66 | "lastCellLog")
|
|---|
| 67 |
|
|---|
| 68 | zPos += lengthLastCell/2
|
|---|
| 69 | print "last cell zPos", zPos, "length", lengthLastCell
|
|---|
| 70 | self.arrPosLogVol.append(posLog.PosLog(zPos, self.logLastCell))
|
|---|
| 71 |
|
|---|
| 72 |
|
|---|
| 73 | def getArrPosLogVol(self):
|
|---|
| 74 | return self.arrPosLogVol
|
|---|
| 75 |
|
|---|
| 76 |
|
|---|
| 77 | class VariableImpSlabGeometry(object):
|
|---|
| 78 | def __init__(self, tiaraSpecs,
|
|---|
| 79 | parallelGeo = None):
|
|---|
| 80 | self.tiaraSpecs = tiaraSpecs
|
|---|
| 81 | self.cellSizeImportanceList = []
|
|---|
| 82 | self.parallelGeo = parallelGeo
|
|---|
| 83 | self.iStore = None
|
|---|
| 84 | self.geometryCells = []
|
|---|
| 85 | self.base = 0.0
|
|---|
| 86 | self.nameExt = "-variableCellWidth"
|
|---|
| 87 |
|
|---|
| 88 |
|
|---|
| 89 | def addCellImportance(self, width, faktor):
|
|---|
| 90 | self.cellSizeImportanceList.append(
|
|---|
| 91 | {"width":width, "faktor":faktor})
|
|---|
| 92 |
|
|---|
| 93 |
|
|---|
| 94 | def construct(self):
|
|---|
| 95 | nImps = len(self.cellSizeImportanceList)
|
|---|
| 96 | if nImps>0:
|
|---|
| 97 | for i in range(nImps):
|
|---|
| 98 | self.base+=1.0*self.cellSizeImportanceList[i]["faktor"]
|
|---|
| 99 | self.base/=nImps
|
|---|
| 100 | self.createParallelGeometry(self.tiaraSpecs)
|
|---|
| 101 | self.setImportances()
|
|---|
| 102 |
|
|---|
| 103 |
|
|---|
| 104 | def createParallelGeometry(self, tiaraSpecs):
|
|---|
| 105 | self.parallelGeo = parallelHall.ParallelHall(tiaraSpecs)
|
|---|
| 106 | self.slobedGeo = VariableSlobedGeometry(\
|
|---|
| 107 | tiaraSpecs,
|
|---|
| 108 | self.cellSizeImportanceList,
|
|---|
| 109 | self.parallelGeo)
|
|---|
| 110 | self.parallelGeo.placeCells(self.slobedGeo.getArrPosLogVol())
|
|---|
| 111 | self.iStore = G4Kernel.G4IStore(self.parallelGeo.getWorldVolume())
|
|---|
| 112 | self.geometryCells = self.parallelGeo.getGeometryCells()
|
|---|
| 113 |
|
|---|
| 114 | def setImportances(self):
|
|---|
| 115 | worldCell = G4Kernel.G4GeometryCell(self.parallelGeo.\
|
|---|
| 116 | getWorldVolume(), 0)
|
|---|
| 117 | self.iStore.AddImportanceGeometryCell(1, worldCell)
|
|---|
| 118 | nCells = len(self.geometryCells)
|
|---|
| 119 | nImps = len(self.cellSizeImportanceList)
|
|---|
| 120 | if ((nCells - 1) != nImps):
|
|---|
| 121 | print "VariableImpSlabGeometry: ERROR importances and cells don't mach!", nCells, nImps
|
|---|
| 122 | importance = 1
|
|---|
| 123 | for i in range(nImps):
|
|---|
| 124 | cell = self.geometryCells[i]
|
|---|
| 125 | importance*=self.cellSizeImportanceList[i]["faktor"]
|
|---|
| 126 | print "i=", importance
|
|---|
| 127 | self.iStore.AddImportanceGeometryCell(importance, cell)
|
|---|
| 128 |
|
|---|
| 129 | lastCell = self.geometryCells[nCells-1]
|
|---|
| 130 | print "last cells i=", importance
|
|---|
| 131 | self.iStore.AddImportanceGeometryCell(importance, lastCell)
|
|---|
| 132 |
|
|---|
| 133 | def getWorldVolume(self):
|
|---|
| 134 | return self.parallelGeo.getWorldVolume()
|
|---|
| 135 |
|
|---|
| 136 | def getImportanceStore(self):
|
|---|
| 137 | return self.iStore
|
|---|