DUNE-DAQ
DUNE Trigger and Data Acquisition software
Loading...
Searching...
No Matches
tdedecoder Namespace Reference

Functions

 main (filename, nrecords, nskip, print_adc_stats, print_wvfm_samples, det)
 

Function Documentation

◆ main()

tdedecoder.main ( filename,
nrecords,
nskip,
print_adc_stats,
print_wvfm_samples,
det )

Definition at line 24 of file tdedecoder.py.

24def main(filename, nrecords, nskip, print_adc_stats, print_wvfm_samples, det):
25
26 h5_file = HDF5RawDataFile(filename)
27
28 records = h5_file.get_all_record_ids()
29
30 if nskip > len(records):
31 print(f'Requested records to skip {nskip} is greater than number of records {len(records)}. Exiting...')
32 return
33 if nrecords>0:
34 if (nskip+nrecords)>len(records):
35 nrecords=-1
36 else:
37 nrecords=nskip+nrecords
38
39 records_to_process = []
40 if nrecords==-1:
41 records_to_process = records[nskip:]
42 else:
43 records_to_process = records[nskip:nrecords]
44 print(f'Will process {len(records_to_process)} of {len(records)} records.')
45
46 unpacker = TDEEthUnpacker(channel_map=None,ana_data_prescale=1,wvfm_data_prescale=1)
47
48 for r in records_to_process:
49
50 print(f'Processing (Record Number,Sequence Number)=({r[0],r[1]})')
51 geo_ids = h5_file.get_geo_ids_for_subdetector(r,detdataformats.DetID.string_to_subdetector(det))
52
53 for gid in geo_ids:
54
55 det_stream = 0xffff & (gid >> 48);
56 det_slot = 0xffff & (gid >> 32);
57 det_crate = 0xffff & (gid >> 16);
58 det_id = 0xffff & gid;
59 subdet = detdataformats.DetID.Subdetector(det_id)
60 det_name = detdataformats.DetID.subdetector_to_string(subdet)
61 print(f'\tProcessing subdetector {det_name}, '
62 f'crate {det_crate}, '
63 f'slot {det_slot}, '
64 f'stream {det_stream}')
65
66 #get the fragment
67 frag = h5_file.get_frag(r,gid)
68
69 #perform unpacking of fragment and detector header info
70 frag_header = unpacker.get_frh_data(frag)[0]
71
72 print('\t',frag_header)
73
74 n_frames = unpacker.get_n_obj(frag)
75 print(f'Found {n_frames} TDE frames in this fragment.')
76 if n_frames==0:
77 continue
78
79 daq_header_data = unpacker.get_daq_header_data(frag)
80 tde_header_data = unpacker.get_det_header_data(frag)
81
82 for i_tdeh, tdeh in enumerate(tde_header_data):
83 print(f'\tDAQ header {i_tdeh}: ',daq_header_data[i_tdeh])
84 print(f'\tTDE header info: ',tdeh)
85
86 tde_ana_data, tde_wvfm_data = unpacker.get_det_data_all(frag)
87
88 if print_adc_stats:
89 for tde_ana in tde_ana_data:
90 print(f'\t\tTDE channel {tde_ana.channel} adc stats:')
91 print('\t\t',tde_ana)
92
93 if print_wvfm_samples:
94 for tde_wvfm in tde_wvfm_data:
95 print(f'\t\tTDE channel {tde_wvfm.channel} waveform:')
96 for i_sample in range(print_wvfm_samples):
97 ts_str = np.format_float_positional(tde_wvfm.timestamps[i_sample])
98 print(f'\t\t\t {i_sample:>5}: ts={ts_str:<25} val={tde_wvfm.adcs[i_sample]}')
99
100
101 #end record loop
102
103 print(f'Processed all requested records')
104
int main(int argc, char **argv)