Versions Compared

Key

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

Include Page
PageMenuBegin
PageMenuBegin
Table of Contents
Include Page
PageMenuEnd
PageMenuEnd

About

This page provides a list of existing modules for psana framework. Only the modules that are included in the standard analysis releases appear on this page.

...

This page provides examples for selected modules in Psana Module Examples.

Package psana

Psana package include several simple modules which do generic tasks that do not need knowledge of the event data types.

Module psana.EventKeys

This module dumps the list of the event keys in the event or configuration store. Event key is a triplet of data type, data source address, and string key.

...

Note that one can specify EventKeys instead of psana.EventKeys as psana package name is optional.

Module psana.PrintEventId

This module prints the content of the Event ID object on every event.

...

Code Block
bgColor#F7F7ED
[info:psana.PrintEventId] event ID: XtcEventId(run=100, time=2010-12-12 11:09:36.300506429-08)
[info:psana.PrintEventId] event ID: XtcEventId(run=100, time=2010-12-12 11:09:36.317163082-08)

Module psana.PrintSeparator

This module prints separator line on every event. Can be used to indicate event boundaries in job's log.

...

Code Block
bgColor#F7F7ED
[info:/root/] ================================================================================
[info:psana.PrintEventId] event ID: XtcEventId(run=100, time=2010-12-12 11:09:36.300506429-08)
[info:/root/] ================================================================================
[info:psana.PrintEventId] event ID: XtcEventId(run=100, time=2010-12-12 11:09:36.317163082-08)

Package psana_examples
Anchor
psana_examples
psana_examples

This package contains modules that are meant to be used as examples of accessing different data types or framework services. Can be used by developers as templates for new modules. To find the code:

Module psana_examples.DumpAcqiris

Extracts and dumps the content of Acqiris configuration (Psana::Acqiris::ConfigV1) and event data (Psana::Acqiris::DataDescV1) objects.

parameter

default value

description

source

"DetInfo(:Acqiris)"

data source address

Module psana_examples.DumpAcqTdc

Extracts and dumps the content of Acqiris TDC configuration (Psana::Acqiris::TdcConfigV1) and event data (Psana::Acqiris::TdcDataV1) objects.

parameter

default value

description

source

"DetInfo(:AcqTDC.0)"

data source address

Module psana_examples.DumpBld

Extracts and dumps the content of beamline data objects (Psana::Bld::BldDataEBeamV0, Psana::Bld::BldDataEBeam, Psana::Bld::BldDataPhaseCavity, Psana::Bld::BldDataFEEGasDetEnergy, and Psana::Bld::BldDataIpimb).

parameter

default value

description

eBeamSource

"BldInfo(EBeam)"

data source address for Psana::Bld::BldDataEBeam

phaseCavSource

"BldInfo(PhaseCavity)"

data source address for Psana::Bld::BldDataPhaseCavity

feeSource

"BldInfo(FEEGasDetEnergy)"

data source address for Psana::Bld::BldDataFEEGasDetEnergy

ipimbSource

"BldInfo(NH2-SB1-IPM-01)"

data source address for Psana::Bld::BldDataIpimb

Module psana_examples.DumpCamera

Extracts and dumps the content of camera configuration (Psana::Camera::FrameFexConfigV1) and event data (Psana::Camera::FrameV1 and Psana::Camera::TwoDGaussianV1) objects.

parameter

default value

description

source

"DetInfo(:Opal1000)"

data source address

Module psana_examples.DumpControl
Anchor
dumpcontrol
dumpcontrol

Extracts and dumps the content of scan control configuration (Psana::ControlData::ConfigV1) object.

parameter

default value

description

source

"ProcInfo()"

data source address

Module psana_examples.DumpCsPad

Extracts and dumps the content of CsPad configuration (Psana::CsPad::ConfigV*) and event data (Psana::CsPad::DataV*) objects.

parameter

default value

description

source

"DetInfo(:Cspad)"

data source address

Module psana_examples.DumpEncoder

Extracts and dumps the content of encoder configuration (Psana::Encoder::ConfigV1) and event data (Psana::Encoder::DataV*) objects.

parameter

default value

description

source

"DetInfo(:Encoder)"

data source address

Module psana_examples.DumpEpics

Extracts and dumps the list of EPICS PVs and their values and status information on every event.

Module psana_examples.DumpEvr

Extracts and dumps the content of Evr configuration (Psana::EvrData::ConfigV* and Psana::EvrData::IOConfigV1) and event data (Psana::EvrData::DataV*) objects.

parameter

default value

description

source

"DetInfo(:Evr)"

data source address

Module psana_examples.DumpFccd

Extracts and dumps the content of FCCD configuration (Psana::FCCD::FccdConfigV*) objects. To dump event data objects use psana_examples.DumpCamera module.

parameter

default value

description

source

"DetInfo(:Fccd)"

data source address

Module psana_examples.DumpIpimb

Extracts and dumps the content of IPIMB configuration (Psana::Ipimb::ConfigV1) and event data (Psana::Ipimb::DataV1) objects.

parameter

default value

description

source

"DetInfo(:Ipimb)"

data source address

Module psana_examples.DumpLusi

Extracts and dumps the content of LUSI configuration (Psana::Lusi::DiodeFexConfigV1, Psana::Lusi::IpmFexConfigV1, and Psana::Lusi::PimImageConfigV1) and event data (Psana::Lusi::DiodeFexV1 and Psana::Lusi::IpmFexV1) objects.

parameter

default value

description

tmSource

"DetInfo(:Tm6740)"

data source address for Psana::Lusi::PimImageConfigV1

ipimbSource

"DetInfo(:Ipimb)"

data source address for other data

Module psana_examples.DumpOpal1k

Extracts and dumps the content of Opal1000 configuration (Psana::Opal1k::ConfigV1) object. To dump event data objects use psana_examples.DumpCamera module.

parameter

default value

description

source

"DetInfo(:Opal1000)"

data source address

Module psana_examples.DumpPnccd

Extracts and dumps the content of pnCCD configuration (Psana::PNCCD::ConfigV*) and event data (Psana::PNCCD::FrameV1) objects.

parameter

default value

description

source

"DetInfo(:pnCCD)"

data source address

Module psana_examples.DumpPrinceton

Extracts and dumps the content of Princeton configuration (Psana::Princeton::ConfigV1) and event data (Psana::Princeton::FrameV1) objects.

parameter

default value

description

source

"DetInfo(:Princeton)"

data source address

Module psana_examples.DumpPulnix

Extracts and dumps the content of Pulnix configuration (Psana::Pulnix::TM6740ConfigV*) objects.

parameter

default value

description

source

"DetInfo(:Tm6740)"

data source address

Module psana_examples.EBeamHist

This module is an example of histogramming service usage. It extracts beam line data and fills couple of histograms with the beam parameters.

parameter

default value

description

eBeamSource

"BldInfo(EBeam)"

data source address

Package cspad_mod

Package cspad_mod contains common modules useful for analysis of data from CsPad detector.

Module cspad_mod.CsPadPedestals

This module is supposed to run on dark cspad2x2 frame data. It calculates average and standard deviation values for each pixel and writes these values to output files in text format.

...

This should produce file pedestals.dat in the current directory. As the source address is more specific this configuration file can be used even if input data contain more than one CsPad device.

Module cspad_mod.CsPad2x2Pedestals

This module is supposed to run on cspad2x2 dark frame data. It calculates average and standard deviation values for each pixel and writes these values to output files in text format.

...

This should produce file pedestals.dat in the current directory. As the source address is more specific this configuration file can be used even if input data contain more than one CsPad2x2 device.

Module cspad_mod.CsPadCalib

This module performs standard CsPad calibration procedures: per-pixel pedestal subtraction and common mode correction. The algorithms used in calibrations are identical to translator algorithms, the result of calibration should be the same as the data stored in HDF5 files.

...

parameter

default value

description

inputKey

""

string key used to locate uncalibrated data objects in event

outputKey

"calibrated"

string key used to store calibrated data objects in event

doPedestals

"yes"

can be set to "no" to explicitly disable pedestal subtraction algorithm

doPixelStatus

"yes"

can be set to "no" to explicitly disable reading of pixel status data, all pixels will be used for common mode

doCommonMode

"yes"

can be set to "no" to explicitly disable common mode algorithm

doPixelGain

"yes"

can be set to "no" to explicitly disable pixel gain correction algorithm

Module cspad_mod.CsPadFilter

This is a filter module which implements skipping for the events which have too low signal in CsPad. filtering algorithm can be controlled trough the module parameter and/or parameters in calibration file. The name of the calibration file is "filter" and it will be searched in the standard calibration directories of the experiment.

...

With the default parameters module works with non-calibrated data, to switch to calibrated data add the module cspad_mod.CsPadCalib before filter and change inputKey parameter to calibrated.

Package CSPadPixCoords

Package CSPadPixCoords calculates the 2x1 section, quad, and CSPad pixel coordinates and produces the image.
For complete reference select Doxygen documentation.

Module CSPadPixCoords::PixCoordsTest

This module demonstrates of how to use the PixCoords2x1, PixCoordsQuad, and PixCoordsCSPad classes
in order to pre-calculate pixel coordinates, taking into account the calibration parameters.
Relevant images are produced in combination of the pixel coordinates with event data and saved in text files.

parameter

default value

description

calibDir

"/reg/d/psdm/CXI/cxi35711/calib"

directory with calibration file

typeGroupName

"CsPad::CalibV1"

data type and group names

source

"CxiDs1.0:Cspad.0"

source of data

runNumber

32

run number for calibration file

events

32

number of events before stop a job

filter

false

on/off for potential selection filter

Module CSPadPixCoords::CSPadImageProducer

CSPadImageProducer works in psana framework. It does a few operation as follows:

...

  • By default the empty key corresponds to raw data.

Module CSPadPixCoords::CSPadInterpolImageProducer

CSPadInterpolImageProducer works in psana framework. It does a few operation as follows:

...

Module configuration parameters are the same as for the CSPadPixCoords::CSPadImageProducer.

Module CSPadPixCoords::CSPad2x2ImageProducer

CSPad2x2ImageProducer works in psana framework. It does a few operation as follows:

...

  • By default the empty inkey corresponds to raw data.
  • If the outimgkey is defined as "Image2D", the image is saved in the event as a CSPadPixCoords::Image2D<double> object, otherwise (for other names) as a ndarray<double,2> object.

See also Example for Module CSPadPixCoords::CSPad2x2ImageProducer.

Module CSPadPixCoords::CSPadNDArrProducer

CSPadNDArrProducer is a module for psana framework. It uses specified source and inkey parameters,

...

parameter

default value

description

source

":Cspad.0"

source of data

inkey

 

key for data processing stage

outkey

"cspad_ndarr"

output key for image saved in event

outtype

float

type of output data from the list of supported (float, double, int, int16)

is_fullsizefalsesize of output array; true means [32,185,388], false means "as data" [N,185,388]
is_2darrayfalseif is_fullsize=true && is_2darray=true then shape of output 2-d array is [32*185,388] 

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - configuration parameters
  • +4 - consumed time per event
  • +16 - print type size and one character id name

See also Example for Module CSPadPixCoords::CSPadNDArrProducer.

Module CSPadPixCoords::CSPad2x2NDArrProducer

CSPad2x2NDArrProducer is a module for psana framework. It uses specified source and inkey parameters,

...

parameter

default value

description

source

":Cspad2x2.0"

source of data

inkey

 

key for data processing stage

outkey

"cspad2x2_ndarr"

output key for image saved in event

outtype

float

type of output data from the list of supported (float, double, int, int16)

is_2darrayfalseif is_2darray=true then shape of output 2-d array is [185,388*2] 

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input parameters
  • +2 - configuration parameters
  • +4 - consumed time per event
  • +16 - print type size and one character id name

See also Example for Module CSPadPixCoords::CSPad2x2NDArrProducer.

Package ImgPixSpectra

For complete reference see the Doxygen documentation.

...

This information can be used in analysis or presentation of this array.

Module ImgPixSpectra::CSPadPixSpectra

List of parameters:

parameter

default value

description

source

"CxiDs1.0:Cspad.0"

source of data for CSPad

events

1<<31U

number of events before stop a job

inputKey

 

input key for data processing stage

amin

0.

minimal spectral amplitude

amax

1000.

maximal spectral amplitude

nbins

100

number of bins in spectra

arr_fname

"..._spectral_array.txt"

output file name

See also: Example for Module ImgPixSpectra::CSPadPixSpectra.

Module ImgPixSpectra::CSPad2x2PixSpectra

The only difference in interface of this module from previous is in the default name for the source parameter and the output file name.

parameter

default value

description

source

"DetInfo(:Cspad2x2)"

source of data for CSPad2x2

See also: Example for Module ImgPixSpectra::CSPad2x2PixSpectra.

Module ImgPixSpectra::CameraPixSpectra

The only difference in interface of this module from previous is in the default name for the source parameter and the output file name.

...

parameter

default value

description

source

"DetInfo(:Princeton)"

source of data for Princeton camera

See also Example for Package ImgPixSpectra.

Package ImgAlgos

This packages contains a few psana modules for analysis and image processing

Module ImgAlgos::Tahometer

This module measures the time interval for entire job and for each dn events and prints the rate info as requested by the print_bits parameter.

parameter

default value

description

dn

100

number of events between printout

print_bits

2

filter verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - start notice and summary at stop
  • +4 - instant rate performance after each dn events
  • +8 - print summary parameters for parser in log file

See also Example for Module ImgAlgos::Tahometer.

Module ImgAlgos::TimeStampFilter

This module passes only the events if their time stamp is in the requested range.
The range of allowed time stamps is defined by the configuration parameters.

...

  • YYYYMMDD HHMMSS.FFF
  • YYYYMMDDTHHMMSS.F
  • YYYY-MM-DD HH:MM:SS.FFF
    but the date field has to be presented mandatory.
    If the tsinterval is defined and is different from the default, it will be used in filter and override the tstamp_min and tstamp_max.

See also Example for TimeStampFilter and XtcOutputModule.

Module ImgAlgos::EventNumberFilter

This filter selects events by their number counting from the beginning of job, starting from 0. The event number is not a parameter which is associated with event. Use this filter cautiously on your own risk for debugging purpose only.

...

  1. If the first and/or last event numbers are defined, then the filter will select events in this range only.
  2. If the evtstring is defined, only listed events of event ranges will be selected. For example, the evtstringparameter can be defined as

    Code Block
    bgColor#F7F7ED
     2,5,11-15,20-25,29,30
    

    that means the list of events:

    Code Block
    bgColor#F7F7ED
      2  5  11  12  13  14  15  20  21  22  23  24  25  29  30
    

    In the evtstring parameter the comma "," and sign minus "-" as a dash are the only allowed separators. Blank spaces are also allowed. Other characters may abort the program. The evtstring mode has higher priority than the 1st mode.
    The filterIsOn allows easy turn on/off this filter in *.cfg file.

Module ImgAlgos::AndorImageProducer

Functionality:

  • gets Andor data from the event for specified source and key_in parameters,
  • puts the ndarray<double,2> object with camera image in the event using specified key_out parameter.

parameter

default value

description

source

"DetInfo(:Andor)"

source of data

key_in

 

key for input data

key_out

"andorimg"

output key for image saved in event

outtype

"asdata"

out data type: implemented values: asdata (default, unsigned short), float, double, int and int16.

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - data from event()
  • +4 - configuration parameters
  • +8 - table with sizes of types

Module ImgAlgos::PnccdNDArrProducer

Functionality:

  • gets pnCCD data from Psana::PNCCD::FramesV1 object from the event for specified source and key_in parameters,
  • puts the ndarray<TOUT,3> object of shape 4x512x512 specified key_out parameter.

parameter

default value

description

source

"DetInfo(:pnCCD)"

source of data

key_in

 

key for input data

key_out

"andorimg"

output key for image saved in event

outtype

"asdata"

out data type: implemented values: asdata (default, unsigned short), float, double, int and int16.

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - data from event()
  • +4 - configuration parameters
  • +8 - table with sizes of types
  • +16 - warning about missing data

Module ImgAlgos::PnccdImageProducer

Functionality:

  • gets from the event store the object with pnCCD data of type
    • Psana::PNCCD::FullFrameV1 containing four [512][512] frames with T=uint16_t, or
    • ndarray<T,3> , where shape=[4][512][512], T=unsigned short, float, double, int, or int16,
    for specified source and inkey parameters

...

parameter

default value

description

source

"DetInfo(:pnCCD)"

source of data

inkey

 

key for input data

outimgkey

"pnccdimg"

output key for image saved in event

gap_size0

vertical gap between top and bottom segments in number of pixels

gap_value0Image effective pixel intensity value in the gap

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - initial portion of pnccd array
  • +4 - configuration pars
  • +16 - warning about missing data

See also Example for Module ImgAlgos::PnccdImageProducer.

Module ImgAlgos::CameraImageProducer

This module takes care about any generic camera image.
Functionality:

...

parameter

default value

description

source

"DetInfo(:Opal1000)"

source of data

key_in

 

key for input data

key_out

"pnccdimg"

output key for image saved in event

subtract_offset

true

on/off the amplitude offset using configuration data

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - time stamp for each event
  • +4 - summary at the endJob
  • +8 - details about data format conversion and applied offset

See also Example for Module ImgAlgos::CameraImageProducer.

Module ImgAlgos::PrincetonImageProducer

Functionality:

  • gets the Princeton camera image data from event for specified source and key_in parameters,
  • puts the ndarray<uint16_t,2> object with image in the event using specified key_out parameter.

parameter

default value

description

source

"DetInfo(:Princeton)"

source of data

key_in

 

key for input data (raw - by default)

key_out

"image"

output key for image saved in event

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input parameters
  • +2 - record for each event
  • +4 - summary at the endJob
  • +8 - first 10 elements of the data array
  • +16 - configuration info for each beginCalibCycle(...)

See also Example for Module ImgAlgos::PrincetonImageProducer.

 

Anchor
AcqirisArrProducer
AcqirisArrProducer

Module ImgAlgos::AcqirisArrProducer

  • Gets acqiris configuration and data from Acqiris::ConfigV1 and Acqiris::DataDescV1,  objects using parameters source and key_in;
  • produces ndarray<double,2> of shape[] = {nbrChannels, nbrSamples} for waveforms and time stamps;
  • saves configuration data in the file defined by fname_prefix;
  • saves waveforms and time stamps in the event store with keys key_wform and key_wtime.

parameter

default value

description

source

"DetInfo(:Acqiris)"

source of data

key_in

""

key for input data (by default  (empty)  – raw data)

key_wform

"acq_wform"

output key for waveforms saved in event

key_wtime

"acq_wtime"

output key for waveform times saved in event

fname_prefix

""

file name prefix for configuration parameters (by default  (empty)  – do not save file)

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input parameters
  • +2 - configuration parameters
  • +4 - record about saving file with configuration parameters
  • +8 - print part of waveform for all channels and segments in each event

 

Anchor
AcqirisAverage
AcqirisAverage

Module ImgAlgos::AcqirisAverage

  • Gets Acqiris waveforms from event store as ndarray<double,2> object using parameters source and key_in;
  • performs waveform selection controlled by parameters: thresholds, is_postive_signal, do_inverse_selection, in the range depending on local event numbers skip_events and proc_events;
  • after number of events proc_events or at the end of job (whatever happens first), saves array of averaged waveforms in the text file with name constructed from fname_ave_prefix and in the event store using parameters source and key_average.

parameter

default value

description

source

"DetInfo(:Acqiris)"

Source of data.

key_in

"acq_wform"

Key for input data (raw - by default).

key_average"acq-ave"Keyword for averaged waveform array saved in the evt store. If empty – array is not saved.
fname_ave_prefix"acq-ave"Text file name prefix for averaged array, full name will be extended by the experiment name, run number and suffix "-ave-wfs.txt", for example: "acq-amo01509-r0125-ave-wfs.txt".
thresholds""List of threshold values for all Acqiris channels separated by space. If empty – threshold selection is not applied, all waveforms are averaged.
is_positive_signal""Space-separated list of 1/0 values indicating signal polarity. For example, "1 1 1 0 1" (without the quotes!) would indicate Acqiris channels 1,2,3,5 contained positive signal polarity, while channel 4 contained a negative signal polarity.
do_inverse_selection

""

Space-separated ist of 1/0 values indicating which waveforms to include in average. For example, "0 0 0 1 0" (without the quotes) would tell the code to average only waveforms that do not cross the threshold for channels 1,2,3,5 while channel 4 would average only waveforms that do cross the threshold.

skip_events

0

Number of events (from the beginning of job) to skip before begin averaging.

proc_events

10000000

Number of events for averaging.

print_bits

0

Verbosity:

  • =0 - print nothing
  • +1 - input parameters
  • +2 - ndarray dimensions
  • +4 - begin/end accumulate statistics record
  • +8 - record about saving file with averaged array
  • +16 - statistics of averaged waveforms (number of accumulated)
  • +32 - part of the input waveform

 Example for Module ImgAlgos::AcqirisAverage

 

Anchor
AcqirisCalib
AcqirisCalib

Module ImgAlgos::AcqirisCalib

  • Gets Acqiris waveforms from event store as ndarray<double,2> object using parameters source and key_in;
  • processes events in the range depending on local event numbers skip_events and proc_events;
  • at the 1st processed event loads the fname_base_line file with baseline  ndarray<double,2>;
  • subtract baseline from waveforms;
  • save corrected waveforms in the event store as ndarray<double,2> object using parameters source and key_out.

parameter

default value

description

source

"DetInfo(:Acqiris)"

Source of data.

key_in

"acq_wform"

Key for input ndarray with raw waveforms from evt store. For now it is assumed that this array is produced by the

AcqirisArrProducer or AcqirisAverage modules.

key_out

"wf-calibrated"

Key for output ndarray with calibrated waveforms.

fname_base_line

"acq-ave"

Name of the input text file with array of the baselines for active  Acqiris channels. By default this name coincides with the name of the file produced by the module AcqirisAverage. This allows to use these to modules in chain with auto-generated names of files. If the file with auto-generated extended name (which looks like "acq-ave-amo01509-r0125-ave-wfs.txt") is not found on disk, the file name without extension will be tested. If it is not found as well, baseline subtraction will not be performed and output array will be identical to input one.

skip_events

0

Number of events (from the beginning of job) to skip before begin subtraction.

proc_events

10000000

Number of events for subtraction.

print_bits

0

Verbosity:

  • =0 - print nothing
  • +1 - input parameters
  • +2 - ndarray dimensions
  • +4 - begin/end of subtraction
  • +8 - Information about loading of the input file with baseline array
  • +16 - part of the input array
  • +32 - part of baseline array

 Example for Module ImgAlgos::AcqirisCalib

Anchor
AcqirisCFD
AcqirisCFD

Module ImgAlgos::AcqirisCFD

  • Gets Acqiris waveforms from event store as ndarray<double,2> object using parameters source, key_wform, key_wtime;
  • runs constant-fraction discriminator algorithm on all acqiris channels using user-specified per-channel parameters;
  • saves edges into the event as a set of ndarray<double,1>;

     

    parameter

    default value

    description

    source

    "DetInfo(:Acqiris)"

    Source of data.

    key_wform

    "acqiris_wform"

    Key for input ndarray with waveforms (either raw, or subtracted using AcqirisCalib module) from evt store.

    key_wtime

    "acqiris_wtime"

    Key for input ndarray with waveform times from evt store.

    key_edges

    "acqiris_edges_"

    Key for output ndarray<double,1> with calibrated waveforms. This key will have the acqiris channel number (1 thru 20) appended to the end of it, and the data for that channel will be added to the event only if edges were found.

    baselines

    ""

    A list of baseline values (one per channel) to subtract from the waveform in volts.

    fractions

    ""

    A list of fractions (one per channel) between 0 and 1. The edge-time reported will be at the time when the pulse is at this fraction of the peak value.

    thresholds

    ""

    A list of threshold values (one per channel) in volts that indicate a new edge should be found. If this value is less than the baseline, then the algorithm will look for negative pulses, otherwise it will look for positive pulses.

    deadtimes

    ""

    A list of deadtimes (one per channel) in seconds. After each edge the algorithm will ignore any new hits in this time interval.

    leading_edges

    ""

    A list of 0/1 values (one per channel) indicating whether edge-times are desired for leading edges (1) or falling edges (0).

 Example for Module ImgAlgos::AcqirisCFD

Module ImgAlgos::NDArrAverage

This module averages over events the per-element data of the image array (ndarray<T,NDim>, where T is implemented for almost all types: int, int16, uint, float, double etc., NDim≤5) and saves files for sum, averaged, rms values, mask, and, the hot pixel map. Input ndarray can be specified by the source and key parameters. Averaging may have up to three stages, depending on configuration parameters:

...

If all file names are empty (by default), the files with pre-defined names "arr-ave-<exp>-r<run>.dat" and "arr-rms-<exp>-r<run>.dat" will be saved for averaged and rms arrays, respectively. Otherwise, the files with specified names will be saved.
Default parameters are set for regular single-stage averaging without any constrains.
See also Example for Module ImgAlgos::NDArrAverage.

Module ImgAlgos::NDArrCalib

Functionality

  • NDArrCalib uses the source and key_in parameters to get any ndarray<T,NDIM> object from the event store, where T stands for uint16_t, int, float, uint8_t, or double, 1≤NDim≤5,
  • automaticly gets parameters from calibration store for types pedestals, common_mode, pixel_status, pixel_gain, and pixel_rms,
  • gets parameters from user-defined files fname_bkgd and  fname_mask, if their names are specified,
  • the specified by the do_... parameter corrections are applied to raw data  ndarray<T,NDIM> as follows:

...

parameter

default value

description

source

DetInfo(:Camera)

source of data

key_in

 

key for input ndarray<T,NDIM>

key_out

calibrated

output key for calibrated image saved in event

do_peds

false

true: pedestals subtracted if available in calib store

do_cmod

false

true: common mode correction is evaluated and applied

do_stat

false

true: bad/hot pixels in pixel_status are masked

do_mask

false

true: mask is applied if the file fname_mask is available

do_bkgd

false

true: normalized background is subtracted if the file fname_bkgd is available

do_gain

false

true: pixel_gain correction is applied if available in calib store

do_nrms

false

true: per-pixel threshold is applied if pixel_rms  is available in calib store

do_thre

false

true: low level threshold in ADU is applied

fname_bkgd

 

input file name for background, applied if the file name is specified

fname_mask

 

input file name for mask, applied if the file name is specified

masked_value

0.

intensity value (in ADU) substituted for masked pixels

threshold_nrms

3.

threshold as a number of sigmas to pixel_rms parameters

threshold

0.

common low level threshold in ADU

below_thre_value

0.

intensity substituted for pixels below threshold

bkgd_ind_min

0

minimal index in flatten ndarray, which is used for background normalization

bkgd_ind_max

100

maximal index in flatten ndarray, which is used for background normalization

bkgd_ind_inc

2

index increment in flatten ndarray, which is used for background normalization

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - calibration parameters
  • +4 - common mode algorithm parameters
  • +8 - ndarray parameters; type, ndim, shape, etc.
  • +16- time stamp for each event
  • +32 - first 10 elements of the raw image data
  • +64 - first 10 elements of the calibrated image data

See also Example for Module ImgAlgos::NDArrCalib.

Module ImgAlgos::ImgAverage

This module averages over events the per-pixel data of the image array (ndarray<double,2>) and saves files for averaged, rms values, and, if requested, the hot pixel mask. Input data can be specified by the source and key parameters. Averaging may have up to three stages, depending on configuration parameters:

...

If all file names are empty (by default), the files with pre-defined names "img-ave-r####.dat" and "img-rms-r####.dat" (where #### stands for run number) will be saved for averaged and rms images, respectively. Otherwise, the files with specified names will be saved.
Default parameters are set for regular single-stage averaging without any constrains.
See also Example for Module ImgAlgos::ImgAverage.

Module ImgAlgos::ImgMaskEvaluation

This module gets the image data array (ndarray<T,2>), where T stands for double, float, int, uint8_t, or uint16_t, and evaluates two masks:

...

parameter

default value

description

source

"DetInfo(:Opal1000")

input source of data

key

 

key for input data, for example, it might be "calibrated"

file_mask_satu

"img-mask-satu.dat"

out file with saturated mask

file_mask_nois

"img-mask-nois.dat"

out file with noise mask

file_mask_comb

"img-mask-comb.dat"

out file with combined mask

file_frac_satu

"img-frac-satu.dat"

out file with fraction of saturated events

file_frac_nois

"img-frac-nois.dat"

out file with fraction of noisy events

thre_satu

1000000

saturation-threshold (in ADU if the gain correction was not applied to image)

frac_satu

0

allowed fraction of saturated events

dr_SoN_ave

1

radial size of the area for S/N evaluation

thre_SoN

3

noise-threshold ( in ADU if the gain correction was not applied to image)

frac_nois

0.5

allowed fraction of noisy events

print_bits

0

module verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - event record
  • +4 - vector of indexes for SoN evaluation
  • +8 - processed statistics at the end of job
  • +16 - output in files

See also Example for Module ImgAlgos::ImgMaskEvaluation.

Module ImgAlgos::ImgCalib

ImgCalib gets the raw image from data and process it as follows:

...

The pedestal, background, gain, mask, and N*RMS corrections are applied if associated file name is specified.
The constant low level threshold is applied if do_threshold is true.
Corrections are not applied by default or with empty file names.

See also Example for Module ImgAlgos::ImgCalib.

Module ImgAlgos::ImgIntForBins

Functionality:

  • ImgIntForBins uses the source and key_in parameters to get the input image (as ndarray<T,2> object), where T stands for uint16_t, int, float, uint8_t, or double,
  • gets the pixel-bin indexes from files fname_map_bins, which has a size of image,
  • calculates average per pixel intensity for each of number_of_bins bin (from 0 to number_of_bins-1),
  • saves the 2-D array of <I>(event, bin) in file fname_int_bins.

parameter

default value

description

source

"DetInfo(:Camera)"

source of data

key_in

 

key for input image

fname_map_bins

 

input file name for map of bin indexes

fname_int_bins

 

output file name for intensity(bin,event)

number_of_bins

10

number of bins for output intensities, if map has bins \>=number_of_bins they will be ignored

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - time stamp for each event
  • +4 - detailed info about input file pars
  • +8 - the first 100 chars of the output intensity string
  • +32 - info about open/close output file

Module ImgAlgos::ImgRadialCorrection

This module averages the image pixel amplitude in r-phi bins, normalizes it per single pixel and subtracts the average amplitude from each pixel. Image is obtained from event by its source and inkey values. The output corrected image is saved in the event with outkey keyword. Carthesian to polar coordinate transformation is done with respect to center coordinates xcenter, ycenter. The central region (r<rmin) and edges of the image (r>rmax) pixels can be removed from further consideration by setting rmin and rmax. The number of radial bins is defined as an int(rmax-rmin). The number of angular bins is set by n_phi_bins.

parameter

default value

description

source

"DetInfo()"

input source of data

inkey

 

key for input data, by default use raw data

outkey

"rad_corrected"

output key for further image processing

xcenter

850

x coordinate of the image center

ycenter

850

y coordinate of the image center

rmin

10

radius minimal image is not processed for r<rmin

rmax

1000

radius maximal image is not processed for r>rmax

n_phi_bins

12

number of angular sectors for the background averaging

event

0

test event for print/save

print_bits

0

module verbosity:

  • =0 - print nothing,
  • +1 - input pars,
  • +2 - summary,
  • +4 - event ID,
  • +8 - info about input image type (ndarray<double,2> or Image2D<double>)

See also Example for Module ImgAlgos::ImgRadialCorrection.

Module ImgAlgos::ImgPixAmpFilter

The ImgAlgos::ImgPixAmpFilter is a filter for event selection.
This filter counts the number of image pixels in the specified window with amplitude exceeding the threshold. If the number of high-amplitude pixels exceed the numPixMin, the event is passed for further analysis.

...

  • The default key ("Image2D") stands for the CSPadPixCoords::Image2D<double> image object. Other key names work for the ndarray<double,2> image object.
  • The xmin, xmax, ymin, ymax (in pixels) defines the window in the image for pixel counting. Default values means the entire image range.
  • The threshold, numPixMin, and the window extents have to be adjusted for particular experiment.

Module ImgAlgos::ImgPeakFinder

This algorithm was motivated by users of amo42112:
1. Select the pixels in the window xmin, xmax, ymin, ymax
with amplitudes above the threshold_low.
2. Smear image for selected pixels, using 2-d matrix of weights over pixels
from -smear_radius to +smear_radius around each smeared pixel amplitude.
The matrix of weights is defined by the 2-d Gaussian function of width sigma.
3. Find peaks as pixels with absolute-maximal amplitude above the threshold_high in the center of the matrix -peak_radius to +peak_radius.
4. Put the vector of found peaks in the event with key peaksKey. Each entry of this vector has an object of the struct Peak, containing x, y positions, peak pixel amplitude, the total amplitude in the matrix, defined by the peak_radius, and the number of pixels in the matrix above threshold_low:

...

  • This algorithm consumes ~15 ms/event on psana0101 for full Opal1000 (1024x1024) camera image.
  • Smearing algorithm use a "safety margin" which is currently set to 10 pixels (offset from each boarder of the full image size).

See also Example for Module ImgAlgos::ImgPeakFinder.

Module ImgAlgos::ImgPeakFilter

This module use results and should work after the ImgAlgos::ImgPeakFinder. It gets the vector of peaks for the source and key, loops over all founded peaks and counts the number of peaks above the thresholds threshold_peak and threshold_total. If the selection_mode is "SELECTION_ON" and the number of found peaks exceeds the n_peaks_min the event is passed for further analysis/processing,
the table of found peaks may be saved in file with prefix defined by the fname parameter.

parameter

default value

description

source

"DetInfo()"

source of data

key

"peaks"

key for input list of peaks, should be the same as peaksKey in ImgPeakFinder

selection_mode

"SELECTION_ON"

three possible options:

  • SELECTION_ON is a normal mode for selector
  • SELECTION_OFF selector is turned off, all events are passed
  • SELECTION_INV inversed mode for selector - selected events are discarded

threshold_peak

0

threshold on peak amplitude

threshold_total

0

threshold on total peak intensity (in the matrix around peak)

n_peaks_min

1

minimal number of peaks above all thresholds

fname

 

file name prefix; by default the prefix is empty and file is not saved

print_bits

0

filter verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - summary
  • +4 - peaks' info
  • +8 - event record
  • +16 - event ID

See also Example for Module ImgAlgos::ImgPeakFilter.

Module ImgAlgos::ImgPeakFinderAB

This module finds peaks in the ndarray<double,2> image object. Algorithm and the list of parameters are the same as described is section Psana Module CatalogImgAlgos::CSPadArrPeakFinder. The only difference is that the image size is defined by the ndarray<double,2> object.

See also Example for Module ImgAlgos::ImgPeakFinderAB.

Module ImgAlgos::ImgHitFinder

ImgHitFinder is created by request for amo74213. It works pretty similar to ImgCalib, but the threshold algorithms are extended and background subtraction is removed.
It gets the raw image from data and process it as follows:

...

Corrections are not applied by default or with empty file names.

See also Example for Module ImgAlgos::ImgHitFinder.

Module ImgAlgos::ImgSpectra

This module is motivated by the discussion with Josef Frisch, Ryan Coffee, Nick Hartmann. In xppi0412 etc. experiments they need to extract two spectra from Opal1000 camera image for signal and reference, evaluate their relative difference, and find peak position in the differential spectrum.
Module mgAlgos::ImgSpectra works as follows:

  • gets the ndarray<double,2> image object from event,
  • selects two spectral band regions and integrates amplitudes for each column (it is assumed that both spectra are oriented along the rows),
  • saves two spectral arrays for signal and reference bands and their relative difference as another ndarray<double,2> object with shape (3,<number-of-columns>) in the event.
  • Further analytical work is assumed to be done in the next module ImgAlgos::ImgSpectraProc.

parameter

default value

description

source

"DetInfo(:Opal1000)"

source of data

key_in

"img"

key for input image data

key_out

"spectra"

key for output array with spectra

sig_band_rowc

510

signal band central row at column=0

ref_band_rowc

550

reference ...

sig_band_tilt

0

signal band tilt angle

ref_band_tilt

0

reference ...

sig_band_width

10

signal band width in number op rows

ref_band_width

10

reference ...

print_bits

0

module verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - event record
  • +4 - image shape
  • +8 - spectral array

See also Example for Module ImgAlgos::ImgSpectra.

Module ImgAlgos::ImgSpectraProc

Works after module ImgAlgos::ImgSpectra.
This module is designed as an example, in order to show how to get access to spectral array.
In particular, method ImgSpectraProc::getSpectra(...) shows how to get pointer to data, and method ImgSpectraProc::printSpectra(...) iterates over array and selectively prints its elements.

parameter

default value

description

source

"DetInfo(:Opal1000)"

source of data

key_in

"spectra"

key for input image data

print_bits

0

module verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - event record
  • +4 - spectral array shape
  • +8 - spectral array

See also Example for Module ImgAlgos::ImgSpectraProc.

Module ImgAlgos::ImgSaveInFile

Note

Aka depricated modules: CSPadPixCoords::CSPadImageGetTest, CSPadPixCoords::SaveImageInFile, and ImgAlgos::SaveImageInFile.

...

ImgSaveInFile works after the CSPadImageProducer, CSPadInterpolImageProducer, CameraImageProducer, PnccdImageProducer, etc., which produce image object in formats CSPadPixCoords::Image2D<T> or ndarray<T,2>, where the T stands for one of the data types, double, float, int, uint8_t, or uint16_t.

...

Note

Saving in PNG currently works for uint8_t and uint16_t formats only...

See also Example for Module ImgAlgos::ImgSaveInFile

Module ImgAlgos::ImgVsTimeSplitInFiles

This module is a part of complex algorithm, described in Command Line Interface For Time Correlation Analysis.

...

parameter

default value

description

source

"DetInfo(:Princeton)"

source of data

key

"img"

input image key

fname_prefix

"my-exp"

output files common prefix

file_type

"bin"

output files type: "bin", "txt"

add_tstamp

true

add time stamp to the output file names

nfiles_out

8

number of output files (or number of parts to split image), it works tested and works for nfiles_out < 1016

ampl_thr

1

pixel amplitude threshold in image amplitude units

ampl_min

1

default pixel amplitude if it is below ampl_min

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - event record
  • +4 - job summary
  • +8 - details about split and saving
  • +16 - info about saved files
  • +32 - the first 10 elements of input data

See also Example for Module ImgAlgos::ImgVsTimeSplitInFiles.

Further processing of the files

  • <fname_prefix>-<fname-common>-b<block-number>.<file_type>
  • <fname_prefix>-<fname-common>-med.txt
  • <fname_prefix>-<fname-common>-time.txt
    is implemented in stand-alone c++ module

    Code Block
    bgColor#F7F7ED
    ImgAlgos/app/corana.cpp (or ImgAlgos/test/corana.cpp)
    
    Note

    Note, the application in the test directory is compiled and run by the commands:
    scons test
    <path>/corana -f <fname_data> -t <fname_tau>\ -h -l <logfile>\ -b <basedir>\

    where

  • <fname_data> is one of the data files: <fname_prefix>-<fname-common>-b<block-number>.<file_type>, which needs to be available;
  • <fname_tau> is a file with a list of indexes of tau for evaluation of correlations. By default or if the file is missing, the list of indexes will be generated automatically, and for book-keeping is saved in the file <fname_prefix>-<fname-common>-tau.txt;
  • <basedir> is a directory for all data files, which is current by default;
  • <logfile> is an output log-file, or standard output by default.

Module ImgAlgos::ImgTimeStampList

This module is reduced from ImgAlgos::ImgVsTimeSplitInFiles.
Functionality is restricted to:

...

parameter

default value

description

fname

"tstamp-list.txt"

output files common prefix

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - event record
  • +4 - job summary
  • +8 - print summary parameters for parser

Module ImgAlgos::ImgIntMonCorr

This module is intended for CorAna project.
ImgIntMonCorr gets the image and intensity monitor data, evaluate the normalization factor, applies this factor to the image intensity, and saves the corrected image in the event.

...

Code Block
bgColor#F7F7ED
 BldInfo(FEEGasDetEnergy)         FEEGasDetEnergy  1 1 1 1  0 1   3.000000  7.500000  5.250000
 BldInfo(XCS-IPM-02)              XCS-IPM-02       1 1 1 0  1 0  10.000000 13.000000 11.500000
 BldInfo(XCS-IPM-mono)            XCS-IPM-mono     1 1 1 0  0 1  14.500000 16.000000 15.250000
 DetInfo(XcsBeamline.1:Ipimb.4)   Ipimb.4          1 1 1 1  0 0  -1.000000 -1.000000  1.000000
 DetInfo(XcsBeamline.1:Ipimb.5)   Ipimb.5          1 1 1 1  0 0  -1.000000 -1.000000  1.000000

Module ImgAlgos::IntensityMonitorsData

This module is intended for CorAna project.
It gets the 5 intensity monitors data (4 channels for each) and saves them in the text or binary file file_data. Comments (or header) for this file is saved separately in file_header. It also prints the summary parameters for parser, for example:

...

parameter

default value

description

imon1

"BldInfo(FEEGasDetEnergy)"

source name for intensity monitor

imon2

"BldInfo(XCS-IPM-02)"

source name for intensity monitor

imon3

"BldInfo(XCS-IPM-mono)"

source name for intensity monitor

imon4

"DetInfo(XcsBeamline.1:Ipimb.4)"

source name for intensity monitor

imon5

"DetInfo(XcsBeamline.1:Ipimb.5)"

source name for intensity monitor

file_type

"txt"

file type may be "txt" or "bin"

file_data

"intensity-monitor-data.txt"

file name for data from intensity monitors

file_header

"intensity-monitor-comments.txt"

file name for comments

print_bits

0

verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - event record
  • +4 - job summary
  • +8 - summary parameters for parser
  • +16 - all available data for all sources
  • +32 - information about opened/closed files

Module ImgAlgos::CSPadArrSaveInFile

This module saves the CSPad data array formatted as [5920=4*8*185][388] in output file for each passes event.

parameter

default value

description

source

"DetInfo(:Cspad)"

input source of data

key

 

key for input data, for example, it might be "calibrated"

outfile

"cspad-arr"

out file name prefix for saved array

print_bits

0

module verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - event ID
  • +4 - time stamp
  • +8 - saved file names

Module ImgAlgos::CSPadArrAverage

This module averages the CSPad data array and saves two files for averaged and rms values in CSPad format [5920=4*8*185][388]. In contrast to the cspad_mod.CsPadPedestals, the input data can be specified with a key, that allows to average CSPad array for already pre-processed data, for example "calibrated". This feature can be used to evaluate the averaged signal or background event. Implemented algorithm of averaging allows to eliminate large statistical fluctuations in the pixel amplitude spectrum. In advanced case averaging may have up to three stages, depending on configuration parameters:

...

Default version of the configuration parameters works the same way as cspad_mod.CsPadPedestals. In this case module gets raw events and stage 0 continues for entire input data sample.

See also Example for Module ImgAlgos::CSPadArrAverage.

Module ImgAlgos::CSPadCommonModeCorrection

Alternative to the cspad_mod.CsPadCalib algorithm for the common mode correction.
Takes the CSPad data array with subtracted pedestals, evaluate the average amplitude for each 2x1 section for amplitudes below the threshold, and subtract it from all pixel amplitudes. This algorithm consumes about 30 ms/event on psana0205.

parameter

default value

description

source

"DetInfo(:Cspad)"

source of data for CSPad

inputKey

"calibrated"

key for input data, by default expects data from cspad_mod.CsPadCalib

outputKey

"cm_subtracted"

output key for the next data processing stage

ampthr

30

threshold to exclude the large pixel amplitudes in average

Module ImgAlgos::CSPadBkgdSubtract

This module uses the CSPad array, specified by the configuration parameters source and inputKey, subtracts the background, defined in the file bkgd_fname, and saves the resulting array in the event with outputKey. The subtracted background array is normalized on the sum of pixel amplitudes in the quad section norm_sector, which can be set from 0 to 7.

...

parameter

default value

description

source

"DetInfo(:Cspad)"

input source of data

inputKey

 

key for input data, by default use raw data

outputKey

"bkgd_subtracted"

output key for the next data processing stage

bkgd_fname

"cspad_background.dat"

file with CSPad array [4*8*185][388] of averaged background

norm_sector

0

CSPad sector in quad from 0 to 7

print_bits

0

module verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - event ID
  • +4 - normalization factor for each event
  • +8 - part of the background array

See also Example for Module ImgAlgos::CSPadBkgdSubtract.

Module ImgAlgos::CSPadMaskApply

This module uses the CSPad array, defined by the configuration parameters source and inkey, apply the mask from file mask_fnname and saves the masked data with key outkey. For masked pixels the amplitude will be replaced by the value from masked_amp.

The file mask_fnname has the same structure as files for pedestals and background with dimensions [4*8*185][388]. Masked pixels are indicated by 0-th in this file. This file can be generated, for example, from the averaged background file, using amplitude threshold. This can be done with auxiliary python script MakePixelMask.py as explained in Example for Module ImgAlgos::CSPadMaskApply.

parameter

default value

description

source

"DetInfo(:Cspad)"

input source of data

inkey

 

key for input data, by default use raw data

outkey

"bkgd_subtracted"

output key for the next data processing stage

mask_fname

"cspad_mask.dat"

file with CSPad mask array [4*8*185][388]

masked_amp

0

this amplitude will replace the amplitude in each masked pixel

mask_control_bits

1

control bits for applied mask:

  • =0 - do not apply any mask
  • +1 - apply mask from file
  • +2 - mask two long edges of 2x1
  • +4 - mask two short edges of 2x1
  • +8 - mask two short rows in the middle of 2x1 (rows with wide pixels)

print_bits

0

module verbosity:

  • =0 - print nothing
  • +1 - input pars (in beginJob)
  • +2 - event ID (in event)
  • +4 - mask statistics (in beginJob)
  • +8 - part of the mask array (in beginJob)

Module ImgAlgos::CSPadArrNoise

This module works on CSPad data array shaped as [5920=4*8*185][388], uses the "median algorithm" to evaluate the signal and noise for each pixel, evaluates S/N ratio for each pixel, counts the fraction of events where S/N > SoNThr, and writes the same shape arrays for pixel mask and status information in the maskfile and statusfile, respectively. The statusfile contains for each pixel the fraction of events where S/N > SoNThr. This module presents a part of features implemented in the module ImgAlgos::CSPadArrPeakFinder.

parameter

default value

description

source

"DetInfo(:Cspad)"

input source of data

key

 

key for input data, for example, it might be "calibrated"

statusfile

"cspad-pix-status.dat"

out file with pixel status: fraction of noisy images

maskfile

"cspad-pix-mask.dat"

out file with pixel mask

rmin

3

radial parameter of the area for median algorithm

dr

1

radial band width of the area for median algorithm

SoNThr

3

S/N threshold for each pixel to be considered as noisy

frac_noisy_img

0.1

fraction of noisy images above which pixel is masked in the maskfile

print_bits

0

module verbosity:

  • =0 - print nothing
  • +1 - input pars
  • +2 - empty
  • +4 - processed statistics
  • +8 - output in files
  • +16 - event ID
  • +32 - event time stamp
  • +32 - vector of indexes and map of indexes for the median algorithm

See also Example for Module ImgAlgos::CSPadArrNoise.

Module ImgAlgos::CSPadArrPeakFinder

Module ImgAlgos::CSPadArrPeakFinder is a psana-based implementation of the "median algorithm" for peak finding in CSPad data array shaped as [5920=4*8*185][388]. This algorithm was first implemented in myana/Cheetah by Anton Barty and Co. The "median algorithm" assumes that the amplitude level of background and noise for each pixel can be estimated as a mean and RMS of the surrounding pixels, located in the ring with parameters rmin and dr around the pixel in question. The threshold SoNThr_noise on signal over noise (S/N) ratio allow to asset the pixel amplitude as a large noise fluctuation. Statistics of pixels above the S/N threshold accumulated over many images can be used to form the noisy-pixel mask. For example, if the fraction of images where pixel exceeds the S/N threshold grater than certain value (frac_noisy_imgs=0.9), the pixel is considered as noisy. The permanent bad pixel mask (see module ImgAlgos::CSPadMaskApply) and dynamically evaluated noisy pixel mask are used to get rid of bad pixels and improve the image quality. Healthy pixels with S/N above threshold (SoNThr_signal about 3-5) are treated as potential signals. Using recursive flood-filling algorithm the groups of connected signal pixels can be found and considered as a candidate for a diffraction peaks. Peak finding algorithm uses the amplitude, S/N thresholds, and limits on number of pixels in the connected region (parameters peak_amp_tot_thr, peak_SoN_thr, peak_npix_min, and peak_npix_max) in order to define the peak. Finally, the event is selected or discarded depending on number of found peaks and total amplitude threshold, defined by the parameters event_npeak_min, event_npeak_max, and event_amp_tot_thr, respectively.

...

parameter

default value

description

source

"DetInfo(:Cspad)"

input source of data

key

 

key for input data, for example, it might be "calibrated"

key_signal_out

 

key for output signal array. If the string non-empty, the array is added in the datagram for each event (before selection).

key_peaks_out

"peaks"

key for vector of found peaks in the selected event

hot_pix_mask_inp_file

"cspad-pix-mask-in.dat"

in read the pixel mask from file

hot_pix_mask_out_file

"cspad-pix-mask-out.dat"

out write current pixel mask in the file

frac_noisy_evts_file

"cspad-pix-frac-out.dat"

out file with per-pixel fraction of noisy images

evt_file_out

"./cspad-ev-"

out file with signal CSPad array. Time stamp is added.

rmin

3

radial parameter of the area for median algorithm

dr

1

radial band width of the area for median algorithm

SoNThr_noise

3

S/N threshold for each pixel to be considered as noisy

SoNThr_signal

5

S/N threshold for each pixel to be considered as noisy

frac_noisy_imgs

0.9

fraction of noisy images above which pixel will be masked

peak_npix_min

4

minimal number of connected pixels for the good peak

peak_npix_max

25

maximal number of connected pixels for the good peak

peak_amp_tot_thr

0.

threshold on total signal amplitude of the group of connected pixels, if =0:OFF

peak_SoN_thr

7.

threshold on peak S/N (S and N are sums over connected pixels)

event_npeak_min

10

threshold on minimal number of good peaks for the event selection

event_npeak_max

10000

threshold on maximal number of good peaks for the event selection

event_amp_tot_thr

0.

threshold on total signal amplitude in ADU of all good peaks for the event selection, if =0:OFF

nevents_mask_update

0

number of skipped events before each mask re-evaluation cycle

nevents_mask_accum

50

number of events for the mask re-evaluation

selection_mode

SELECTION_ON

selection mode, other allowed values are: SELECTION_OFF, or SELECTION_INV

out_file_bits

0

control on writing of files:

  • =0 - save nothing
  • +1 - save the hot_pix_mask_out_file file with current mask array in the endJob(...) method
  • +2 - save the frac_noisy_evts_file file with current fraction of noisy events array in the endJob(...) method
  • +4 - save the CSPad signal array for selected events in the file with name like <evt_file_out><counter><run>-<time stamp>.txt
  • +8 - save the vector of found peaks in file <evt_file_out><counter><run>-<time-stamp>-peaks.txt

print_bits

0

module verbosity:

  • =0 - summary at the endJob
  • +1 - input pars (once in beginJob)
  • +2 - initial and current mask statistics (in constructor and when mask is updated)
  • +4 - event selection parameters (for each event); event no., time-stamp, mode, number of peaks, and amp_tot
  • +8 - output in files (for selected events)
  • +16 - start/stop to collect data for mask re-evaluation (driven by the mode counters)
  • +32 - event time stamp (for each event)
  • +64 - vector of indexes and map of indexes for the median algorithm (once in beginJob)
  • +128 - peak parameters before selection (for each event)
  • +256 - peak parameters saved in file (for selected events)
  • +512 - selection statistics (N<5: for each event; N<50: for each 10-th; N<500: for each 100-th, then for each 1000-th)
  • +1024 - event time stamp (for selected events)
  • +2048 - peak finding from connected pixels; this is printed for connected region of signal pixels if npix>peak_npix_min-2 (otherwise too much junk output)

See also Example for Module ImgAlgos::CSPadArrPeakFinder.

Module ImgAlgos::CSPadArrPeakAnalysis

This module is intended for analysis of the results obtained in the peak finding algorithm implemented in the ImgAlgos::CSPadArrPeakFinder module.

...

parameter

default value

description

source

"DetInfo(:Cspad)"

input source of data

key

"peaks"

key for input data for peaks found in event

fname_root

"file.root"

name of the output file with root histograms and ntuples

print_bits

0

module verbosity:

  • =0 - print nothing
  • +1 - input pars (once in beginJob)
  • +2 - summary, number of processed and collected events (in endJob)
  • +4 - peak parameters (in event)
  • +8 - event ID (in event)

See also Example for Module ImgAlgos::CSPadArrPeakAnalysis.

Package pyimgalgos

This package contains python modules which work with both frameworks pyana and psana. Functionality of these modules resembles modules from C++ package ImgAlgos. The difference between two frameworks at code level is explained in Migration from pyana to psana.

Module pyimgalgos.cspad_arr_producer

This module gets data from evt store for CSAPD or CSPAD2x2 depending on unique detector name in parameter source, produce numpy array of full scale shape (4,8,185,388) or (185, 388, 2) of specified in dtype type, and saves it in the evt store with unique name key_out. In case of missing 2x1 sections, their pixel amplitudes substituted by the value form val_miss.

parameter

default value

type

description

source

*-*|Cspad-*

string

address of Detector-Id|Device-Id

data_type

int

string

output array data type. Implemented types: int, int8, int16, int32, uint8, uint16, uint32, float, double.

key_out

cspad_array

string

unique keyword for output array identification

val_miss

0

float

intensity value substituted for missing 2x1 sections in data

print_bits

1

int

module verbosity:

  • =0 - print nothing
  • +1 - input pars (in __init__)
  • +2 - configuration parameters (in beginjob)
  • +8 - part of the output 2-d array (in event)
  • +32 - per quad info (in event)

See also Examples for package pyimgalgos.

Module pyimgalgos.cspad_image_producer

This module gets from evt store the numpy array identified by key_in of full scale shape (4,8,185,388) or (185, 388, 2) for CSPAD or CSPAD2x2, respectively, and produces 2-d image numpy array, taking into account geometry calibration parameters specified by the path calib_dir. The output image array is saved in the evt store with unique name, specified by parameter key_out.

parameter

default value

type

description

calib_dir

'' (empty)

string

path to calibration directory for ex.: /reg/d/psdm/mec/meca6113/calib/CsPad2x2::CalibV1/MecTargetChamber.0:Cspad2x2.1/

source

*-*|Cspad-*

string

address of Detector-Id|Device-Id

key_in

cspad_array

string

keyword for input numpy array, shape=(4, 8, 185, 388) - for cspad or (185, 388, 2) - for cspad2x2

key_out

cspad_image

string

unique keyword for output 2-d image numpy array

print_bits

1

int

module verbosity:

  • =0 - print nothing
  • +1 - input pars (in __init__)
  • +2 - calibration parameters (in the 1st event)
  • +4 - configuration parameters (in the 1st event)
  • +8 - part of CSPAD array (in event)
  • +16 - output image shape (in event)

See also Examples for package pyimgalgos.

Module pyimgalgos.image_crop

This module gets from evt store the 2-d image numpy array identified by source and key_in, crop it using range of row and column parameters, and saves cropped 2-d image numpy array  in the evt store with unique key_out.

parameter

default value

type

description

source

*-*|Cspad-*

string

address of Detector.Id:Device.Id, or Detector-Id|Device-Id

key_in

mage_in

string

keyword for input 2-d image numpy array

key_out

image_out

string

keyword for output 2-d image numpy array

rowmin 0introw minimal to crop image (dafault =  0 - for full size)
rowmax-1introw maximal to crop image (dafault = -1 - for full size)
colmin 0intcolumn minimal to crop image (dafault =  0 - for full size)
colmax-1intcolumn maximal to crop image (dafault = -1 - for full size)

print_bits

 1

int

module verbosity:

  • =0 - print nothing
  • +1 - input pars (in __init__)
  • +2 - input image parameters (in the 1st event)

Module pyimgalgos.image_save_in_file

This module gets from evt store 2-d image numpy array for specified unique name in key_in and saves it in the file with name given by parameter ofname. File extension defines the output file format. Experiment, run, and event numbers are added to the name of the output file. For example, for ofname = image.tiff files will be created with names image-<experinent>-r####-ev######.tiff, where symbols # stands for numbers.

parameter

default value

type

description

source

*-*|Cspad-*

string

address of Detector-Id|Device-Id

key_in

image

string

unique keyword for input 2-d image numpy array

ofname

img.npy

string

output file name (type is selected by extension) supported formats: txt, tiff, gif, pdf, eps, png, jpg, jpeg, npy (default), npz

print_bits

1

int

module verbosity:

  • =0 - print nothing
  • +1 - input pars (in __init__)
  • +4 - info about saved file
  • +8 - part of the image array (in event)

See also Examples for package pyimgalgos.

Module pyimgalgos.tahometer

Is intended to print records showing job performance current and integrated from the beginning of job:

...

parameter

default value

type

description

dn

100

int

interval in number of events to print current statistics

print_bits

1

int

module verbosity:

  • =0 - print nothing
  • +1 - input pars (once in __init__)
  • +2 - current event statistics (in event and endJob)

See also Examples for package pyimgalgos.

References

...