73def main(filename, det, nrecords, nskip, adc_stats, check_ts, summary, print_frame_timestamps):
76 records = h5_file.get_all_record_ids()
78 if nskip > len(records):
79 print(f
'Requested records to skip {nskip} is greater than number of records {len(records)}. Exiting...')
83 if (nskip+nrecords) > len(records):
86 nrecords=nskip+nrecords
88 records_to_process = []
91 records_to_process = records[nskip:]
93 records_to_process = records[nskip:nrecords]
95 print(f
'Will process {len(records_to_process)} of {len(records)} records.')
97 for r
in records_to_process:
99 pds_geo_ids = list(h5_file.get_geo_ids_for_subdetector(r,detdataformats.DetID.string_to_subdetector(det)))
101 if len(pds_geo_ids) == 0:
102 print(f
"Record {r} has no data for {det}. Exiting..")
113 headline = f
"{'CRATE':^10} {'SLOT':^10} {'LINK':^10} {'Fragment Type':^15} {'CHANNEL':^10} "
116 headline += f
" {'MEAN':^10} {'Std.dev.':^10}"
119 headline += f
" {'TS stats':^17} {'TS Check':^18}"
121 trg_ts_nsec = float(h5_file.get_frag(r,pds_geo_ids[0]).get_trigger_timestamp())/62500000.0
122 trg_time_string = datetime.datetime.fromtimestamp(trg_ts_nsec)
125 print(f
"{'RECORD':>50}: {r[0]:<15} {str(trg_time_string):^26}")
133 for gid
in pds_geo_ids:
135 frag = h5_file.get_frag(r,gid)
136 det_link = 0xffff & (gid >> 48);
137 det_slot = 0xffff & (gid >> 32);
138 det_crate = 0xffff & (gid >> 16);
139 det_id = 0xffff & gid;
140 subdet = detdataformats.DetID.Subdetector(det_id)
141 det_name = detdataformats.DetID.subdetector_to_string(subdet)
142 fragType = frag.get_header().fragment_type
144 if fragType == FragmentType.kDAPHNE.value:
146 first_frame = fddetdataformats.DAPHNEFrame(frag.get_data())
147 timestamps = np_array_timestamp(frag)
148 adcs = np_array_adc(frag)
149 channels = np_array_channels(frag)
150 n_channels = len(np.unique(channels))
152 elif fragType == FragmentType.kDAPHNEStream.value:
154 first_frame = fddetdataformats.DAPHNEStreamFrame(frag.get_data())
155 timestamps = np_array_timestamp_stream(frag)
156 adcs = np_array_adc_stream(frag)
157 channels = np_array_channels_stream(frag)[0]
158 n_channels = len(np.unique(channels))
161 trigger_stamps.append(frag.get_trigger_timestamp())
163 daq_header = first_frame.get_daqheader()
164 print(daq_header,daq_header.version)
166 daq_header = first_frame.get_daqheader()
167 print(daq_header,daq_header.version)
169 ts_status = f
"{bcolors.FAIL}{'Problems':^20}{bcolors.ENDC}"
171 for ch_num
in range(n_channels):
172 scanned_channels += 1
173 line = f
"{det_crate:^10} {det_slot:^10} {det_link:^10} {dmodes[fragType] :^15} {channels[ch_num]:^10} "
175 if np.mean(adcs[:]) > 10:
179 if fragType == FragmentType.kDAPHNE.value:
180 line += f
"{np.mean(adcs[:]):^10.2f} {np.std(adcs[:]):^10.2f} "
182 line += f
"{np.mean(adcs[:, ch_num]):^10.2f} {np.std(adcs[:, ch_num]):^10.2f} "
185 delta = np.diff(timestamps)
186 line += f
"{np.mean(delta):>8.1f}/{np.std(delta):<8.1f}"
188 if np.std(delta) < 2:
189 ts_status = f
"{bcolors.OKGREEN}{'OK':^18}{bcolors.ENDC}"
195 if (print_frame_timestamps):
196 temp_channels = np_array_channels_stream(frag)
197 temp_dashes_string =
"-"*110
198 print(f
" {temp_dashes_string}")
199 print(
" --> Frame timestamp details <--")
200 print(
" Index Channel DTS Timestamp (ticks) DTS Timestamp (time string)")
201 print(f
" {temp_dashes_string}")
203 for idx
in range(len(timestamps)):
204 if fragType == FragmentType.kDAPHNEStream.value
and (idx % 64) != 0:
206 ts_nsec = float(timestamps[idx])/62500000.0
207 time_string = datetime.datetime.fromtimestamp(ts_nsec)
208 if fragType == FragmentType.kDAPHNEStream.value:
209 print(f
' {(idx/64):>5} {temp_channels[loop_counter]} {timestamps[idx]:>20} {str(time_string):<26}')
211 print(f
' {idx:>5} {channels[idx]:>5} {timestamps[idx]:>20} {str(time_string):<26}')
215 if tslot == det_slot:
221 print(f
"Number of active/total channels \t-- {active_channels:>20}/{scanned_channels}\n")
226 print(f
"{'SUMMARY':^80}")
228 print(f
"Processed records \t - \t {len(records_to_process)} \n")
230 print(f
"\t crates \t slots \t\t links")
234 if (np.all(timelines) == 1):
235 print(f
"Timelines \t - \t {bcolors.OKGREEN} OK {bcolors.ENDC} \n")
237 print(f
"Timelines \t - \t {bcolors.FAIL} PROBLEMS {bcolors.ENDC} \n")
239 print(f
"{'Processing fnished': ^80}")