539 if event.EventHeader.GetRunId() < 6204
and event.EventHeader.GetRunId() > 5480: vetoHitsFromPrev = 5
541 N1 = event.GetReadEntry()
542 Tcurrent = event.EventHeader.GetEventTime()
549 if dT > vetoHitsFromPrev:
continue
550 rc = event.GetEvent(N1-1)
552 for aHit
in event.Digi_MuFilterHits:
553 Minfo = self.
M.MuFilter_PlaneBars(aHit.GetDetectorID())
554 s,l,bar = Minfo[
'station'],Minfo[
'plane'],Minfo[
'bar']
555 if s==2
and j==0: USQDC += aHit.SumOfSignals()[
'Sum']
557 X = aHit.GetAllSignals()
558 if len(X)<5:
continue
559 vetoHits.append(aHit.GetDetectorID())
560 if prevAdded
and N1>1:
561 rc = event.GetEvent(N1-2)
562 Tprevprev = event.EventHeader.GetEventTime()
563 dT = abs(Tcurrent-Tprevprev)
564 if prevAdded: event.GetEvent(N1)
566 if dT < self.
deadTime and dT > vetoHitsFromPrev:
575 for theTrack
in self.
M.Reco_MuonTracks:
577 fitStatus = theTrack.getFitStatus()
578 if not fitStatus.isFitConverged():
continue
579 if theTrack.GetUniqueID()==1: ScifiTracks.append(k)
580 if theTrack.GetUniqueID()==3: MufiTracks.append(k)
581 if len(MufiTracks)==0:
return
583 xExTag, yExTag = -10000,-10000
584 for kMu
in MufiTracks:
585 theTrack = self.
M.Reco_MuonTracks[kMu]
586 fstate = theTrack.getFittedState()
587 posT,momT = fstate.getPos(),fstate.getMom()
588 slopeXT = momT.X()/momT.Z()
589 slopeYT = momT.Y()/momT.Z()
590 if not abs(slopeXT)<0.1
or not abs(slopeYT)<0.1:
continue
591 lam = (self.
zEx-posT.z())/momT.z()
592 yExTag = posT.y()+lam*momT.y()
593 xExTag = posT.x()+lam*momT.x()
596 for detID
in vetoHits:
599 lam = (self.
zExVeto-posT.z())/momT.z()
600 xExV,yExV = posT.x()+lam*momT.x(),posT.y()+lam*momT.y()
602 uCrossv= (B-A).Cross(momT)
603 doca = pq.Dot(uCrossv)/uCrossv.Mag()
604 if abs(doca)<self.
res:
608 rc = h[
'DStag'].Fill(xExTag,yExTag)
609 for kSc
in ScifiTracks:
610 scifiTrack = self.
M.Reco_MuonTracks[kSc]
611 fstate = scifiTrack.getFittedState()
612 pos,mom = fstate.getPos(),fstate.getMom()
613 lam = (self.
zEx-pos.z())/mom.z()
614 yEx = pos.y()+lam*mom.y()
615 xEx = pos.x()+lam*mom.x()
618 rc = h[
'Xdx'].Fill(dx)
619 rc = h[
'Xdy'].Fill(dy)
620 if abs(dy)<self.
res and abs(dx)<self.
res:
621 rc = h[
'scifiTrack'].Fill(xExTag,yExTag)
622 rc = h[
'USQDC'].Fill(USQDC)
625 for aCl
in self.
M.trackTask.clusScifi:
626 s = aCl.GetFirst()//100000
627 if not (s
in sortedClusters): sortedClusters[s]=0
628 sortedClusters[s]+=aCl.GetN()
629 rc = h[
'clSize'].Fill(aCl.GetN())
630 for s
in sortedClusters:
631 rc = h[
'hitPerPlane'].Fill(sortedClusters[s])
634 if len(ScifiTracks) < 1:
return
635 if xExTag< -9000
or not ok:
return
637 for aCl
in self.
M.trackTask.clusScifi:
638 so = aCl.GetFirst()//100000
639 if not so
in sortedClusters: sortedClusters[so]=0
640 sortedClusters[so]+=1
642 for x
in self.
M.trackTask.trackCandidates[
'Scifi'][0]:
643 aCl = self.
M.trackTask.trackCandidates[
'Scifi'][0][x]
644 so = aCl.GetFirst()//100000
645 if not so
in trackClusters: trackClusters[so]=0
652 self.
M.trackTask.maskPlane = s
653 self.
M.trackTask.fittedTracks.Delete()
654 self.
M.trackTask.ExecuteTask(option=
'Scifi')
655 if self.
M.trackTask.fittedTracks.GetEntries()==0:
continue
656 theTrack = self.
M.trackTask.fittedTracks[0]
657 if not hasattr(theTrack,
"getFittedState"):
continue
658 if not theTrack.getFitStatus().isFitConverged():
659 self.
M.trackTask.fittedTracks.Delete()
664 for aCl
in trackClusters:
666 if sq==s
or self.
masked.find(str(sq))>-0.5:
continue
668 if nproj[0]<3
or nproj[1]<3:
continue
669 theTrack = self.
M.Reco_MuonTracks[ScifiTracks[0]]
671 flightDir = self.
M.trackTask.trackDir(theTrack)
672 rc = h[
'flightDir'].Fill(flightDir[0])
673 if flightDir[0] < -100:
674 if self.
unbiased: self.
M.trackTask.fittedTracks.Delete()
676 fstate = theTrack.getFittedState()
677 pos,mom = fstate.getPos(),fstate.getMom()
678 lam = (self.
zEx-pos.z())/mom.z()
679 yEx = pos.y()+lam*mom.y()
680 xEx = pos.x()+lam*mom.x()
683 slopeX = mom.X()/mom.Z()
684 slopeY = mom.Y()/mom.Z()
685 if not abs(slopeX)<0.1
or not abs(slopeY)<0.1:
686 if self.
unbiased: self.
M.trackTask.fittedTracks.Delete()
688 if abs(dy)>self.
res or abs(dx)>self.
res:
689 if self.
unbiased: self.
M.trackTask.fittedTracks.Delete()
692 z = self.
M.zPos[
'Scifi'][testPlane]
693 lam = (z-pos.z())/mom.z()
694 yEx = pos.y()+lam*mom.y()
695 xEx = pos.x()+lam*mom.x()
696 rc = h[
'XscifiTrack_0'+str(s)].Fill(xEx,yEx)
697 if not ( (s*10
in sortedClusters)
or ( (s*10+1)
in sortedClusters) ):
698 rc = h[
'XscifiTrack_'+str(s)].Fill(xEx,yEx)
699 if -39<xEx
and xEx<-16
and 22<yEx
and yEx<47
and self.
debug:
700 print(
'inefficient scifi detector ',s,self.
M.EventNumber,xEx,yEx,len(vetoHits))
701 if not (s*10
in sortedClusters):
702 rc = h[
'XscifiTrack_'+str(s*10)].Fill(xEx,yEx)
703 if not ((s*10+1)
in sortedClusters):
704 rc = h[
'XscifiTrack_'+str(s*10+1)].Fill(xEx,yEx)
707 for aCl
in trackClusters:
709 if sq==2
or sq==1:
continue
711 if nproj[0]<3
or nproj[1]<3:
continue
712 rc = h[
'2scifiTrack_0'+str(s)].Fill(xEx,yEx)
713 if not ( (s*10
in sortedClusters)
or ( (s*10+1)
in sortedClusters)
or ( (2*10)
in sortedClusters)
or ( (2*10+1)
in sortedClusters) ):
714 rc = h[
'2scifiTrack_'+str(s)].Fill(xEx,yEx)
715 if not (s*10
in sortedClusters
or 2*10
in sortedClusters ):
716 rc = h[
'2scifiTrack_'+str(s*10)].Fill(xEx,yEx)
717 if not ((s*10+1)
in sortedClusters
or (2*10+1)
in sortedClusters):
718 rc = h[
'2scifiTrack_'+str(s*10+1)].Fill(xEx,yEx)
721 self.
M.trackTask.maskPlane = -1
722 self.
M.trackTask.fittedTracks.Delete()
726 ut.bookCanvas(h,
'dxdy',
'',1200,1200,2,1)
731 self.
M.myPrint(h[
'dxdy'],
'ScifiMufiPulls',subdir=
'scifi/expert')
732 ut.bookCanvas(h,
'scifiEff',
'',1600,800,3,1)
733 tc = h[
'scifiEff'].cd(1)
734 h[
'DStag'].Draw(
'colz')
735 tc = h[
'scifiEff'].cd(2)
736 h[
'scifiTrack'].Draw(
'colz')
737 h[
'eff']=h[
'scifiTrack'].Clone(
'eff')
738 h[
'eff'].Divide(h[
'DStag'])
739 tc = h[
'scifiEff'].cd(3)
740 h[
'eff'].DrawCopy(
'colz')
741 self.
M.myPrint(h[
'scifiEff'],
'ScifiTrackEfficiency',subdir=
'scifi/expert')
742 limits = {1:{
'X':[-44,-8],
'Y':[16,50]},2:{
'X':[-40,-12],
'Y':[18,47]}}
747 for x
in limits[l][p]:
748 bins[l].append(eval(
'h["DStag"].Get'+p+
'axis().FindBin(x)'))
749 e = h[
'scifiTrack'].Integral(bins[l][0],bins[l][1],bins[l][2],bins[l][3])/h[
'DStag'].Integral(bins[l][0],bins[l][1],bins[l][2],bins[l][3])*100
750 print(
'average efficiency: %5.2F<X<%5.2F %5.2F<Y<%5.2F = %5.2F%%'%(limits[l][
'X'][0],limits[l][
'X'][1],limits[l][
'Y'][0],limits[l][
'Y'][1],e))
752 ut.bookCanvas(h,
'Tsineff',
'',1200,900,3,2)
754 border = [14.964849051657234, 54.00431913184336, -46.21974599493218, -7.146496817384938]
755 h[
'TlineTop'+str(sRef)] = ROOT.TLine(border[2],border[1],border[3],border[1])
756 h[
'TlineBot'+str(sRef)] = ROOT.TLine(border[2],border[0],border[3],border[0])
757 h[
'TlineLef'+str(sRef)] = ROOT.TLine(border[2],border[0],border[2],border[1])
758 h[
'TlineRig'+str(sRef)] = ROOT.TLine(border[3],border[0],border[3],border[1])
759 for x
in [
'TlineTop'+str(sRef),
'TlineBot'+str(sRef),
'TlineLef'+str(sRef),
'TlineRig'+str(sRef)]:
761 h[x].SetLineColor(ROOT.kRed)
763 tc = h[
'Tsineff'].cd(s)
764 tc.SetRightMargin(0.1)
766 h[
'sineff'+str(s)] = h[
'XscifiTrack_'+str(s)].Clone(
'sineff'+str(s))
767 h[
'sineff'+str(s)].Divide(h[
'XscifiTrack_0'])
768 h[
'sineff'+str(s)].SetStats(0)
769 h[
'sineff'+str(s)].SetMaximum(0.1)
770 h[
'sineff'+str(s)].DrawCopy(
'colz')
771 for x
in [
'TlineTop'+str(sRef),
'TlineBot'+str(sRef),
'TlineLef'+str(sRef),
'TlineRig'+str(sRef)]: h[x].Draw(
'same')
774 e = h[
'XscifiTrack_'+str(s)].Integral(bins[l][0],bins[l][1],bins[l][2],bins[l][3])/h[
'scifiTrack'].Integral(bins[l][0],bins[l][1],bins[l][2],bins[l][3])
775 print(
'average efficiency station: %2i %5.2F<X<%5.2F %5.2F<Y<%5.2F = %5.2G'%(s,limits[l][
'X'][0],limits[l][
'X'][1],limits[l][
'Y'][0],limits[l][
'Y'][1],e))
776 self.
M.myPrint(h[
'Tsineff'],
'ScifiStationInEfficiency',subdir=
'scifi/expert')
777 ut.bookCanvas(h,
'Tqdc',
'',1200,900,1,1)
780 self.
M.myPrint(h[
'Tqdc'],
'US QDC for muon track',subdir=
'mufilter/expert')