FairShip
Loading...
Searching...
No Matches
shipVeto.Task Class Reference

Public Member Functions

None __init__ (self, t)
 detMap (self)
tuple[bool, float, int] SBT_plastic_decision (self, mcParticle=None)
tuple[bool, float, int] SBT_liquid_decision (self, mcParticle=None)
tuple[bool, float, int] SBT_decision (self, mcParticle=None, detector="liquid")
tuple[bool, float, int] UBT_decision (self, mcParticle=None)
tuple[bool, int|float, int] Track_decision (self, mcParticle=None)
 fiducialCheckSignal (self, n)
 fiducialCheck (self, aPoint)

Public Attributes

float SBTefficiency = 0.99
float UBTefficiency = 0.999
 random = ROOT.TRandom3()
 detList = self.detMap()
 sTree = t

Protected Attributes

bool _warned_no_ubt_digis = False

Detailed Description

Definition at line 11 of file shipVeto.py.

Constructor & Destructor Documentation

◆ __init__()

None shipVeto.Task.__init__ ( self,
t )

Definition at line 14 of file shipVeto.py.

14 def __init__(self, t) -> None:
15 self.SBTefficiency = 0.99 # Surrounding Background tagger: 99% efficiency picked up from TP
16 self.UBTefficiency = 0.999 # Upstream background tagger, per triggered tile
17 self.random = ROOT.TRandom3()
18 self.random.SetSeed(13)
19 self.detList = self.detMap()
20 self.sTree = t
21 self._warned_no_ubt_digis = False
22

Member Function Documentation

◆ detMap()

shipVeto.Task.detMap ( self)

Definition at line 23 of file shipVeto.py.

23 def detMap(self):
24 fGeo = ROOT.gGeoManager
25 detList = {}
26 for v in fGeo.GetListOfVolumes():
27 nm = v.GetName()
28 i = fGeo.FindVolumeFast(nm).GetNumber()
29 detList[i] = nm
30 return detList
31

◆ fiducialCheck()

shipVeto.Task.fiducialCheck ( self,
aPoint )

Definition at line 125 of file shipVeto.py.

125 def fiducialCheck(self, aPoint):
126 nav = ROOT.gGeoManager.GetCurrentNavigator()
127 phi = 0.0
128 nSteps = 36
129 delPhi = 2.0 * ROOT.TMath.Pi() / nSteps
130 distmin = 1e10
131 nav.SetCurrentPoint(aPoint.x(), aPoint.y(), aPoint.z())
132 cNode = "outside"
133 aNode = nav.FindNode()
134 if aNode:
135 cNode = aNode.GetName()
136 if not cNode.startswith("decay_medium"):
137 distmin = 0.0
138 else:
139 for n in range(nSteps):
140 # set direction
141 xDir = ROOT.TMath.Sin(phi)
142 yDir = ROOT.TMath.Cos(phi)
143 nav.SetCurrentPoint(aPoint.x(), aPoint.y(), aPoint.z())
144 cNode = nav.FindNode().GetName()
145 nav.SetCurrentDirection(xDir, yDir, 0.0)
146 nav.FindNextBoundaryAndStep()
147 x, y = nav.GetCurrentPoint()[0], nav.GetCurrentPoint()[1]
148 if cNode != nav.GetCurrentNode().GetName():
149 dist = ROOT.TMath.Sqrt((aPoint.x() - x) ** 2 + (aPoint.y() - y) ** 2)
150 if dist < distmin:
151 distmin = dist
152 phi += delPhi
153 # distance to Tr1_x1
154 nav.cd("/Tr1_1")
155 shape = nav.GetCurrentNode().GetVolume().GetShape()
156 origin = array("d", [0, 0, shape.GetDZ()])
157 master = array("d", [0, 0, 0])
158 nav.LocalToMaster(origin, master)
159 dist = master[2] - aPoint.z()
160 if dist < distmin:
161 distmin = dist
162 # distance to straw veto:
163 nav.cd("/Veto_5")
164 shape = nav.GetCurrentNode().GetVolume().GetShape()
165 origin = array("d", [0, 0, shape.GetDZ()])
166 master = array("d", [0, 0, 0])
167 nav.LocalToMaster(origin, master)
168 dist = aPoint.z() - master[2]
169 if dist < distmin:
170 distmin = dist
171 return distmin
172
173
174# usage
175# import shipVeto
176# veto = shipVeto.Task(sTree)
177# veto,w = veto.SBT_decision()
178# or for plastic veto,w = veto.SBT_decision(detector='plastic')
179# if veto: continue # reject event
180# or
181# continue using weight w

◆ fiducialCheckSignal()

shipVeto.Task.fiducialCheckSignal ( self,
n )

Definition at line 119 of file shipVeto.py.

119 def fiducialCheckSignal(self, n):
120 hnl = self.sTree.Particles[n]
121 aPoint = ROOT.TVector3(hnl.Vx(), hnl.Vy(), hnl.Vz())
122 distmin = self.fiducialCheck(aPoint)
123 return distmin
124

◆ SBT_decision()

tuple[bool, float, int] shipVeto.Task.SBT_decision ( self,
mcParticle = None,
detector = "liquid" )

Definition at line 38 of file shipVeto.py.

38 def SBT_decision(self, mcParticle=None, detector="liquid") -> tuple[bool, float, int]:
39 # if mcParticle >0, only count hits with this particle
40 # if mcParticle <0, do not count hits with this particle
41 hitSegments = 0
42 index = -1
43 fdetector = detector == "liquid"
44 for aDigi in self.sTree.Digi_SBTHits:
45 index += 1
46 detID = aDigi.GetDetectorID()
47 if fdetector and detID > 999999:
48 continue
49 if not fdetector and not detID > 999999:
50 continue
51 if mcParticle:
52 contributors = list(self.sTree.digiSBT2MC[index])
53 if mcParticle > 0:
54 # only count hits from this particle: skip if it is absent
55 if mcParticle not in contributors:
56 continue
57 elif mcParticle < 0:
58 # do not count hits from this particle: skip if it is present
59 if abs(mcParticle) in contributors:
60 continue
61 aDigi.GetXYZ()
62 aDigi.GetEloss()
63 if aDigi.isValid():
64 hitSegments += 1 # threshold of 45 MeV per segment
65 w = (1 - self.SBTefficiency) ** hitSegments
66 veto = self.random.Rndm() > w
67 # print 'SBT :',hitSegments
68 return veto, w, hitSegments
69

◆ SBT_liquid_decision()

tuple[bool, float, int] shipVeto.Task.SBT_liquid_decision ( self,
mcParticle = None )

Definition at line 35 of file shipVeto.py.

35 def SBT_liquid_decision(self, mcParticle=None) -> tuple[bool, float, int]:
36 return self.SBT_decision(mcParticle, detector="liquid")
37

◆ SBT_plastic_decision()

tuple[bool, float, int] shipVeto.Task.SBT_plastic_decision ( self,
mcParticle = None )

Definition at line 32 of file shipVeto.py.

32 def SBT_plastic_decision(self, mcParticle=None) -> tuple[bool, float, int]:
33 return self.SBT_decision(mcParticle, detector="plastic")
34

◆ Track_decision()

tuple[bool, int | float, int] shipVeto.Task.Track_decision ( self,
mcParticle = None )

Definition at line 96 of file shipVeto.py.

96 def Track_decision(self, mcParticle=None) -> tuple[bool, int | float, int]:
97 nMultCon = 0
98 k = -1
99 acts_tracks = uses_acts(self.sTree)
100 for aTrack in get_tracks(self.sTree):
101 k += 1
102 if mcParticle:
103 if mcParticle > 0 and mcParticle != self.sTree.fitTrack2MC[k]:
104 continue
105 if mcParticle < 0 and abs(mcParticle) == self.sTree.fitTrack2MC[k]:
106 continue
107 info = track_info(aTrack, acts_tracks)
108 if not info.converged:
109 continue
110 if info.ndf < 25:
111 continue
112 nMultCon += 1
113 w = 1.0
114 veto = nMultCon > 2
115 if veto:
116 w = 0.0
117 return veto, w, nMultCon
118

◆ UBT_decision()

tuple[bool, float, int] shipVeto.Task.UBT_decision ( self,
mcParticle = None )

Definition at line 70 of file shipVeto.py.

70 def UBT_decision(self, mcParticle=None) -> tuple[bool, float, int]:
71 # Count the triggered tiles: one digitized hit per fired tile, above
72 # the ADC trigger threshold.
73 # if mcParticle >0, only count tiles with a point of this particle
74 # if mcParticle <0, do not count tiles with a point of this particle
75 nHits = 0
76 if not self.sTree.GetBranch("Digi_UpstreamTaggerHits"):
77 # Not digitized: a geometry from before the scintillator UBT
78 if not self._warned_no_ubt_digis:
79 print("Warning: no Digi_UpstreamTaggerHits, the UBT does not veto")
80 self._warned_no_ubt_digis = True
81 return False, 1.0, 0
82 for index, aDigi in enumerate(self.sTree.Digi_UpstreamTaggerHits):
83 if not aDigi.IsTriggered():
84 continue
85 if mcParticle:
86 contributors = {self.sTree.UpstreamTaggerPoint[i].GetTrackID() for i in self.sTree.digiUBT2MC[index]}
87 if mcParticle > 0 and mcParticle not in contributors:
88 continue
89 if mcParticle < 0 and abs(mcParticle) in contributors:
90 continue
91 nHits += 1
92 w = (1 - self.UBTefficiency) ** nHits
93 veto = self.random.Rndm() > w
94 return veto, w, nHits
95

Member Data Documentation

◆ _warned_no_ubt_digis

bool shipVeto.Task._warned_no_ubt_digis = False
protected

Definition at line 21 of file shipVeto.py.

◆ detList

shipVeto.Task.detList = self.detMap()

Definition at line 19 of file shipVeto.py.

◆ random

shipVeto.Task.random = ROOT.TRandom3()

Definition at line 17 of file shipVeto.py.

◆ SBTefficiency

float shipVeto.Task.SBTefficiency = 0.99

Definition at line 15 of file shipVeto.py.

◆ sTree

shipVeto.Task.sTree = t

Definition at line 20 of file shipVeto.py.

◆ UBTefficiency

float shipVeto.Task.UBTefficiency = 0.999

Definition at line 16 of file shipVeto.py.


The documentation for this class was generated from the following file: