845 def get_det_data_all(self,frag):
846 frh = frag.get_header()
847 trigger_number = frh.trigger_number
848 wvfm_data = None
849 ana_data = None
850
851 get_ana_data = (self.ana_data_prescale is not None and (trigger_number % self.ana_data_prescale)==0)
852 get_wvfm_data = (self.wvfm_data_prescale is not None and (trigger_number % self.wvfm_data_prescale)==0)
853
854 if not (get_ana_data or get_wvfm_data):
855 return None,None
856
857 n_frames = self.get_n_obj(frag)
858 adcs = self.unpacker.np_array_adc(frag)
859
860 daphne_headers = [ self.frame_obj(frag.get_data(iframe*self.frame_obj.sizeof())).get_header() for iframe in range(n_frames) ]
861 timestamp = self.unpacker.np_array_timestamp(frag)
862
863 if (len(adcs)) == 0:
864 return None, None
865
866 det, crate, slot, stream = self.get_det_crate_slot_stream(frag)
867
868 if get_ana_data:
869 ax = 1
870 adc_mean = np.mean(adcs,axis=ax)
871 adc_rms = np.std(adcs,axis=ax)
872 adc_max = np.max(adcs,axis=ax)
873 adc_min = np.min(adcs,axis=ax)
874 adc_median = np.median(adcs,axis=ax)
875 ts_max = np.argmax(adcs,axis=ax)*self.SAMPLING_PERIOD + timestamp
876 ts_min = np.argmin(adcs,axis=ax)*self.SAMPLING_PERIOD + timestamp
877
878 ana_data = [ DAPHNEAnalysisData(run=frh.run_number,
879 trigger=frh.trigger_number,
880 sequence=frh.sequence_number,
881 src_id=frh.element_id.id,
882 channel=self.channel_map.get_offline_channel_from_det_crate_slot_stream_chan(det, crate, slot, stream, daphne_headers[iframe].channel),
883 daphne_chan=daphne_headers[iframe].channel,
884 timestamp_dts=timestamp[iframe],
885 trigger_sample_value=daphne_headers[iframe].trigger_sample_value,
886 threshold=daphne_headers[iframe].threshold,
887 baseline=daphne_headers[iframe].baseline,
888 adc_mean=adc_mean[iframe],
889 adc_rms=adc_rms[iframe],
890 adc_max=adc_max[iframe],
891 adc_min=adc_min[iframe],
892 adc_median=adc_median[iframe],
893 timestamp_max_dts=ts_max[iframe],
894 timestamp_min_dts=ts_min[iframe]) for iframe in range(n_frames) ]
895
896
897 if get_wvfm_data:
898
899 wvfm_data = [ DAPHNEWaveformData(run=frh.run_number,
900 trigger=frh.trigger_number,
901 sequence=frh.sequence_number,
902 src_id=frh.element_id.id,
903 channel=self.channel_map.get_offline_channel_from_det_crate_slot_stream_chan(det, crate, slot, stream, daphne_headers[iframe].channel),
904 daphne_chan=daphne_headers[iframe].channel,
905 timestamp_dts=timestamp[iframe],
906 timestamps=np.arange(np.size(adcs[iframe,:]))*self.SAMPLING_PERIOD+timestamp[iframe],
907 adcs=adcs[iframe,:]) for iframe in range(n_frames) ]
908
909 return ana_data, wvfm_data
910