Page History
Include Page | ||||
---|---|---|---|---|
|
Table of Contents |
---|
Include Page | ||||
---|---|---|---|---|
|
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.
...
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 |
---|---|---|
| "DetInfo(:Cspad)" | input source of data |
|
| key for input data, for example, it might be "calibrated" |
| "cspad-arr" | out file name prefix for saved array |
| 0 | module verbosity:
|
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|PSDM:Psana Module Catalog#Modulecspadmod.CsPadPedestals], the input data can be specified with a {{ Wiki Markup 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:
- 0-stage: the 1st portion of events from 0 to
evts_stage1
is averaged without any constrains, the preliminary averaged and rms values are defined for each pixel
at the end of this stage. - 1-stage: starting from the event
evts_stage1
data are collected only forabs(amplitude-average0) < gate_width1
. At the end of this stage the preliminary averaged and rms values are defined for each pixel. - 2-stage: starting from the event
evts_stage1 + evts_stage2
data are collected only forabs(amplitude-average1) < gate_width2
. At the end of this stage the preliminary averaged and rms values are defined for each pixel and saved in the files specified by theavefile
andrmsfile
parameters, respectively.
...
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.
Note | ||||||
---|---|---|---|---|---|---|
|
parameter | default value | description | |||||
---|---|---|---|---|---|---|---|
| "DetInfo(:Cspad)" | input source of data | |||||
|
| key for input data, by default use raw data | |||||
| "bkgd_subtracted" | output key for the next data processing stage | |||||
| "cspad_background.dat" | file with CSPad array [4*8*185][ | <ac:structured-macro ac:name="unmigrated-wiki-markup" ac:schema-version="1" ac:macro-id="fc13e855-7306-45d6-83e9-86be716cc2b3"><ac:plain-text-body><![CDATA[ | | "cspad_background.dat" | file with CSPad array [4*8*185][388] of averaged background | ]]></ac:plain-text-body></ac:structured-macro> |
| 0 | CSPad sector in quad from 0 to 7 | |||||
| 0 | module verbosity:
|
...
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
.unmigrated-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].
parameter | default value | description |
---|---|---|
| "DetInfo(:Cspad)" | input source of data |
|
| key for input data, by default use raw data |
| "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="c24f66a9-6d28-497a-be5c-02715490e4d7"><ac:plain-text-body><![CDATA[ |
| "cspad_mask.dat" | file with CSPad mask array [4*8*185][388] ]]></ac:plain-text-body></ac:structured-macro> |
| 0 | this amplitude will replace the amplitude in each masked pixel |
| 1 | control bits for applied mask:
|
| 0 | module verbosity:
|
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 {{ Wiki Markup 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].
parameter | default value | description |
---|---|---|
| "DetInfo(:Cspad)" | input source of data |
|
| key for input data, for example, it might be "calibrated" |
| "cspad-pix-status.dat" | out file with pixel status: fraction of noisy images |
| "cspad-pix-mask.dat" | out file with pixel mask |
| 3 | radial parameter of the area for median algorithm |
| 1 | radial band width of the area for median algorithm |
| 3 | S/N threshold for each pixel to be considered as noisy |
| 0.1 | fraction of noisy images above which pixel is masked in the |
| 0 | module verbosity:
|
...
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|PCDS:myana user guide]/[Cheetah|https://github.com/antonbarty/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|PSDM:Psana Module Catalog#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.
Description of implemented algorithm:
- 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: fill \ [4\]\[8\]\[185\]\[388\] per-pixel arrays:Wiki Markup m_stat
- number of events with|S/N| > SoNThr
,m_signal
- signal amplitude, or 0(zero) for masked pixels,m_proc_status
- sets 255 forS/N > SoNThr
or 0(zero) for masked pixels.
- use arrays
m_proc_status
andm_signal
to find peaks: iterate over \ [185\]\[388\] 2x1 pixels and find the connected regions (using recursive flood-filling algorithm)Wiki Markup - create vector of peaks
v_peaks
ofstruct Peak
, usingpeak_npix_min
,peak_npix_max
, andpeak_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
, andselection_mode
parameters. - periodically dynamically re-generate the mask, based on
m_stat
array andfrac_noisy_imgs
parameter. When to start and for how many events to update the mask is defined by thenevents_mask_update
andnevents_mask_accum
parameters, respectively. - save
m_signal
in file for selected events, depending onout_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 inout_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
- save current hot-pixel mask in the file
...