@@ -162,18 +162,21 @@ def export_to_hdf5(event_id_list,
162
162
io_groups = np .unique (np .array (list (detector .MODULE_TO_IO_GROUPS .values ())))
163
163
io_groups = io_groups if i_mod < 0 else io_groups [(i_mod - 1 )* 2 : i_mod * 2 ]
164
164
packets = []
165
- packets_mc = []
165
+ packets_mc_evt = []
166
+ packets_mc_trk = []
166
167
packets_frac = []
167
168
168
169
if is_first_batch :
169
170
for io_group in io_groups :
170
171
packets .append (TimestampPacket (timestamp = 0 ))
171
172
packets [- 1 ].chip_key = Key (io_group ,0 ,0 )
172
- packets_mc .append ([- 1 ] * track_ids .shape [1 ])
173
+ packets_mc_evt .append ([- 1 ])
174
+ packets_mc_trk .append ([- 1 ] * track_ids .shape [1 ])
173
175
packets_frac .append ([0 ] * current_fractions .shape [2 ])
174
176
175
177
packets .append (SyncPacket (sync_type = b'S' , timestamp = 0 , io_group = io_group ))
176
- packets_mc .append ([- 1 ] * track_ids .shape [1 ])
178
+ packets_mc_evt .append ([- 1 ])
179
+ packets_mc_trk .append ([- 1 ] * track_ids .shape [1 ])
177
180
packets_frac .append ([0 ] * current_fractions .shape [2 ])
178
181
179
182
packets_mc_ds = []
@@ -221,7 +224,8 @@ def export_to_hdf5(event_id_list,
221
224
for io_group in io_groups :
222
225
packets .append (SyncPacket (sync_type = b'S' ,
223
226
timestamp = CLOCK_RESET_PERIOD - 1 , io_group = io_group ))
224
- packets_mc .append ([- 1 ] * track_ids .shape [1 ])
227
+ packets_mc_evt .append ([- 1 ])
228
+ packets_mc_trk .append ([- 1 ] * track_ids .shape [1 ])
225
229
packets_frac .append ([0 ] * current_fractions .shape [2 ])
226
230
event_start_time_list [itick :] -= CLOCK_RESET_PERIOD
227
231
else :
@@ -238,7 +242,8 @@ def export_to_hdf5(event_id_list,
238
242
for io_group in io_groups :
239
243
packets .append (TimestampPacket (timestamp = event_start_times [unique_events_inv [itick ]] * units .mus / units .s ))
240
244
packets [- 1 ].chip_key = Key (io_group ,0 ,0 )
241
- packets_mc .append ([- 1 ] * track_ids .shape [1 ])
245
+ packets_mc_evt .append ([- 1 ])
246
+ packets_mc_trk .append ([- 1 ] * track_ids .shape [1 ])
242
247
packets_frac .append ([0 ] * current_fractions .shape [2 ])
243
248
244
249
trig_mask = light_trigger_event_id == event
@@ -248,7 +253,8 @@ def export_to_hdf5(event_id_list,
248
253
if light .LIGHT_TRIG_MODE == 0 :
249
254
for io_group in detector .MODULE_TO_IO_GROUPS [int (module_trig )]:
250
255
packets .append (TriggerPacket (io_group = io_group , trigger_type = b'\x02 ' , timestamp = t_trig ))
251
- packets_mc .append ([- 1 ] * track_ids .shape [1 ])
256
+ packets_mc_evt .append ([- 1 ])
257
+ packets_mc_trk .append ([- 1 ] * track_ids .shape [1 ])
252
258
packets_frac .append ([0 ] * current_fractions .shape [2 ])
253
259
# redundant here
254
260
elif light .LIGHT_TRIG_MODE == 1 :
@@ -257,7 +263,8 @@ def export_to_hdf5(event_id_list,
257
263
elif module_trig == 0 : #threshold trigger
258
264
io_group = THRES_TRIG_IO
259
265
packets .append (TriggerPacket (io_group = io_group , trigger_type = b'\x02 ' , timestamp = t_trig ))
260
- packets_mc .append ([- 1 ] * track_ids .shape [1 ])
266
+ packets_mc_evt .append ([- 1 ])
267
+ packets_mc_trk .append ([- 1 ] * track_ids .shape [1 ])
261
268
packets_frac .append ([0 ] * current_fractions .shape [2 ])
262
269
last_event = event
263
270
@@ -297,7 +304,8 @@ def export_to_hdf5(event_id_list,
297
304
p .first_packet = 1
298
305
p .assign_parity ()
299
306
300
- packets_mc .append (track_ids [itick ])
307
+ packets_mc_evt .append ([event ])
308
+ packets_mc_trk .append (track_ids [itick ])
301
309
packets_frac .append (current_fractions [itick ][iadc ])
302
310
packets .append (p )
303
311
else :
@@ -307,16 +315,18 @@ def export_to_hdf5(event_id_list,
307
315
packet_list = PacketCollection (packets , read_id = 0 , message = '' )
308
316
hdf5format .to_file (filename , packet_list , workers = 1 )
309
317
310
- dtype = np .dtype ([('segment_ids' ,f'({ ASSOCIATION_COUNT_TO_STORE } ,)i8' ),
318
+ dtype = np .dtype ([('event_ids' ,f'(1,)i8' ),
319
+ ('segment_ids' ,f'({ ASSOCIATION_COUNT_TO_STORE } ,)i8' ),
311
320
('fraction' , f'({ ASSOCIATION_COUNT_TO_STORE } ,)f8' )])
312
321
packets_mc_ds = np .empty (len (packets ), dtype = dtype )
313
322
314
323
# First, sort the back-tracking information by the magnitude of the fraction
315
324
packets_frac = np .array (packets_frac )
316
- packets_mc = np .array (packets_mc )
325
+ packets_mc_trk = np .array (packets_mc_trk )
326
+ packets_mc_evt = np .array (packets_mc_evt )
317
327
318
328
frac_order = np .flip (np .argsort (np .abs (packets_frac ),axis = 1 ),axis = 1 )
319
- ass_track_ids = np .take_along_axis (packets_mc , frac_order , axis = 1 )
329
+ ass_track_ids = np .take_along_axis (packets_mc_trk , frac_order , axis = 1 )
320
330
ass_fractions = np .take_along_axis (packets_frac , frac_order , axis = 1 )
321
331
322
332
# Second, only store the relevant portion.
@@ -333,6 +343,9 @@ def export_to_hdf5(event_id_list,
333
343
pad_width = ((0 ,0 ),(0 ,num_to_pad )),
334
344
mode = 'constant' ,
335
345
constant_values = 0. )
346
+ packets_mc_ds ['event_ids' ] = packets_mc_evt
347
+ print ("packets_mc_ds['event_ids']: " ,packets_mc_ds ['event_ids' ])
348
+ print ("packets_mc_ds['event_ids'].shape: " , packets_mc_ds ['event_ids' ].shape )
336
349
337
350
with h5py .File (filename , 'a' ) as f :
338
351
if "mc_packets_assn" not in f .keys ():
0 commit comments