Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
from ImgAlgos.PyAlgos import PyAlgos
from psana import *

ds = DataSource('exp=xcs06016:run=37:smd')
det = Detector('epix_2')
alg = PyAlgos()
alg.set_peak_selection_pars(npix_min=1, npix_max=9, amax_thr=0, atot_thr=35, son_min=0)

centroids = []
for nevent, evt in enumerate(ds.events()):
    if nevent == 25: break

    nda = det.calib(evt)
    peaks = alg.peak_finder_v1(nda, thr_low=10, thr_high=30, radius=1, dr=0)
    for p in peaks:
        centroids.append([p[6], p[7]])
centroids = np.array(centroids)

# This should only be run once to save run-dependent calibration constants
calib = CentroidSmootherCalib()
calib.add(centroids)
rNumBeginrunNumBegin = 0 # There is also an optional runNumEnd parameter
calib.save(ds, det, rNumBegin) # There is also an optional rNumEndrunNumBegin)
 
# This loads the run-dependent calibration constants for run number evt.run()
cs = CentroidSmoother(ds, det, evt.run())
 
smoothCents = cs.getSmoothedCentroids(centroids)