Versions Compared

Key

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

This script lives in in /reg/g/psdm/tutorials/examplePythonexamplePython3/cfd.py and demonstrates how to run a constant-fraction-discriminator algorithm on a waveform (similar to a peak-finder for area-detectors).

Code Block
from psana import *
from pypsalg import find_edges
ds = DataSource('exp=amotut13:run=206')
det = Detector('AmoETOF.0:Acqiris.0')
import matplotlib.pyplot as plt
for nevent,evt in enumerate(ds.events()):
    waveforms,times = det.raw(evt)
    # find edges for channel 0                                                  
    # parameters: baseline, threshold, fraction, deadtime, leading_edges        
    edges = find_edges(waveforms[0],0.0,-0.05,1.0,5.0,True)
    # pairs of (amplitude,sampleNumber)                                         
    print (edges)
    break

...


Sven Augustin suggested this code to get actual times instead of sample numbers for the edges:

...