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