Belle II Software
development
SetMetaTimeModule.py
1
#!/usr/bin/env python3
2
3
10
11
from
basf2
import
Module
12
from
ROOT
import
Belle2
13
from
basf2
import
B2DEBUG, B2FATAL
14
15
16
class
SetMetaTimeModule
(Module):
17
18
"""
19
module which sets time in EventMetaData from detector raw data
20
21
Author: bjoern.spruck@belle2.org
22
"""
23
24
25
detectorlist =
"SVD CDC ECL TOP"
26
27
28
meta =
None
29
30
31
raws = []
32
33
def
initialize
(self):
34
"""initialize"""
35
36
self.
meta
=
Belle2.PyStoreObj
(
'EventMetaData'
)
37
if
not
self.
meta
:
38
B2FATAL(
"no EventMetaData object"
)
39
return
40
41
self.
raws
= [
Belle2.PyStoreArray
(f
"Raw{e}s"
)
for
e
in
self.
detectorlist
.split()]
42
43
def
calc_time
(self, it):
44
"""Calculate the time in ns since epoch from UnixTime and Accelerator Clock count"""
45
# t = it.GetTTTimeNs(0)
46
return
it.GetTTUtime(0) * 1000000000 + int(round(it.GetTTCtime(0) / 0.127216))
47
48
def
event
(self):
49
"""event"""
50
if
not
self.
meta
.isValid():
51
B2FATAL(
"no valid EventMetaData object in this event"
)
52
return
53
54
t = self.
meta
.getTime()
# Check if it already set, t=0 means not set
55
if
t != 0:
56
return
# No need to update
57
58
for
det
in
self.
raws
:
59
if
det:
60
for
it
in
det:
61
t = self.
calc_time
(it)
62
self.
meta
.setTime(t)
63
return
64
65
B2DEBUG(1,
"No time for EventMetaData extracted as no raw data entries were available from selected detectors"
)
Belle2::PyStoreArray
A (simplified) python wrapper for StoreArray.
Definition
PyStoreArray.h:73
Belle2::PyStoreObj
a (simplified) python wrapper for StoreObjPtr.
Definition
PyStoreObj.h:67
SetMetaTimeModule.SetMetaTimeModule
Definition
SetMetaTimeModule.py:16
SetMetaTimeModule.SetMetaTimeModule.meta
meta
pointer to event meta data
Definition
SetMetaTimeModule.py:28
SetMetaTimeModule.SetMetaTimeModule.initialize
initialize(self)
Definition
SetMetaTimeModule.py:33
SetMetaTimeModule.SetMetaTimeModule.detectorlist
str detectorlist
List of detector names to check in that order (for fallback)
Definition
SetMetaTimeModule.py:25
SetMetaTimeModule.SetMetaTimeModule.calc_time
calc_time(self, it)
Definition
SetMetaTimeModule.py:43
SetMetaTimeModule.SetMetaTimeModule.event
event(self)
Definition
SetMetaTimeModule.py:48
SetMetaTimeModule.SetMetaTimeModule.raws
list raws
array of pointers to the detector raw data arrays
Definition
SetMetaTimeModule.py:31
rawdata
modules
scripts
SetMetaTimeModule.py
Generated on Mon Sep 1 2025 02:55:22 for Belle II Software by
1.13.2