SND@LHC Software
Loading...
Searching...
No Matches
2dEventDisplay Namespace Reference

Functions

 pyExit ()
 
 goodEvent (event)
 
 userProcessing (event)
 
 bunchXtype ()
 
 getSciFiHitDensity (g, x_range=0.5)
 
 drawLegend (max_density, max_QDC, n_legend_points)
 
 drawSciFiHits (g, colour)
 
 loopEvents (start=0, save=False, goodEvents=False, withTrack=-1, withHoughTrack=-1, nTracks=0, minSipmMult=1, withTiming=False, option=None, Setup='', verbose=0, auto=False, hitColour=None)
 
 addTrack (OT, scifi=False)
 
 twoTrackEvent (sMin=10, dClMin=7, minDistance=1.5, sepDistance=0.5)
 
 drawDetectors ()
 
 zoom (xmin=None, xmax=None, ymin=None, ymax=None, zmin=None, zmax=None)
 
 dumpVeto ()
 
 MuFilter_PlaneBars (detID)
 
 checkOtherTriggers (event, deadTime=100, debug=False)
 
 cleanTracks ()
 
 timingOfEvent (makeCluster=False, debug=False)
 
 mufiNoise ()
 
 firstTimeStamp (event)
 
 dumpChannels (D='Digi_MuFilterHits')
 
 fillNode (node, color=None)
 
 drawInfo (pad, k, run, event, timestamp, moreEventInfo=[])
 

Variables

 A
 
 B
 
dict eventComment = {}
 
dict h = {}
 
 parser = ArgumentParser()
 
 dest
 
 help
 
 type
 
 int
 
 required
 
 False
 
 default
 
 options = parser.parse_args()
 
 storePic
 
bool trans2local = False
 
bool runInfo = False
 
 fg = ROOT.TFile.Open(options.server+options.p+"RunInfodict.root")
 
 pkl = Unpickler(fg)
 
 geo = SndlhcGeo.GeoInterface(options.geoFile)
 
 lsOfGlobals = ROOT.gROOT.GetListOfGlobals()
 
dict detSize = {}
 
 si = geo.snd_geo.Scifi
 
 mi = geo.snd_geo.MuFilter
 
 vetoXdim
 
bool withDetector = True
 
bool with2Points = False
 
bool mc = False
 
int firstScifi_z = 300 * u.cm
 
 logger = ROOT.FairLogger.GetLogger()
 
 run = ROOT.FairRunAna()
 
 ioman = ROOT.FairRootManager.Instance()
 
 f = ROOT.TFile.Open(options.path+'sndsw_raw_'+str(options.runNumber).zfill(6)+'.root')
 
 eventTree = f.cbmsim
 
str runId = 'sim'
 
 outFile = ROOT.TMemFile('dummy','CREATE')
 
 source = ROOT.FairFileSource(f)
 
 sink = ROOT.FairRootFileSink(outFile)
 
dict HT_tasks
 
 trackTask = SndlhcTracking.Tracking()
 
 xrdb = ROOT.FairRuntimeDb.instance()
 
 OT = sink.GetOutTree()
 
 Digi_MuFilterHits
 
 nav = ROOT.gGeoManager.GetCurrentNavigator()
 
 runNumber = eventTree.EventHeader.GetRunId()
 
 FSdict = pkl.load('FSdict')
 
 fsdict = False
 
int Nlimit = 4
 
bool onlyScifi = False
 

Function Documentation

◆ addTrack()

2dEventDisplay.addTrack (   OT,
  scifi = False 
)

Definition at line 582 of file 2dEventDisplay.py.

582def addTrack(OT,scifi=False):
583 xax = h['xz'].GetXaxis()
584 nTrack = 0
585 for aTrack in OT.Reco_MuonTracks:
586 trackColor = ROOT.kRed
587 if aTrack.GetUniqueID()==1:
588 trackColor = ROOT.kBlue+2
589 flightDir = trackTask.trackDir(aTrack)
590 print('flight direction: %5.3F significance: %5.3F'%(flightDir[0],flightDir[1]))
591 if aTrack.GetUniqueID()==3: trackColor = ROOT.kBlack
592 if aTrack.GetUniqueID()==11: trackColor = ROOT.kAzure-2 # HT scifi track
593 if aTrack.GetUniqueID()==13: trackColor = ROOT.kGray+2 # HT ds track
594 # HT cross-system track fit
595 if aTrack.GetUniqueID()==15: trackColor = ROOT.kOrange+7
596 S = aTrack.getFitStatus()
597 if not S.isFitConverged() and (scifi or (aTrack.GetUniqueID()==1 or aTrack.GetUniqueID()==11) ):# scifi trk object ids are 1 or 11(Hough tracking)
598 print('not converge')
599 continue
600 for p in [0,1]:
601 h['aLine'+str(nTrack*10+p)] = ROOT.TGraph()
602
603 zEx = xax.GetBinCenter(1)
604 mom = aTrack.getFittedState().getMom()
605 pos = aTrack.getFittedState().getPos()
606 lam = (zEx-pos.z())/mom.z()
607 Ex = [pos.x()+lam*mom.x(),pos.y()+lam*mom.y()]
608 for p in [0,1]: h['aLine'+str(nTrack*10+p)].SetPoint(0,zEx,Ex[p])
609
610 for i in range(aTrack.getNumPointsWithMeasurement()):
611 state = aTrack.getFittedState(i)
612 pos = state.getPos()
613 for p in [0,1]:
614 h['aLine'+str(nTrack*10+p)].SetPoint(i+1,pos[2],pos[p])
615
616 zEx = xax.GetBinCenter(xax.GetLast())
617 mom = aTrack.getFittedState().getMom()
618 pos = aTrack.getFittedState().getPos()
619 lam = (zEx-pos.z())/mom.z()
620 Ex = [pos.x()+lam*mom.x(),pos.y()+lam*mom.y()]
621 for p in [0,1]: h['aLine'+str(nTrack*10+p)].SetPoint(i+2,zEx,Ex[p])
622
623 for p in [0,1]:
624 tc = h[ 'simpleDisplay'].cd(p+1)
625 h['aLine'+str(nTrack*10+p)].SetLineColor(trackColor)
626 h['aLine'+str(nTrack*10+p)].SetLineWidth(2)
627 h['aLine'+str(nTrack*10+p)].Draw('same')
628 tc.Update()
629 h[ 'simpleDisplay'].Update()
630 nTrack+=1
631

◆ bunchXtype()

2dEventDisplay.bunchXtype ( )

Definition at line 206 of file 2dEventDisplay.py.

206def bunchXtype():
207# check for b1,b2,IP1,IP2
208 xing = {'all':True,'B1only':False,'B2noB1':False,'noBeam':False}
209 if fsdict:
210 T = eventTree.EventHeader.GetEventTime()
211 bunchNumber = int(T%(4*3564)/4+0.5)
212 nb1 = (3564 + bunchNumber - fsdict['phaseShift1'])%3564
213 nb2 = (3564 + bunchNumber - fsdict['phaseShift1']- fsdict['phaseShift2'])%3564
214 b1 = nb1 in fsdict['B1']
215 b2 = nb2 in fsdict['B2']
216 IP1 = False
217 IP2 = False
218 if b1:
219 IP1 = fsdict['B1'][nb1]['IP1']
220 if b2:
221 IP2 = fsdict['B2'][nb2]['IP2']
222 if b2 and not b1:
223 xing['B2noB1'] = True
224 if b1 and not b2 and not IP1:
225 xing['B1only'] = True
226 if not b1 and not b2: xing['noBeam'] = True
227 return xing
228

◆ checkOtherTriggers()

2dEventDisplay.checkOtherTriggers (   event,
  deadTime = 100,
  debug = False 
)

Definition at line 844 of file 2dEventDisplay.py.

844def checkOtherTriggers(event,deadTime = 100,debug=False):
845 T0 = event.EventHeader.GetEventTime()
846 N = event.EventHeader.GetEventNumber()
847 Nprev = 1
848 rc = event.GetEvent(N-Nprev)
849 dt = T0 - event.EventHeader.GetEventTime()
850 otherFastTrigger = False
851 otherAdvTrigger = False
852 tightNoiseFilter = False
853 while dt < deadTime:
854 otherFastTrigger = False
855 for x in event.EventHeader.GetFastNoiseFilters():
856 if debug: print('fast:', x.first, x.second )
857 if x.second and not x.first == 'Veto_Total': otherFastTrigger = True
858 otherAdvTrigger = False
859 for x in event.EventHeader.GetAdvNoiseFilters():
860 if debug: print('adv:', x.first, x.second )
861 if x.second and not x.first == 'VETO_Planes': otherAdvTrigger = True
862 if debug: print('pre event ',Nprev,dt,otherFastTrigger,otherAdvTrigger)
863 if otherFastTrigger and otherAdvTrigger:
864 rc = event.GetEvent(N)
865 return otherFastTrigger, otherAdvTrigger, tightNoiseFilter, Nprev, dt
866 Nprev+=1
867 rc = event.GetEvent(N-Nprev)
868 dt = T0 - event.EventHeader.GetEventTime()
869 Nprev = 1
870 rc = event.GetEvent(N-Nprev)
871 dt = T0 - event.EventHeader.GetEventTime()
872 while dt < deadTime:
873 hits = {1:0,0:0}
874 for aHit in event.Digi_MuFilterHits:
875 Minfo = MuFilter_PlaneBars(aHit.GetDetectorID())
876 s,l,bar = Minfo['station'],Minfo['plane'],Minfo['bar']
877 if s>1: continue
878 allChannels = aHit.GetAllSignals(False,False)
879 hits[l]+=len(allChannels)
880 noiseFilter0 = (hits[0]+hits[1])>4.5
881 noiseFilter1 = hits[0]>0 and hits[1]>0
882 if debug: print('veto hits:',hits)
883 if noiseFilter0 and noiseFilter1:
884 tightNoiseFilter = True
885 rc = event.GetEvent(N)
886 return otherFastTrigger, otherAdvTrigger, tightNoiseFilter, Nprev-1, dt
887 Nprev+=1
888 rc = event.GetEvent(N-Nprev)
889 dt = T0 - event.EventHeader.GetEventTime()
890 if Nprev>1:
891 rc = event.GetEvent(N-Nprev+1)
892 dt = T0 - event.EventHeader.GetEventTime()
893 rc = event.GetEvent(N)
894 return otherFastTrigger, otherAdvTrigger, tightNoiseFilter, Nprev-1, dt
895

◆ cleanTracks()

2dEventDisplay.cleanTracks ( )

Definition at line 896 of file 2dEventDisplay.py.

896def cleanTracks():
897 OT = sink.GetOutTree()
898 listOfDetIDs = {}
899 n = 0
900 for aTrack in OT.Reco_MuonTracks:
901 listOfDetIDs[n] = []
902 for i in range(aTrack.getNumPointsWithMeasurement()):
903 M = aTrack.getPointWithMeasurement(i)
904 R = M.getRawMeasurement()
905 listOfDetIDs[n].append(R.getDetId())
906 if R.getDetId()>0: listOfDetIDs[n].append(R.getDetId()-1)
907 listOfDetIDs[n].append(R.getDetId()+1)
908 n+=1
909 uniqueTracks = []
910 for n1 in range( len(listOfDetIDs) ):
911 unique = True
912 for n2 in range( len(listOfDetIDs) ):
913 if n1==n2: continue
914 I = set(listOfDetIDs[n1]).intersection(listOfDetIDs[n2])
915 if len(I)>0: unique = False
916 if unique: uniqueTracks.append(n1)
917 if len(uniqueTracks)>1:
918 for n1 in range( len(listOfDetIDs) ): print(listOfDetIDs[n1])
919 return uniqueTracks
920
set(INCLUDE_DIRECTORIES ${SYSTEM_INCLUDE_DIRECTORIES} ${VMC_INCLUDE_DIRS} ${CMAKE_SOURCE_DIR}/shipdata ${CMAKE_SOURCE_DIR}/shipLHC ${CMAKE_SOURCE_DIR}/analysis/cuts ${CMAKE_SOURCE_DIR}/analysis/tools ${FMT_INCLUDE_DIR}) include_directories($
Definition CMakeLists.txt:1

◆ drawDetectors()

2dEventDisplay.drawDetectors ( )

Definition at line 719 of file 2dEventDisplay.py.

719def drawDetectors():
720 nodes = {'volMuFilter_1/volFeBlockEnd_1':ROOT.kGreen-6}
721 for i in range(mi.NVetoPlanes):
722 nodes['volVeto_1/volVetoPlane_{}_{}'.format(i, i)]=ROOT.kRed
723 for j in range(mi.NVetoBars):
724 if i<2: nodes['volVeto_1/volVetoPlane_{}_{}/volVetoBar_1{}{:0>3d}'.format(i, i, i, j)]=ROOT.kRed
725 if i==2: nodes['volVeto_1/volVetoPlane_{}_{}/volVetoBar_ver_1{}{:0>3d}'.format(i, i, i, j)]=ROOT.kRed
726 if i<2: nodes['volVeto_1/subVetoBox_{}'.format(i)]=ROOT.kGray+1
727 if i==2: nodes['volVeto_1/subVeto3Box_{}'.format(i)]=ROOT.kGray+1
728 for i in range(mi.NDownstreamPlanes):
729 nodes['volMuFilter_1/volMuDownstreamDet_{}_{}'.format(i, i+mi.NVetoPlanes+mi.NUpstreamPlanes)]=ROOT.kBlue+1
730 for j in range(mi.NDownstreamBars):
731 nodes['volMuFilter_1/volMuDownstreamDet_{}_{}/volMuDownstreamBar_ver_3{}{:0>3d}'.format(i, i+mi.NVetoPlanes+mi.NUpstreamPlanes, i, j+mi.NDownstreamBars)]=ROOT.kBlue+1
732 if i < 3:
733 nodes['volMuFilter_1/volMuDownstreamDet_{}_{}/volMuDownstreamBar_hor_3{}{:0>3d}'.format(i, i+mi.NVetoPlanes+mi.NUpstreamPlanes, i, j)]=ROOT.kBlue+1
734 for i in range(mi.NDownstreamPlanes):
735 nodes['volMuFilter_1/subDSBox_{}'.format(i+mi.NVetoPlanes+mi.NUpstreamPlanes)]=ROOT.kGray+1
736 for i in range(mi.NUpstreamPlanes):
737 nodes['volTarget_1/ScifiVolume{}_{}000000'.format(i+1, i+1)]=ROOT.kBlue+1
738 nodes['volTarget_1/volWallborder_{}'.format(i)]=ROOT.kGray
739 nodes['volMuFilter_1/subUSBox_{}'.format(i+mi.NVetoPlanes)]=ROOT.kGray+1
740 nodes['volMuFilter_1/volMuUpstreamDet_{}_{}'.format(i, i+mi.NVetoPlanes)]=ROOT.kBlue+1
741 # iron blocks btw SciFi planes in the testbeam 2023 det layout
742 nodes['volTarget_1/volFeTarget{}_1'.format(i+1)]=ROOT.kGreen-6
743 for j in range(mi.NUpstreamBars):
744 nodes['volMuFilter_1/volMuUpstreamDet_{}_{}/volMuUpstreamBar_2{}00{}'.format(i, i+mi.NVetoPlanes, i, j)]=ROOT.kBlue+1
745 nodes['volMuFilter_1/volFeBlock_{}'.format(i)]=ROOT.kGreen-6
746 for i in range(mi.NVetoPlanes+mi.NUpstreamPlanes,mi.NVetoPlanes+mi.NUpstreamPlanes+mi.NDownstreamPlanes):
747 nodes['volMuFilter_1/volFeBlock_{}'.format(i)]=ROOT.kGreen-6
748 passNodes = {'Block', 'Wall', 'FeTarget'}
749 xNodes = {'UpstreamBar', 'VetoBar', 'hor'}
750 proj = {'X':0,'Y':1}
751 for node_ in nodes:
752 node = '/cave_1/Detector_0/'+node_
753 for p in proj:
754 if node+p in h and any(passNode in node for passNode in passNodes):
755 X = h[node+p]
756 c = proj[p]
757 h['simpleDisplay'].cd(c+1)
758 X.Draw('f&&same')
759 X.Draw('same')
760 else:
761 # check if node exists
762 if not nav.CheckPath(node): continue
763 nav.cd(node)
764 N = nav.GetCurrentNode()
765 S = N.GetVolume().GetShape()
766 dx,dy,dz = S.GetDX(),S.GetDY(),S.GetDZ()
767 ox,oy,oz = S.GetOrigin()[0],S.GetOrigin()[1],S.GetOrigin()[2]
768 P = {}
769 M = {}
770 if p=='X' and (not any(xNode in node for xNode in xNodes) or 'VetoBar_ver' in node):
771 P['LeftBottom'] = array('d',[-dx+ox,oy,-dz+oz])
772 P['LeftTop'] = array('d',[dx+ox,oy,-dz+oz])
773 P['RightBottom'] = array('d',[-dx+ox,oy,dz+oz])
774 P['RightTop'] = array('d',[dx+ox,oy,dz+oz])
775 elif p=='Y' and 'ver' not in node:
776 P['LeftBottom'] = array('d',[ox,-dy+oy,-dz+oz])
777 P['LeftTop'] = array('d',[ox,dy+oy,-dz+oz])
778 P['RightBottom'] = array('d',[ox,-dy+oy,dz+oz])
779 P['RightTop'] = array('d',[ox,dy+oy,dz+oz])
780 else: continue
781 for C in P:
782 M[C] = array('d',[0,0,0])
783 nav.LocalToMaster(P[C],M[C])
784 h[node+p] = ROOT.TPolyLine()
785 X = h[node+p]
786 c = proj[p]
787 X.SetPoint(0,M['LeftBottom'][2],M['LeftBottom'][c])
788 X.SetPoint(1,M['LeftTop'][2],M['LeftTop'][c])
789 X.SetPoint(2,M['RightTop'][2],M['RightTop'][c])
790 X.SetPoint(3,M['RightBottom'][2],M['RightBottom'][c])
791 X.SetPoint(4,M['LeftBottom'][2],M['LeftBottom'][c])
792 X.SetLineColor(nodes[node_])
793 X.SetLineWidth(1)
794 h['simpleDisplay'].cd(c+1)
795 if any(passNode in node for passNode in passNodes):
796 X.SetFillColorAlpha(nodes[node_], 0.5)
797 X.Draw('f&&same')
798 X.Draw('same')

◆ drawInfo()

2dEventDisplay.drawInfo (   pad,
  k,
  run,
  event,
  timestamp,
  moreEventInfo = [] 
)

Definition at line 1075 of file 2dEventDisplay.py.

1075def drawInfo(pad, k, run, event, timestamp,moreEventInfo=[]):
1076 drawLogo = True
1077 drawText = True
1078 if drawLogo:
1079 padLogo = ROOT.TPad("logo","logo",0.1,0.1,0.2,0.3)
1080 padLogo.SetFillStyle(4000)
1081 padLogo.SetFillColorAlpha(0, 0)
1082 padLogo.Draw()
1083 logo = ROOT.TImage.Open('$SNDSW_ROOT/shipLHC/Large__SND_Logo_black_cut.png')
1084 logo.SetConstRatio(True)
1085 logo.DrawText(0, 0, 'SND', 98)
1086 padLogo.cd()
1087 logo.Draw()
1088 pad.cd(k)
1089
1090 if drawText:
1091 if k==1 or len(moreEventInfo)<5:
1092 runNumber = eventTree.EventHeader.GetRunId()
1093 timestamp_print = False
1094 if not mc and hasattr(eventTree.EventHeader, "GetUTCtimestamp"):
1095 timestamp_print = True
1096 time_event= datetime.utcfromtimestamp(eventTree.EventHeader.GetUTCtimestamp())
1097 padText = ROOT.TPad("info","info",0.19,0.1,0.6,0.3)
1098 padText.SetFillStyle(4000)
1099 padText.Draw()
1100 padText.cd()
1101 textInfo = ROOT.TLatex()
1102 textInfo.SetTextAlign(11)
1103 textInfo.SetTextFont(42)
1104 textInfo.SetTextSize(.15)
1105 textInfo.DrawLatex(0, 0.6, 'SND@LHC Experiment, CERN')
1106 if hasattr(eventTree.EventHeader,'GetEventNumber'): N = eventTree.EventHeader.GetEventNumber()
1107 else: N = event
1108 textInfo.DrawLatex(0, 0.4, 'Run / Event: '+str(run)+' / '+str(N))
1109 if timestamp_print:
1110 textInfo.DrawLatex(0, 0.2, 'Time (GMT): {}'.format(time_event))
1111 pad.cd(k)
1112 elif options.extraInfo:
1113 padText = ROOT.TPad("info","info",0.29,0.12,0.9,0.35)
1114 padText.SetFillStyle(4000)
1115 padText.Draw()
1116 padText.cd()
1117 textInfo = ROOT.TLatex()
1118 textInfo.SetTextAlign(11)
1119 textInfo.SetTextFont(42)
1120 textInfo.SetTextSize(.1)
1121 textInfo.SetTextColor(ROOT.kMagenta+2)
1122 dely = 0.12
1123 ystart = 0.85
1124 for i in range(7):
1125 textInfo.DrawLatex(0.4, 0.9-dely*i, moreEventInfo[i])
1126 pad.cd(k)
1127

◆ drawLegend()

2dEventDisplay.drawLegend (   max_density,
  max_QDC,
  n_legend_points 
)
Draws legend for hit colour

Definition at line 244 of file 2dEventDisplay.py.

244def drawLegend(max_density, max_QDC, n_legend_points):
245 """Draws legend for hit colour"""
246 h['simpleDisplay'].cd(1)
247 n_legend_points = 5
248 padLegScifi = ROOT.TPad("legend","legend",0.4,0.15,0.4+0.25, 0.15+0.25)
249 padLegScifi.SetFillStyle(4000)
250 padLegScifi.Draw()
251 padLegScifi.cd()
252 text_scifi_legend = ROOT.TLatex()
253 text_scifi_legend.SetTextAlign(11)
254 text_scifi_legend.SetTextFont(42)
255 text_scifi_legend.SetTextSize(.15)
256 for i in range(n_legend_points) :
257 if i < (n_legend_points - 1) :
258 text_scifi_legend.DrawLatex((i+0.3)*(1./(n_legend_points+2)), 0.2, "{:d}".format(int(i*max_density/(n_legend_points-1))))
259 text_scifi_legend.DrawLatex((i+0.3)*(1./(n_legend_points+2)), 0., "{:.0f}".format(int(i*max_QDC/(n_legend_points-1))))
260 else :
261 text_scifi_legend.DrawLatex((i+0.3)*(1./(n_legend_points+2)), 0.2, "{:d} SciFi hits/cm".format(int(i*max_density/(n_legend_points-1))))
262 text_scifi_legend.DrawLatex((i+0.3)*(1./(n_legend_points+2)), 0., "{:.0f} QDC units".format(int(i*max_QDC/(n_legend_points-1))))
263
264 h["markerCollection"].append(ROOT.TEllipse((i+0.15)*(1./(n_legend_points+2)), 0.26, 0.05/4, 0.05))
265 h["markerCollection"][-1].SetFillColor(ROOT.TColor.GetPalette()[int(float(i*max_density/(n_legend_points-1))/max_density*(len(ROOT.TColor.GetPalette())-1))])
266 h["markerCollection"][-1].Draw("SAME")
267
268 h["markerCollection"].append(ROOT.TBox((i+0.15)*(1./(n_legend_points+2))-0.05/4 , 0.06 - 0.05, (i+0.15)*(1./(n_legend_points+2))+0.05/4, 0.06 + 0.05))
269 h["markerCollection"][-1].SetFillColor(ROOT.TColor.GetPalette()[int(float(i*max_QDC/(n_legend_points-1))/max_QDC*(len(ROOT.TColor.GetPalette())-1))])
270 h["markerCollection"][-1].Draw("SAME")
271

◆ drawSciFiHits()

2dEventDisplay.drawSciFiHits (   g,
  colour 
)
Takes TGraph g and draws the graphs markers with the TColor given in list colour.

Definition at line 272 of file 2dEventDisplay.py.

272def drawSciFiHits(g, colour):
273 """Takes TGraph g and draws the graphs markers with the TColor given in list colour."""
274 n = g.GetN()
275 # Draw highest density points last
276 sorted_indices = np.argsort(colour)
277 for i_unsorted in range(0, n):
278 i = int(sorted_indices[i_unsorted])
279
280 x = g.GetPointX(i)
281 y = g.GetPointY(i)
282
283 h["markerCollection"].append(ROOT.TEllipse(x, y, 1.5, 1.5))
284 h["markerCollection"][-1].SetLineWidth(0)
285 h["markerCollection"][-1].SetFillColor(colour[i])
286 h["markerCollection"][-1].Draw("SAME")
287

◆ dumpChannels()

2dEventDisplay.dumpChannels (   D = 'Digi_MuFilterHits')

Definition at line 1026 of file 2dEventDisplay.py.

1026def dumpChannels(D='Digi_MuFilterHits'):
1027 X = eval("eventTree."+D)
1028 text = {}
1029 for aHit in X:
1030 side = 'L'
1031 txt = "%8i"%(aHit.GetDetectorID())
1032 for k in range(aHit.GetnSiPMs()*aHit.GetnSides()):
1033 qdc = aHit.GetSignal(k)
1034 if qdc < -900: continue
1035 i = k
1036 if not k<aHit.GetnSiPMs():
1037 i = k-aHit.GetnSiPMs()
1038 if side == 'L':
1039 txt += " | "
1040 side = 'R'
1041 txt+= " %2i:%4.1F "%(i,qdc)
1042 text[aHit.GetDetectorID()] = txt
1043 keys = list(text.keys())
1044 keys.sort()
1045 for k in keys: print(text[k])
1046

◆ dumpVeto()

2dEventDisplay.dumpVeto ( )

Definition at line 814 of file 2dEventDisplay.py.

814def dumpVeto():
815 muHits = {10:[],11:[]}
816 for aHit in eventTree.Digi_MuFilterHits:
817 if not aHit.isValid(): continue
818 s = aHit.GetDetectorID()//10000
819 if s>1: continue
820 p = (aHit.GetDetectorID()//1000)%10
821 bar = (aHit.GetDetectorID()%1000)%60
822 plane = s*10+p
823 muHits[plane].append(aHit)
824 for plane in [10,11]:
825 for aHit in muHits[plane]:
826 S =aHit.GetAllSignals(False,False)
827 txt = ""
828 for x in S:
829 if x[1]>0: txt+=str(x[1])+" "
830 print(plane, (aHit.GetDetectorID()%1000)%60, txt)
831
832# decode MuFilter detID

◆ fillNode()

2dEventDisplay.fillNode (   node,
  color = None 
)

Definition at line 1047 of file 2dEventDisplay.py.

1047def fillNode(node, color=None):
1048 xNodes = {'UpstreamBar', 'VetoBar', 'hor'}
1049 proj = {'X':0,'Y':1}
1050 if color == None :
1051 hcal_color = ROOT.kBlack
1052 veto_color = ROOT.kRed+1
1053 else :
1054 hcal_color = color
1055 veto_color = color
1056 thick = 5
1057 for p in proj:
1058 if node+p in h:
1059 X = h[node+p]
1060 if 'Veto' in node:
1061 color = veto_color
1062 else :
1063 color = hcal_color
1064
1065 if 'Downstream' in node:
1066 thick = 5
1067 c = proj[p]
1068 h[ 'simpleDisplay'].cd(c+1)
1069 X.SetFillColor(color)
1070 X.SetLineColor(color)
1071 X.SetLineWidth(thick)
1072 X.Draw('f&&same')
1073 X.Draw('same')
1074

◆ firstTimeStamp()

2dEventDisplay.firstTimeStamp (   event)

Definition at line 1010 of file 2dEventDisplay.py.

1010def firstTimeStamp(event):
1011 tmin = [1E9,'']
1012 digis = [event.Digi_MuFilterHits,event.Digi_ScifiHits]
1013 for digi in event.Digi_ScifiHits:
1014 dt = digi.GetTime()
1015 if dt<tmin[0]:
1016 tmin[0]=dt
1017 tmin[1]=digi
1018 for digi in event.Digi_MuFilterHits:
1019 for t in digi.GetAllTimes(): # will not give time if QDC<0!
1020 dt = t.second
1021 if dt<tmin[0]:
1022 tmin[0]=dt
1023 tmin[1]=digi
1024 return tmin
1025

◆ getSciFiHitDensity()

2dEventDisplay.getSciFiHitDensity (   g,
  x_range = 0.5 
)
Takes ROOT TGraph g and returns array with number of hits within x_range cm of each hit.

Definition at line 229 of file 2dEventDisplay.py.

229def getSciFiHitDensity(g, x_range=0.5):
230 """Takes ROOT TGraph g and returns array with number of hits within x_range cm of each hit."""
231 ret = []
232 for i in range(g.GetN()):
233 x_i = g.GetPointX(i)
234 y_i = g.GetPointY(i)
235 density = 0
236 for j in range(g.GetN()):
237 x_j = g.GetPointX(j)
238 y_j = g.GetPointY(j)
239 if ((x_i - x_j)**2 + (y_i - y_j)**2) <= x_range**2:
240 density += 1
241 ret.append(density)
242 return ret
243

◆ goodEvent()

2dEventDisplay.goodEvent (   event)

Definition at line 162 of file 2dEventDisplay.py.

162def goodEvent(event):
163# can be replaced by any user selection
164 stations = {'Scifi':{},'Mufi':{}}
165 if event.Digi_ScifiHits.GetEntries()>25: return False
166 for d in event.Digi_ScifiHits:
167 stations['Scifi'][d.GetDetectorID()//1000000] = 1
168 for d in event.Digi_MuFilterHits:
169 plane = d.GetDetectorID()//1000
170 stations['Mufi'][plane] = 1
171 totalN = len(stations['Mufi'])+len(stations['Scifi'])
172 if len(stations['Scifi'])>4 and len(stations['Mufi'])>6: return True
173 else: False
174 if onlyScifi and len(stations['Scifi'])>Nlimit: return True
175 elif not onlyScifi and totalN > Nlimit: return True
176 else: return False
177

◆ loopEvents()

2dEventDisplay.loopEvents (   start = 0,
  save = False,
  goodEvents = False,
  withTrack = -1,
  withHoughTrack = -1,
  nTracks = 0,
  minSipmMult = 1,
  withTiming = False,
  option = None,
  Setup = '',
  verbose = 0,
  auto = False,
  hitColour = None 
)

Definition at line 288 of file 2dEventDisplay.py.

302 ):
303 if 'simpleDisplay' not in h: ut.bookCanvas(h,key='simpleDisplay',title='simple event display',nx=1200,ny=1600,cx=1,cy=2)
304 h['simpleDisplay'].cd(1)
305 zStart = 250. # TI18 coordinate system
306 if Setup == 'H6': zStart = 60.
307 if Setup == 'TP': zStart = -50. # old coordinate system with origin in middle of target
308 if 'xz' in h:
309 h.pop('xz').Delete()
310 h.pop('yz').Delete()
311 else:
312 h['xmin'],h['xmax'] = -100.,10.
313 h['ymin'],h['ymax'] = -30.,80.
314 h['zmin'],h['zmax'] = zStart,zStart+350.
315 for d in ['xmin','xmax','ymin','ymax','zmin','zmax']: h['c'+d]=h[d]
316 ut.bookHist(h,'xz','; z [cm]; x [cm]',500,h['czmin'],h['czmax'],100,h['cxmin'],h['cxmax'])
317 ut.bookHist(h,'yz','; z [cm]; y [cm]',500,h['czmin'],h['czmax'],100,h['cymin'],h['cymax'])
318
319 proj = {1:'xz',2:'yz'}
320 h['xz'].SetStats(0)
321 h['yz'].SetStats(0)
322
323 N = -1
324 Tprev = -1
325 A,B = ROOT.TVector3(),ROOT.TVector3()
326 ptext={0:' Y projection',1:' X projection'}
327 text = ROOT.TLatex()
328 event = eventTree
329 OT = sink.GetOutTree()
330 if withTrack==0 or withHoughTrack==0: OT = eventTree
331 if type(start) == type(1):
332 s = start
333 e = event.GetEntries()
334 else:
335 s = 0
336 e = len(start)
337 for N in range(s,e):
338 if type(start) == type(1): rc = event.GetEvent(N)
339 else: rc = event.GetEvent(start[N])
340 if goodEvents and not goodEvent(event): continue
341 nHoughtracks = 0
342 OT.Reco_MuonTracks = ROOT.TObjArray(10)
343 if withHoughTrack > 0:
344 rc = source.GetInTree().GetEvent(N)
345 # Delete SndlhcMuonReco kalman tracks container
346 for ht_task in HT_tasks.values():
347 ht_task.kalman_tracks.Delete()
348 if withHoughTrack==1:
349 HT_tasks['muon_reco_task_Sf'].Exec(0)
350 HT_tasks['muon_reco_task_DS'].Exec(0)
351 elif withHoughTrack==2:
352 HT_tasks['muon_reco_task_Sf'].Exec(0)
353 elif withHoughTrack==3:
354 HT_tasks['muon_reco_task_DS'].Exec(0)
355 elif withHoughTrack==4:
356 HT_tasks['muon_reco_task_nuInt'].Exec(0)
357 # Save the tracks in OT.Reco_MuonTracks object
358 for ht_task in HT_tasks.values():
359 for trk in ht_task.kalman_tracks:
360 OT.Reco_MuonTracks.Add(trk)
361 nHoughtracks = OT.Reco_MuonTracks.GetEntries()
362 if nHoughtracks>0: print('number of tracks by HT:', nHoughtracks)
363
364 if withTrack > 0:
365 # Delete SndlhcTracking fitted tracks container
366 trackTask.fittedTracks.Delete()
367 if withTrack==1:
368 trackTask.ExecuteTask("ScifiDS")
369 elif withTrack==2:
370 trackTask.ExecuteTask("Scifi")
371 elif withTrack==3:
372 trackTask.ExecuteTask("DS")
373 # Save found tracks
374 for trk in trackTask.fittedTracks:
375 OT.Reco_MuonTracks.Add(trk)
376 ntracks = len(OT.Reco_MuonTracks) - nHoughtracks
377 if ntracks>0: print('number of tracks by ST:', ntracks)
378 nAlltracks = len(OT.Reco_MuonTracks)
379 if nAlltracks<nTracks: continue
380
381 if verbose>0:
382 for aTrack in OT.Reco_MuonTracks:
383 print(aTrack.__repr__())
384 mom = aTrack.getFittedState().getMom()
385 pos = aTrack.getFittedState().getPos()
386 mom.Print()
387 pos.Print()
388 T,dT = 0,0
389 T = event.EventHeader.GetEventTime()
390 runId = eventTree.EventHeader.GetRunId()
391 if Tprev >0: dT = T-Tprev
392 Tprev = T
393 if nAlltracks > 0: print('total number of tracks: ', nAlltracks)
394
395 digis = []
396 if event.FindBranch("Digi_ScifiHits"): digis.append(event.Digi_ScifiHits)
397 if event.FindBranch("Digi_MuFilterHits"): digis.append(event.Digi_MuFilterHits)
398 if event.FindBranch("Digi_MuFilterHit"): digis.append(event.Digi_MuFilterHit)
399 empty = True
400 for x in digis:
401 if x.GetEntries()>0:
402 if empty: print( "event -> %i"%N)
403 empty = False
404 if empty: continue
405 h['hitCollectionX']= {'Veto':[0,ROOT.TGraphErrors()],'Scifi':[0,ROOT.TGraphErrors()],'DS':[0,ROOT.TGraphErrors()]}
406 h['hitCollectionY']= {'Veto':[0,ROOT.TGraphErrors()],'Scifi':[0,ROOT.TGraphErrors()],'US':[0,ROOT.TGraphErrors()],'DS':[0,ROOT.TGraphErrors()]}
407 if hitColour:
408 h['hitColourX'] = {'Veto': [], 'Scifi': [], 'DS' : []}
409 h['hitColourY'] = {'Veto': [], 'Scifi' : [], 'US' : [], 'DS' : []}
410 h["markerCollection"] = []
411
412 h['firedChannelsX']= {'Veto':[0,0,0,0],'Scifi':[0,0,0],'DS':[0,0,0]}
413 h['firedChannelsY']= {'Veto':[0,0,0,0],'Scifi':[0,0,0],'US':[0,0,0,0],'DS':[0,0,0,0]}
414 systems = {1:'Veto',2:'US',3:'DS',0:'Scifi'}
415 for collection in ['hitCollectionX','hitCollectionY']:
416 for c in h[collection]:
417 rc=h[collection][c][1].SetName(c)
418 rc=h[collection][c][1].Set(0)
419
420 if hitColour:
421 h["markerCollection"] = []
422
423 #Do we still use these lines? Seems no.
424 #And for events having all negative QDCs minT[1] is returned empty and the display crashes.
425 #dTs = "%5.2Fns"%(dT/u.snd_freq*1E9)
426 # find detector which triggered
427 #minT = firstTimeStamp(event)
428 #dTs+= " " + str(minT[1].GetDetectorID())
429 for p in proj:
430 rc = h[ 'simpleDisplay'].cd(p)
431 h[proj[p]].Draw('b')
432
433 if withDetector:
434 drawDetectors()
435 for D in digis:
436 for digi in D:
437 detID = digi.GetDetectorID()
438 sipmMult = 1
439 if digi.GetName() == 'MuFilterHit':
440 system = digi.GetSystem()
441 geo.modules['MuFilter'].GetPosition(detID,A,B)
442 sipmMult = len(digi.GetAllSignals(False,False))
443 if sipmMult<minSipmMult and (system==1 or system==2): continue
444 else:
445 geo.modules['Scifi'].GetSiPMPosition(detID,A,B)
446 system = 0
447 curPath = nav.GetPath()
448 tmp = curPath.rfind('/')
449 nav.cd(curPath[:tmp])
450 first = True
451 for X in [A, B]:
452 if not first and not with2Points:
453 continue
454 first = False
455 globA, locA = array('d', [X[0], X[1], X[2]]), array('d', [X[0], X[1], X[2]])
456 if trans2local:
457 nav.MasterToLocal(globA, locA)
458 Z = X[2]
459 if digi.isVertical():
460 collection = 'hitCollectionX'
461 Y = locA[0]
462 sY = detSize[system][0]
463 else:
464 collection = 'hitCollectionY'
465 Y = locA[1]
466 sY = detSize[system][1]
467 c = h[collection][systems[system]]
468 rc = c[1].SetPoint(c[0], Z, Y)
469 rc = c[1].SetPointError(c[0], detSize[system][2], sY)
470 c[0] += 1
471 if hitColour == "q" :
472 max_QDC = 200 * 16
473 this_qdc = 0
474 ns = max(1,digi.GetnSides())
475 for side in range(ns):
476 for m in range(digi.GetnSiPMs()):
477 qdc = digi.GetSignal(m+side*digi.GetnSiPMs())
478 if not qdc < 0 :
479 this_qdc += qdc
480 if this_qdc > max_QDC :
481 this_qdc = max_QDC
482 fillNode(curPath, ROOT.TColor.GetPalette()[int(this_qdc/max_QDC*(len(ROOT.TColor.GetPalette())-1))])
483 else :
484 fillNode(curPath)
485
486 if digi.isVertical(): F = 'firedChannelsX'
487 else: F = 'firedChannelsY'
488 ns = max(1,digi.GetnSides())
489 for side in range(ns):
490 for m in range(digi.GetnSiPMs()):
491 qdc = digi.GetSignal(m+side*digi.GetnSiPMs())
492 if qdc < 0 and qdc > -900: h[F][systems[system]][1]+=1
493 elif not qdc<0:
494 h[F][systems[system]][0]+=1
495 if len(h[F][systems[system]]) < 2+side: continue
496 h[F][systems[system]][2+side]+=qdc
497 h['hitCollectionY']['Scifi'][1].SetMarkerColor(ROOT.kBlue+2)
498 h['hitCollectionX']['Scifi'][1].SetMarkerColor(ROOT.kBlue+2)
499
500 if hitColour == "q" :
501 for orientation in ['X', 'Y']:
502 max_density = 40
503 density = np.clip(0, max_density, getSciFiHitDensity(h['hitCollection'+orientation]['Scifi'][1]))
504 for i in range(h['hitCollection'+orientation]['Scifi'][1].GetN()) :
505 h['hitColour'+orientation]['Scifi'].append(ROOT.TColor.GetPalette()[int(float(density[i])/max_density*(len(ROOT.TColor.GetPalette())-1))])
506
507 drawLegend(max_density, max_QDC, 5)
508
509 k = 1
510 moreEventInfo = []
511
512
513 for collection in ['hitCollectionX','hitCollectionY']:
514 h['simpleDisplay'].cd(k)
515 drawInfo(h['simpleDisplay'], k, runId, N, T)
516 k+=1
517 for c in h[collection]:
518 F = collection.replace('hitCollection','firedChannels')
519 pj = collection.split('ion')[1]
520 if pj =="X" or c=="Scifi":
521 atext = "%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])
522 else:
523 atext = "%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])
524 moreEventInfo.append(atext)
525 print(atext)
526 if h[collection][c][1].GetN()<1: continue
527 if c=='Scifi':
528 if hitColour not in ["q"] :
529 h[collection][c][1].SetMarkerStyle(20)
530 h[collection][c][1].SetMarkerSize(1.5)
531 rc=h[collection][c][1].Draw('sameP')
532 h['display:'+c]=h[collection][c][1]
533 elif hitColour == "q" :
534 drawSciFiHits(h[collection][c][1], h['hitColour'+collection[-1]][c])
535
536 T0 = eventTree.EventHeader.GetEventTime()
537 if type(start) == type(1): rc = event.GetEvent(N-1)
538 else: rc = event.GetEvent(start[N]-1)
539 delTM1 = eventTree.EventHeader.GetEventTime() - T0
540 if type(start) == type(1): rc = event.GetEvent(N+1)
541 else: rc = event.GetEvent(start[N]+1)
542 delTP1 = eventTree.EventHeader.GetEventTime() - T0
543 atext = "timing info, prev event: %6i cc next event: %6i cc"%(delTM1,delTP1)
544 moreEventInfo.append(atext)
545 if type(start) == type(1): rc = event.GetEvent(N)
546 else: rc = event.GetEvent(start[N])
547
548 k = 1
549 for collection in ['hitCollectionX','hitCollectionY']:
550 h['simpleDisplay'].cd(k)
551 drawInfo(h['simpleDisplay'], k, runId, N, T,moreEventInfo)
552 k+=1
553
554 h['simpleDisplay'].Update()
555 if withTiming: timingOfEvent()
556 addTrack(OT)
557
558 if option == "2tracks":
559 rc = twoTrackEvent(sMin=10,dClMin=7,minDistance=0.5,sepDistance=0.5)
560 if not rc: rc = twoTrackEvent(sMin=10,dClMin=7,minDistance=0.5,sepDistance=0.75)
561 if not rc: rc = twoTrackEvent(sMin=10,dClMin=7,minDistance=0.5,sepDistance=1.0)
562 if not rc: rc = twoTrackEvent(sMin=10,dClMin=7,minDistance=0.5,sepDistance=1.75)
563 if not rc: rc = twoTrackEvent(sMin=10,dClMin=7,minDistance=0.5,sepDistance=2.5)
564 if not rc: rc = twoTrackEvent(sMin=10,dClMin=7,minDistance=0.5,sepDistance=3.0)
565
566 if verbose>0: dumpChannels()
567 userProcessing(event)
568
569 if save: h['simpleDisplay'].Print('{:0>2d}-event_{:04d}'.format(runId,N)+'.png')
570 if auto:
571 h['simpleDisplay'].Print(options.storePic+str(runId)+'-event_'+str(event.EventHeader.GetEventNumber())+'.png')
572 if not auto:
573 rc = input("hit return for next event or p for print or q for quit: ")
574 if rc=='p':
575 h['simpleDisplay'].Print(options.storePic+str(runId)+'-event_'+str(event.EventHeader.GetEventNumber())+'.png')
576 elif rc == 'q':
577 break
578 else:
579 eventComment[f"{runId}-event_{event.EventHeader.GetEventNumber()}"] = rc
580 if save: os.system("convert -delay 60 -loop 0 event*.png animated.gif")
581

◆ MuFilter_PlaneBars()

2dEventDisplay.MuFilter_PlaneBars (   detID)

Definition at line 833 of file 2dEventDisplay.py.

833def MuFilter_PlaneBars(detID):
834 s = detID//10000
835 l = (detID%10000)//1000 # plane number
836 bar = (detID%1000)
837 if s>2:
838 l=2*l
839 if bar>59:
840 bar=bar-60
841 if l<6: l+=1
842 return {'station':s,'plane':l,'bar':bar}
843

◆ mufiNoise()

2dEventDisplay.mufiNoise ( )

Definition at line 967 of file 2dEventDisplay.py.

967def mufiNoise():
968 for s in range(1,4):
969 ut.bookHist(h,'mult'+str(s),'hit mult for system '+str(s),100,-0.5,99.5)
970 ut.bookHist(h,'multb'+str(s),'hit mult per bar for system '+str(s),20,-0.5,19.5)
971 ut.bookHist(h,'res'+str(s),'residual system '+str(s),20,-10.,10.)
972 OT = sink.GetOutTree()
973 N=0
974 for event in eventTree:
975 N+=1
976 if N%1000==0: print(N)
977 OT.Reco_MuonTracks.Delete()
978 rc = trackTask.ExecuteTask("Scifi")
979 for aTrack in OT.Reco_MuonTracks:
980 mom = aTrack.getFittedState().getMom()
981 pos = aTrack.getFittedState().getPos()
982 if not aTrack.getFitStatus().isFitConverged(): continue
983 mult = {1:0,2:0,3:0}
984 for aHit in eventTree.Digi_MuFilterHits:
985 if not aHit.isValid(): continue
986 s = aHit.GetDetectorID()//10000
987 S = aHit.GetAllSignals(False,False)
988 rc = h['multb'+str(s)].Fill(len(S))
989 mult[s]+=len(S)
990 if s==2 or s==1:
991 geo.modules['MuFilter'].GetPosition(aHit.GetDetectorID(),A,B)
992 y = (A[1]+B[1])/2.
993 zEx = (A[2]+B[2])/2.
994 lam = (zEx-pos.z())/mom.z()
995 Ey = pos.y()+lam*mom.y()
996 rc = h['res'+str(s)].Fill(Ey-y)
997 for s in mult: rc = h['mult'+str(s)].Fill(mult[s])
998 ut.bookCanvas(h,'noise','',1200,1200,2,3)
999 for s in range(1,4):
1000 tc = h['noise'].cd(s*2-1)
1001 tc.SetLogy(1)
1002 h['mult'+str(s)].Draw()
1003 h['noise'].cd(s*2)
1004 h['multb'+str(s)].Draw()
1005 ut.bookCanvas(h,'res','',600,1200,1,3)
1006 for s in range(1,4):
1007 tc = h['res'].cd(s)
1008 h['res'+str(s)].Draw()
1009

◆ pyExit()

2dEventDisplay.pyExit ( )

Definition at line 19 of file 2dEventDisplay.py.

19def pyExit():
20 "unfortunately need as bypassing an issue related to use xrootd"
21 os.system('kill '+str(os.getpid()))

◆ timingOfEvent()

2dEventDisplay.timingOfEvent (   makeCluster = False,
  debug = False 
)

Definition at line 921 of file 2dEventDisplay.py.

921def timingOfEvent(makeCluster=False,debug=False):
922 ut.bookHist(h,'evTimeDS','cor time of hits;[ns]',70,-5.,30)
923 ut.bookHist(h,'evTimeScifi','cor time of hits blue DS red Scifi;[ns]',70,-5.,30)
924 ut.bookCanvas(h,'tevTime','cor time of hits',1024,768,1,1)
925 h['evTimeScifi'].SetLineColor(ROOT.kRed)
926 h['evTimeDS'].SetLineColor(ROOT.kBlue)
927 h['evTimeScifi'].SetStats(0)
928 h['evTimeDS'].SetStats(0)
929 h['evTimeScifi'].SetLineWidth(2)
930 h['evTimeDS'].SetLineWidth(2)
931 if makeCluster: trackTask.scifiCluster()
932 meanXY = {}
933 for siCl in trackTask.clusScifi:
934 detID = siCl.GetFirst()
935 s = detID//1000000
936 isVertical = detID%1000000//100000
937 siCl.GetPosition(A,B)
938 z=(A[2]+B[2])/2.
939 pos = (A[1]+B[1])/2.
940 L = abs(A[0]-B[0])/2.
941 if isVertical:
942 pos = (A[0]+B[0])/2.
943 L = abs(A[1]-B[1])/2.
944 corTime = geo.modules['Scifi'].GetCorrectedTime(detID, siCl.GetTime(), 0) - (z-firstScifi_z)/u.speedOfLight
945 h['evTimeScifi'].Fill(corTime)
946 if debug: print(detID,corTime,pos)
947 for aHit in eventTree.Digi_MuFilterHits:
948 detID = aHit.GetDetectorID()
949 if not detID//10000==3: continue
950 if aHit.isVertical(): nmax = 1
951 else: nmax=2
952 geo.modules['MuFilter'].GetPosition(detID,A,B)
953 z=(A[2]+B[2])/2.
954 pos = (A[1]+B[1])/2.
955 L = abs(A[0]-B[0])/2.
956 if isVertical:
957 pos = (A[0]+B[0])/2.
958 L = abs(A[1]-B[1])/2.
959 for i in range(nmax):
960 corTime = geo.modules['MuFilter'].GetCorrectedTime(detID, i, aHit.GetTime(i)*u.snd_TDC2ns, 0)- (z-firstScifi_z)/u.speedOfLight
961 h['evTimeDS'].Fill(corTime)
962 if debug: print(detID,i,corTime,pos)
963 tc=h['tevTime'].cd()
964 h['evTimeScifi'].Draw()
965 h['evTimeDS'].Draw('same')
966 tc.Update()

◆ twoTrackEvent()

2dEventDisplay.twoTrackEvent (   sMin = 10,
  dClMin = 7,
  minDistance = 1.5,
  sepDistance = 0.5 
)

Definition at line 632 of file 2dEventDisplay.py.

632def twoTrackEvent(sMin=10,dClMin=7,minDistance=1.5,sepDistance=0.5):
633 trackTask.clusScifi.Clear()
634 trackTask.scifiCluster()
635 clusters = trackTask.clusScifi
636 sortedClusters={}
637 for aCl in clusters:
638 so = aCl.GetFirst()//100000
639 if not so in sortedClusters: sortedClusters[so]=[]
640 sortedClusters[so].append(aCl)
641 if len(sortedClusters)<sMin: return False
642 M=0
643 for x in sortedClusters:
644 if len(sortedClusters[x]) == 2: M+=1
645 if M < dClMin: return False
646 seeds = {}
647 S = [-1,-1]
648 for o in range(0,2):
649# same procedure for both projections
650# take seeds from from first station with 2 clusters
651 for s in range(1,6):
652 x = 10*s+o
653 if x in sortedClusters:
654 if len(sortedClusters[x])==2:
655 sortedClusters[x][0].GetPosition(A,B)
656 if o%2==1: pos0 = (A[0]+B[0])/2
657 else: pos0 = (A[1]+B[1])/2
658 sortedClusters[x][1].GetPosition(A,B)
659 if o%2==1: pos1 = (A[0]+B[0])/2
660 else: pos1 = (A[1]+B[1])/2
661 if abs(pos0-pos1) > minDistance:
662 S[o] = s
663 break
664 if S[o]<0: break # no seed found
665 seeds[o]={}
666 k = -1
667 for c in sortedClusters[S[o]*10+o]:
668 k += 1
669 c.GetPosition(A,B)
670 if o%2==1: pos = (A[0]+B[0])/2
671 else: pos = (A[1]+B[1])/2
672 seeds[o][k] = [[c,pos]]
673 if k!=1: continue
674 if abs(seeds[o][0][0][1] - seeds[o][1][0][1]) < sepDistance: continue
675 for s in range(1,6):
676 if s==S[o]: continue
677 for c in sortedClusters[s*10+o]:
678 c.GetPosition(A,B)
679 if o%2==1: pos = (A[0]+B[0])/2
680 else: pos = (A[1]+B[1])/2
681 for k in range(2):
682 if abs(seeds[o][k][0][1] - pos) < sepDistance:
683 seeds[o][k].append([c,pos])
684 if S[0]<0 or S[1]<0:
685 passed = False
686 else:
687 passed = True
688 for o in range(0,2):
689 for k in range(2):
690 if len(seeds[o][k])<3:
691 passed = False
692 break
693 print(passed)
694 if passed:
695 tracks = []
696 for k in range(2):
697 # arbitrarly combine X and Y of combination 0
698 n = 0
699 hitlist = {}
700 for o in range(0,2):
701 for X in seeds[o][k]:
702 hitlist[n] = X[0]
703 n+=1
704 theTrack = trackTask.fitTrack(hitlist)
705 if not hasattr(theTrack,"getFittedState"):
706 validTrack = False
707 continue
708 fitStatus = theTrack.getFitStatus()
709 if not fitStatus.isFitConverged():
710 theTrack.Delete()
711 else:
712 tracks.append(theTrack)
713 if len(tracks)==2:
714 OT = sink.GetOutTree()
715 OT.Reco_MuonTracks = tracks
716 addTrack(OT,True)
717 return passed
718

◆ userProcessing()

2dEventDisplay.userProcessing (   event)
User hook to add action after event is plotted.

Useful for adding special objects to the display for example.
An example for display of 3-track events with external reco:

```python
trackTask.multipleTrackCandidates(
    nMaxCl=8, dGap=0.2, dMax=0.8, dMax3=0.8, ovMax=1, doublet=True, debug=False
)
n3D = [0, 0]
for p in range(2):
    tc = h['simpleDisplay'].cd(-p + 2)
    for trackId in trackTask.multipleTrackStore['trackCand'][p]:
        if trackId < 100000 and not trackTask.multipleTrackStore['doublet']:
            continue
        if trackId in trackTask.multipleTrackStore['cloneCand'][p]:
            continue
        n3D[p] += 1
        rc = trackTask.multipleTrackStore['trackCand'][p][trackId].Fit('pol1', 'SQ')
        trackTask.multipleTrackStore['trackCand'][p][trackId].Draw('same')
    tc.Update()
print('Number of full tracks', n3D)
return True
```

Definition at line 178 of file 2dEventDisplay.py.

178def userProcessing(event):
179 '''User hook to add action after event is plotted.
180
181 Useful for adding special objects to the display for example.
182 An example for display of 3-track events with external reco:
183
184 ```python
185 trackTask.multipleTrackCandidates(
186 nMaxCl=8, dGap=0.2, dMax=0.8, dMax3=0.8, ovMax=1, doublet=True, debug=False
187 )
188 n3D = [0, 0]
189 for p in range(2):
190 tc = h['simpleDisplay'].cd(-p + 2)
191 for trackId in trackTask.multipleTrackStore['trackCand'][p]:
192 if trackId < 100000 and not trackTask.multipleTrackStore['doublet']:
193 continue
194 if trackId in trackTask.multipleTrackStore['cloneCand'][p]:
195 continue
196 n3D[p] += 1
197 rc = trackTask.multipleTrackStore['trackCand'][p][trackId].Fit('pol1', 'SQ')
198 trackTask.multipleTrackStore['trackCand'][p][trackId].Draw('same')
199 tc.Update()
200 print('Number of full tracks', n3D)
201 return True
202 ```
203 '''
204 return
205

◆ zoom()

2dEventDisplay.zoom (   xmin = None,
  xmax = None,
  ymin = None,
  ymax = None,
  zmin = None,
  zmax = None 
)

Definition at line 799 of file 2dEventDisplay.py.

799def zoom(xmin=None,xmax=None,ymin=None,ymax=None,zmin=None,zmax=None):
800# zoom() will reset to default setting
801 for d in ['xmin','xmax','ymin','ymax','zmin','zmax']:
802 if eval(d): h['c'+d]=eval(d)
803 else: h['c'+d]=h[d]
804 h['xz'].GetXaxis().SetRangeUser(h['czmin'],h['czmax'])
805 h['yz'].GetXaxis().SetRangeUser(h['czmin'],h['czmax'])
806 h['xz'].GetYaxis().SetRangeUser(h['cxmin'],h['cxmax'])
807 h['yz'].GetYaxis().SetRangeUser(h['cymin'],h['cymax'])
808 tc = h['simpleDisplay'].cd(1)
809 tc.Update()
810 tc = h['simpleDisplay'].cd(2)
811 tc.Update()
812 h['simpleDisplay'].Update()
813

Variable Documentation

◆ A

2dEventDisplay.A

Definition at line 25 of file 2dEventDisplay.py.

◆ B

2dEventDisplay.B

Definition at line 25 of file 2dEventDisplay.py.

◆ default

2dEventDisplay.default

Definition at line 33 of file 2dEventDisplay.py.

◆ dest

2dEventDisplay.dest

Definition at line 32 of file 2dEventDisplay.py.

◆ detSize

dict 2dEventDisplay.detSize = {}

Definition at line 61 of file 2dEventDisplay.py.

◆ Digi_MuFilterHits

2dEventDisplay.Digi_MuFilterHits

Definition at line 142 of file 2dEventDisplay.py.

◆ eventComment

dict 2dEventDisplay.eventComment = {}

Definition at line 27 of file 2dEventDisplay.py.

◆ eventTree

2dEventDisplay.eventTree = f.cbmsim

Definition at line 91 of file 2dEventDisplay.py.

◆ f

2dEventDisplay.f = ROOT.TFile.Open(options.path+'sndsw_raw_'+str(options.runNumber).zfill(6)+'.root')

Definition at line 86 of file 2dEventDisplay.py.

◆ False

2dEventDisplay.False

Definition at line 33 of file 2dEventDisplay.py.

◆ fg

2dEventDisplay.fg = ROOT.TFile.Open(options.server+options.p+"RunInfodict.root")

Definition at line 48 of file 2dEventDisplay.py.

◆ firstScifi_z

int 2dEventDisplay.firstScifi_z = 300 * u.cm

Definition at line 74 of file 2dEventDisplay.py.

◆ FSdict

2dEventDisplay.FSdict = pkl.load('FSdict')

Definition at line 151 of file 2dEventDisplay.py.

◆ fsdict

bool 2dEventDisplay.fsdict = False

Definition at line 153 of file 2dEventDisplay.py.

◆ geo

2dEventDisplay.geo = SndlhcGeo.GeoInterface(options.geoFile)

Definition at line 55 of file 2dEventDisplay.py.

◆ h

dict 2dEventDisplay.h = {}

Definition at line 29 of file 2dEventDisplay.py.

◆ help

2dEventDisplay.help

Definition at line 32 of file 2dEventDisplay.py.

◆ HT_tasks

dict 2dEventDisplay.HT_tasks
Initial value:
1= {'muon_reco_task_Sf':SndlhcMuonReco.MuonReco(),
2 'muon_reco_task_DS':SndlhcMuonReco.MuonReco(),
3 'muon_reco_task_nuInt':SndlhcMuonReco.MuonReco()}

Definition at line 104 of file 2dEventDisplay.py.

◆ int

2dEventDisplay.int

Definition at line 32 of file 2dEventDisplay.py.

◆ ioman

2dEventDisplay.ioman = ROOT.FairRootManager.Instance()

Definition at line 83 of file 2dEventDisplay.py.

◆ logger

2dEventDisplay.logger = ROOT.FairLogger.GetLogger()

Definition at line 76 of file 2dEventDisplay.py.

◆ lsOfGlobals

2dEventDisplay.lsOfGlobals = ROOT.gROOT.GetListOfGlobals()

Definition at line 57 of file 2dEventDisplay.py.

◆ mc

2dEventDisplay.mc = False

Definition at line 72 of file 2dEventDisplay.py.

◆ mi

2dEventDisplay.mi = geo.snd_geo.MuFilter

Definition at line 64 of file 2dEventDisplay.py.

◆ nav

2dEventDisplay.nav = ROOT.gGeoManager.GetCurrentNavigator()

Definition at line 144 of file 2dEventDisplay.py.

◆ Nlimit

int 2dEventDisplay.Nlimit = 4

Definition at line 159 of file 2dEventDisplay.py.

◆ onlyScifi

bool 2dEventDisplay.onlyScifi = False

Definition at line 160 of file 2dEventDisplay.py.

◆ options

2dEventDisplay.options = parser.parse_args()

Definition at line 43 of file 2dEventDisplay.py.

◆ OT

2dEventDisplay.OT = sink.GetOutTree()

Definition at line 131 of file 2dEventDisplay.py.

◆ outFile

2dEventDisplay.outFile = ROOT.TMemFile('dummy','CREATE')

Definition at line 98 of file 2dEventDisplay.py.

◆ parser

2dEventDisplay.parser = ArgumentParser()

Definition at line 31 of file 2dEventDisplay.py.

◆ pkl

2dEventDisplay.pkl = Unpickler(fg)

Definition at line 49 of file 2dEventDisplay.py.

◆ required

2dEventDisplay.required

Definition at line 32 of file 2dEventDisplay.py.

◆ run

2dEventDisplay.run = ROOT.FairRunAna()

Definition at line 82 of file 2dEventDisplay.py.

◆ runId

str 2dEventDisplay.runId = 'sim'

Definition at line 92 of file 2dEventDisplay.py.

◆ runInfo

2dEventDisplay.runInfo = False

Definition at line 46 of file 2dEventDisplay.py.

◆ runNumber

2dEventDisplay.runNumber = eventTree.EventHeader.GetRunId()

Definition at line 148 of file 2dEventDisplay.py.

◆ si

2dEventDisplay.si = geo.snd_geo.Scifi

Definition at line 62 of file 2dEventDisplay.py.

◆ sink

2dEventDisplay.sink = ROOT.FairRootFileSink(outFile)

Definition at line 101 of file 2dEventDisplay.py.

◆ source

2dEventDisplay.source = ROOT.FairFileSource(f)

Definition at line 99 of file 2dEventDisplay.py.

◆ storePic

2dEventDisplay.storePic

Definition at line 44 of file 2dEventDisplay.py.

◆ trackTask

2dEventDisplay.trackTask = SndlhcTracking.Tracking()

Definition at line 111 of file 2dEventDisplay.py.

◆ trans2local

bool 2dEventDisplay.trans2local = False

Definition at line 45 of file 2dEventDisplay.py.

◆ type

2dEventDisplay.type

Definition at line 32 of file 2dEventDisplay.py.

◆ vetoXdim

2dEventDisplay.vetoXdim

Definition at line 65 of file 2dEventDisplay.py.

◆ with2Points

bool 2dEventDisplay.with2Points = False

Definition at line 71 of file 2dEventDisplay.py.

◆ withDetector

bool 2dEventDisplay.withDetector = True

Definition at line 70 of file 2dEventDisplay.py.

◆ xrdb

2dEventDisplay.xrdb = ROOT.FairRuntimeDb.instance()

Definition at line 116 of file 2dEventDisplay.py.