13 def Init(self,options,monitor):
19 run = ROOT.FairRunAna.Instance()
22 self.
OT = run.GetSink().GetOutTree()
23 si = self.
M.snd_geo.snd_geo.Scifi
24 self.
detSize[0] =[si.channel_width, si.channel_width, si.scifimat_z]
25 mi = self.
M.snd_geo.snd_geo.MuFilter
26 self.
detSize[1] =[mi.VetoBarX/2, mi.VetoBarY/2, mi.VetoBarZ/2]
27 self.
detSize[2] =[mi.UpstreamBarX/2, mi.UpstreamBarY/2, mi.UpstreamBarZ/2]
28 self.
detSize[3] =[mi.DownstreamBarX_ver/2,mi.DownstreamBarY/2,mi.DownstreamBarZ/2]
31 if 'simpleDisplay' not in h: ut.bookCanvas(h,key=
'simpleDisplay',title=
'2d event display',nx=1200,ny=1600,cx=1,cy=2)
32 h[
'simpleDisplay'].cd(1)
34 if self.
M.snd_geo.snd_geo.Floor.z == 0: zStart = 60.
35 ut.bookHist(h,
'xz',
'; z [cm]; x [cm]',500,zStart,zStart+350.,100,-100.,10.)
36 ut.bookHist(h,
'yz',
'; z [cm]; y [cm]',500,zStart,zStart+350.,100,-30.,80.)
40 self.
proj = {1:
'xz',2:
'yz'}
42 self.
xNodes = {
'UpstreamBar',
'VetoBar',
'hor'}
47 self.
nodes = {
'volMuFilter_1/volFeBlockEnd_1':ROOT.kGreen-6}
50 nodes[
'volVeto_1/volVetoPlane_{}_{}'.format(i, i)]=ROOT.kRed
52 nodes[
'volVeto_1/volVetoPlane_{}_{}/volVetoBar_1{}{:0>3d}'.format(i, i, i, j)]=ROOT.kRed
53 nodes[
'volVeto_1/subVetoBox_{}'.format(i)]=ROOT.kGray+1
55 nodes[
'volMuFilter_1/volMuDownstreamDet_{}_{}'.format(i, i+7)]=ROOT.kBlue+1
57 nodes[
'volMuFilter_1/volMuDownstreamDet_{}_{}/volMuDownstreamBar_ver_3{}{:0>3d}'.format(i, i+7, i, j+60)]=ROOT.kBlue+1
59 nodes[
'volMuFilter_1/volMuDownstreamDet_{}_{}/volMuDownstreamBar_hor_3{}{:0>3d}'.format(i, i+7, i, j)]=ROOT.kBlue+1
61 nodes[
'volMuFilter_1/subDSBox_{}'.format(i+7)]=ROOT.kGray+1
63 nodes[
'volTarget_1/ScifiVolume{}_{}000000'.format(i+1, i+1)]=ROOT.kBlue+1
64 nodes[
'volTarget_1/volWallborder_{}'.format(i)]=ROOT.kGray
65 nodes[
'volMuFilter_1/subUSBox_{}'.format(i+2)]=ROOT.kGray+1
66 nodes[
'volMuFilter_1/volMuUpstreamDet_{}_{}'.format(i, i+2)]=ROOT.kBlue+1
68 nodes[
'volMuFilter_1/volMuUpstreamDet_{}_{}/volMuUpstreamBar_2{}00{}'.format(i, i+2, i, j)]=ROOT.kBlue+1
69 nodes[
'volMuFilter_1/volFeBlock_{}'.format(i)]=ROOT.kGreen-6
71 nodes[
'volMuFilter_1/volFeBlock_{}'.format(i)]=ROOT.kGreen-6
73 self.
xNodes = {
'UpstreamBar',
'VetoBar',
'hor'}
79 Enodes[
'volVeto_1/volVetoPlane_{}_{}/volVetoBar_1{}{:0>3d}'.format(i, i, i, j)]=ROOT.kRed
82 Enodes[
'volMuFilter_1/volMuDownstreamDet_{}_{}/volMuDownstreamBar_hor_3{}{:0>3d}'.format(i, i+7, i, j)]=ROOT.kBlue+2
83 Enodes[
'volMuFilter_1/volMuDownstreamDet_{}_{}/volMuDownstreamBar_ver_3{}{:0>3d}'.format(i, i+7, i, j+60)]=ROOT.kBlue+2
85 Enodes[
'volMuFilter_1/volMuDownstreamDet_3_10/volMuDownstreamBar_ver_33{:0>3d}'.format(j+60)]=ROOT.kBlue+2
88 Enodes[
'volMuFilter_1/volMuUpstreamDet_{}_{}/volMuUpstreamBar_2{}00{}'.format(i, i+2, i, j)]=ROOT.kBlue+2
96 N = self.
M.EventNumber
99 nav = ROOT.gGeoManager.GetCurrentNavigator()
100 if options.goodEvents
and not self.
goodEvent(event):
return
101 if options.withTrack:
103 ntracks = self.
M.Reco_MuonTracks.GetEntries()
104 uniqueTracks = self.
M.Reco_MuonTracks
105 if len(uniqueTracks)<options.nTracks:
return
107 for aTrack
in self.
M.Reco_MuonTracks:
108 mom = aTrack.getFittedState().getMom()
109 pos = aTrack.getFittedState().getPos()
110 if aTrack.GetUniqueID()==3: tt =
'DS'
112 print(tt+
' track direction: X %5.2Fmrad Y %5.2Fmrad'%(mom.X()/mom.Z()*1000,mom.Y()/mom.Z()*1000))
113 print(
' track position: X %5.2Fcm Y %5.2Fcm '%(pos.X(),pos.Y()))
116 if event.FindBranch(
"Digi_ScifiHits"): digis.append(event.Digi_ScifiHits)
117 if event.FindBranch(
"Digi_MuFilterHits"): digis.append(event.Digi_MuFilterHits)
121 if empty: print(
"event -> %i"%N)
124 h[
'hitCollectionX']= {
'Scifi':[0,ROOT.TGraphErrors()],
'DS':[0,ROOT.TGraphErrors()]}
125 h[
'hitCollectionY']= {
'Veto':[0,ROOT.TGraphErrors()],
'Scifi':[0,ROOT.TGraphErrors()],
'US':[0,ROOT.TGraphErrors()],
'DS':[0,ROOT.TGraphErrors()]}
126 h[
'firedChannelsX']= {
'Scifi':[0,0,0],
'DS':[0,0,0]}
127 h[
'firedChannelsY']= {
'Veto':[0,0,0,0],
'Scifi':[0,0,0],
'US':[0,0,0,0],
'DS':[0,0,0,0]}
128 systems = {1:
'Veto',2:
'US',3:
'DS',0:
'Scifi'}
129 for collection
in [
'hitCollectionX',
'hitCollectionY']:
130 for c
in h[collection]:
131 rc=h[collection][c][1].SetName(c)
132 rc=h[collection][c][1].Set(0)
135 rc = h[
'simpleDisplay'].cd(p)
141 detID = digi.GetDetectorID()
143 if digi.GetName() ==
'MuFilterHit':
144 system = digi.GetSystem()
145 geo.modules[
'MuFilter'].GetPosition(detID,A,B)
146 sipmMult = len(digi.GetAllSignals())
147 if sipmMult<self.
minSipmMult and (system==1
or system==2):
continue
149 geo.modules[
'Scifi'].GetSiPMPosition(detID,A,B)
151 curPath = nav.GetPath()
152 tmp = curPath.rfind(
'/')
153 nav.cd(curPath[:tmp])
154 globA,locA = array(
'd',[A[0],A[1],A[2]]),array(
'd',[A[0],A[1],A[2]])
157 if digi.isVertical():
158 collection =
'hitCollectionX'
160 sY = detSize[system][0]
162 collection =
'hitCollectionY'
164 sY = detSize[system][1]
165 c = h[collection][systems[system]]
166 rc = c[1].SetPoint(c[0],Z, Y)
167 rc = c[1].SetPointError(c[0],detSize[system][2],sY)
172 if digi.isVertical(): F =
'firedChannelsX'
173 else: F =
'firedChannelsY'
174 ns = max(1,digi.GetnSides())
175 for side
in range(ns):
176 for m
in range(digi.GetnSiPMs()):
177 qdc = digi.GetSignal(m+side*digi.GetnSiPMs())
178 if qdc < 0
and qdc > -900: h[F][systems[system]][1]+=1
180 h[F][systems[system]][0]+=1
182 h[
'hitCollectionY'][
'Scifi'][1].SetMarkerColor(ROOT.kBlue+2)
183 h[
'hitCollectionX'][
'Scifi'][1].SetMarkerColor(ROOT.kBlue+2)
185 for collection
in [
'hitCollectionX',
'hitCollectionY']:
186 h[
'simpleDisplay'].cd(k)
187 self.
drawInfo(h[
'simpleDisplay'], k, N, event)
189 for c
in h[collection]:
190 F = collection.replace(
'hitCollection',
'firedChannels')
191 pj = collection.split(
'ion')[1]
192 if pj ==
"X" or c==
"Scifi":
193 print(
"%1s %5s %3i +:%3i -:%3i qdc :%5.1F"%(pj,c,h[collection][c][1].GetN(),h[F][c][0],h[F][c][1],h[F][c][2]))
195 print(
"%1s %5s %3i +:%3i -:%3i qdcL:%5.1F qdcR:%5.1F"%(pj,c,h[collection][c][1].GetN(),h[F][c][0],h[F][c][1],h[F][c][2],h[F][c][3]))
196 if h[collection][c][1].GetN()<1:
continue
198 h[collection][c][1].SetMarkerStyle(20)
199 h[collection][c][1].SetMarkerSize(1.5)
200 rc=h[collection][c][1].Draw(
'sameP')
201 h[
'display:'+c]=h[collection][c][1]
202 if options.withTrack: self.
addTrack()
203 h[
'simpleDisplay'].Update()
204 if options.save: h[
'simpleDisplay'].Print(
'event_'+
"{:04d}".format(N)+
'.png')
205 if options.interactive:
206 rc = input(
"hit return for next event ")
208 self.
M.myPrint(h[
'simpleDisplay'],
'event'+str(N%10),subdir=
'eventdisplay')
231 xax = h[
'xz'].GetXaxis()
233 for aTrack
in self.
M.Reco_MuonTracks:
235 h[
'aLine'+str(nTrack*10+p)] = ROOT.TGraph()
236 zEx = xax.GetBinCenter(1)
237 mom = aTrack.getFittedState().getMom()
238 pos = aTrack.getFittedState().getPos()
239 lam = (zEx-pos.z())/mom.z()
240 Ex = [pos.x()+lam*mom.x(),pos.y()+lam*mom.y()]
241 for p
in [0,1]: h[
'aLine'+str(nTrack*10+p)].SetPoint(0,zEx,Ex[p])
243 for i
in range(aTrack.getNumPointsWithMeasurement()):
244 state = aTrack.getFittedState(i)
247 h[
'aLine'+str(nTrack*10+p)].SetPoint(i+1,pos[2],pos[p])
249 zEx = xax.GetBinCenter(xax.GetLast())
250 mom = aTrack.getFittedState().getMom()
251 pos = aTrack.getFittedState().getPos()
252 lam = (zEx-pos.z())/mom.z()
253 Ex = [pos.x()+lam*mom.x(),pos.y()+lam*mom.y()]
254 for p
in [0,1]: h[
'aLine'+str(nTrack*10+p)].SetPoint(i+2,zEx,Ex[p])
257 tc = h[
'simpleDisplay'].cd(p+1)
258 h[
'aLine'+str(nTrack*10+p)].SetLineColor( self.
trackColor[aTrack.GetUniqueID()])
259 h[
'aLine'+str(nTrack*10+p)].SetLineWidth(2)
260 h[
'aLine'+str(nTrack*10+p)].Draw(
'same')
262 h[
'simpleDisplay'].Update()
268 for aTrack
in self.
M.Reco_MuonTracks:
270 for i
in range(aTrack.getNumPointsWithMeasurement()):
271 M = aTrack.getPointWithMeasurement(i)
272 R = M.getRawMeasurement()
273 listOfDetIDs[n].append(R.getDetId())
274 if R.getDetId()>0: listOfDetIDs[n].append(R.getDetId()-1)
275 listOfDetIDs[n].append(R.getDetId()+1)
278 for n1
in range( len(listOfDetIDs) ):
280 for n2
in range( len(listOfDetIDs) ):
282 I =
set(listOfDetIDs[n1]).intersection(listOfDetIDs[n2])
283 if len(I)>0: unique =
False
284 if unique: uniqueTracks.append(n1)
285 if len(uniqueTracks)>1:
286 for n1
in range( len(listOfDetIDs) ): print(listOfDetIDs[n1])
295 nav = ROOT.gGeoManager.GetCurrentNavigator()
298 node =
'/cave_1/Detector_0/'+node_
302 N = nav.GetCurrentNode()
303 S = N.GetVolume().GetShape()
304 dx,dy,dz = S.GetDX(),S.GetDY(),S.GetDZ()
305 ox,oy,oz = S.GetOrigin()[0],S.GetOrigin()[1],S.GetOrigin()[2]
308 if p==
'X' and not any(xNode
in node
for xNode
in xNodes):
309 P[
'LeftBottom'] = array(
'd',[-dx+ox,oy,-dz+oz])
310 P[
'LeftTop'] = array(
'd',[dx+ox,oy,-dz+oz])
311 P[
'RightBottom'] = array(
'd',[-dx+ox,oy,dz+oz])
312 P[
'RightTop'] = array(
'd',[dx+ox,oy,dz+oz])
313 elif p==
'Y' and 'ver' not in node:
314 P[
'LeftBottom'] = array(
'd',[ox,-dy+oy,-dz+oz])
315 P[
'LeftTop'] = array(
'd',[ox,dy+oy,-dz+oz])
316 P[
'RightBottom'] = array(
'd',[ox,-dy+oy,dz+oz])
317 P[
'RightTop'] = array(
'd',[ox,dy+oy,dz+oz])
320 M[C] = array(
'd',[0,0,0])
321 nav.LocalToMaster(P[C],M[C])
322 h[node+p] = ROOT.TPolyLine()
325 X.SetPoint(0,M[
'LeftBottom'][2],M[
'LeftBottom'][c])
326 X.SetPoint(1,M[
'LeftTop'][2],M[
'LeftTop'][c])
327 X.SetPoint(2,M[
'RightTop'][2],M[
'RightTop'][c])
328 X.SetPoint(3,M[
'RightBottom'][2],M[
'RightBottom'][c])
329 X.SetPoint(4,M[
'LeftBottom'][2],M[
'LeftBottom'][c])
330 X.SetLineColor(nodes[node_])
332 h[
'simpleDisplay'].cd(c+1)
333 if any(passNode
in node
for passNode
in passNodes):
334 X.SetFillColorAlpha(nodes[node_], 0.5)
340 h[
'simpleDisplay'].cd(c+1)
341 if any(passNode
in node
for passNode
in passNodes):
388 padLogo = ROOT.TPad(
"logo",
"logo",0.1,0.1,0.2,0.3)
389 padLogo.SetFillStyle(4000)
390 padLogo.SetFillColorAlpha(0, 0)
392 logo = ROOT.TImage.Open(
'$SNDSW_ROOT/shipLHC/Large__SND_Logo_black_cut.png')
393 logo.SetConstRatio(
True)
394 logo.DrawText(0, 0,
'SND', 98)
400 runNumber = event.EventHeader.GetRunId()
402 time_event = time.ctime()
403 timestamp_start =
True
405 timestamp = event.EventHeader.GetEventTime()
409 timestamp_s = timestamp * TDC2ns * 1E-9
410 timestamp_event = int(timestamp_start + timestamp_s)
411 time_event = datetime.fromtimestamp(timestamp_event)
412 padText = ROOT.TPad(
"info",
"info",0.19,0.1,0.6,0.3)
413 padText.SetFillStyle(4000)
416 textInfo = ROOT.TLatex()
417 textInfo.SetTextAlign(11)
418 textInfo.SetTextFont(42)
419 textInfo.SetTextSize(.15)
420 textInfo.DrawLatex(0, 0.6,
'SND@LHC Experiment, CERN')
421 textInfo.DrawLatex(0, 0.4,
'Run / Event: '+str(runNumber)+
' / '+str(N))
423 textInfo.DrawLatex(0, 0.2,
'Time (GMT): {}'.format(time_event))