Belle II Software development
skim_utils.py
1# !/usr/bin/env python
2
3
10
11
23
24from ROOT import Belle2
25import basf2 as b2
26
27
28class skimOutRNDTrgModule(b2.Module):
29 """
30 returns True if the event is NOT a random triggered event
31 """
32
33 def __init__(self):
34 """constructor"""
35
36 super().__init__()
37
38 def event(self):
39 """
40 check RawFTSW to get the event type
41 """
42
43 rawFTSW = Belle2.PyStoreArray('RawFTSWs')
44
45 if not rawFTSW.isValid():
46 b2.B2WARNING('No RawFTSW available - event ignored')
47 self.return_value(0)
48
49 return
50
51 # unknown meaning of this number
52 unknownInt = 0
53 if rawFTSW[0].GetTRGType(unknownInt) != Belle2.TRGSummary.TTYP_RAND:
54 self.return_value(1)
55 else:
56 self.return_value(0)
57
58
59class skimSVDBurstEventsModule(b2.Module):
60 """
61 returns True if the event is a Burst event (number of strips > max number of strips)
62 use :code:`set_nMaxStrips(nMaxStrips)` to set the max number of strips of a non-burst event, default is :code:`nMaxStrips=5000`
63 """
64
65 def __init__(self):
66 """constructor"""
67
68 super().__init__()
69
70
71 self.nMaxStrips = 5000
72
73 def set_nMaxStrips(self, user_nMaxStrips):
74 """set the max strips, otherwise 5000"""
75
76 self.nMaxStrips = user_nMaxStrips
77
78 def event(self):
79 '''event'''
80
81 strips = Belle2.PyStoreArray('SVDShaperDigits')
82
83 if not strips.isValid():
84 b2.B2WARNING('No SVDShaperDigits - event ignored')
85 self.return_value(0)
86
87 return
88
89 if strips.getEntries() > self.nMaxStrips:
90 self.return_value(1)
91 else:
92 self.return_value(0)
93
94
96 """
97 returns True if the event is acquired with 6 samples
98 """
99
100 def __init__(self):
101 """constructor"""
102
103 super().__init__()
104
105 def event(self):
106 '''event'''
107
108 # take SVDEventInfo or SVDvVentInfoSim
109 eventInfo = Belle2.PyStoreObj('SVDEventInfo')
110
111 if not eventInfo.isValid():
112 eventInfo = Belle2.PyStoreObjPtr('SVDEventInfoSim')
113
114 if not eventInfo.isValid():
115 b2.B2WARNING('No SVDEventInfo/SVDEventInfoSim - event ignored')
116 self.return_value(0)
117
118 return
119
120 # check if we acquired 6-sample strips in this event
121 if eventInfo.getNSamples() == 6:
122 self.return_value(1)
123 else:
124 self.return_value(0)
125
126
128 """
129 returns True if TriggerBin of the event is the selected one,
130 use :code:`set_tb(tb)` to set the value of the selected TriggerBin (0,1,2,3)
131 """
132
133 def __init__(self):
134 """constructor"""
135
136 super().__init__()
137
138
139 self.tb = 99 # no selection of TB
140
141 def set_tb(self, user_tb):
142 '''set the trigger bin, otherwise 99, i.e. no selection'''
143
144 self.tb = user_tb
145
146 def event(self):
147 '''event'''
148
149 if int(self.tb) == 99:
150 self.return_value(1)
151
152 eventInfo = Belle2.PyStoreObj('SVDEventInfo')
153
154 if not eventInfo.isValid():
155 b2.B2ERROR('No SVDEventInfo - event ignored')
156 self.return_value(0)
157
158 return
159
160 if ord(eventInfo.getModeByte().getTriggerBin()) == int(self.tb):
161 self.return_value(1)
162 else:
163 self.return_value(0)
164
165
167 """
168 returns True if the event has a fine trigger from TRGSummary
169 """
170
171 def __init__(self):
172 """constructor"""
173
174 super().__init__()
175
176 def event(self):
177 '''event'''
178
179 trgQuality = Belle2.PyStoreObj('TRGSummary')
180
181 if not trgQuality.isValid():
182 b2.B2WARNING('No TRGSummary - event ignored')
183 self.return_value(0)
184
185 return
186
187 # check trigger quality
188 if trgQuality.getTimQuality() == 2:
189 self.return_value(1)
190 else:
191 self.return_value(0)
192
193
195 """
196 returns True if (:code:`abs(EventT0)` is smaller than a selected value
197 that can be set with :code:`set_maxAbsEventT0(evtT0max)`) AND (:code:`abs(EventT0)` is larger than a selected value
198 that can be set with :code:`set_minAbsEventT0(evtT0min)`)
199 """
200
201 def __init__(self):
202 """constructor"""
203
204 super().__init__()
205
206
207 self.maxEvtT0 = 10 # ns
208
209
210 self.minEvtT0 = 0 # ns
211
212 def set_maxAbsEventT0(self, user_maxEvtT0):
213 '''set the maximum abs(EventT0), otherwise 10 ns'''
214
215 self.maxEvtT0 = user_maxEvtT0
216
217 def set_minAbsEventT0(self, user_minEvtT0):
218 '''set the minimum EventT0, otherwise 0 ns'''
219
220 self.minEvtT0 = user_minEvtT0
221
222 def event(self):
223 '''event'''
224
225 eventT0 = Belle2.PyStoreObj('EventT0')
226
227 if not eventT0.isValid():
228 b2.B2ERROR('No valid EventT0 - event ignored')
229 self.return_value(0)
230
231 return
232
233 if not eventT0.hasEventT0():
234 b2.B2ERROR('No EventT0 - event ignored')
235 self.return_value(0)
236
237 return
238
239 if (abs(eventT0.getEventT0()) < self.maxEvtT0) and (abs(eventT0.getEventT0()) > self.minEvtT0):
240 self.return_value(1)
241 else:
242 self.return_value(0)
A (simplified) python wrapper for StoreArray.
Definition: PyStoreArray.h:72
a (simplified) python wrapper for StoreObjPtr.
Definition: PyStoreObj.h:67
minEvtT0
minimum value of abs(EventT0) allowed
Definition: skim_utils.py:210
maxEvtT0
maximum value of abs(EventT0) allowed
Definition: skim_utils.py:207
nMaxStrips
max number of strips for NON-BURST events
Definition: skim_utils.py:71
def set_nMaxStrips(self, user_nMaxStrips)
Definition: skim_utils.py:73