diff --git a/src/nectarchain/dqm/camera_monitoring.py b/src/nectarchain/dqm/camera_monitoring.py index 59a5279f..57af29e9 100644 --- a/src/nectarchain/dqm/camera_monitoring.py +++ b/src/nectarchain/dqm/camera_monitoring.py @@ -13,22 +13,42 @@ class CameraMonitoring(DQMSummary): def __init__(self, gaink): self.k = gaink + self.Pix = None + self.Samp = None + self.camera = None + self.cmap = None + self.subarray = None + self.event_id = [] + self.event_times = [] + self.DrawerTemp = None + self.run_start = None + self.run_end = None + self.DrawerTimes = None + self.DrawerTemp11 = None + self.DrawerTemp21 = None + self.DrawerNum1 = None + self.DrawerTimes_new = None + self.DrawerTemp12 = None + self.DrawerTemp22 = None + self.DrawerNum2 = None + self.DrawerTemp1_mean = [] + self.DrawerTemp2_mean = [] + self.CameraMonitoring_Results_Dict = {} + self.ChargeInt_Figures_Dict = {} + self.ChargeInt_Figures_Names_Dict = {} def ConfigureForRun(self, path, Pix, Samp, Reader1): # define number of pixels and samples self.Pix = Pix self.Samp = Samp - self.camera = CameraGeometry.from_name("NectarCam-003").transform_to( + self.camera = Reader1.subarray.tel[0].camera.geometry.transform_to( EngineeringCameraFrame() ) self.cmap = "gnuplot2" self.subarray = Reader1.subarray - self.event_id = [] - self.event_times = [] - for i, evt1 in enumerate(Reader1): self.run_start1 = evt1.nectarcam.tel[0].svc.date @@ -89,8 +109,6 @@ def FinishRun(self): self.DrawerTemp22 = self.DrawerTemp21[self.DrawerTimes_new < self.run_end] self.DrawerNum2 = self.DrawerNum1[self.DrawerTimes_new < self.run_end] - self.DrawerTemp1_mean = [] - self.DrawerTemp2_mean = [] TotalDrawers = np.max(self.DrawerNum2) for i in range(TotalDrawers + 1): @@ -110,7 +128,6 @@ def FinishRun(self): print("DRAWER TEMPERATURE COULD NOT BE RETRIEVED!") def GetResults(self): - self.CameraMonitoring_Results_Dict = {} try: self.CameraMonitoring_Results_Dict[ "CAMERA-TEMPERATURE-AVERAGE" @@ -122,8 +139,6 @@ def GetResults(self): return self.CameraMonitoring_Results_Dict def PlotResults(self, name, FigPath): - self.ChargeInt_Figures_Dict = {} - self.ChargeInt_Figures_Names_Dict = {} try: fig, disp = plt.subplots() diff --git a/src/nectarchain/dqm/charge_integration.py b/src/nectarchain/dqm/charge_integration.py index 7803f30d..6417f04e 100644 --- a/src/nectarchain/dqm/charge_integration.py +++ b/src/nectarchain/dqm/charge_integration.py @@ -12,6 +12,32 @@ class ChargeIntegrationHighLowGain(DQMSummary): def __init__(self, gaink): self.k = gaink + self.Pix = None + self.Samp = None + self.counter_evt = None + self.counter_ped = None + self.image_all = [] + self.peakpos_all = [] + self.image_ped = [] + self.peakpos_ped = [] + self.camera = None + self.cmap = None + self.subarray = None + self.integrator = None + self.pixelBAD = None + self.image_all = [] + self.image_all_median = None + self.image_all_average = None + self.image_all_std = None + self.image_all_rms = None + self.image_ped = [] + self.image_ped_median = None + self.image_ped_average = None + self.image_ped_std = None + self.image_ped_rms = None + self.ChargeInt_Results_Dict = {} + self.ChargeInt_Figures_Dict = {} + self.ChargeInt_Figures_Names_Dict = {} def ConfigureForRun(self, path, Pix, Samp, Reader1): # define number of pixels and samples @@ -21,9 +47,10 @@ def ConfigureForRun(self, path, Pix, Samp, Reader1): self.counter_evt = 0 self.counter_ped = 0 - self.camera = CameraGeometry.from_name("NectarCam-003").transform_to( + self.camera = Reader1.subarray.tel[0].camera.geometry.transform_to( EngineeringCameraFrame() ) + self.cmap = "gnuplot2" self.subarray = Reader1.subarray @@ -37,11 +64,7 @@ def ConfigureForRun(self, path, Pix, Samp, Reader1): self.integrator = LocalPeakWindowSum(subarray, config=config) - self.image_all = [] - self.peakpos_all = [] - self.image_ped = [] - self.peakpos_ped = [] def ProcessEvent(self, evt, noped): self.pixelBAD = evt.mon.tel[0].pixel_status.hardware_failing_pixels @@ -106,7 +129,6 @@ def FinishRun(self): self.image_ped_rms = np.sqrt(np.sum(self.image_ped**2, axis=0)) def GetResults(self): - self.ChargeInt_Results_Dict = {} if self.k == 0: self.ChargeInt_Results_Dict[ @@ -167,8 +189,6 @@ def GetResults(self): return self.ChargeInt_Results_Dict def PlotResults(self, name, FigPath): - self.ChargeInt_Figures_Dict = {} - self.ChargeInt_Figures_Names_Dict = {} # titles = ['All', 'Pedestals'] if self.k == 0: diff --git a/src/nectarchain/dqm/dqm_summary_processor.py b/src/nectarchain/dqm/dqm_summary_processor.py index e9a04437..89584903 100644 --- a/src/nectarchain/dqm/dqm_summary_processor.py +++ b/src/nectarchain/dqm/dqm_summary_processor.py @@ -13,7 +13,6 @@ def DefineForRun(self, reader1): self.FirstReader = reader1 self.Samp = len(evt1.r0.tel[0].waveform[0][0]) self.Pix = len(evt1.r0.tel[0].waveform[0]) - return self.Pix, self.Samp def ConfigureForRun(self): @@ -36,11 +35,12 @@ def PlotResults( def WriteAllResults(self, path, DICT): data2 = Table() data1 = Table() + data0 = Table() data = Table() - hdu, hdu1, hdu2 = None, None, None + hdu, hdu0, hdu1, hdu2 = None, None, None, None hdulist = fits.HDUList() for i, j in DICT.items(): - if i == "Results_TriggerStatistics": + if (i == "Results_TriggerStatistics"): for n2, m2 in j.items(): data2[n2] = m2 hdu2 = fits.BinTableHDU(data2) @@ -52,7 +52,13 @@ def WriteAllResults(self, path, DICT): for n1, m1 in j.items(): data1[n1] = m1 hdu1 = fits.BinTableHDU(data1) - hdu1.name = "MWF" + hdu1.name = "MWF" + + elif (i == "Results_PixelTimeline_HighGain") or (i == "Results_PixelTimeline_LowGain"): + for n0, m0 in j.items(): + data0[n0] = m0 + hdu0 = fits.BinTableHDU(data0) + hdu0.name = "BPX" else: for n, m in j.items(): @@ -67,11 +73,17 @@ def WriteAllResults(self, path, DICT): hdulist.append(hdu1) else: print("No MWF studies requests") + if hdu0: + hdulist.append(hdu0) + else: + print("No Pixel Timeline studies requests") if hdu: hdulist.append(hdu) else: print("No Camera studies requests") - FileName = path + "_Results.fits" + + + FileName = path + '_Results.fits' print(FileName) hdulist.writeto(FileName, overwrite=True) return None diff --git a/src/nectarchain/dqm/mean_camera_display.py b/src/nectarchain/dqm/mean_camera_display.py index 837e2f84..43baf4b7 100644 --- a/src/nectarchain/dqm/mean_camera_display.py +++ b/src/nectarchain/dqm/mean_camera_display.py @@ -8,15 +8,31 @@ class MeanCameraDisplay_HighLowGain(DQMSummary): def __init__(self, gaink): self.k = gaink - return None + self.Pix = None + self.Samp = None + self.CameraAverage = None + self.CameraAverage_ped = None + self.counter_evt = None + self.counter_ped = None + self.camera = None + self.cmap = None + self.CameraAverage = [] + self.CameraAverage1 = [] + self.CameraAverage_ped = [] + self.CameraAverage_ped1 = [] + self.CameraAverage_overEvents = None + self.CameraAverage_overEvents_overSamp = None + self.CameraAverage_ped_overEvents = None + self.CameraAverage_ped_overEvents_overSamp = None + self.MeanCameraDisplay_Results_Dict = {} + self.MeanCameraDisplay_Figures_Dict = {} + self.MeanCameraDisplay_Figures_Names_Dict = {} def ConfigureForRun(self, path, Pix, Samp, Reader1): # define number of pixels and samples self.Pix = Pix self.Samp = Samp - self.CameraAverage = np.zeros(self.Pix) - self.CameraAverage_ped = np.zeros(self.Pix) self.counter_evt = 0 self.counter_ped = 0 @@ -26,8 +42,6 @@ def ConfigureForRun(self, path, Pix, Samp, Reader1): self.cmap = "gnuplot2" - self.CameraAverage = [] - self.CameraAverage_ped = [] def ProcessEvent(self, evt, noped): self.pixelBAD = evt.mon.tel[0].pixel_status.hardware_failing_pixels @@ -72,8 +86,6 @@ def FinishRun(self): ) def GetResults(self): - # INITIATE DICT - self.MeanCameraDisplay_Results_Dict = {} # ASSIGN RESUTLS TO DICT if self.k == 0: @@ -113,8 +125,6 @@ def GetResults(self): return self.MeanCameraDisplay_Results_Dict def PlotResults(self, name, FigPath): - self.MeanCameraDisplay_Figures_Dict = {} - self.MeanCameraDisplay_Figures_Names_Dict = {} # titles = ['All', 'Pedestals'] if self.k == 0: @@ -123,14 +133,14 @@ def PlotResults(self, name, FigPath): gain_c = "Low" if self.counter_evt > 0: - fig1, self.disp1 = plt.subplots() - self.disp1 = CameraDisplay( + fig1, disp1 = plt.subplots() + disp1 = CameraDisplay( geometry=self.camera[~self.pixelBAD[0]], image=self.CameraAverage_overEvents_overSamp[~self.pixelBAD[0]], cmap=plt.cm.coolwarm, ) - self.disp1.add_colorbar() - self.disp1.axes.text(2.0, 0, "Charge (DC)", rotation=90) + disp1.add_colorbar() + disp1.axes.text(2.0, 0, "Charge (DC)", rotation=90) plt.title("Camera average %s gain (ALL)" % gain_c) self.MeanCameraDisplay_Figures_Dict[ @@ -144,14 +154,14 @@ def PlotResults(self, name, FigPath): plt.close() if self.counter_ped > 0: - fig2, self.disp2 = plt.subplots() - self.disp2 = CameraDisplay( + fig2, disp2 = plt.subplots() + disp2 = CameraDisplay( geometry=self.camera[~self.pixelBAD[0]], image=self.CameraAverage_ped_overEvents_overSamp[~self.pixelBAD[0]], cmap=plt.cm.coolwarm, ) - self.disp2.add_colorbar() - self.disp2.axes.text(2.0, 0, "Charge (DC)", rotation=90) + disp2.add_colorbar() + disp2.axes.text(2.0, 0, "Charge (DC)", rotation=90) plt.title("Camera average %s gain (PED)" % gain_c) self.MeanCameraDisplay_Figures_Dict[ diff --git a/src/nectarchain/dqm/mean_waveforms.py b/src/nectarchain/dqm/mean_waveforms.py index 9f61e40e..7e17b2cb 100644 --- a/src/nectarchain/dqm/mean_waveforms.py +++ b/src/nectarchain/dqm/mean_waveforms.py @@ -6,24 +6,30 @@ class MeanWaveFormsHighLowGain(DQMSummary): def __init__(self, gaink): self.k = gaink - return None + self.Pix = None + self.Samp = None + self.Mwf = None + self.Mwf_ped = None + self.counter_evt = None + self.counter_ped = None + self.Mwf_average = None + self.Mwf_ped_average = None + self.Mwf_Mean_overPix = [] + self.Mwf_ped_Mean_overPix = [] + self.MeanWaveForms_Results_Dict = {} + self.MeanWaveForms_Figures_Dict = {} + self.MeanWaveForms_Figures_Names_Dict = {} def ConfigureForRun(self, path, Pix, Samp, Reader1): # define number of pixels and samples self.Pix = Pix self.Samp = Samp - - # redefine everything self.Mwf = np.zeros((self.Pix, self.Samp)) self.Mwf_ped = np.zeros((self.Pix, self.Samp)) self.counter_evt = 0 self.counter_ped = 0 - self.Mwf_average = np.zeros((self.Pix, self.Samp)) self.Mwf_ped_average = np.zeros((self.Pix, self.Samp)) - self.Mwf_Mean_overPix = [] - self.Mwf_ped_Mean_overPix = [] - self.wf_list_plot = list(range(1, self.Samp + 1)) # used for plotting later on return None @@ -64,8 +70,6 @@ def FinishRun(self): return None def GetResults(self): - # INITIATE DICT - self.MeanWaveForms_Results_Dict = {} # ASSIGN RESUTLS TO DICT if self.k == 0: @@ -89,8 +93,6 @@ def GetResults(self): return self.MeanWaveForms_Results_Dict def PlotResults(self, name, FigPath): - self.MeanWaveForms_Figures_Dict = {} - self.MeanWaveForms_Figures_Names_Dict = {} wf_list = np.array(self.wf_list_plot) diff --git a/src/nectarchain/dqm/pixel_participation.py b/src/nectarchain/dqm/pixel_participation.py new file mode 100644 index 00000000..b58b2aed --- /dev/null +++ b/src/nectarchain/dqm/pixel_participation.py @@ -0,0 +1,147 @@ +import numpy as np +from ctapipe.coordinates import EngineeringCameraFrame +from ctapipe.visualization import CameraDisplay +from dqm_summary_processor import DQMSummary +from matplotlib import pyplot as plt + + +class PixelParticipationHighLowGain(DQMSummary): + def __init__(self, gaink): + self.k = gaink + self.Pix = None + self.Samp = None + self.counter_evt = None + self.counter_ped = None + self.BadPixels_ped = None + self.BadPixels = None + self.camera = None + self.camera2 = None + self.cmap = None + self.cmap2 = None + self.PixelParticipation_Results_Dict = {} + self.PixelParticipation_Figures_Dict = {} + self.PixelParticipation_Figures_Names_Dict = {} + + def ConfigureForRun(self, path, Pix, Samp, Reader1): + # define number of pixels and samples + self.Pix = Pix + self.Samp = Samp + self.counter_evt = 0 + self.counter_ped = 0 + self.BadPixels_ped = np.zeros(self.Pix) + self.BadPixels = np.zeros(self.Pix) + + self.camera = Reader1.subarray.tel[0].camera.geometry.transform_to( + EngineeringCameraFrame() + ) + + self.camera2 = Reader1.subarray.tel[0].camera.geometry.transform_to( + EngineeringCameraFrame() + ) + + self.cmap = "gnuplot2" + self.cmap2 = "gnuplot2" + + def ProcessEvent(self, evt, noped): + pixelBAD = evt.mon.tel[0].pixel_status.hardware_failing_pixels[self.k] + pixel = evt.nectarcam.tel[0].svc.pixel_ids + if len(pixel) < self.Pix: + pixel21 = list(np.arange(0, self.Pix - len(pixel), 1, dtype=int)) + pixel = list(pixel) + pixels = np.concatenate([pixel21, pixel]) + else: + pixels = pixel + + if evt.trigger.event_type.value == 32: # count peds + self.counter_ped += 1 + BadPixels_ped1 = list(map(int, pixelBAD[pixels])) + self.BadPixels_ped += BadPixels_ped1 + + else: + self.counter_evt += 1 + BadPixels1 = list(map(int, pixelBAD[pixels])) + self.BadPixels += BadPixels1 + return None + + def FinishRun(self): + self.BadPixels_ped = np.array(self.BadPixels_ped) + self.BadPixels = np.array(self.BadPixels) + + def GetResults(self): + # ASSIGN RESUTLS TO DICT + if self.k == 0: + if self.counter_evt > 0: + self.PixelParticipation_Results_Dict[ + "CAMERA-BadPix-PHY-OverEVENTS-HIGH-GAIN" + ] = self.BadPixels + + if self.counter_ped > 0: + self.PixelParticipation_Results_Dict[ + "CAMERA-BadPix-PED-PHY-OverEVENTS-HIGH-GAIN" + ] = self.BadPixels_ped + + if self.k == 1: + if self.counter_evt > 0: + self.PixelParticipation_Results_Dict[ + "CAMERA-BadPix-PHY-OverEVENTS-LOW-GAIN" + ] = self.BadPixels + + if self.counter_ped > 0: + self.PixelParticipation_Results_Dict[ + "CAMERA-BadPix-PED-PHY-OverEVENTS-LOW-GAIN" + ] = self.BadPixels_ped + + return self.PixelParticipation_Results_Dict + + def PlotResults(self, name, FigPath): + # titles = ['All', 'Pedestals'] + if self.k == 0: + gain_c = "High" + if self.k == 1: + gain_c = "Low" + + if self.counter_evt > 0: + entity = self.BadPixels + title = "Camera BPX %s gain (ALL)" % gain_c + + if self.counter_ped > 0: + entity = self.BadPixels_ped + title = "Camera BPX %s gain (PED)" % gain_c + + fig, disp = plt.subplots() + disp = CameraDisplay( + geometry=self.camera, + image=entity, + cmap=self.cmap, + ) + disp.cmap = self.cmap + disp.cmap = plt.cm.coolwarm + disp.add_colorbar() + disp.axes.text(2.0, 0, "Bad Pixels", rotation=90) + plt.title(title) + + if self.counter_ped > 0: + self.PixelParticipation_Figures_Dict[ + "CAMERA-BADPIX-PHY-DISPLAY-%s-GAIN" % gain_c + ] = fig + full_name = name + "_Camera_BPX_%sGain.png" % gain_c + FullPath = FigPath + full_name + self.PixelParticipation_Figures_Names_Dict[ + "CAMERA-BADPIX-PHY-DISPLAY-%s-GAIN" % gain_c + ] = FullPath + if self.counter_evt > 0: + self.PixelParticipation_Figures_Dict[ + "CAMERA-BADPIX-PED-DISPLAY-%s-GAIN" % gain_c + ] = fig + full_name = name + "_Pedestal_BPX_%sGain.png" % gain_c + FullPath = FigPath + full_name + self.PixelParticipation_Figures_Names_Dict[ + "CAMERA-BADPIX-PED-DISPLAY-%s-GAIN" % gain_c + ] = FullPath + + plt.close() + + return ( + self.PixelParticipation_Figures_Dict, + self.PixelParticipation_Figures_Names_Dict, + ) diff --git a/src/nectarchain/dqm/pixel_timeline.py b/src/nectarchain/dqm/pixel_timeline.py new file mode 100644 index 00000000..e120f561 --- /dev/null +++ b/src/nectarchain/dqm/pixel_timeline.py @@ -0,0 +1,145 @@ +import numpy as np +from dqm_summary_processor import DQMSummary +from matplotlib import pyplot as plt + + +class PixelTimelineHighLowGain(DQMSummary): + def __init__(self, gaink): + self.k = gaink + self.Pix = None + self.Samp = None + self.counter_evt = None + self.counter_ped = None + self.SumBadPixels_ped = [] + self.SumBadPixels = [] + self.BadPixelTimeline_ped = None + self.BadPixelTimeline = None + self.camera = None + self.cmap = None + self.cmap2 = None + self.PixelTimeline_Results_Dict = {} + self.PixelTimeline_Figures_Dict = {} + self.PixelTimeline_Figures_Names_Dict = {} + + def ConfigureForRun(self, path, Pix, Samp, Reader1): + # define number of pixels and samples + self.Pix = Pix + self.Samp = Samp + self.counter_evt = 0 + self.counter_ped = 0 + + def ProcessEvent(self, evt, noped): + pixelBAD = evt.mon.tel[0].pixel_status.hardware_failing_pixels[self.k] + pixel = evt.nectarcam.tel[0].svc.pixel_ids + if len(pixel) < self.Pix: + pixel21 = list(np.arange(0, self.Pix - len(pixel), 1, dtype=int)) + pixel = list(pixel) + pixels = np.concatenate([pixel21, pixel]) + else: + pixels = pixel + + if evt.trigger.event_type.value == 32: # count peds + self.counter_ped += 1 + self.counter_evt += 1 + BadPixels_ped1 = list(map(int, pixelBAD[pixels])) + SumBadPixelsEvent_ped = sum(BadPixels_ped1) + self.SumBadPixels_ped.append(SumBadPixelsEvent_ped) + self.SumBadPixels.append(0) + + else: + self.counter_evt += 1 + self.counter_ped += 1 + BadPixels1 = list(map(int, pixelBAD[pixels])) + SumBadPixelsEvent = sum(BadPixels1) + self.SumBadPixels.append(SumBadPixelsEvent) + self.SumBadPixels_ped.append(0) + + return None + + def FinishRun(self): + self.BadPixelTimeline_ped = ( + np.array(self.SumBadPixels_ped, dtype=float) / self.Pix + ) + self.BadPixelTimeline = np.array(self.SumBadPixels, dtype=float) / self.Pix + print(self.BadPixelTimeline) + print(self.BadPixelTimeline_ped) + + def GetResults(self): + # ASSIGN RESUTLS TO DICT + if self.k == 0: + if self.counter_evt > 0: + self.PixelTimeline_Results_Dict[ + "CAMERA-BadPixTimeline-PHY-HIGH-GAIN" + ] = self.BadPixelTimeline + + if self.counter_ped > 0: + self.PixelTimeline_Results_Dict[ + "CAMERA-BadPixTimeline-PED-HIGH-GAIN" + ] = self.BadPixelTimeline_ped + + if self.k == 1: + if self.counter_evt > 0: + self.PixelTimeline_Results_Dict[ + "CAMERA-BadPixTimeline-PHY-LOW-GAIN" + ] = self.BadPixelTimeline + + if self.counter_ped > 0: + self.PixelTimeline_Results_Dict[ + "CAMERA-BadPixTimeline-PED-LOW-GAIN" + ] = self.BadPixelTimeline_ped + + return self.PixelTimeline_Results_Dict + + def PlotResults(self, name, FigPath): + # titles = ['All', 'Pedestals'] + if self.k == 0: + gain_c = "High" + if self.k == 1: + gain_c = "Low" + + if self.counter_evt > 0: + fig1, disp = plt.subplots() + plt.plot( + np.arange(self.counter_evt), + self.BadPixelTimeline * 100, + label="Physical events", + ) + plt.legend() + plt.xlabel("Timeline") + plt.ylabel("BPX fraction (%)") + plt.title("BPX Timeline %s gain (ALL)" % gain_c) + + full_name = name + "_BPX_Timeline_%sGain_All.png" % gain_c + FullPath = FigPath + full_name + self.PixelTimeline_Figures_Dict["BPX-TIMELINE-ALL-%s-GAIN" % gain_c] = fig1 + self.PixelTimeline_Figures_Names_Dict[ + "BPX-TIMELINE-ALL-%s-GAIN" % gain_c + ] = FullPath + + plt.close() + + if self.counter_ped > 0: + fig2, disp = plt.subplots() + plt.plot( + np.arange(self.counter_ped), + self.BadPixelTimeline_ped * 100, + label="Pedestal events", + ) + plt.legend() + plt.xlabel("Timeline") + plt.ylabel("BPX fraction (%)") + plt.title("BPX Timeline %s gain (PED)" % gain_c) + + full_name = name + "_BPX_Timeline_%sGain_Ped.png" % gain_c + FullPath = FigPath + full_name + self.PixelTimeline_Figures_Dict["BPX-TIMELINE-PED-%s-GAIN" % gain_c] = fig2 + self.PixelTimeline_Figures_Names_Dict[ + "BPX-TIMELINE-PED-%s-GAIN" % gain_c + ] = FullPath + + plt.close() + + return ( + self.PixelTimeline_Figures_Dict, + self.PixelTimeline_Figures_Names_Dict, + ) diff --git a/src/nectarchain/dqm/start_dqm.py b/src/nectarchain/dqm/start_dqm.py index a40e37b5..f6c91701 100644 --- a/src/nectarchain/dqm/start_dqm.py +++ b/src/nectarchain/dqm/start_dqm.py @@ -11,6 +11,8 @@ from matplotlib import pyplot as plt from mean_camera_display import MeanCameraDisplay_HighLowGain from mean_waveforms import MeanWaveFormsHighLowGain +from pixel_participation import PixelParticipationHighLowGain +from pixel_timeline import PixelTimelineHighLowGain from tqdm import tqdm from traitlets.config import Config from trigger_statistics import TriggerStatistics @@ -140,28 +142,51 @@ def CreateFigFolder(name, type): # LIST OF PROCESSES TO RUN ######################################################################################## -processors = [ - TriggerStatistics(HIGH_GAIN), - MeanWaveFormsHighLowGain(HIGH_GAIN), - MeanWaveFormsHighLowGain(LOW_GAIN), - MeanCameraDisplay_HighLowGain(HIGH_GAIN), - MeanCameraDisplay_HighLowGain(LOW_GAIN), - ChargeIntegrationHighLowGain(HIGH_GAIN), - ChargeIntegrationHighLowGain(LOW_GAIN), - CameraMonitoring(HIGH_GAIN), -] +a = TriggerStatistics(HIGH_GAIN) +b = MeanWaveFormsHighLowGain(HIGH_GAIN) +c = MeanWaveFormsHighLowGain(LOW_GAIN) +d = MeanCameraDisplay_HighLowGain(HIGH_GAIN) +e = MeanCameraDisplay_HighLowGain(LOW_GAIN) +f = ChargeIntegrationHighLowGain(HIGH_GAIN) +g = ChargeIntegrationHighLowGain(LOW_GAIN) +h = CameraMonitoring(HIGH_GAIN) +i = PixelParticipationHighLowGain(HIGH_GAIN) +j = PixelParticipationHighLowGain(LOW_GAIN) +k = PixelTimelineHighLowGain(HIGH_GAIN) +ll = PixelTimelineHighLowGain(LOW_GAIN) + +processors = list() + +processors.append(a) +processors.append(b) +processors.append(c) +processors.append(d) +processors.append(e) +processors.append(f) +processors.append(g) +processors.append(h) +processors.append(i) +processors.append(j) +processors.append(k) +processors.append(ll) + # LIST OF DICT RESULTS +Results_TriggerStatistics = {} Results_MeanWaveForms_HighGain = {} Results_MeanWaveForms_LowGain = {} Results_MeanCameraDisplay_HighGain = {} Results_MeanCameraDisplay_LowGain = {} Results_ChargeIntegration_HighGain = {} Results_ChargeIntegration_LowGain = {} -Results_TriggerStatistics = {} Results_CameraMonitoring = {} +Results_PixelParticipation_HighGain = {} +Results_PixelParticipation_LowGain = {} +Results_PixelTimeline_HighGain = {} +Results_PixelTimeline_LowGain = {} NESTED_DICT = {} # The final results dictionary + NESTED_DICT_KEYS = [ "Results_TriggerStatistics", "Results_MeanWaveForms_HighGain", @@ -171,8 +196,13 @@ def CreateFigFolder(name, type): "Results_ChargeIntegration_HighGain", "Results_ChargeIntegration_LowGain", "Results_CameraMonitoring", + "Results_PixelParticipation_HighGain", + "Results_PixelParticipation_LowGain", + "Results_PixelTimeline_HighGain", + "Results_PixelTimeline_LowGain", ] -# NESTED_DICT_KEYS = ["Results_CameraMonitoring"] + +# NESTED_DICT_KEYS = ["Results_PixelParticipation_HighGain"] # START for p in processors: diff --git a/src/nectarchain/dqm/trigger_statistics.py b/src/nectarchain/dqm/trigger_statistics.py index 8effd922..fe429223 100644 --- a/src/nectarchain/dqm/trigger_statistics.py +++ b/src/nectarchain/dqm/trigger_statistics.py @@ -9,17 +9,32 @@ class TriggerStatistics(DQMSummary): def __init__(self, gaink): self.k = gaink + self.Pix = None + self.Samp = None + self.event_type = [] + self.event_times = [] + self.event_id = [] + self.run_times = [] + self.run_start1 = None + self.run_start = None + self.run_end = None + self.event_ped_times = None + self.event_phy_times = None + self.event_other_times = None + self.event_ped_id = None + self.event_phy_id = None + self.event_other_id = None + self.event_wrong_times = None + self.TriggerStat_Results_Dict = {} + self.TriggerStat_Figures_Dict = {} + self.TriggerStat_Figures_Names_Dict = {} + def ConfigureForRun(self, path, Pix, Samp, Reader1): # define number of pixels and samples self.Pix = Pix self.Samp = Samp - self.event_type = [] - self.event_times = [] - self.event_id = [] - self.run_times = [] - def ProcessEvent(self, evt, noped): trigger_type = evt.trigger.event_type.value trigger_time = evt.trigger.time.value @@ -72,7 +87,6 @@ def FinishRun(self): self.event_times = self.event_times[self.event_times > self.run_start] def GetResults(self): - self.TriggerStat_Results_Dict = {} self.TriggerStat_Results_Dict["TRIGGER-TYPES"] = self.triggers self.TriggerStat_Results_Dict[ "TRIGGER-STATISTICS" @@ -97,8 +111,6 @@ def PlotResults(self, name, FigPath): n1 = np.array(self.event_times.max() - self.event_times.min(), dtype=object) n = math.ceil(n1 / w) - self.TriggerStat_Figures_Dict = {} - self.TriggerStat_Figures_Names_Dict = {} fig1, ax = plt.subplots() ax.hist( self.event_type,