SND@LHC Software
Loading...
Searching...
No Matches
shipDet_conf.py
Go to the documentation of this file.
1#!/usr/bin/env python
2# -*- coding: latin-1 -*-
3from __future__ import print_function
4from __future__ import division
5import ROOT,os
6import shipunit as u
7from ShipGeoConfig import AttrDict,ConfigRegistry
8detectorList = []
9
10def getParameter(x,ship_geo,latestShipGeo):
11 lv = x.split('.')
12 last = lv[len(lv)-1]
13 top = ''
14 for l in range(len(lv)-1):
15 top += lv[l]
16 if l<len(lv)-2: top +='.'
17 a = getattr(ship_geo,top)
18 if hasattr(a,last): return getattr(a,last)
19# not in the list of recorded parameteres. probably added after
20# creation of file. Check newest geometry_config:
21 a = getattr(latestShipGeo,top)
22 return getattr(a,last)
23
24def posHcal(z,hfile,HcalOption):
25 HcalZSize = 0
26 sz = hfile+"z"+str(z)+".geo"
27 floc = os.environ["FAIRSHIP"]+"/geometry"
28 f_hcal = floc+"/"+hfile
29 f_hcalz = floc+"/"+sz
30 f = open(f_hcal)
31 rewrite = True
32 if sz in os.listdir(floc):
33 test = os.popen("diff "+ f_hcal+ " "+ f_hcalz).read()
34 if str.count(test,'---')==1 and not test.find('Position')<0: rewrite = False # only different is z position
35 if rewrite: fn = open(f_hcalz,'w')
36 for l in f.readlines():
37 if rewrite:
38 if not l.find("ZPos")<0:
39 l ="ZPos="+str(z)+ " #Position of Hcal center [cm]\n"
40 fn.write(l)
41 if not l.find("HcalZSize")<0:
42 HcalZSize = float(l[len('HcalZSize')+1:].split('#')[0])
43 f.close()
44 if rewrite: fn.close()
45 if HcalOption==2: hcal = ROOT.hcal("Hcal", ROOT.kFALSE, sz)
46 else: hcal = ROOT.hcal("Hcal", ROOT.kTRUE, sz)
47 return hcal,HcalZSize
48def makeEcalGeoFile(z,efile):
49 EcalZSize = 0
50 sz = efile+"z"+str(z)+".geo"
51 floc = os.environ["FAIRSHIP"]+"/geometry"
52 f_ecal = floc+"/"+efile
53 f_ecalz = floc+"/"+sz
54 f = open(f_ecal)
55 rewrite = True
56 if sz in os.listdir(floc):
57 test = os.popen("diff "+ f_ecal+ " "+ f_ecalz).read()
58 if str.count(test,'---')==1 and not test.find('Position')<0: rewrite = False # only different is z position
59 if rewrite: fn = open(f_ecalz,'w')
60 for l in f.readlines():
61 if rewrite:
62 if not l.find("ZPos")<0:
63 l ="ZPos="+str(z)+ " #Position of Ecal start [cm]\n"
64 fn.write(l)
65 if not l.find("EcalZSize")<0:
66 EcalZSize = float(l[len('EcalZSize')+1:].split('#')[0])
67 f.close()
68 if rewrite: fn.close()
69 return EcalZSize,sz
70def posEcal(z,efile):
71 EcalZSize,sz = makeEcalGeoFile(z,efile)
72 ecal = ROOT.ecal("Ecal", ROOT.kTRUE, sz)
73 return ecal,EcalZSize
74
75def configure(run,ship_geo):
76# ---- for backward compatibility ----
77 if not hasattr(ship_geo,"tankDesign"): ship_geo.tankDesign = 5
78 if not hasattr(ship_geo,"muShieldGeo"): ship_geo.muShieldGeo = None
79 if not hasattr(ship_geo.hcal,"File"): ship_geo.hcal.File = "hcal.geo"
80 if not hasattr(ship_geo.Bfield,'x') : ship_geo.Bfield.x = 3.*u.m
81 if not hasattr(ship_geo,'cave') :
82 ship_geo.cave = AttrDict(z=0*u.cm)
83 ship_geo.cave.floorHeightMuonShield = 5*u.m
84 ship_geo.cave.floorHeightTankA = 4.5*u.m
85 ship_geo.cave.floorHeightTankB = 2.*u.m
86 if not hasattr(ship_geo,'NuTauTT') : ship_geo.NuTauTT= AttrDict(z=0*u.cm)
87 if not hasattr(ship_geo.NuTauTT,'design') : ship_geo.NuTauTT.design = 0
88 if not hasattr(ship_geo,'EcalOption'): ship_geo.EcalOption = 1
89 latestShipGeo = ConfigRegistry.loadpy("$FAIRSHIP/geometry/geometry_config.py",Yheight = ship_geo.Yheight/u.m, tankDesign = ship_geo.tankDesign, muShieldDesign = ship_geo.muShieldDesign, nuTauTargetDesign = ship_geo.nuTauTargetDesign, muShieldGeo = ship_geo.muShieldGeo)
90# -----Create media-------------------------------------------------
91 run.SetMaterials("media.geo") # Materials
92# ------------------------------------------------------------------------
93
94# -----Create geometry----------------------------------------------
95 cave= ROOT.ShipCave("CAVE")
96 if ship_geo.tankDesign < 5: cave.SetGeometryFileName("cave.geo")
97 else: cave.SetGeometryFileName("caveWithAir.geo")
98 detectorList.append(cave)
99
100 if ship_geo.muShieldDesign in [6, 7, 8, 9,10]: # magnetized hadron absorber defined in ShipMuonShield
101 TargetStation = ROOT.ShipTargetStation("TargetStation",ship_geo.target.length,
102 ship_geo.target.z,ship_geo.targetOpt,ship_geo.target.sl)
103 else:
104 TargetStation = ROOT.ShipTargetStation("TargetStation",ship_geo.target.length,ship_geo.hadronAbsorber.length,
105 ship_geo.target.z,ship_geo.hadronAbsorber.z,ship_geo.targetOpt,ship_geo.target.sl)
106
107 if ship_geo.targetOpt>10:
108 slices_length = ROOT.std.vector('float')()
109 slices_material = ROOT.std.vector('std::string')()
110 for i in range(1,ship_geo.targetOpt+1):
111 slices_length.push_back( eval("ship_geo.target.L"+str(i)))
112 slices_material.push_back(eval("ship_geo.target.M"+str(i)))
113 TargetStation.SetLayerPosMat(ship_geo.target.xy,slices_length,slices_material)
114 detectorList.append(TargetStation)
115
116 if ship_geo.muShieldDesign==1:
117 MuonShield = ROOT.ShipMuonShield("MuonShield",ship_geo.muShieldDesign,"ShipMuonShield",ship_geo.muShield.z,ship_geo.muShield.dZ0,ship_geo.muShield.length,\
118 ship_geo.muShield.LE)
119 elif ship_geo.muShieldDesign==2:
120 MuonShield = ROOT.ShipMuonShield("MuonShield",ship_geo.muShieldDesign,"ShipMuonShield",ship_geo.muShield.z,ship_geo.muShield.dZ0,ship_geo.muShield.dZ1,\
121 ship_geo.muShield.dZ2,ship_geo.muShield.dZ3,ship_geo.muShield.dZ4,ship_geo.muShield.dZ5,ship_geo.muShield.dZ6,ship_geo.muShield.LE)
122 elif ship_geo.muShieldDesign in [3, 4, 5, 6, 7, 9]:
123 MuonShield = ROOT.ShipMuonShield(
124 "MuonShield", ship_geo.muShieldDesign, "ShipMuonShield",
125 ship_geo.muShield.z, ship_geo.muShield.dZ0, ship_geo.muShield.dZ1,
126 ship_geo.muShield.dZ2, ship_geo.muShield.dZ3,
127 ship_geo.muShield.dZ4, ship_geo.muShield.dZ5,
128 ship_geo.muShield.dZ6, ship_geo.muShield.dZ7,
129 ship_geo.muShield.dZ8, ship_geo.muShield.dXgap,
130 ship_geo.muShield.LE, ship_geo.Yheight * 4. / 10.,
131 ship_geo.cave.floorHeightMuonShield,ship_geo.muShield.Field,
132 ship_geo.muShieldWithCobaltMagnet, ship_geo.muShieldStepGeo,
133 ship_geo.hadronAbsorber.WithConstField, ship_geo.muShield.WithConstField)
134 elif ship_geo.muShieldDesign == 8:
135 MuonShield = ROOT.ShipMuonShield(ship_geo.muShieldGeo,
136 ship_geo.muShieldWithCobaltMagnet,
137 ship_geo.muShieldStepGeo,
138 ship_geo.hadronAbsorber.WithConstField,
139 ship_geo.muShield.WithConstField)
140
141 detectorList.append(MuonShield)
142
143 if not hasattr(ship_geo,"magnetDesign"):
144 # backward compatibility
145 magnet_design = 2
146 if ship_geo.tankDesign == 5: magnet_design = 3
147 if ship_geo.tankDesign == 6: magnet_design = 4
148 ship_geo.magnetDesign = magnet_design
149 ship_geo.Bfield.YokeWidth = 200.*u.cm
150 ship_geo.Bfield.YokeDepth = 200.*u.cm
151 ship_geo.Bfield.CoilThick = 25.*u.cm
152# sanity check, 2018 layout ship_geo.tankDesign == 6 has to be together with ship_geo.nuTauTargetDesign == 3
153 if (ship_geo.tankDesign == 6 and ship_geo.nuTauTargetDesign != 3) or (ship_geo.tankDesign != 6 and ship_geo.nuTauTargetDesign == 3):
154 print("version of tankDesign and nuTauTargetDesign are not compatible, should be 6 and 3, it is ",ship_geo.tankDesign, ship_geo.nuTauTargetDesign)
155 exit()
156 if ship_geo.strawDesign > 1 :
157 if ship_geo.magnetDesign>3:
158 B = ship_geo.Bfield
159 magnet = ROOT.ShipMagnet("Magnet","SHiP Magnet",B.z, ship_geo.magnetDesign, B.x, B.y, ship_geo.cave.floorHeightTankB, B.YokeWidth, B.YokeDepth, B.CoilThick)
160# xaperture, yaperture
161 else:
162 magnet = ROOT.ShipMagnet("Magnet","SHiP Magnet",ship_geo.Bfield.z, ship_geo.magnetDesign, ship_geo.Bfield.x, ship_geo.Bfield.y, ship_geo.cave.floorHeightTankB)
163 else: magnet = ROOT.ShipMagnet("Magnet","SHiP Magnet",ship_geo.Bfield.z)
164 detectorList.append(magnet)
165
166 Veto = ROOT.veto("Veto", ROOT.kTRUE) # vacuum tank
167 Veto.SetLiquidVeto(1) # liquid scintillator
168 Veto.SetPlasticVeto(1) # plastic scintillator
169
170 Veto.SetZpositions(ship_geo.vetoStation.z, ship_geo.TrackStation1.z, ship_geo.TrackStation2.z, \
171 ship_geo.TrackStation3.z, ship_geo.TrackStation4.z,ship_geo.tankDesign)
172 Veto.SetTubZpositions(ship_geo.Chamber1.z,ship_geo.Chamber2.z,ship_geo.Chamber3.z,ship_geo.Chamber4.z,ship_geo.Chamber5.z,ship_geo.Chamber6.z)
173 Veto.SetTublengths(ship_geo.chambers.Tub1length,ship_geo.chambers.Tub2length,ship_geo.chambers.Tub3length, \
174 ship_geo.chambers.Tub6length)
175 Veto.SetB(ship_geo.Yheight/2.)
176 Veto.SetFloorHeight(ship_geo.cave.floorHeightTankA,ship_geo.cave.floorHeightTankB)
177 if ship_geo.tankDesign > 4:
178 dzX = ship_geo.zFocusX+ship_geo.target.z0
179 x1 = ship_geo.xMax/(ship_geo.Chamber1.z -ship_geo.chambers.Tub1length-dzX)*(ship_geo.TrackStation4.z-dzX)
180 dzY = ship_geo.zFocusY+ship_geo.target.z0
181 y1 = ship_geo.Yheight/(ship_geo.Chamber1.z -ship_geo.chambers.Tub1length-dzY)*(ship_geo.TrackStation4.z-dzY)
182 Veto.SetXYstart(x1,dzX,y1,dzY)
183 Veto.SetVesselStructure(ship_geo.Veto.innerSupport,ship_geo.Veto.sensitiveThickness,ship_geo.Veto.outerSupport,\
184 ship_geo.Veto.innerSupportMed,ship_geo.Veto.lidThickness,ship_geo.Veto.sensitiveMed,\
185 ship_geo.Veto.outerSupportMed,ship_geo.Veto.decayMed,\
186 ship_geo.Veto.rib)
187
188 detectorList.append(Veto)
189 if hasattr(ship_geo,'tauMudet'): # don't support old designs
190
191 if ship_geo.muShieldDesign not in [2,3,4] and hasattr(ship_geo.tauMudet,'Xtot'):
192 taumuondetector = ROOT.NuTauMudet("NuTauMudet", ship_geo.tauMudet.zMudetC, ROOT.kTRUE)
193 taumuondetector.SetDesign(ship_geo.nuTauTargetDesign)
194 taumuondetector.SetTotDimensions(ship_geo.tauMudet.Xtot,ship_geo.tauMudet.Ytot, ship_geo.tauMudet.Ztot )
195 if hasattr(ship_geo.tauMudet,'ZFethin'):
196 taumuondetector.SetFeDimensions(ship_geo.tauMudet.XFe,ship_geo.tauMudet.YFe, ship_geo.tauMudet.ZFethick,ship_geo.tauMudet.ZFethin)
197 taumuondetector.SetNFeInArm(ship_geo.tauMudet.NFethick, ship_geo.tauMudet.NFethin)
198 taumuondetector.SetLateralCutSize(ship_geo.tauMudet.CutHeight, ship_geo.tauMudet.CutLength)
199 taumuondetector.SetSupportTransverseDimensions(ship_geo.tauMudet.UpperSupportX,ship_geo.tauMudet.UpperSupportY, \
200 ship_geo.tauMudet.LowerSupportX, ship_geo.tauMudet.LowerSupportY, \
201 ship_geo.tauMudet.LateralSupportX, ship_geo.tauMudet.LateralSupportY, ship_geo.tauMudet.YSpacing)
202 else: #geometry used before new iron sampling
203 taumuondetector.SetFeDimensions(ship_geo.tauMudet.XFe,ship_geo.tauMudet.YFe, ship_geo.tauMudet.ZFe)
204 taumuondetector.SetNFeInArm(ship_geo.tauMudet.NFe)
205 taumuondetector.SetRpcDimensions(ship_geo.tauMudet.XRpc,ship_geo.tauMudet.YRpc, ship_geo.tauMudet.ZRpc)
206 taumuondetector.SetRpcGasDimensions(ship_geo.tauMudet.XGas,ship_geo.tauMudet.YGas, ship_geo.tauMudet.ZGas)
207 taumuondetector.SetRpcStripDimensions(ship_geo.tauMudet.XStrip,ship_geo.tauMudet.YStrip, ship_geo.tauMudet.ZStrip)
208 taumuondetector.SetRpcElectrodeDimensions(ship_geo.tauMudet.XEle,ship_geo.tauMudet.YEle, ship_geo.tauMudet.ZEle)
209 taumuondetector.SetRpcPETDimensions(ship_geo.tauMudet.XPet,ship_geo.tauMudet.YPet, ship_geo.tauMudet.ZPet)
210 taumuondetector.SetNRpcInArm(ship_geo.tauMudet.NRpc)
211 taumuondetector.SetUpperCoverDimensions(ship_geo.tauMudet.XCov, ship_geo.tauMudet.YCov, ship_geo.tauMudet.ZCov)
212 taumuondetector.SetLateralCoverDimensions(ship_geo.tauMudet.XLateral, ship_geo.tauMudet.YLateral, ship_geo.tauMudet.ZLateral)
213 taumuondetector.SetCrossDimensions(ship_geo.tauMudet.XCross, ship_geo.tauMudet.YCross, ship_geo.tauMudet.ZCross, ship_geo.tauMudet.WidthArm)
214 taumuondetector.SetRpcOuterDimensions(ship_geo.tauMudet.XRpc_outer, ship_geo.tauMudet.YRpc_outer, ship_geo.tauMudet.ZRpc_outer)
215 taumuondetector.SetRpcInnerDimensions(ship_geo.tauMudet.XRpc_inner, ship_geo.tauMudet.YRpc_inner, ship_geo.tauMudet.ZRpc_inner)
216 taumuondetector.SetRpcGapDimensions(ship_geo.tauMudet.XRpcGap, ship_geo.tauMudet.YRpcGap, ship_geo.tauMudet.ZRpcGap)
217 taumuondetector.SetPillarDimensions(ship_geo.tauMudet.PillarX,ship_geo.tauMudet.PillarY, ship_geo.tauMudet.PillarZ)
218 detectorList.append(taumuondetector)
219 if ship_geo.nuTauTargetDesign==3:
220 if hasattr(ship_geo.tauMudet, "deltax"): #now replaced with veto taggers
221 taumuondetector.SetRpcDimDifferences(ship_geo.tauMudet.deltax, ship_geo.tauMudet.deltay)
222 if ship_geo.nuTauTargetDesign<3:
223 taumuondetector.SetReturnYokeDimensions(ship_geo.tauMudet.XRyoke,ship_geo.tauMudet.YRyoke, ship_geo.tauMudet.ZRyoke)
224 taumuondetector.SetSmallerYokeDimensions(ship_geo.tauMudet.XRyoke_s,ship_geo.tauMudet.YRyoke_s, ship_geo.tauMudet.ZRyoke_s)
225 taumuondetector.SetZDimensionArm(ship_geo.tauMudet.ZArm)
226 taumuondetector.SetGapDownstream(ship_geo.tauMudet.GapD)
227 taumuondetector.SetGapMiddle(ship_geo.tauMudet.GapM)
228 taumuondetector.SetMagneticField(ship_geo.tauMudet.B)
229 taumuondetector.SetCoilParameters(ship_geo.tauMudet.CoilH, ship_geo.tauMudet.CoilW, ship_geo.tauMudet.N, ship_geo.tauMudet.CoilG)
230
231 if ship_geo.nuTauTargetDesign==0 or ship_geo.nuTauTargetDesign==1 or ship_geo.nuTauTargetDesign==3:
232 EmuMagnet = ROOT.EmulsionMagnet("EmuMagnet",ship_geo.EmuMagnet.zC,"EmulsionMagnet")
233 EmuMagnet.SetDesign(ship_geo.EmuMagnet.Design)
234 EmuMagnet.SetGaps(ship_geo.EmuMagnet.GapUp, ship_geo.EmuMagnet.GapDown)
235 EmuMagnet.SetMagneticField(ship_geo.EmuMagnet.B)
236 EmuMagnet.SetConstantField(ship_geo.EmuMagnet.WithConstField)
237 EmuMagnet.SetMagnetSizes(ship_geo.EmuMagnet.X, ship_geo.EmuMagnet.Y, ship_geo.EmuMagnet.Z)
238 if ship_geo.nuTauTargetDesign==0 or ship_geo.nuTauTargetDesign==1:
239 EmuMagnet.SetCoilParameters(ship_geo.EmuMagnet.Radius, ship_geo.EmuMagnet.Height1, ship_geo.EmuMagnet.Height2, ship_geo.EmuMagnet.Distance)
240 if ship_geo.nuTauTargetDesign==3:
241 EmuMagnet.SetCoilParameters(ship_geo.EmuMagnet.CoilX,ship_geo.EmuMagnet.CoilY,ship_geo.EmuMagnet.Height1, ship_geo.EmuMagnet.Height2, ship_geo.EmuMagnet.Thickness)
242 EmuMagnet.SetCutDimensions(ship_geo.EmuMagnet.CutLength, ship_geo.EmuMagnet.CutHeight)
243 EmuMagnet.SetMagnetColumn(ship_geo.EmuMagnet.ColX, ship_geo.EmuMagnet.ColY, ship_geo.EmuMagnet.ColZ)
244 EmuMagnet.SetBaseDim(ship_geo.EmuMagnet.BaseX, ship_geo.EmuMagnet.BaseY, ship_geo.EmuMagnet.BaseZ)
245 EmuMagnet.SetPillarDimensions(ship_geo.EmuMagnet.PillarX, ship_geo.EmuMagnet.PillarY, ship_geo.EmuMagnet.PillarZ)
246 detectorList.append(EmuMagnet)
247 if ship_geo.nuTauTargetDesign==2:
248 EmuMagnet = ROOT.EmulsionMagnet()
249
250 NuTauTarget = ROOT.Target("NuTauTarget",ship_geo.NuTauTarget.Ydist,ROOT.kTRUE)
251 NuTauTarget.MakeNuTargetPassive(ship_geo.NuTauTarget.nuTargetPassive)
252 if hasattr(ship_geo.NuTauTarget,"SingleEmFilm"): #for backward compatibility
253 NuTauTarget.MergeTopBot(ship_geo.NuTauTarget.SingleEmFilm)
254 NuTauTarget.SetDetectorDesign(ship_geo.NuTauTarget.Design)
255 if ship_geo.nuTauTargetDesign!=3:
256 NuTauTarget.SetCenterZ(ship_geo.NuTauTarget.zC)
257 if ship_geo.nuTauTargetDesign==3:
258 NuTauTarget.SetCenterZ(ship_geo.EmuMagnet.zC) #now the centers of emumagnet and nutautarget are different (target does not include HPT)
259 NuTauTarget.SetNumberTargets(ship_geo.NuTauTarget.target)
260 NuTauTarget.SetHpTParam(ship_geo.tauHPT.nHPT, ship_geo.tauHPT.distHPT, ship_geo.tauHPT.DZ)
261 NuTauTarget.SetNumberBricks(ship_geo.NuTauTarget.col,ship_geo.NuTauTarget.row,ship_geo.NuTauTarget.wall)
262 NuTauTarget.SetDetectorDimension(ship_geo.NuTauTarget.xdim, ship_geo.NuTauTarget.ydim, ship_geo.NuTauTarget.zdim)
263 if hasattr(ship_geo.NuTauTarget,"WallXDim") and hasattr(ship_geo.NuTauTarget,"WallYDim") and hasattr(ship_geo.NuTauTarget,"WallZDim"):
264 NuTauTarget.SetTargetWallDimension(ship_geo.NuTauTarget.WallXDim, ship_geo.NuTauTarget.WallYDim, ship_geo.NuTauTarget.WallZDim)
265 NuTauTarget.SetEmulsionParam(ship_geo.NuTauTarget.EmTh, ship_geo.NuTauTarget.EmX, ship_geo.NuTauTarget.EmY, ship_geo.NuTauTarget.PBTh,ship_geo.NuTauTarget.EPlW, ship_geo.NuTauTarget.LeadTh, ship_geo.NuTauTarget.AllPW)
266
267 if not hasattr(ship_geo.NuTauTarget,"n_plates"): #for backward compatibility
268 ship_geo.NuTauTarget.n_plates = 56
269 NuTauTarget.SetBrickParam(ship_geo.NuTauTarget.BrX, ship_geo.NuTauTarget.BrY, ship_geo.NuTauTarget.BrZ, ship_geo.NuTauTarget.BrPackX, ship_geo.NuTauTarget.BrPackY, ship_geo.NuTauTarget.BrPackZ, ship_geo.NuTauTarget.n_plates)
270
271 NuTauTarget.SetCESParam(ship_geo.NuTauTarget.RohG, ship_geo.NuTauTarget.LayerCESW, ship_geo.NuTauTarget.CESW, ship_geo.NuTauTarget.CESPack)
272 NuTauTarget.SetCellParam(ship_geo.NuTauTarget.CellW)
273 if ship_geo.nuTauTargetDesign==0 or ship_geo.nuTauTargetDesign==1:
274 NuTauTarget.SetMagnetHeight(ship_geo.EmuMagnet.Y)
275 NuTauTarget.SetColumnHeight(ship_geo.EmuMagnet.ColY)
276 NuTauTarget.SetBaseHeight(ship_geo.EmuMagnet.BaseY)
277 NuTauTarget.SetCoilUpHeight(ship_geo.EmuMagnet.Height1)
278 NuTauTarget.SetCoilDownHeight(ship_geo.EmuMagnet.Height2)
279 if ship_geo.nuTauTargetDesign!=2:
280 NuTauTarget.SetMagneticField(ship_geo.EmuMagnet.B)
281 if ship_geo.nuTauTargetDesign==2:
282 NuTauTarget.SetPillarDimension(ship_geo.NuTauTarget.PillarX,ship_geo.NuTauTarget.PillarY,ship_geo.NuTauTarget.PillarZ)
283 NuTauTarget.SetBaseDimension(ship_geo.NuTauTarget.BaseX, ship_geo.NuTauTarget.BaseY, ship_geo.NuTauTarget.BaseZ)
284
285# Target Tracker
286 NuTauTT = ROOT.TargetTracker("TargetTrackers", ship_geo.NuTauTT.TTX, ship_geo.NuTauTT.TTY, ship_geo.NuTauTT.TTZ, ROOT.kTRUE)
287 NuTauTT.SetDesign(ship_geo.NuTauTT.design)
288 if hasattr(ship_geo.NuTauTT, "scifimat_width"):#for backward compatibility
289 NuTauTT.SetSciFiParam(ship_geo.NuTauTT.scifimat_width, ship_geo.NuTauTT.scifimat_hor, ship_geo.NuTauTT.scifimat_vert, ship_geo.NuTauTT.scifimat_z, ship_geo.NuTauTT.support_z, ship_geo.NuTauTT.honeycomb_z)
290 NuTauTT.SetNumberSciFi(ship_geo.NuTauTT.n_hor_planes, ship_geo.NuTauTT.n_vert_planes)
291 NuTauTT.SetTargetTrackerParam(ship_geo.NuTauTT.TTX, ship_geo.NuTauTT.TTY, ship_geo.NuTauTT.TTZ)
292 NuTauTT.SetBrickParam(ship_geo.NuTauTarget.CellW)
293 NuTauTT.SetTotZDimension(ship_geo.NuTauTarget.zdim)
294 NuTauTT.SetNumberTT(ship_geo.NuTauTT.n)
295 # method of nutau target that must be called after TT parameter definition
296 NuTauTarget.SetTTzdimension(ship_geo.NuTauTT.TTZ)
297 detectorList.append(NuTauTarget)
298 detectorList.append(NuTauTT)
299
300# High Precision Tracker
301 tauHpt = ROOT.Hpt("HighPrecisionTrackers",ship_geo.tauHPT.DX, ship_geo.tauHPT.DY, ship_geo.tauHPT.DZ, ROOT.kTRUE)
302 tauHpt.SetZsize(ship_geo.tauMudet.Ztot)
303 tauHpt.SetDesign(ship_geo.NuTauTarget.Design)
304 if hasattr(ship_geo.tauHPT, "scifimat_width"):#for backward compatibility
305 tauHpt.SetSciFiParam(ship_geo.tauHPT.scifimat_width, ship_geo.tauHPT.scifimat_hor, ship_geo.tauHPT.scifimat_vert, ship_geo.tauHPT.scifimat_z, ship_geo.tauHPT.support_z, ship_geo.tauHPT.honeycomb_z)
306 tauHpt.SetNumberSciFi(ship_geo.tauHPT.n_hor_planes, ship_geo.tauHPT.n_vert_planes)
307 tauHpt.SetHPTrackerParam(ship_geo.tauHPT.TX, ship_geo.tauHPT.TY, ship_geo.tauHPT.TZ)
308 if ship_geo.nuTauTargetDesign<3:
309 tauHpt.SetConcreteBaseDim(ship_geo.tauHPT.ConcreteX,ship_geo.tauHPT.ConcreteY,ship_geo.tauHPT.ConcreteZ)
310 if ship_geo.nuTauTargetDesign==3:
311 tauHpt.SetHPTNumber(ship_geo.tauHPT.nHPT)
312 tauHpt.SetDistanceHPTs(ship_geo.tauHPT.distHPT)
313 if hasattr(ship_geo.tauHPT, "SRDY"):
314 tauHpt.SetSurroundingDetHeight(ship_geo.tauHPT.SRDY)
315 tauHpt.GetMagnetGeometry(ship_geo.EmuMagnet.zC, ship_geo.EmuMagnet.Y)
316 tauHpt.GetNumberofTargets(ship_geo.NuTauTarget.target)
317 detectorList.append(tauHpt)
318
319 # for backward compatibility
320 if not hasattr(ship_geo.strawtubes, "YPlaneOffset"):
321 ship_geo.strawtubes.YLayerOffset = ship_geo.strawtubes.StrawPitch / 2.
322 ship_geo.strawtubes.YPlaneOffset = ship_geo.strawtubes.StrawPitch / 4.
323 if ship_geo.strawDesign > 1 :
324 # for backward compatibility
325 if ship_geo.strawDesign == 10 and not hasattr(ship_geo.strawtubes, "DeltazFrame"):
326 ship_geo.strawtubes.DeltazFrame = 2.5*u.cm
327 ship_geo.strawtubes.FrameLateralWidth = 1.2*u.m
328 ship_geo.strawtubes.FrameMaterial = "steel"
329 elif not hasattr(ship_geo.strawtubes, "DeltazFrame"):
330 ship_geo.strawtubes.DeltazFrame = 10.*u.cm
331 ship_geo.strawtubes.FrameLateralWidth = 1.*u.cm
332 ship_geo.strawtubes.FrameMaterial = "aluminium"
333
334 Strawtubes = ROOT.strawtubes("Strawtubes", ROOT.kTRUE)
335 Strawtubes.SetZpositions(ship_geo.vetoStation.z, ship_geo.TrackStation1.z, ship_geo.TrackStation2.z, ship_geo.TrackStation3.z, ship_geo.TrackStation4.z)
336 Strawtubes.SetDeltazFrame(ship_geo.strawtubes.DeltazFrame)
337 Strawtubes.SetFrameLateralWidth(ship_geo.strawtubes.FrameLateralWidth)
338 Strawtubes.SetFrameMaterial(ship_geo.strawtubes.FrameMaterial)
339 Strawtubes.SetDeltazView(ship_geo.strawtubes.DeltazView)
340 Strawtubes.SetInnerStrawDiameter(ship_geo.strawtubes.InnerStrawDiameter)
341 Strawtubes.SetOuterStrawDiameter(ship_geo.strawtubes.OuterStrawDiameter)
342 Strawtubes.SetStrawPitch(ship_geo.strawtubes.StrawPitch,ship_geo.strawtubes.YLayerOffset,ship_geo.strawtubes.YPlaneOffset)
343 Strawtubes.SetDeltazLayer(ship_geo.strawtubes.DeltazLayer)
344 Strawtubes.SetDeltazPlane(ship_geo.strawtubes.DeltazPlane)
345 Strawtubes.SetStrawsPerLayer(ship_geo.strawtubes.StrawsPerLayer)
346 Strawtubes.SetStereoAngle(ship_geo.strawtubes.ViewAngle)
347 Strawtubes.SetWireThickness(ship_geo.strawtubes.WireThickness)
348 Strawtubes.SetVacBox_x(ship_geo.strawtubes.VacBox_x)
349 Strawtubes.SetVacBox_y(ship_geo.strawtubes.VacBox_y)
350 Strawtubes.SetStrawLength(ship_geo.strawtubes.StrawLength)
351
352 if hasattr(ship_geo.strawtubes,"StrawLengthVeto"):
353 Strawtubes.SetStrawLengthVeto(ship_geo.strawtubes.StrawLengthVeto)
354 Strawtubes.SetStrawLength12(ship_geo.strawtubes.StrawLength12)
355 Strawtubes.SetVetoYDim(ship_geo.strawtubes.vetoydim)
356 Strawtubes.SetTr12YDim(ship_geo.strawtubes.tr12ydim)
357 Strawtubes.SetTr34YDim(ship_geo.strawtubes.tr34ydim)
358 else:
359 Strawtubes.SetStrawLengthVeto(ship_geo.strawtubes.StrawLength)
360 Strawtubes.SetStrawLength12(ship_geo.strawtubes.StrawLength)
361 Strawtubes.SetVetoYDim(ship_geo.Yheight/2.)
362 Strawtubes.SetTr12YDim(ship_geo.Yheight/2.)
363 Strawtubes.SetTr34YDim(ship_geo.Yheight/2.)
364 # for the digitizing step
365 Strawtubes.SetStrawResolution(getParameter("strawtubes.v_drift",ship_geo,latestShipGeo),getParameter("strawtubes.sigma_spatial",ship_geo,latestShipGeo) )
366 detectorList.append(Strawtubes)
367
368 if ship_geo.EcalOption == 1: # shashlik design TP
369 if ship_geo.preshowerOption > 0 :
370 Preshower = ROOT.preshower("Preshower", ROOT.kTRUE)
371 Preshower.SetZStationPosition2(ship_geo.PreshowerStation0.z,ship_geo.PreshowerStation1.z)
372 Preshower.SetZFilterPosition2(ship_geo.PreshowerFilter0.z,ship_geo.PreshowerFilter1.z)
373 Preshower.SetXMax(ship_geo.Preshower.XMax)
374 Preshower.SetYMax(ship_geo.Preshower.YMax)
375 Preshower.SetActiveThickness(ship_geo.Preshower.ActiveThickness)
376 Preshower.SetFilterThickness2(ship_geo.Preshower.FilterThickness0,ship_geo.Preshower.FilterThickness1)
377 detectorList.append(Preshower)
378
379 ecal,EcalZSize = posEcal(ship_geo.ecal.z,ship_geo.ecal.File)
380 detectorList.append(ecal)
381
382 if ship_geo.EcalOption == 2: # splitCal with pointing information
383 SplitCal = ROOT.splitcal("SplitCal", ROOT.kTRUE)
384 x = ship_geo.SplitCal
385 SplitCal.SetThickness(x.ActiveECALThickness,x.ActiveHCALThickness,x.FilterECALThickness,x.FilterECALThickness_first,x.FilterHCALThickness,x.ActiveECAL_gas_Thickness)
386 SplitCal.SetMaterial(x.ActiveECALMaterial,x.ActiveHCALMaterial,x.FilterECALMaterial ,x.FilterHCALMaterial)
387 SplitCal.SetNSamplings(x.nECALSamplings,x.nHCALSamplings,x.ActiveHCAL)
388 SplitCal.SetZStart(x.ZStart)
389 SplitCal.SetXMax(x.XMax)
390 SplitCal.SetYMax(x.YMax)
391 SplitCal.SetEmpty(x.Empty,x.BigGap,x.ActiveECAL_gas_gap,x.first_precision_layer,x.second_precision_layer,x.third_precision_layer,x.num_precision_layers)
392 SplitCal.SetNModules(x.NModulesInX, x.NModulesInY)
393 SplitCal.SetNStrips(x.NStripsPerModule)
394 SplitCal.SetStripSize(x.StripHalfWidth, x.StripHalfLength)
395 detectorList.append(SplitCal)
396
397 if not ship_geo.HcalOption < 0:
398 hcal,HcalZSize = posHcal(ship_geo.hcal.z,ship_geo.hcal.File,ship_geo.HcalOption)
399 if ship_geo.HcalOption!=2 and abs(ship_geo.hcal.hcalSpace - HcalZSize) > 10*u.cm:
400 print('mismatch between hcalsize in geo file and python configuration')
401 print(ship_geo.hcal.hcalSpace - HcalZSize, ship_geo.hcal.hcalSpace , HcalZSize)
402 detectorList.append(hcal)
403 Muon = ROOT.muon("Muon", ROOT.kTRUE)
404 Muon.SetZStationPositions(ship_geo.MuonStation0.z, ship_geo.MuonStation1.z,ship_geo.MuonStation2.z,ship_geo.MuonStation3.z)
405 Muon.SetZFilterPositions(ship_geo.MuonFilter0.z, ship_geo.MuonFilter1.z,ship_geo.MuonFilter2.z)
406 Muon.SetXMax(ship_geo.Muon.XMax)
407 Muon.SetYMax(ship_geo.Muon.YMax)
408 Muon.SetActiveThickness(ship_geo.Muon.ActiveThickness)
409 Muon.SetFilterThickness(ship_geo.Muon.FilterThickness)
410 detectorList.append(Muon)
411
412 upstreamTagger = ROOT.UpstreamTagger("UpstreamTagger", ROOT.kTRUE)
413 upstreamTagger.SetZposition(ship_geo.UpstreamTagger.Z_Position)
414 upstreamTagger.SetSizeX_Glass(ship_geo.UpstreamTagger.X_Glass)
415 upstreamTagger.SetSizeY_Glass(ship_geo.UpstreamTagger.Y_Glass)
416 upstreamTagger.SetSizeZ_Glass(ship_geo.UpstreamTagger.Z_Glass)
417 upstreamTagger.SetSizeX_Glass_Border(ship_geo.UpstreamTagger.X_Glass_Border)
418 upstreamTagger.SetSizeY_Glass_Border(ship_geo.UpstreamTagger.Y_Glass_Border)
419 upstreamTagger.SetSizeZ_Glass_Border(ship_geo.UpstreamTagger.Z_Glass_Border)
420 upstreamTagger.SetSizeX_PMMA(ship_geo.UpstreamTagger.X_PMMA)
421 upstreamTagger.SetSizeY_PMMA(ship_geo.UpstreamTagger.Y_PMMA)
422 upstreamTagger.SetSizeZ_PMMA(ship_geo.UpstreamTagger.Z_PMMA)
423 upstreamTagger.SetSizeDX_PMMA(ship_geo.UpstreamTagger.DX_PMMA)
424 upstreamTagger.SetSizeDY_PMMA(ship_geo.UpstreamTagger.DY_PMMA)
425 upstreamTagger.SetSizeDZ_PMMA(ship_geo.UpstreamTagger.DZ_PMMA)
426 upstreamTagger.SetSizeX_FreonSF6(ship_geo.UpstreamTagger.X_FreonSF6)
427 upstreamTagger.SetSizeY_FreonSF6(ship_geo.UpstreamTagger.Y_FreonSF6)
428 upstreamTagger.SetSizeZ_FreonSF6(ship_geo.UpstreamTagger.Z_FreonSF6)
429 upstreamTagger.SetSizeX_FreonSF6_2(ship_geo.UpstreamTagger.X_FreonSF6_2)
430 upstreamTagger.SetSizeY_FreonSF6_2(ship_geo.UpstreamTagger.Y_FreonSF6_2)
431 upstreamTagger.SetSizeZ_FreonSF6_2(ship_geo.UpstreamTagger.Z_FreonSF6_2)
432 upstreamTagger.SetSizeX_FR4(ship_geo.UpstreamTagger.X_FR4)
433 upstreamTagger.SetSizeY_FR4(ship_geo.UpstreamTagger.Y_FR4)
434 upstreamTagger.SetSizeZ_FR4(ship_geo.UpstreamTagger.Z_FR4)
435 upstreamTagger.SetSizeX_Al(ship_geo.UpstreamTagger.X_Aluminium)
436 upstreamTagger.SetSizeY_Al(ship_geo.UpstreamTagger.Y_Aluminium)
437 upstreamTagger.SetSizeZ_Al(ship_geo.UpstreamTagger.Z_Aluminium)
438 upstreamTagger.SetSizeDX_Al(ship_geo.UpstreamTagger.DX_Aluminium)
439 upstreamTagger.SetSizeDY_Al(ship_geo.UpstreamTagger.DY_Aluminium)
440 upstreamTagger.SetSizeDZ_Al(ship_geo.UpstreamTagger.DZ_Aluminium)
441 upstreamTagger.SetSizeX_Air(ship_geo.UpstreamTagger.X_Air)
442 upstreamTagger.SetSizeY_Air(ship_geo.UpstreamTagger.Y_Air)
443 upstreamTagger.SetSizeZ_Air(ship_geo.UpstreamTagger.Z_Air)
444 upstreamTagger.SetSizeX_Strip(ship_geo.UpstreamTagger.X_Strip)
445 upstreamTagger.SetSizeY_Strip(ship_geo.UpstreamTagger.Y_Strip)
446 upstreamTagger.SetSizeX_Strip64(ship_geo.UpstreamTagger.X_Strip64)
447 upstreamTagger.SetSizeY_Strip64(ship_geo.UpstreamTagger.Y_Strip64)
448 upstreamTagger.SetSizeZ_Strip(ship_geo.UpstreamTagger.Z_Strip)
449 detectorList.append(upstreamTagger)
450
451 timeDet = ROOT.TimeDet("TimeDet", ROOT.kTRUE)
452 timeDet.SetZposition(ship_geo.TimeDet.z)
453 timeDet.SetBarZspacing(ship_geo.TimeDet.dzBarRow, ship_geo.TimeDet.dzBarCol)
454 timeDet.SetBarZ(ship_geo.TimeDet.zBar)
455 timeDet.SetSizeX(2 * ship_geo.TimeDet.DX)
456 timeDet.SetSizeY(2 * ship_geo.TimeDet.DY)
457 detectorList.append(timeDet)
458
459#----- Magnetic field -------------------------------------------
460 if not hasattr(ship_geo.Bfield,"fieldMap"):
461 if ship_geo.strawDesign == 4 or ship_geo.strawDesign == 10 : fMagField = ROOT.ShipBellField("wilfried", ship_geo.Bfield.max ,ship_geo.Bfield.z,2,ship_geo.Yheight/2.*u.m )
462 else : fMagField = ROOT.ShipBellField("wilfried", ship_geo.Bfield.max ,ship_geo.Bfield.z,1,ship_geo.Yheight/2.*u.m )
463 if ship_geo.muShieldDesign==6: fMagField.IncludeTarget(ship_geo.target.xy, ship_geo.target.z0, ship_geo.target.length)
464 run.SetField(fMagField)
465#
466 exclusionList = []
467 #exclusionList = ["Muon","Ecal","Hcal","Strawtubes","TargetTrackers","NuTauTarget","HighPrecisionTrackers",\
468 # "Veto","Magnet","MuonShield","TargetStation","NuTauMudet","EmuMagnet", "TimeDet", "UpstreamTagger"]
469
470 for x in detectorList:
471 if x.GetName() in exclusionList: continue
472 run.AddModule(x)
473# return list of detector elements
474 detElements = {}
475 for x in run.GetListOfModules(): detElements[x.GetName()]=x
476 return detElements
getParameter(x, ship_geo, latestShipGeo)
posHcal(z, hfile, HcalOption)
configure(run, ship_geo)
makeEcalGeoFile(z, efile)
posEcal(z, efile)