lcls2
C++ API: public headers of xtcdata, psalg, psdaq and psana
Loading...
Searching...
No Matches
psalgos Namespace Reference

Waveform and peak-finding algorithms of psana (constant-fraction discrimination, PeakFinderAlgos, ...). More...

Classes

struct  Peak
 Peak parameters. More...
 
class  PeakFinderAlgos
 PeakFinderAlgos - class contains collection of methods for peak finding algorithms of 2-d image. More...
 
struct  RingAvgRms
 Structure to hold background algorithm results. More...
 

Typedefs

typedef std::vector< double > Waveform
 std::vector<double> of waveform samples, the input of getcfd().
 
typedef types::mask_t mask_t
 Alias for types::mask_t (uint16_t).
 
typedef types::extrim_t extrim_t
 Alias for types::extrim_t (uint16_t).
 
typedef types::conmap_t conmap_t
 Alias for types::conmap_t (uint32_t).
 
typedef types::TwoIndexes TwoIndexes
 Alias for types::TwoIndexes.
 

Functions

std::vector< double > diff_table (int deg, const std::vector< double > &x, const std::vector< double > &y)
 Return y[0] followed by difference quotients taken column by column, each computed as (next - current) / (x[row] - x[row+1]) with adjacent x spacing at every order; the first entry of each column is appended.
 
double eval_poly (double x, const std::vector< double > &coeffs)
 Evaluate the polynomial with coefficients coeffs, highest power first, at x.
 
double find_root (const std::vector< double > &f, const std::vector< double > &df, double error, double x0, int max_its=1000)
 Newton iteration from x0 on the polynomial f with derivative polynomial df (both evaluated with eval_poly()).
 
double getcfd (const double sampleInterval, const double horpos, const double gain, const double offset, const Waveform &waveform, const int32_t delay, const double walk, const double threshold, const double fraction)
 Scan waveform for the first sample i (from delay+1) where the constant-fraction signal s(k) = -(w[k]-off)*fraction + (w[k-delay]-off) crosses walk/gain between i and i+1, |w[i]-off| > threshold/gain and the polarity matches, with off = (int)(offset/gain).
 
std::ostream & operator<< (std::ostream &os, const Peak &p)
 Stream insertion operator,.
 
std::ostream & operator<< (std::ostream &os, const RingAvgRms &b)
 Write " Bkgd avg:", " RMS:" and " Npix:" with the values of b to os, and return os.
 

Detailed Description

Waveform and peak-finding algorithms of psana (constant-fraction discrimination, PeakFinderAlgos, ...).

Typedef Documentation

◆ conmap_t

◆ extrim_t

◆ mask_t

◆ TwoIndexes

◆ Waveform

typedef std::vector<double> psalgos::Waveform

std::vector<double> of waveform samples, the input of getcfd().

Function Documentation

◆ diff_table()

std::vector< double > psalgos::diff_table ( int  deg,
const std::vector< double > &  x,
const std::vector< double > &  y 
)

Return y[0] followed by difference quotients taken column by column, each computed as (next - current) / (x[row] - x[row+1]) with adjacent x spacing at every order; the first entry of each column is appended.

At most deg+1 values are appended (fewer if x has too few points).

◆ eval_poly()

double psalgos::eval_poly ( double  x,
const std::vector< double > &  coeffs 
)

Evaluate the polynomial with coefficients coeffs, highest power first, at x.

◆ find_root()

double psalgos::find_root ( const std::vector< double > &  f,
const std::vector< double > &  df,
double  error,
double  x0,
int  max_its = 1000 
)

Newton iteration from x0 on the polynomial f with derivative polynomial df (both evaluated with eval_poly()).

Returns the first iterate that moves by less than error, or NaN after max_its + 2 steps without that.

◆ getcfd()

double psalgos::getcfd ( const double  sampleInterval,
const double  horpos,
const double  gain,
const double  offset,
const Waveform &  waveform,
const int32_t  delay,
const double  walk,
const double  threshold,
const double  fraction 
)

Scan waveform for the first sample i (from delay+1) where the constant-fraction signal s(k) = -(w[k]-off)*fraction + (w[k-delay]-off) crosses walk/gain between i and i+1, |w[i]-off| > threshold/gain and the polarity matches, with off = (int)(offset/gain).

Then take the four points i-1 .. i+2 through diff_table() and find_root() and return that root (in sample-index units), or 0.0 if no sample qualifies. sampleInterval and horpos are not used.

◆ operator<<() [1/2]

std::ostream & psalgos::operator<< ( std::ostream &  os,
const Peak &  p 
)

Stream insertion operator,.

◆ operator<<() [2/2]

std::ostream & psalgos::operator<< ( std::ostream &  os,
const RingAvgRms &  b 
)

Write " Bkgd avg:", " RMS:" and " Npix:" with the values of b to os, and return os.