Coverage for src/km3pipe/dataclass_templates.py: 100%

11 statements  

« prev     ^ index     » next       coverage.py v7.5.1, created at 2024-05-08 03:14 +0000

1# Filename: dataclasses.py 

2# pylint: disable=W0232,C0103,C0111 

3# vim:set ts=4 sts=4 sw=4 et syntax=python: 

4""" 

5Dataclasses for internal use. Heavily based on Numpy arrays. 

6""" 

7import numpy as np 

8 

9__author__ = "Tamas Gal and Moritz Lotze" 

10__copyright__ = "Copyright 2016, Tamas Gal and the KM3NeT collaboration." 

11__credits__ = [] 

12__license__ = "MIT" 

13__maintainer__ = "Moritz Lotze" 

14__email__ = "mlotze@km3net.de" 

15__status__ = "Development" 

16__all__ = ("TEMPLATES",) 

17 

18TEMPLATES = { 

19 "Direction": { 

20 "dtype": np.dtype( 

21 [ 

22 ("dir_x", "<f4"), 

23 ("dir_y", "<f4"), 

24 ("dir_z", "<f4"), 

25 ] 

26 ), 

27 "h5loc": None, 

28 "split_h5": False, 

29 "h5singleton": False, 

30 }, 

31 "Position": { 

32 "dtype": np.dtype( 

33 [ 

34 ("pos_x", "<f4"), 

35 ("pos_y", "<f4"), 

36 ("pos_z", "<f4"), 

37 ] 

38 ), 

39 "h5loc": None, 

40 "split_h5": False, 

41 "h5singleton": False, 

42 }, 

43 "EventInfo": { 

44 "dtype": np.dtype( 

45 [ 

46 ("det_id", "<i4"), 

47 ("frame_index", "<u4"), 

48 ("livetime_sec", "<u8"), 

49 ("mc_id", "<i4"), 

50 ("mc_t", "<f8"), 

51 ("n_events_gen", "<u8"), 

52 ("n_files_gen", "<u8"), 

53 ("overlays", "<u4"), 

54 ("trigger_counter", "<u8"), 

55 ("trigger_mask", "<u8"), 

56 ("utc_nanoseconds", "<u8"), 

57 ("utc_seconds", "<u8"), 

58 ("weight_w1", "<f8"), 

59 ("weight_w2", "<f8"), 

60 ("weight_w3", "<f8"), 

61 ("run_id", "<u8"), 

62 ("group_id", "<u8"), 

63 ] 

64 ), 

65 "h5loc": "/event_info", 

66 "split_h5": False, 

67 "h5singleton": False, 

68 }, 

69 "TimesliceHits": { 

70 "dtype": np.dtype( 

71 [ 

72 ("channel_id", "u1"), 

73 ("dom_id", "<u4"), 

74 ("time", "<f8"), 

75 ("tot", "u1"), 

76 ("group_id", "<u4"), 

77 ] 

78 ), 

79 "h5loc": "/timeslice_hits", 

80 "split_h5": True, 

81 "h5singleton": False, 

82 }, 

83 "Hits": { 

84 "dtype": np.dtype( 

85 [ 

86 ("channel_id", "u1"), 

87 ("dom_id", "<u4"), 

88 ("time", "<f8"), 

89 ("tot", "u1"), 

90 ("triggered", "?"), 

91 ("group_id", "<u4"), 

92 ] 

93 ), 

94 "h5loc": "/hits", 

95 "split_h5": True, 

96 "h5singleton": False, 

97 }, 

98 "CalibHits": { 

99 "dtype": np.dtype( 

100 [ 

101 ("channel_id", "u1"), 

102 ("dir_x", "<f4"), 

103 ("dir_y", "<f4"), 

104 ("dir_z", "<f4"), 

105 ("dom_id", "<u4"), 

106 ("du", "u1"), 

107 ("floor", "u1"), 

108 ("pos_x", "<f4"), 

109 ("pos_y", "<f4"), 

110 ("pos_z", "<f4"), 

111 ("t0", "<f4"), 

112 ("time", "<f8"), 

113 ("tot", "u1"), 

114 ("triggered", "?"), 

115 ("group_id", "<u4"), 

116 ] 

117 ), 

118 "h5loc": "/hits", 

119 "split_h5": True, 

120 "h5singleton": False, 

121 }, 

122 "McHits": { 

123 "dtype": np.dtype( 

124 [ 

125 ("a", "<f4"), 

126 ("origin", "<u4"), 

127 ("pmt_id", "<u4"), 

128 ("time", "<f8"), 

129 ("group_id", "<u4"), 

130 ] 

131 ), 

132 "h5loc": "/mc_hits", 

133 "split_h5": True, 

134 "h5singleton": False, 

135 }, 

136 "CalibMcHits": { 

137 "dtype": np.dtype( 

138 [ 

139 ("a", "<f4"), 

140 ("dir_x", "<f4"), 

141 ("dir_y", "<f4"), 

142 ("dir_z", "<f4"), 

143 ("origin", "<u4"), 

144 ("pmt_id", "<u4"), 

145 ("pos_x", "<f4"), 

146 ("pos_y", "<f4"), 

147 ("pos_z", "<f4"), 

148 ("time", "<f8"), 

149 ("group_id", "<u4"), 

150 ] 

151 ), 

152 "h5loc": "/mc_hits", 

153 "split_h5": True, 

154 "h5singleton": False, 

155 }, 

156 "Tracks": { 

157 "dtype": np.dtype( 

158 [ 

159 ("bjorkeny", "<f8"), 

160 ("dir_x", "<f8"), 

161 ("dir_y", "<f8"), 

162 ("dir_z", "<f8"), 

163 ("energy", "<f8"), 

164 ("id", "<u4"), 

165 ("interaction_channel", "<u4"), 

166 ("is_cc", "<u4"), # TODO: consider bool ('?') for slicing 

167 ("length", "<f8"), 

168 ("pos_x", "<f8"), 

169 ("pos_y", "<f8"), 

170 ("pos_z", "<f8"), 

171 ("time", "<i4"), 

172 ("type", "<i4"), 

173 ("group_id", "<u4"), 

174 ] 

175 ), 

176 "h5loc": "/tracks", 

177 "split_h5": False, 

178 "h5singleton": False, 

179 }, 

180 "McTracks": { 

181 "dtype": np.dtype( 

182 [ 

183 ("bjorkeny", "<f8"), 

184 ("dir_x", "<f8"), 

185 ("dir_y", "<f8"), 

186 ("dir_z", "<f8"), 

187 ("energy", "<f8"), 

188 ("id", "<u4"), 

189 ("interaction_channel", "<u4"), 

190 ("is_cc", "<u4"), # TODO: consider bool ('?') for slicing 

191 ("length", "<f8"), 

192 ("pos_x", "<f8"), 

193 ("pos_y", "<f8"), 

194 ("pos_z", "<f8"), 

195 ("time", "<i4"), 

196 ("type", "<i4"), 

197 ("group_id", "<u4"), 

198 ] 

199 ), 

200 "h5loc": "/mc_tracks", 

201 "split_h5": False, 

202 "h5singleton": False, 

203 }, 

204 "SummaryFrameInfo": { 

205 "dtype": np.dtype( 

206 [ 

207 ("dom_id", "<u4"), 

208 ("fifo_status", "<u4"), 

209 ("frame_id", "<u4"), 

210 ("frame_index", "<u4"), 

211 ("has_udp_trailer", "<u4"), 

212 ("high_rate_veto", "<u4"), 

213 ("max_sequence_number", "<u4"), 

214 ("n_packets", "<u4"), 

215 ("slice_id", "<u4"), 

216 ("utc_nanoseconds", "<u4"), 

217 ("utc_seconds", "<u4"), 

218 ("white_rabbit_status", "<u4"), 

219 ] 

220 ), 

221 "h5loc": "/summary_slice_info", 

222 "split_h5": False, 

223 "h5singleton": False, 

224 }, 

225 "SummarysliceInfo": { 

226 "dtype": np.dtype( 

227 [ 

228 ("frame_index", "<u4"), 

229 ("slice_id", "<u4"), 

230 ("timestamp", "<u4"), 

231 ("nanoseconds", "<u4"), 

232 ("n_frames", "<u4"), 

233 ] 

234 ), 

235 "h5loc": "/todo", 

236 "split_h5": False, 

237 "h5singleton": False, 

238 }, 

239 "TimesliceInfo": { 

240 "dtype": np.dtype( 

241 [ 

242 ("frame_index", "<u4"), 

243 ("slice_id", "<u4"), 

244 ("timestamp", "<u4"), 

245 ("nanoseconds", "<u4"), 

246 ("n_frames", "<u4"), 

247 ] 

248 ), 

249 "h5loc": "/timeslice_info", 

250 "split_h5": False, 

251 "h5singleton": False, 

252 }, 

253 "SummaryframeSeries": { 

254 "dtype": np.dtype( 

255 [ 

256 ("dom_id", "<u4"), 

257 ("max_sequence_number", "<u4"), 

258 ("n_received_packets", "<u4"), 

259 ("group_id", "<u4"), 

260 ] 

261 ), 

262 "h5loc": "/todo", 

263 "split_h5": False, 

264 "h5singleton": False, 

265 }, 

266 "TimesliceFrameInfo": { 

267 "dtype": np.dtype( 

268 [ 

269 ("det_id", "<i4"), 

270 ("run_id", "<u8"), 

271 ("sqnr", "<u8"), 

272 ("timestamp", "<u4"), 

273 ("nanoseconds", "<u4"), 

274 ("dom_id", "<u4"), 

275 ("dataqueue_status", "<u4"), 

276 ("dom_status", "<u4"), 

277 ("n_hits", "<u4"), 

278 ] 

279 ), 

280 "h5loc": "/todo", 

281 "split_h5": False, 

282 "h5singleton": False, 

283 }, 

284 "SummaryFrameSeries": { 

285 "dtype": np.dtype( 

286 [ 

287 ("dom_id", "<u4"), 

288 ("max_sequence_number", "<u4"), 

289 ("n_received_packets", "<u4"), 

290 ("group_id", "<u4"), 

291 ] 

292 ), 

293 "h5loc": "/summary_frame_series", 

294 "split_h5": False, 

295 "h5singleton": False, 

296 }, 

297}