3 from __future__
import print_function
6 This library defines different classes for filtering events in athena.
7 Intended for use in JobRunner templates.
9 __author__ =
'Juerg Beringer'
14 from AthenaCommon.AlgSequence
import AthSequencer
19 from AthenaPython.PyAthena
import StatusCode
20 import AthenaPython.PyAthena
as PyAthena
28 super(BCIDFilter,self).
__init__(name=name)
33 print (
'BCIDFilter: Found %i BCIDs to accept: ' % len(self.
bcidList), self.
bcidList)
35 print (
'BCIDFilter: WARNING: Empty bcidList - will accept all events')
36 self.
sg = PyAthena.py_svc(
'StoreGateSvc')
37 return StatusCode.Success
41 eventID = self.
sg.
retrieve(
'EventInfo',
'ByteStreamEventInfo').event_ID()
42 bcid = eventID.bunch_crossing_id()
44 self.setFilterPassed(bcid
in self.
bcidList)
46 self.setFilterPassed(
True)
47 return StatusCode.Success
50 return StatusCode.Success
58 super(LBFilter,self).
__init__(name=name)
65 print (
'LBFilter: Found %i LBs to accept: ' % len(self.
lbList), self.
lbList)
67 print (
'LBFilter: WARNING: Empty lbList - will accept all events')
68 self.
sg = PyAthena.py_svc(
'StoreGateSvc')
69 return StatusCode.Success
74 for item
in self.
sg.
keys():
75 if 'EventInfo' in item:
78 if 'EventInfo' in self.
sg.
keys():
80 lb = eventInfo.event_ID().lumi_block()
81 self.
msg.
debug(
'LBFilter %d %d', lb, eventInfo.event_ID().event_number() )
82 self.setFilterPassed(lb
in self.
lbList)
84 self.
msg.
info(
'LBFilter : no LB info' )
85 self.setFilterPassed(
True)
87 self.setFilterPassed(
True)
88 return StatusCode.Success
91 return StatusCode.Success
99 super(LBPrinter,self).
__init__(name=name)
103 print (
'LBPrinter: Init')
104 self.
sg = PyAthena.py_svc(
'StoreGateSvc')
107 return StatusCode.Success
112 for item
in self.
sg.
keys():
113 if 'EventInfo' in item:
115 if 'EventInfo' in self.
sg.
keys():
117 lb = eventInfo.event_ID().lumi_block()
118 self.
msg.
info(
'LBPrinter %d %d' , lb, eventInfo.event_ID().event_number() )
120 self.
msg.
info(
'LBPrinter : no LB info' )
121 return StatusCode.Success
124 return StatusCode.Success
130 from time
import asctime,gmtime
159 super(LumiBlockFilter,self).
__init__(name=name)
163 lbInfo =
open(lbData)
if isinstance(lbData,str)
else lbData
166 if l[0]==
'#':
continue
169 if hasattr (lbInfo,
'close'):
173 print (
'Found',len(self.
lbList),
'(pseudo)LB entries:')
175 print (
'Data for new LB %3i: ' % self.
lbList[i].lbNumber, self.
lbList[i])
180 self.
sg = PyAthena.py_svc(
'StoreGateSvc')
181 return StatusCode.Success
184 eventID = self.
sg.
retrieve(
'EventInfo',
'ByteStreamEventInfo').event_ID()
187 if lb.match(eventID.time_stamp(),eventID.time_stamp_ns_offset())
and lb.isScanPoint():
189 eventID.set_lumi_block(lb.lbNumber)
192 self.setFilterPassed(foundEvent)
193 return StatusCode.Success
196 return StatusCode.Success
204 super(ZFilter,self).
__init__(name=name)
211 print (
'ZFilter: accepting only primary vertices from',self.
zMin,
'to',self.
zMax)
212 self.
sg = PyAthena.py_svc(
'StoreGateSvc')
213 return StatusCode.Success
216 vxContainer = self.
sg.
retrieve(
"VxContainer",
"VxPrimaryCandidate")
219 for i
in range(vxContainer.size()):
221 z = vxContainer[i].recVertex().position().z()
222 accept = (z >= self.
zMin)
and (z <= self.
zMax)
225 self.setFilterPassed(accept)
226 return StatusCode.Success
229 return StatusCode.Success