From 0faf641720e91c75fac5f92f2bb043c7567e7882 Mon Sep 17 00:00:00 2001 From: philiph-slac Date: Tue, 27 Aug 2024 12:41:18 -0700 Subject: [PATCH 1/5] updates for analyzing epix10k data --- calibrationSuite/detectorInfo.py | 17 +++++++++++++++++ setup_epix100.sh | 20 ++++++++++++++++++++ setup_epix10k.sh | 20 ++++++++++++++++++++ 3 files changed, 57 insertions(+) create mode 100755 setup_epix100.sh create mode 100755 setup_epix10k.sh diff --git a/calibrationSuite/detectorInfo.py b/calibrationSuite/detectorInfo.py index f32d33d..49cdad1 100644 --- a/calibrationSuite/detectorInfo.py +++ b/calibrationSuite/detectorInfo.py @@ -145,6 +145,23 @@ def setup_jungfrau(self): self.seedCut = 3 self.neighborCut = 0.5 + def setup_epix10k(self): + self.cameraType = self.epix10kCameraTypes[self.nModules] + self.g0cut = 1 << 14 + self.nRows = 352 + self.nCols = 384 + self.nColsPerBank = 96 + self.nBanksRow = int(self.nCols / self.nColsPerBank) + self.nBanksCol = 2 + self.nRowsPerBank = int(self.nRows / self.nBanksCol) + # need to still implement getGainMode() + # self.gainMode = self.getGainMode() + self.preferredCommonMode = "colCommonMode" + self.clusterShape = [3, 3] + self.aduPerKeV = 16 ## high gain; 5.5 for medium + self.seedCut = 3 + self.neighborCut = 0.5 + def setup_rixsCCD(self): print("rixsCCD mode:", self.detectorSubtype) self.cameraType = "rixsCCD" ##+ mode ## psana should support mode diff --git a/setup_epix100.sh b/setup_epix100.sh new file mode 100755 index 0000000..3ce945d --- /dev/null +++ b/setup_epix100.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Setup environment variables + + +# current_dir=$(pwd) +git_project_root_dir=$(git rev-parse --show-toplevel) +# so scripts can find the calibrationSuite library code +export PYTHONPATH="$PYTHONPATH:$git_project_root_dir" +echo "PYTHONPATH = $PYTHONPATH" + +# so output folders are written in a shared location +##export OUTPUT_ROOT="/sdf/data/lcls/ds/rix/rixx1005922/scratch/" +##export OUTPUT_ROOT="/sdf/data/lcls/ds/rix/rixx1005922/results/" +export OUTPUT_ROOT="/sdf/data/lcls/ds/det/detdaq21/results/" +echo "OUTPUT_ROOT = $OUTPUT_ROOT" + +# point to which config file to use +##export SUITE_CONFIG="$git_project_root_dir/config_files/epixMSuiteConfig.py" +export SUITE_CONFIG="$git_project_root_dir/config_files/epix100SuiteConfig.py" +echo "SUITE_CONFIG = $SUITE_CONFIG" diff --git a/setup_epix10k.sh b/setup_epix10k.sh new file mode 100755 index 0000000..4670c13 --- /dev/null +++ b/setup_epix10k.sh @@ -0,0 +1,20 @@ +#!/bin/bash +# Setup environment variables + + +# current_dir=$(pwd) +git_project_root_dir=$(git rev-parse --show-toplevel) +# so scripts can find the calibrationSuite library code +export PYTHONPATH="$PYTHONPATH:$git_project_root_dir" +echo "PYTHONPATH = $PYTHONPATH" + +# so output folders are written in a shared location +##export OUTPUT_ROOT="/sdf/data/lcls/ds/rix/rixx1005922/scratch/" +##export OUTPUT_ROOT="/sdf/data/lcls/ds/rix/rixx1005922/results/" +export OUTPUT_ROOT="/sdf/data/lcls/ds/det/detdaq21/results/" +echo "OUTPUT_ROOT = $OUTPUT_ROOT" + +# point to which config file to use +##export SUITE_CONFIG="$git_project_root_dir/config_files/epixMSuiteConfig.py" +export SUITE_CONFIG="$git_project_root_dir/config_files/epix10kQuadSuiteConfig.py" +echo "SUITE_CONFIG = $SUITE_CONFIG" From 0b2d24a8a85fe8023f7d5e422baeb1ebc1cae3d4 Mon Sep 17 00:00:00 2001 From: philiph-slac Date: Tue, 27 Aug 2024 13:10:40 -0700 Subject: [PATCH 2/5] added zero counter for bad lane handling --- calibrationSuite/basicSuiteScript.py | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/calibrationSuite/basicSuiteScript.py b/calibrationSuite/basicSuiteScript.py index 1005868..36269b9 100755 --- a/calibrationSuite/basicSuiteScript.py +++ b/calibrationSuite/basicSuiteScript.py @@ -95,6 +95,16 @@ def getRawData(self, evt, gainBitsMasked=True, negativeGain=False): frames = self.plainGetRawData(evt) if frames is None: return None + + nZero = frames.size - np.count_nonzero(frames) + try: + dz = self.nZero - nZero + if dz > 0: + print("found %d new zero pixels, expected %d, setting frame to None" %(dz, self.nZero)) + return None + except: + self.nZero = nZero + if False and self.special: ## turned off for a tiny bit of speed if "thirteenBits" in self.special: frames = frames & 0xFFFE From a97fd5f4d3db464c1bc7353823f223425e803f71 Mon Sep 17 00:00:00 2001 From: philiph-slac Date: Wed, 28 Aug 2024 11:32:46 -0700 Subject: [PATCH 3/5] Updates to support epix10kquad - camera type recognition needs work still --- calibrationSuite/basicSuiteScript.py | 7 ++++--- calibrationSuite/detectorInfo.py | 4 ++-- calibrationSuite/psana1Base.py | 5 ++++- calibrationSuite/psanaCommon.py | 2 +- config_files/epix10kQuadSuiteConfig.py | 3 ++- suite_scripts/CalcNoiseAndMean.py | 1 + 6 files changed, 14 insertions(+), 8 deletions(-) diff --git a/calibrationSuite/basicSuiteScript.py b/calibrationSuite/basicSuiteScript.py index 36269b9..7362816 100755 --- a/calibrationSuite/basicSuiteScript.py +++ b/calibrationSuite/basicSuiteScript.py @@ -95,16 +95,17 @@ def getRawData(self, evt, gainBitsMasked=True, negativeGain=False): frames = self.plainGetRawData(evt) if frames is None: return None - + nZero = frames.size - np.count_nonzero(frames) try: dz = self.nZero - nZero - if dz > 0: + if dz != 0: print("found %d new zero pixels, expected %d, setting frame to None" %(dz, self.nZero)) return None except: self.nZero = nZero - + print("Starting with %d zero pixels, will require exactly that many for this run" %(nZero)) + if False and self.special: ## turned off for a tiny bit of speed if "thirteenBits" in self.special: frames = frames & 0xFFFE diff --git a/calibrationSuite/detectorInfo.py b/calibrationSuite/detectorInfo.py index 49cdad1..d6e55e9 100644 --- a/calibrationSuite/detectorInfo.py +++ b/calibrationSuite/detectorInfo.py @@ -42,11 +42,11 @@ def __init__(self, detType, detSubtype="1d", detVersion=0): knownTypes = ["epixhr", "epixm", "epix100", "Epix100a", "jungfrau", "Jungfrau",## cxic00121 has no alias in run 88 - "epix10k", "archon"] + "epix10k", "Epix10ka", "archon"] if detType not in knownTypes: raise Exception("type %s not in known types %s" % (detType, str(knownTypes))) - self.ePix10kCameraTypes = {1: "Epix10ka", 4: "Epix10kaQuad", 16: "Epix10ka2M"} + self.epix10kCameraTypes = {1: "Epix10ka", 4: "Epix10kaQuad", 16: "Epix10ka2M"} self.jungfrauCameraTypes = {1: "Jungfrau0.5", 2: "Jungfrau1M", 8: "Jungfrau4M"} def setupDetector(self): ## needs nModules to be set diff --git a/calibrationSuite/psana1Base.py b/calibrationSuite/psana1Base.py index 3328ad5..7726ccf 100755 --- a/calibrationSuite/psana1Base.py +++ b/calibrationSuite/psana1Base.py @@ -44,7 +44,10 @@ def setupPsana(self): self.run = self.runRange[0] self.ds = self.get_ds() - self.det = psana.Detector("%s.0:%s.%d" % (self.location, self.detType, self.camera), self.ds.env()) +## self.det = psana.Detector("%s.0:%s.%d" % (self.location, self.detType, self.camera), self.ds.env()) + self.det = psana.Detector("%s.0:%s.%d" % (self.location, self.detectorInfo.cameraType, self.camera), self.ds.env()) + ## this is to distinguish between epix10ka form factors, etc. + self.evrs = None try: self.wave8 = psana.Detector(self.fluxSource, self.ds.env()) diff --git a/calibrationSuite/psanaCommon.py b/calibrationSuite/psanaCommon.py index 14d12cf..a87a6fe 100755 --- a/calibrationSuite/psanaCommon.py +++ b/calibrationSuite/psanaCommon.py @@ -249,7 +249,7 @@ def setupFromCmdlineArgs(self): self.loadPedestalGainOffsetFiles() - print("det type:", self.args.detType) + print("command line det type:", self.args.detType) if self.args.detType == "": if self.args.nModules is not None: self.detectorInfo.setNModules(self.args.nModules) diff --git a/config_files/epix10kQuadSuiteConfig.py b/config_files/epix10kQuadSuiteConfig.py index f3aded0..e39fd9b 100755 --- a/config_files/epix10kQuadSuiteConfig.py +++ b/config_files/epix10kQuadSuiteConfig.py @@ -21,7 +21,8 @@ singlePixelArray.append([i, 80, 20]) experimentHash = { - "detectorType": "Epix10kaQuad", + ##"detectorType": "Epix10kaQuad",## this needs work + "detectorType": "Epix10ka", "exp": "detdaq21", # "exp": "rixx1003721", "location": "DetLab", diff --git a/suite_scripts/CalcNoiseAndMean.py b/suite_scripts/CalcNoiseAndMean.py index 291aa2b..c3717ac 100755 --- a/suite_scripts/CalcNoiseAndMean.py +++ b/suite_scripts/CalcNoiseAndMean.py @@ -184,5 +184,6 @@ bss.dumpEventCodeStatistics() ## temp for Alex: if False: + ##if True: np.save("nonZeroAsicAccounting.npy", np.array(nonZeroAsicArray)) print("non-zero asic accounting:", nonZeroAsicArray) From dcca862ddc847c814325b8ff92e46c0312806c98 Mon Sep 17 00:00:00 2001 From: philiph-slac Date: Wed, 28 Aug 2024 14:46:15 -0700 Subject: [PATCH 4/5] Make image when counting photons --- calibrationSuite/psana1Base.py | 2 +- suite_scripts/simplePhotonCounter.py | 12 +++++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/calibrationSuite/psana1Base.py b/calibrationSuite/psana1Base.py index 7726ccf..9b0db4a 100755 --- a/calibrationSuite/psana1Base.py +++ b/calibrationSuite/psana1Base.py @@ -152,7 +152,7 @@ def getCalibData(self, evt): return self.det.calib(evt) def getImage(self, evt, data=None): - return self.raw.image(evt, data) + return self.det.image(evt, data) def getPedestal(self, evt, gainmode): if self.detectorInfo.autoRanging: diff --git a/suite_scripts/simplePhotonCounter.py b/suite_scripts/simplePhotonCounter.py index 78882cc..c5a41da 100755 --- a/suite_scripts/simplePhotonCounter.py +++ b/suite_scripts/simplePhotonCounter.py @@ -104,7 +104,7 @@ print("total photons in detector using cut %0.2f is %0.3f" % (spc.photonCut, (thresholded).sum())) logger.info("total photons in detector using cut %0.2f is %0.3f" % (spc.photonCut, (thresholded).sum())) - if False: + if True:##False: spectrumFileName = "%s/%s_%s_r%d_c%d_%s_spectrum.npy" % ( spc.outputDir, scriptType, @@ -115,4 +115,14 @@ ) np.save(spectrumFileName, energyHistogram) + imageFileName = spectrumFileName.replace("spectrum", "image") + tImage = spc.getImage(evt, thresholded) + np.save(imageFileName, tImage) + import matplotlib.pyplot as plt + p90 = np.percentile(tImage, 90) + print("clipping image at 90% of max") + plt.imshow(tImage.clip(0, p90)) + plt.colorbar() + plt.savefig(imageFileName.replace("npy", "png")) + spc.dumpEventCodeStatistics() From 95bde0a99403826232cc064dc75f6a90d0bfa371 Mon Sep 17 00:00:00 2001 From: philiph-slac Date: Thu, 29 Aug 2024 14:47:45 -0700 Subject: [PATCH 5/5] Update epixm setup --- config_files/epixMSuiteConfig.py | 18 ++++---- config_files/epixM_oldCamera_SuiteConfig.py | 49 +++++++++++++++++++++ setup.sh | 8 ++-- 3 files changed, 61 insertions(+), 14 deletions(-) create mode 100755 config_files/epixM_oldCamera_SuiteConfig.py diff --git a/config_files/epixMSuiteConfig.py b/config_files/epixMSuiteConfig.py index 20f422a..c72dcb0 100755 --- a/config_files/epixMSuiteConfig.py +++ b/config_files/epixMSuiteConfig.py @@ -12,22 +12,20 @@ # experimentHash = {'exp':'mfxx1005021', 'location':'MfxEndstation', 'fluxSource':'MFX-USR-DIO', 'fluxChannels':[11], 'fluxSign':-1} # experimentHash = {'exp':'rixc00121', 'location':'RixEndstation', singlePixelArray = [] -for i in range(1, 3): +for i in range(0, 3): singlePixelArray.append([i, 10, 10]) - singlePixelArray.append([i, 10, 100]) - singlePixelArray.append([i, 100, 10]) - singlePixelArray.append([i, 100, 100]) - singlePixelArray.append([i, 150, 150]) - singlePixelArray.append([i, 80, 20]) - -singlePixelArray.append([2, 178, 367]) + singlePixelArray.append([i, 180, 10]) + singlePixelArray.append([i, 10, 200]) + singlePixelArray.append([i, 180, 200]) + singlePixelArray.append([i, 10, 380]) + singlePixelArray.append([i, 180, 380]) experimentHash = { "detectorType": "epixm", + "detectorVersion":1,## new firmware "exp": "rixx1005922", - # "exp": "rixx1003721", "location": "RixEndstation", - "analyzedModules": [1, 2], + "analyzedModules": [0, 2, 3], "seedCut": 40, ## pure guess "neighborCut": 10, ##pure guess # "fluxSource": "MfxDg1BmMon", diff --git a/config_files/epixM_oldCamera_SuiteConfig.py b/config_files/epixM_oldCamera_SuiteConfig.py new file mode 100755 index 0000000..20f422a --- /dev/null +++ b/config_files/epixM_oldCamera_SuiteConfig.py @@ -0,0 +1,49 @@ +############################################################################## +## This file is part of 'SLAC Beamtime Calibration Suite'. +## It is subject to the license terms in the LICENSE.txt file found in the +## top-level directory of this distribution and at: +## https://confluence.slac.stanford.edu/display/ppareg/LICENSE.html. +## No part of 'SLAC Beamtime Calibration Suite', including this file, +## may be copied, modified, propagated, or distributed except according to +## the terms contained in the LICENSE.txt file. +############################################################################## +import numpy as np + +# experimentHash = {'exp':'mfxx1005021', 'location':'MfxEndstation', 'fluxSource':'MFX-USR-DIO', 'fluxChannels':[11], 'fluxSign':-1} +# experimentHash = {'exp':'rixc00121', 'location':'RixEndstation', +singlePixelArray = [] +for i in range(1, 3): + singlePixelArray.append([i, 10, 10]) + singlePixelArray.append([i, 10, 100]) + singlePixelArray.append([i, 100, 10]) + singlePixelArray.append([i, 100, 100]) + singlePixelArray.append([i, 150, 150]) + singlePixelArray.append([i, 80, 20]) + +singlePixelArray.append([2, 178, 367]) + +experimentHash = { + "detectorType": "epixm", + "exp": "rixx1005922", + # "exp": "rixx1003721", + "location": "RixEndstation", + "analyzedModules": [1, 2], + "seedCut": 40, ## pure guess + "neighborCut": 10, ##pure guess + # "fluxSource": "MfxDg1BmMon", + "fluxSource": "MfxDg2BmMon", + "fluxChannels": [15], + "fluxSign": 1, ## for dg2 + # "fluxSign": -1, + "singlePixels": singlePixelArray, + # 'ROIs':['module0', 'module2', 'module4', 'module6', 'module10','module12', 'module14'] + # 'ROIs':['roiFromSwitched_e557_rmfxx1005021'] + # 'ROIs':['allHRasicPixels', 'goodboxROI']#'roiAbove7k_raw_r123'] + # "ROIs": ["../data/XavierV4_2", "../data/OffXavierV4_2"], + "ROIs": [ + "../data/cometPinhole.npy", + "../data/smallRegionFourAsics.npy", + "../data/smallRegionTwoAsicsForBhavna.npy", + ], + "regionSlice": np.s_[0:4, 0:192:, 0:384], ## small region near Kaz rec +} diff --git a/setup.sh b/setup.sh index 3ce945d..8791f69 100755 --- a/setup.sh +++ b/setup.sh @@ -10,11 +10,11 @@ echo "PYTHONPATH = $PYTHONPATH" # so output folders are written in a shared location ##export OUTPUT_ROOT="/sdf/data/lcls/ds/rix/rixx1005922/scratch/" -##export OUTPUT_ROOT="/sdf/data/lcls/ds/rix/rixx1005922/results/" -export OUTPUT_ROOT="/sdf/data/lcls/ds/det/detdaq21/results/" +export OUTPUT_ROOT="/sdf/data/lcls/ds/rix/rixx1005922/results/" +##export OUTPUT_ROOT="/sdf/data/lcls/ds/det/detdaq21/results/" echo "OUTPUT_ROOT = $OUTPUT_ROOT" # point to which config file to use -##export SUITE_CONFIG="$git_project_root_dir/config_files/epixMSuiteConfig.py" -export SUITE_CONFIG="$git_project_root_dir/config_files/epix100SuiteConfig.py" +export SUITE_CONFIG="$git_project_root_dir/config_files/epixMSuiteConfig.py" +##export SUITE_CONFIG="$git_project_root_dir/config_files/epix100SuiteConfig.py" echo "SUITE_CONFIG = $SUITE_CONFIG"