Skip to content

Commit

Permalink
Merge pull request #128 from slaclab/epix10k_psana1
Browse files Browse the repository at this point in the history
Epix10k psana1
  • Loading branch information
nstelter-slac authored Aug 29, 2024
2 parents 1effbdc + 95bde0a commit d80b24d
Show file tree
Hide file tree
Showing 12 changed files with 151 additions and 21 deletions.
11 changes: 11 additions & 0 deletions calibrationSuite/basicSuiteScript.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +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:
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
Expand Down
21 changes: 19 additions & 2 deletions calibrationSuite/detectorInfo.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 5 additions & 2 deletions calibrationSuite/psana1Base.py
Original file line number Diff line number Diff line change
Expand Up @@ -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())
Expand Down Expand Up @@ -149,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:
Expand Down
2 changes: 1 addition & 1 deletion calibrationSuite/psanaCommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion config_files/epix10kQuadSuiteConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
18 changes: 8 additions & 10 deletions config_files/epixMSuiteConfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
49 changes: 49 additions & 0 deletions config_files/epixM_oldCamera_SuiteConfig.py
Original file line number Diff line number Diff line change
@@ -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
}
8 changes: 4 additions & 4 deletions setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
20 changes: 20 additions & 0 deletions setup_epix100.sh
Original file line number Diff line number Diff line change
@@ -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"
20 changes: 20 additions & 0 deletions setup_epix10k.sh
Original file line number Diff line number Diff line change
@@ -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"
1 change: 1 addition & 0 deletions suite_scripts/CalcNoiseAndMean.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
12 changes: 11 additions & 1 deletion suite_scripts/simplePhotonCounter.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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()

0 comments on commit d80b24d

Please sign in to comment.