Versions Compared

Key

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

...

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.Module configuration parameters:

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.

...

  • 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.

Module configuration parameters:

...

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.

...

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.

Module configuration parameters:

...

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.

...

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.

Module configuration parameters:

...

parameter

default value

description

source

"CxiDs1.0:Cspad.0"

...

source of data

...

key

...

"Image2D"

...

input image key

...

eventSave

...

0

event number to save the CSPad image file

...

saveAll

...

false

save or not all selected events

...

ftype

...

"txt"

...

output file format; currently implemented formats txt, bin, png, tiff

fname

...

"img"

...

prefix of the output file name. Entire file name

...

is formed as <cspad_image_ev><timestamp>.<ftype>

...

print_bits

...

0

verbosity:

  • =0 - print nothing

...

  • +1 - input pars

...

  • +2 - info about saved files

...

Note

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

...

  • get image for each event as an ndarray<T,2> object,
  • splits it for nfiles_out equal parts,
  • saves each part of the image for all events in the job in a separate file with name <fname_prefix>-<fname-common>-b<block-number>.<file_type>,
  • saves metadata in the text file with name: <fname_prefix>-<fname-common>-med.txt,
  • saves counter number and the time records in file: <fname_prefix>-<fname-common>-time.txt.

Module configuration parameters:

...

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.

...

  • saves counter number and the time records in file fname.
  • print summary parameters for parser, for example:
    Code Block
    bgColor#F7F7ED
    ImgTimeStampList: Summary for parser
    BATCH_RUN_NUMBER              0020
    BATCH_NUMBER_OF_EVENTS        75
    BATCH_FRAME_TIME_INTERVAL_AVE 8.086934
    BATCH_FRAME_TIME_INTERVAL_RMS 0.120381
    BATCH_FRAME_TIME_INDEX_MAX          74
    

Module configuration parameters:

...

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

...

  • ImgIntMonCorr uses the source and key_in parameters to get the input image (as ndarray<double,2> object),
  • gets and process the intensity monitors' data in accordance with configuration from file fname_imon_cfg,
  • intensity normalized image is saved in the event with key key_out. The type of output data is the same as the type of input data.

Module configuration parameters:

...

parameter

default value

description

source

"DetInfo(:Camera)"

...

source of data

...

key_in

...

"calibrated"

...

key for input image

...

key_out

...

"imon_corrected"

...

key for output calibrated image saved in event

...

fname_imon_cfg

...

 

input file name with intensity monitors' configuration

...

print_bits

...

0

verbosity:

  • =0 - print nothing

...

  • +1 - input pars

...

  • +2 - time stamp for each event

...

  • +4 - intensity monitor data

...

  • +8 - first 10 elements of the input image data
  • +16 - first 10 elements of the output image data
  • +32 - normalization factor

...

fname_imon_cfg file content per line: source name, short name, on/off bits for 4-channels, normalization and selection, minimal, maximal and averaged intensities:

...

Code Block
bgColor#F7F7ED
IntensityMonitorsData: Summary for parser
BATCH_RUN_NUMBER              0020
BATCH_NUMBER_OF_EVENTS        75

...

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

Wiki Markup
This module saves the CSPad data array formatted as \[5920=4*8*185\]\[388\] in output file for each passes event.
Module configuration parameters:

...

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 type of averaging algorithm may be useful for pedestal defenition in case of large amplitude fluctuations.

Module configuration parameters:

...

parameter

default value

description

source

"DetInfo(:Cspad)"

...

input source of data

key

...

 

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

avefile

...

"cspad-ave.dat"

...

out file with averaged amplitudes

rmsfile

...

"cspad-rms.dat"

...

out file with rms

evts_stage1

...

1<<31U

number of events before stage 1

evts_stage2

...

100

additional number of events before stage 2

gate_width1

...

0

gate_width for stage 1

gate_width2

...

0

gate_width for stage 2

print_bits

...

0

module verbosity:

  • =0 - print nothing

...

  • +1 - input pars

...

  • +2 - beginning of 3 stages

...

  • +4 - processed statistics at the end of each stage

...

  • +8 - output in files

...

  • +16 - event ID

...

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.

...

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.Module configuration parameters:

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

...

Note

Wiki Markup
The shape of the CSPad array in the file {{bkgd_fname}} is \[4*8*185\]\[388\] for all 2x1 sections.
The shape of the CSPad array in the event, specified by the {{source}} and {{inputKey}} or {{outputKey}},
is \[number_of_sections*188\]\[388\] depends on number of available in DAQ 2x1 sections, provided by the masks in CSPad configuration, for example:

Code Block
bgColor#F7F7ED
   shared_ptr<Psana::CsPad::ConfigV2> config2 = env.configStore().get(m_str_src);
   unsigned mask = config2->roiMask(quad_number); // should be in the range from 0 to 255

Module configuration parameters:

...

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

<ac:structured-macro ac:name="unmigrated-wiki-markup

...

" ac:schema-version="1" ac:macro-id="86c19b61-6dda-4ae5-bf1f-eddfd32cbe7e"><ac:plain-text-body><![CDATA[

bkgd_fname

"cspad_background.dat"

...

file with CSPad array [4*8*185

...

]

...

[388

...

]

...

of

...

averaged

...

background

]]></ac:plain-text-body></ac:structured-macro>

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.

...

Wiki Markup
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|PSDM:Psana Module Examples#Example for Module ImgAlgos::CSPadMaskApply].

Module configuration parameters:

...

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

<ac:structured-macro ac:name="unmigrated-wiki-markup

...

" ac:schema-version="1" ac:macro-id="6a7d2904-2d90-4400-a146-46a07df5ef71"><ac:plain-text-body><![CDATA[

mask_fname

"cspad_mask.dat"

...

file with CSPad mask array [4*8*185

...

]

...

[388

...

]

]]></ac:plain-text-body></ac:structured-macro>

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

Wiki Markup
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|PSDM:Psana Module Catalog#Module ImgAlgos::CSPadArrPeakFinder].

Module configuration parameters:

...

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.

...

  • in the constructor and beginJob(...) method:
    • enter input parameters,
    • (re)set the initial mask of noisy pixels from file hot_pix_mask_file (if its name is specified in the configuration file),
    • do necessary initialization of work arrays.
  • in the event(...) method the main part of "median algorithm" is implemented:
    • Wiki Markup
      fill \[4\]\[8\]\[185\]\[388\] per-pixel arrays:
      • m_stat - number of events with |S/N| > SoNThr,
      • m_signal - signal amplitude, or 0(zero) for masked pixels,
      • m_proc_status - sets 255 for S/N > SoNThr or 0(zero) for masked pixels.
    • use arrays m_proc_status and m_signal to find peaks:
      • Wiki Markup
        iterate over \[185\]\[388\] 2x1 pixels and find the connected regions (using recursive flood-filling algorithm)
      • create vector of peaks v_peaks of struct Peak, using peak_npix_min, peak_npix_max, and peak_amp_tot_thr parameters,
    • loop over v_peaks, count total amplitude and the number of peaks in the event.
    • decide if the event selected or not based on event_npeak_min, event_amp_tot_thr, and selection_mode parameters.
    • periodically dynamically re-generate the mask, based on m_stat array and frac_noisy_imgs parameter. When to start and for how many events to update the mask is defined by the nevents_mask_update and nevents_mask_accum parameters, respectively.
    • save m_signal in file for selected events, depending on out_file_bits parameter.
    • put the vector with peaks v_peaks in the evt with key=key_peaks_out.
  • in the endJob(...) method, depending on bit status in out_file_bits :
    • save current hot-pixel mask in the file hot_pix_mask_out_file
    • save current fraction of events with noisy/signal pixels in the file frac_noisy_evts_file

...

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.

...