10
def __init__( self, Name ):
22
def SetDimensions( self, Length, Width, Height ):
27
def SetPosition( self, X, Y, Z ):
32
def SetRotation( self, Phi, Theta, Psi ):
42
"""% ( self.Name, self.Width, self.Height, self.Length, self.X, self.Y, self.Z )
10
def __init__( self, Name ):
22
def SetDimensions( self, Length, Width, Height ):
27
def SetPosition( self, X, Y, Z ):
32
def SetRotation( self, Phi, Theta, Psi ):
42
"""% ( self.Name, self.Width, self.Height, self.Length, self.X, self.Y, self.Z )
45
45
class EMRBar( G4MiceGeoBase ):
46
def __init__( self, LayerId, BarId, BarLength, BarHeight, BarWidth ):
47
self.Name = "EMRLayer%dBar%d" % ( LayerId, BarId )
49
self.LayerId = LayerId
50
self.Length = BarLength
52
self.Height = BarHeight
63
# if( self.BarId % 2 ):
65
# Y2HalfLength = ( self.Width / 2 )
67
# Y1HalfLength = ( self.Width / 2 )
70
# XHalfLength = ( self.Length / 2 )
71
# ZHalfLength = ( self.Height / 2 )
74
// FILES/Models/Modules/%s%s.dat
79
Dimensions %.2f %.2f %.2f %.2f %.2f cm
83
PropertyDouble BlueColour 1.0
86
Position 0.0 0.0 0.0 mm
87
Rotation 0.0 0.0 0.0 degree
90
""" % ( ExportFolder, self.Name, self.Name, self.Length / 2, self.Length / 2, 0., self.Width / 2, self.Height / 2, self.LayerId, self.BarId, self.Name )
92
#% ( ExportFolder, self.Name, self.Name, XHalfLength, XHalfLength, Y1HalfLength, Y2HalfLength, ZHalfLength, self.LayerId, self.BarId, self.Name )
94
BarFile = open( ExportFolder + self.Name + ".dat", 'w' )
95
BarFile.write( Content )
98
// FILES/Models/Modules/%s%sSci.dat
104
Dimensions %.2f %.2f %.2f %.2f %.2f cm
107
PropertyString SensitiveDetector EMR
108
PropertyString Material POLYSTYRENE
109
PropertyDouble GreenColour 1.0
110
PropertyDouble RedColour 1.0
112
""" % ( ExportFolder, self.Name, self.Name, self.Length / 2, self.Length / 2, 0., self.Width / 2, self.Height / 2, self.LayerId, self.BarId )
113
#% ( ExportFolder, self.Name, self.Name, XHalfLength, XHalfLength, Y1HalfLength, Y2HalfLength, ZHalfLength, self.LayerId, self.BarId )
114
SciFile = open( ExportFolder + self.Name + "Sci.dat", 'w' )
115
SciFile.write( Content )
46
def __init__( self, LayerId, BarId, BarLength, BarHeight, BarWidth ):
47
self.Name = "EMRLayer%dBar%d" % ( LayerId, BarId )
49
self.LayerId = LayerId
50
self.Length = BarLength
52
self.Height = BarHeight
63
# if( self.BarId % 2 ):
65
# Y2HalfLength = ( self.Width / 2 )
67
# Y1HalfLength = ( self.Width / 2 )
70
# XHalfLength = ( self.Length / 2 )
71
# ZHalfLength = ( self.Height / 2 )
74
// FILES/Models/Modules/%s%s.dat
79
Dimensions %.2f %.2f %.2f %.2f %.2f cm
83
PropertyDouble BlueColour 1.0
86
Position 0.0 0.0 0.0 mm
87
Rotation 0.0 0.0 0.0 degree
90
""" % ( ExportFolder, self.Name, self.Name, self.Length / 2, self.Length / 2, 0., self.Width / 2, self.Height / 2, self.LayerId, self.BarId, self.Name )
92
#% ( ExportFolder, self.Name, self.Name, XHalfLength, XHalfLength, Y1HalfLength, Y2HalfLength, ZHalfLength, self.LayerId, self.BarId, self.Name )
94
BarFile = open( ExportFolder + self.Name + ".dat", 'w' )
95
BarFile.write( Content )
98
// FILES/Models/Modules/%s%sSci.dat
104
Dimensions %.2f %.2f %.2f %.2f %.2f cm
107
PropertyString SensitiveDetector EMR
108
PropertyString Material POLYSTYRENE
109
PropertyDouble GreenColour 1.0
110
PropertyDouble RedColour 1.0
112
""" % ( ExportFolder, self.Name, self.Name, self.Length / 2, self.Length / 2, 0., self.Width / 2, self.Height / 2, self.LayerId, self.BarId )
113
#% ( ExportFolder, self.Name, self.Name, XHalfLength, XHalfLength, Y1HalfLength, Y2HalfLength, ZHalfLength, self.LayerId, self.BarId )
114
SciFile = open( ExportFolder + self.Name + "Sci.dat", 'w' )
115
SciFile.write( Content )
118
118
class EMRLayer( G4MiceGeoBase ):
119
def __init__(self, LayerId, BarCount, BarLength, BarHeight, BarWidth ):
121
self.LayerId = LayerId
122
self.BarCount = BarCount
123
self.Name = "EMRLayer%d" % ( LayerId )
124
self.BarHeight = BarHeight
125
self.BarLength = BarLength
126
self.BarWidth = BarWidth
127
self.Length = self.BarLength
128
self.Width = self.BarWidth * BarCount
129
self.Height = self.BarHeight
136
HalfLayerLength = ( ( self.BarWidth / 2 ) * (self.BarCount - 1) ) / 2
138
for i in range( self.BarCount ):
139
b = EMRBar( self.LayerId, i, self.BarLength, self.BarHeight, self.BarWidth )
140
#if not( self.LayerId % 2 ):
142
# YPos = ( -HalfLayerLength + ( i * ( b.Width / 2 ) ) )
119
def __init__(self, LayerId, BarCount, BarLength, BarHeight, BarWidth ):
121
self.LayerId = LayerId
122
self.BarCount = BarCount
123
self.Name = "EMRLayer%d" % ( LayerId )
124
self.BarHeight = BarHeight
125
self.BarLength = BarLength
126
self.BarWidth = BarWidth
127
self.Length = self.BarLength
128
self.Width = self.BarWidth * BarCount
129
self.Height = self.BarHeight
136
HalfLayerLength = ( ( self.BarWidth / 2 ) * (self.BarCount - 1) ) / 2
138
for i in range( self.BarCount ):
139
b = EMRBar( self.LayerId, i, self.BarLength, self.BarHeight, self.BarWidth )
140
#if not( self.LayerId % 2 ):
142
# YPos = ( -HalfLayerLength + ( i * ( b.Width / 2 ) ) )
144
# XPos = ( -HalfLayerLength + ( i * ( b.Width / 2 ) ) )
146
#b.SetPosition( XPos, YPos, 0.0 )
147
b.SetPosition( 0.0, ( -HalfLayerLength + ( i * ( b.Width / 2 ) ) ), 0.0 )
149
b.SetRotation( 0.0, 0.0, 0.0 )
151
b.SetRotation( 0.0, 180.0, 0.0 )
152
self.Bars.insert( i, b )
154
def IsVertical( self ):
155
return self.LayerId % 2
158
#Calculating trapezoid halflengths
159
#ZHL = ( self.BarHeight / 2 )
160
#if not self.IsVertical():
161
# X1HL = self.BarLength / 2
162
# X2HL = self.BarLength / 2
163
# Y1HL = ( self.BarWidth * ( self.BarCount / 2 ) ) / 2
164
# Y2HL = ( self.BarWidth * ( ( self.BarCount / 2 ) + ( self.BarCount % 2 ) ) ) / 2
144
# XPos = ( -HalfLayerLength + ( i * ( b.Width / 2 ) ) )
146
#b.SetPosition( XPos, YPos, 0.0 )
147
b.SetPosition( 0.0, ( -HalfLayerLength + ( i * ( b.Width / 2 ) ) ), 0.0 )
149
b.SetRotation( 0.0, 0.0, 0.0 )
151
b.SetRotation( 0.0, 180.0, 0.0 )
152
self.Bars.insert( i, b )
154
def IsVertical( self ):
155
return self.LayerId % 2
158
#Calculating trapezoid halflengths
159
#ZHL = ( self.BarHeight / 2 )
160
#if not self.IsVertical():
161
# X1HL = self.BarLength / 2
162
# X2HL = self.BarLength / 2
163
# Y1HL = ( self.BarWidth * ( self.BarCount / 2 ) ) / 2
164
# Y2HL = ( self.BarWidth * ( ( self.BarCount / 2 ) + ( self.BarCount % 2 ) ) ) / 2
166
# X1HL = ( self.BarWidth * ( self.BarCount / 2 ) ) / 2;
167
# X2HL = ( self.BarWidth * ( ( self.BarCount / 2 ) + ( self.BarCount % 2 ) ) ) / 2
168
# Y1HL = self.BarLength / 2
169
# Y2HL = self.BarLength / 2
171
Content = """// FILES/Models/Modules/%s%s.dat
177
Dimensions %.2f %.2f %.2f %.2f %.2f cm
179
PropertyString Material Galactic
182
// PropertyInt numSlabs %d
183
PropertyInt numBars %d
184
PropertyBool Invisible 1
185
"""% ( ExportFolder, self.Name, self.Name, self.Length / 2, self.Length / 2, ( self.BarWidth * ( self.BarCount / 2 ) ) / 2,
186
( self.BarWidth * ( ( self.BarCount / 2 ) + ( self.BarCount % 2 ) ) ) / 2, self.Height / 2, self.LayerId, self.BarCount, self.BarCount )
187
#% ( ExportFolder, self.Name, self.Name, X1HL, X2HL, Y1HL, Y2HL, ZHL, self.LayerId, self.BarCount, self.BarCount )
189
for bar in self.Bars:
190
Content += """Module %s%s.dat
192
Position %.2f %.2f %.2f cm
193
Rotation %.2f %.2f %.2f degree
195
""" % ( ExportFolder, bar.Name, bar.X, bar.Y, bar.Z, bar.Phi, bar.Theta, bar.Psi )
198
LayerFile = open( ExportFolder + self.Name + ".dat", 'w' )
199
LayerFile.write( Content )
166
# X1HL = ( self.BarWidth * ( self.BarCount / 2 ) ) / 2;
167
# X2HL = ( self.BarWidth * ( ( self.BarCount / 2 ) + ( self.BarCount % 2 ) ) ) / 2
168
# Y1HL = self.BarLength / 2
169
# Y2HL = self.BarLength / 2
171
Content = """// FILES/Models/Modules/%s%s.dat
177
Dimensions %.2f %.2f %.2f %.2f %.2f cm
179
PropertyString Material Galactic
182
// PropertyInt numSlabs %d
183
PropertyInt numBars %d
184
PropertyBool Invisible 1
185
"""% ( ExportFolder, self.Name, self.Name, self.Length / 2, self.Length / 2, ( self.BarWidth * ( self.BarCount / 2 ) ) / 2,
186
( self.BarWidth * ( ( self.BarCount / 2 ) + ( self.BarCount % 2 ) ) ) / 2, self.Height / 2, self.LayerId, self.BarCount, self.BarCount )
187
#% ( ExportFolder, self.Name, self.Name, X1HL, X2HL, Y1HL, Y2HL, ZHL, self.LayerId, self.BarCount, self.BarCount )
189
for bar in self.Bars:
190
Content += """Module %s%s.dat
192
Position %.2f %.2f %.2f cm
193
Rotation %.2f %.2f %.2f degree
195
""" % ( ExportFolder, bar.Name, bar.X, bar.Y, bar.Z, bar.Phi, bar.Theta, bar.Psi )
198
LayerFile = open( ExportFolder + self.Name + ".dat", 'w' )
199
LayerFile.write( Content )
202
202
class EMRGeometry( G4MiceGeoBase ):
203
def __init__(self, NumLayers, NumBars, BarLength, BarHeight, BarWidth ):
205
self.Name = "Calorimeter"
207
self.LayersCount = NumLayers
208
self.BarsCount = NumBars
210
self.BarHeight = BarHeight
211
self.BarLength = BarLength
212
self.BarWidth = BarWidth
214
self.Width = self.BarHeight * self.LayersCount
215
self.Height = self.BarWidth * ( self.BarsCount / 2 )
216
self.Length = self.BarLength
226
HalfEMRLength = ( self.BarHeight * (self.LayersCount - 1 ) ) / 2
227
for i in range( self.LayersCount ):
228
l = EMRLayer( i, self.BarsCount, self.BarLength, self.BarHeight, self.BarWidth )
229
l.SetPosition( 0.0, 0.0, - HalfEMRLength + ( i * self.BarHeight ) )
231
l.SetRotation( 0.0, 0.0, 0.0 )
233
l.SetRotation( 0.0, 0.0, 90.0 )
234
self.Layers.insert( i, l )
237
Content = """// FILES/Models/Modules/%s%s.dat
244
Dimensions %.2f %.2f %.2f cm
245
PropertyString Material Galactic
247
PropertyBool Invisible 1
248
// PropertyInt numPlanes %d
249
PropertyInt numLayers %d
250
PropertyDouble G4StepMax 1.0 mm
251
""" % ( ExportFolder, self.Name, self.Name, self.Length, self.Width, self.Height, self.LayersCount, self.LayersCount )
252
for layer in self.Layers:
256
Position %.2f %.2f %.2f cm
257
Rotation %.2f %.2f %.2f degree
259
""" % ( ExportFolder, layer.Name, layer.X, layer.Y, layer.Z, layer.Phi, layer.Theta, layer.Psi )
262
EMRFile = open( ExportFolder + self.Name + ".dat", 'w' )
263
EMRFile.write( Content )
203
def __init__(self, NumLayers, NumBars, BarLength, BarHeight, BarWidth ):
205
self.Name = "Calorimeter"
207
self.LayersCount = NumLayers
208
self.BarsCount = NumBars
210
self.BarHeight = BarHeight
211
self.BarLength = BarLength
212
self.BarWidth = BarWidth
214
self.Width = self.BarHeight * self.LayersCount
215
self.Height = self.BarWidth * ( self.BarsCount / 2 )
216
self.Length = self.BarLength
226
HalfEMRLength = ( self.BarHeight * (self.LayersCount - 1 ) ) / 2
227
for i in range( self.LayersCount ):
228
l = EMRLayer( i, self.BarsCount, self.BarLength, self.BarHeight, self.BarWidth )
229
l.SetPosition( 0.0, 0.0, - HalfEMRLength + ( i * self.BarHeight ) )
231
l.SetRotation( 0.0, 0.0, 0.0 )
233
l.SetRotation( 0.0, 0.0, 90.0 )
234
self.Layers.insert( i, l )
237
Content = """// FILES/Models/Modules/%s%s.dat
244
Dimensions %.2f %.2f %.2f cm
245
PropertyString Material Galactic
247
PropertyBool Invisible 1
248
// PropertyInt numPlanes %d
249
PropertyInt numLayers %d
250
PropertyDouble G4StepMax 1.0 mm
251
""" % ( ExportFolder, self.Name, self.Name, self.Length, self.Width, self.Height, self.LayersCount, self.LayersCount )
252
for layer in self.Layers:
256
Position %.2f %.2f %.2f cm
257
Rotation %.2f %.2f %.2f degree
259
""" % ( ExportFolder, layer.Name, layer.X, layer.Y, layer.Z, layer.Phi, layer.Theta, layer.Psi )
262
EMRFile = open( ExportFolder + self.Name + ".dat", 'w' )
263
EMRFile.write( Content )
266
266
#Geo = G4MiceGeoBase( "Test" )