SND@LHC Software
Loading...
Searching...
No Matches
SciFiMapping Namespace Reference

Functions

 getFibre2SiPMCPP (scifi)
 
 getSiPM2FibreCPP (scifi)
 
 localPosition (fibresSiPM)
 
 overlap (F, Finv)
 
 test (chan)
 
 inspectSiPM ()
 
 inspectMats ()
 
 checkFibreCoverage (Finv)
 
 checkLocalPosition (fibresSiPM)
 
 moreChecks (modules)
 
 someDrawings (F, channel)
 

Variables

str geoFile = "geofile_full.Ntuple-TGeant4.root"
 
 fgeo = ROOT.TFile.Open(geoFile)
 
 upkl = Unpickler(fgeo)
 
 snd_geo = upkl.load('ShipGeo')
 
 run = ROOT.FairRunSim()
 
 rtdb = run.GetRuntimeDb()
 
 modules = sndDet_conf.configure(run,snd_geo)
 
 sGeo = fgeo.FAIRGeom
 
 top = sGeo.GetTopVolume()
 
dict h = {}
 

Function Documentation

◆ checkFibreCoverage()

SciFiMapping.checkFibreCoverage (   Finv)

Definition at line 103 of file SciFiMapping.py.

103def checkFibreCoverage(Finv):
104 for mat in range(1,4):
105 for row in range(1,7):
106 for channel in range(1,473):
107 fID = mat*10000+row*1000+channel
108 if not fID in Finv: print('missing fibre:',fID)

◆ checkLocalPosition()

SciFiMapping.checkLocalPosition (   fibresSiPM)

Definition at line 109 of file SciFiMapping.py.

109def checkLocalPosition(fibresSiPM):
110 ut.bookHist(h,'delta','central - weighted',100,-20.,20.)
111 L = localPosition(fibresSiPM)
112 sGeo = ROOT.gGeoManager
113 SiPMmapVol = sGeo.FindVolumeFast("SiPMmapVol")
114 for l in SiPMmapVol.GetNodes():
115 n = l.GetNumber()
116 ty = l.GetMatrix().GetTranslation()[1]
117 delta = ty-L[n]
118 rc = h['delta'].Fill(delta*10*1000.)

◆ getFibre2SiPMCPP()

SciFiMapping.getFibre2SiPMCPP (   scifi)

Definition at line 31 of file SciFiMapping.py.

31def getFibre2SiPMCPP(scifi):
32 scifi.SiPMOverlap()
33 scifi.SiPMmapping()
34 F=scifi.GetSiPMmap()
35 fibresSiPM = {}
36 for x in F:
37 fibresSiPM[x.first]={}
38 for z in x.second:
39 fibresSiPM[x.first][z.first]={'weight':z.second[0],'xpos':z.second[1]}
40 return fibresSiPM
41

◆ getSiPM2FibreCPP()

SciFiMapping.getSiPM2FibreCPP (   scifi)

Definition at line 42 of file SciFiMapping.py.

42def getSiPM2FibreCPP(scifi):
43 X=scifi.GetFibresMap()
44 siPMFibres = {}
45 for x in X:
46 siPMFibres[x.first]={}
47 for z in x.second:
48 siPMFibres[x.first][z.first]={'weight':z.second[0],'xpos':z.second[1]}
49 return siPMFibres
50

◆ inspectMats()

SciFiMapping.inspectMats ( )

Definition at line 94 of file SciFiMapping.py.

94def inspectMats():
95 sGeo = ROOT.gGeoManager
96 ScifiHorPlaneVol = sGeo.FindVolumeFast("ScifiHorPlaneVol")
97 for l1 in ScifiHorPlaneVol.GetNodes(): # 3 mats
98 t1 = l1.GetMatrix().GetTranslation()[1]
99 print(l1.GetName(),t1)
100 for l2 in l1.GetVolume().GetNodes():
101 t2 = l2.GetMatrix().GetTranslation()[1]
102 print(" ",l2.GetName(),t2,t1+t2)

◆ inspectSiPM()

SciFiMapping.inspectSiPM ( )

Definition at line 87 of file SciFiMapping.py.

87def inspectSiPM():
88 sGeo = ROOT.gGeoManager
89 SiPMmapVol = sGeo.FindVolumeFast("SiPMmapVol")
90 for l1 in SiPMmapVol.GetNodes(): # 3 mats with 4 SiPMs each and 128 channels
91 t1 = l1.GetMatrix().GetTranslation()[1]
92 if l1.GetNumber()%1000==0: print( "%s %5.2F"%(l1.GetName(),(t1)*10.))
93

◆ localPosition()

SciFiMapping.localPosition (   fibresSiPM)

Definition at line 52 of file SciFiMapping.py.

52def localPosition(fibresSiPM):
53 meanPos = {}
54 for N in fibresSiPM:
55 m = 0
56 w = 0
57 for fID in fibresSiPM[N]:
58 m+=fibresSiPM[N][fID]['weight']*fibresSiPM[N][fID]['xpos']
59 w+=fibresSiPM[N][fID]['weight']
60 meanPos[N] = m/w
61 return meanPos
62

◆ moreChecks()

SciFiMapping.moreChecks (   modules)

Definition at line 119 of file SciFiMapping.py.

119def moreChecks(modules):
120 ut.bookHist(h,'dx','dx',100,-0.1,0.1)
121 ut.bookHist(h,'dy','dy',100,-1.,1.)
122 ut.bookHist(h,'dz','dz',100,-0.2,0.2)
123 AS=ROOT.TVector3()
124 BS=ROOT.TVector3()
125 AF=ROOT.TVector3()
126 BF=ROOT.TVector3()
127 scifi = modules['Scifi']
128 F=getFibre2SiPMCPP(modules)
129 for station in range(1,6):
130 for orientation in range(0,2):
131 for channel in F:
132 globChannel = station* 1000000+ orientation*100000 +channel
133 scifi.GetSiPMPosition(globChannel,AS,BS)
134 for fibre in F[channel]:
135 globFibre = station* 1000000+ orientation*100000+fibre
136 scifi.GetPosition(globFibre,AF,BF)
137 if orientation==0:
138 dx = AS[1]-AF[1]
139 dy = AS[0]-AF[0]
140 else:
141 dx = AS[0]-AF[0]
142 dy = AS[1]-AF[1]
143 dz = AS[2]-AF[2]
144 rc = h['dx'].Fill(dx)
145 rc = h['dy'].Fill(dy)
146 rc = h['dz'].Fill(dz)

◆ overlap()

SciFiMapping.overlap (   F,
  Finv 
)

Definition at line 65 of file SciFiMapping.py.

65def overlap(F,Finv):
66 ut.bookHist(h,'W','overlap/fibre',110,0.,1.1)
67 ut.bookHist(h,'C','coverage',50,0.,10.)
68 ut.bookHist(h,'S','fibres/sipm',15,-0.5,14.5)
69 ut.bookHist(h,'Eff','efficiency',110,0.,1.1)
70 for n in F:
71 C=0
72 for fid in F[n]:
73 rc = h['W'].Fill(F[n][fid]['weight'])
74 C+=F[n][fid]['weight']
75 rc = h['C'].Fill(C)
76 for n in Finv:
77 E=0
78 for sipm in Finv[n]:
79 E+=Finv[n][sipm]['weight']
80 rc = h['Eff'].Fill(E)
81 rc = h['S'].Fill(len(Finv[n]))
82

◆ someDrawings()

SciFiMapping.someDrawings (   F,
  channel 
)

Definition at line 147 of file SciFiMapping.py.

147def someDrawings(F,channel):
148 AF = ROOT.TVector3()
149 BF = ROOT.TVector3()
150 ut.bookCanvas(h,'c1',' ;x;y',800,800,1,1)
151 s = int(channel/1000000)
152 o = int( (channel-1000000*s)/100000)
153 locChannel = channel%100000
154 fibreVol = sGeo.FindVolumeFast('FiberVolume')
155 R = fibreVol.GetShape().GetDX()
156 sipmVol = sGeo.FindVolumeFast("ChannelVol")
157 DY = sipmVol.GetShape().GetDY()
158 DZ = sipmVol.GetShape().GetDZ()
159 n = 0
160 xmin = 999.
161 xmax = -999.
162 ymin = 999.
163 ymax = -999.
164 for fibre in F[locChannel]:
165 globFibre = int(s*1000000 + o*100000 + fibre)
166 scifi.GetPosition(globFibre,AF,BF)
167 loc = scifi.GetLocalPos(globFibre,AF)
168 h['ellipse'+str(n)]=ROOT.TEllipse(loc[0],loc[2],R,0)
169 n+=1
170 if xmin>loc[0]: xmin = loc[0]
171 if ymin>loc[2]: ymin = loc[2]
172 if xmax<loc[0]: xmax = loc[0]
173 if ymax<loc[2]: ymax = loc[2]
174 print(xmin,xmax,ymin,ymax)
175 D = ymax - ymin+3*R
176 x0 = (xmax+xmin)/2.
177 ut.bookHist(h,'x','',100,x0-D/2,x0+D/2,100,ymin-1.5*R,ymax+1.5*R)
178 h['x'].SetStats(0)
179 h['x'].Draw()
180 for i in range(n):
181 print(fibre,globFibre,loc[0],loc[1],loc[2])
182 el = h['ellipse'+str(i)]
183 el.SetFillColor(6)
184 el.Draw('same')
185 scifi.GetSiPMPosition(channel,AF,BF)
186 loc = scifi.GetLocalPos(globFibre,AF)
187 h['rectang']=ROOT.TBox(loc[0]-DY,loc[2]-DZ,loc[0]+DY,loc[2]+DZ)
188 h['rectang'].SetFillColor(4)
189 h['rectang'].SetFillStyle(3001)
190 h['rectang'].Draw('same')
191

◆ test()

SciFiMapping.test (   chan)

Definition at line 83 of file SciFiMapping.py.

83def test(chan):
84 for x in F['VertMatVolume'][chan]:
85 print('%6i:%5.2F'%(x,F['VertMatVolume'][chan][x]))
86

Variable Documentation

◆ fgeo

SciFiMapping.fgeo = ROOT.TFile.Open(geoFile)

Definition at line 9 of file SciFiMapping.py.

◆ geoFile

str SciFiMapping.geoFile = "geofile_full.Ntuple-TGeant4.root"

Definition at line 8 of file SciFiMapping.py.

◆ h

dict SciFiMapping.h = {}

Definition at line 63 of file SciFiMapping.py.

◆ modules

SciFiMapping.modules = sndDet_conf.configure(run,snd_geo)

Definition at line 24 of file SciFiMapping.py.

◆ rtdb

SciFiMapping.rtdb = run.GetRuntimeDb()

Definition at line 23 of file SciFiMapping.py.

◆ run

SciFiMapping.run = ROOT.FairRunSim()

Definition at line 19 of file SciFiMapping.py.

◆ sGeo

SciFiMapping.sGeo = fgeo.FAIRGeom

Definition at line 25 of file SciFiMapping.py.

◆ snd_geo

SciFiMapping.snd_geo = upkl.load('ShipGeo')

Definition at line 14 of file SciFiMapping.py.

◆ top

SciFiMapping.top = sGeo.GetTopVolume()

Definition at line 26 of file SciFiMapping.py.

◆ upkl

SciFiMapping.upkl = Unpickler(fgeo)

Definition at line 13 of file SciFiMapping.py.