Versions Compared

Key

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

...

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 parameterAlternative 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:

  • source dn (default: "DetInfo(:Cspad)" 100) – source of data for CSPadinputKey number of events between printout
  • print_bits (default: "calibrated" ) – key for input data, by default expects data from cspad_mod.CsPadCalib
  • outputKey (default: "cm_subtracted" ) – output key for the next data processing stage
  • ampthr (default: 30 ) – threshold to exclude the large pixel amplitudes in average

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.

  • 2) – filter verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - start notice and summary at stop,
    • +4 - instant rate performance after each dn events.

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_binsThe algorithm performance was tested for CSPad images. This algorithm consumes up to 15 ms/event on psana0205 for full CSPad (1650x1650) window size. For smaller window consumed time is negligible, comparing to the image reconstruction time, which is ~70 ms/event (for cspad_mod.CsPadCalib and CSPadPixCoords::CSPadImageProducer) on psana0205.

Module configuration parameters:

  • source (default: "DetInfo(:Cspad)") – input source of data
  • key inkey (default: " Image2D " ) – key for input image data, by default use raw data
  • threshold outkey (default: 10) – minimal threshold on pixel amplitude"rad_corrected" ) – output key for further image processing
  • xcenter numPixMin (default: 100850) – minimal number of pixels with amplitude above the thresholdx coordinate of the image center
  • ycenter filterIsOn (default: true850) – On/Off the filtery coordinate of the image center
  • rmin xmin (default: 010) – minimal column numberxmax radius minimal image is not processed for r<rmin
  • rmax (default: 1000001000) – maximal column numberradius maximal image is not processed for r>rmax
  • n_phi_bins ymin (default: 012) – minimal row numberymax number of angular sectors for the background averaging.
  • event (default: 1000000) – maximal row numbertest event for print/save
  • print_bits (default: 0) – module verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - summary,
    • +4 - per event number of pixels above the thresholdevent ID,
    • +8 - the same as previous, but for each 100's event,
    • +16 - event ID.

Remarks:

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

Code Block

struct Peak{
   double x;
   double y; 
   double ampmax;  // amplitude in the peak maximum   
   double amptot;  // total amplitude in the range of {{peak_radius}}
   unsigned npix;  // number of pixels in the range of {{peak_radius}}
} ;

Module configuration parameters:

  • source (default: "DetInfo()") – source of data
  • key (default: "") – key for input image data
  • peaksKey (default: "peaks") – key for output list of peaks
  • threshold_low (default: 10) – low threshold on pixel amplitude
  • threshold_high (default: 100) – high threshold on pixel amplitude
  • sigma (default: 1.5) – width of the Gaussian for smearing; =0-no smearing
  • smear_radius (default: 3) – radius in pixel for smearing - radial size of matrix of weights
  • peak_radius (default: 3) – radius in pixel for peak finding - radial size of the region to search for local maximum
  • xmin (default: 0) – minimal column number
  • xmax (default: 100000) – maximal column number
  • ymin (default: 0) – minimal row number
  • ymax (default: 100000) – maximal row number
  • testEvent (default: 0) – event number to save images and print info for test purpose
  • finderIsOn (default: true) – On/Off algorithm
  • print_bits (default: 0) – finder verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - summary,
    • +4 - number of peaks in the event,
    • +8 - per event each peak parameters,
    • +16- info about input image format.

Remarks:

  • 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

...

    • 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 algorithm performance was tested for CSPad images. This algorithm consumes up to 15 ms/event on psana0205 for full CSPad (1650x1650) window size. For smaller window consumed time is negligible, comparing to the image reconstruction time, which is ~70 ms/event (for cspad_mod.CsPadCalib and CSPadPixCoords::CSPadImageProducer) on psana0205.

Module configuration parameters:

  • source (default: "DetInfo(:Cspad)") – source of data
  • key (default: "Image2D") – key for input image data
  • threshold (default: 10) – minimal threshold on pixel amplitude
  • numPixMin (default: 100) – minimal number of pixels with amplitude above the threshold
  • filterIsOn (default: true) – On/Off the filter
  • xmin (default: 0) – minimal column number
  • xmax (default: 100000) – maximal column number
  • ymin (default: 0) – minimal row number
  • ymax (default: 100000) – maximal row number
  • print_bits (default: 0) – verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - summary,
    • +4 - per event number of pixels above the threshold,
    • +8 - the same as previous, but for each 100's event,
    • +16 - event ID.

Remarks:

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

Code Block

struct Peak{
   double x;
   double y; 
   double ampmax;  // amplitude in the peak maximum   
   double amptot;  // total amplitude in the range of {{peak_radius}}
   unsigned npix;  // number of pixels in the range of {{peak_radius}}
} ;

Module configuration parameters:

  • source (default: "DetInfo()") – source of data
  • key (default: "") – key for input image data
  • peaksKey (default: "peaks") – key for input output list of peaks, should be the same as peaksKey in ImgPeakFinder
  • selection_mode (default: "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 (default: 0) – threshold on peak amplitude
  • threshold_total(default: 0) – threshold on total peak intensity (in the matrix around peak)
  • n_peaks_min (default: 1) – minimal number of peaks above all thresholds
  • threshold_low (default: 10) – low threshold on pixel amplitude
  • threshold_high (default: 100) – high threshold on pixel amplitude
  • sigma (default: 1.5) – width of the Gaussian for smearing; =0-no smearing
  • smear_radius (default: 3) – radius in pixel for smearing - radial size of matrix of weights
  • peak_radius (default: 3) – radius in pixel for peak finding - radial size of the region to search for local maximum
  • xmin (default: 0) – minimal column number
  • xmax (default: 100000) – maximal column number
  • ymin (default: 0) – minimal row number
  • ymax (default: 100000) – maximal row number
  • testEvent (default: 0) – event number to save images and print info for test purpose
  • finderIsOn (default: true) – On/Off algorithmfname (default: "") – file name prefix; by default the prefix is empty and file is not saved
  • print_bits (default: 0) – filter finder verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - summary,
    • +4 - peaks' infonumber of peaks in the event,
    • +8 - per event recordeach peak parameters,
    • +16- event IDinfo about input image format.

Remarks:

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

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.SaveImageInFile is a psana module class, which works after the CSPadImageProducer or CSPadInterpolImageProducer. It receives the CSPadPixCoords::Image2D<double> or ndarray<double,2> image object from the event. (This image object may be used in further data processing.) For test purpose, the image of particular event, defined by the eventSave parameter in configuration file, is saved in the text file with standard predefined name like cspad_image_ev<number>.txt.

Module configuration parameters:

  • source (default: "CxiDs1.0:Cspad.0DetInfo()") – source of data,
  • key (default: "Image2Dpeaks") – input image key,
  • eventSave (default: 0) – event number to save the CSPad image file,
  • saveAll (default: false) – save or not all selected events,
  • fname (default: "cspad_image_ev") – common part of the output file name, event number with extension ".txt" will be added at the end.
  • print_bits(default: 0) – verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - info about saved files.

See also Example for Module ImgAlgos::SaveImageInFile.

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.

Module configuration parameters:

  • key for input list of peaks, should be the same as peaksKey in ImgPeakFinder
  • selection_mode (default: "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 (default: 0) – threshold on peak amplitude
  • threshold_total(default: 0) – threshold on total peak intensity (in the matrix around peak)
  • n_peaks_min (default: 1) – minimal number of peaks above all thresholds
  • fname (default: "") – file name prefix; by default the prefix is empty and file is not saveddn (default: 100) – number of events between printout
  • print_bits (default: 20) – filter verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - start notice and summary at stop- summary,
    • +4 - peaks' info,
    • +8 - event record,
    • +4 - instant rate performance after each dn events16 - event ID.

See also Example for Module ImgAlgos::ImgPeakFilter.

Module ImgAlgos::

...

SaveImageInFile

SaveImageInFile is a psana module class, which works after the CSPadImageProducer or CSPadInterpolImageProducer. It receives the CSPadPixCoords::Image2D<double> or ndarray<double,2> image object from the event. (This image object may be used in further data processing.) For test purpose, the image of particular event, defined by the eventSave parameter in configuration file, is saved in the text file with standard predefined name like cspad_image_ev<number>.txtThis 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.

Module configuration parameters:

  • tsinterval source (default: "1970-01-01 00:00:00.000000000 / 2100-01-01 00:00:00.000000000") – time-stamp interval string
  • tstamp_min (default: "1970-01-01 00:00:00.000000000") – minimal time-stamp string
  • tstamp_max (default: "2100-01-01 00:00:00.000000000") – maximal time-stamp string
  • filterIsOn (default: true) – On/Off the filter
  • CxiDs1.0:Cspad.0") – source of data,
  • key (default: "Image2D") – input image key,
  • eventSave print_bits (default: 0) – filter verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - summary,
    • +4 - event ID,
    • +8 - time stamp variables for selected event.

The time-stamp string is accepted in various formats:

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

...

  • event number to save the CSPad image file,
  • saveAll (default: false) – save or not all selected events,
  • fname (default: "cspad_image_ev") – common part of the output file name, event number with extension ".txt" will be added at the end.
  • print_bits(default: 0) – verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - info about saved files.

See also Example for Module ImgAlgos::SaveImageInFile.

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.

Module configuration parameters:

  • filterIsOn tsinterval (default: true) – On/Off filter.
  • first (default: 0) – the first event from the beginning of job, starting from 0.
  • last (default: 1<<31) – the last event from the beginning of job.
  • : "1970-01-01 00:00:00.000000000 / 2100-01-01 00:00:00.000000000") – time-stamp interval string
  • tstamp_min (default: "1970-01-01 00:00:00.000000000") – minimal time-stamp string
  • tstamp_max (default: "2100-01-01 00:00:00.000000000") – maximal time-stamp string
  • filterIsOn (default: true) – On/Off the filterevtstring (default: "") – the string of events of intervals from the beginning of job.
  • print_bits (default: 0) – filter verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - summary,
    • +4 - selected event number and ID.

There are two modes of operation of this filter.

  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 evtstring parameter can be defined as
    Code Block
    
     2,5,11-15,20-25,29,30
    
    that means the list of events:
    Code Block
    
      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::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:

    • ,
    • +8 - time stamp variables for selected event.

The time-stamp string is accepted in various formats:

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

Note

The unique parameter associated with the event is a time-stamp. The event number is not defined in the xtc file and is not a recommended to use parameter. The events are counted locally inside this filter from the beginning of job starting from 0. Be cautious of using this filter in consecutive jobs for different runs! For example, this filter returns different subsets of events for the files with raw and selected events.

Module configuration parameters:

  • filterIsOn (default: true) – On/Off filter.
  • first (default: 0) – the first event from the beginning of job, starting from 0.
  • last (default: 1<<31) – the last event from the beginning of job.
  • evtstring (default: "") – the string of events of intervals from the beginning of job.
  • source (default: "DetInfo(:Cspad)") – input source of data
  • key (default: "") – key for input data, for example, it might be "calibrated"
  • outfile (default: "cspad-arr") – out file name prefix for saved array
  • print_bits (default: 0) – module filter verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - event IDsummary,
    • +4 - time stamp,
    • +8 - saved file names.

Module ImgAlgos::CSPadArrAverage

Wiki Markup
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|PCDS:Psana Module Catalog#Modulecspadmod.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:

  • 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 for abs(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_stage2 data are collected only for abs(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 the avefile and rmsfile parameters, respectively.

This type of averaging algorithm may be useful for pedestal defenition in case of large amplitude fluctuations.

Module configuration parameters:

  • source (default: "DetInfo(:Cspad)") – input source of data
  • key (default: "") – key for input data, for example, it might be "calibrated"
  • avefile (default: "cspad-ave.dat") – out file with averaged amplitudes
  • rmsfile (default: "cspad-rms.dat") – out file with rms
  • evts_stage1 (default: 1<<31U) – number of events before stage 1
  • evts_stage2 (default: 100) – additional number of events before stage 2
  • gate_width1 (default: 0) – gate_width for stage 1
  • gate_width2 (default: 0) – gate_width for stage 2
  • print_bits (default: 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.

See also Example for Module ImgAlgos::CSPadArrAverage.

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.

...

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:

...

    • selected event number and ID.

There are two modes of operation of this filter.

  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 evtstring parameter can be defined as
    Code Block
    
     2,5,11-15,20-25,29,30
    
    that means the list of events:
    Code Block
    
      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::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:

  • source (default: "DetInfo(:Cspad)") – input source of data
  • key (default: "") – key for input data, for example, it might be "calibrated"
  • outfile (default: "cspad-arr") – out file name prefix for saved array
  • print_bits (default: 0) – module verbosity:
    • =0 - print nothing,
    • +1 - input pars,
    • +2 - event ID,
    • +4 - time stamp,
    • +8 - saved file names.

Module ImgAlgos::CSPadArrAverage

Wiki Markup
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|PCDS:Psana Module Catalog#Modulecspadmod.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:

  • 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 for abs(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_stage2 data are collected only for abs(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 the avefile and rmsfile parameters, respectively.

This type of averaging algorithm may be useful for pedestal defenition in case of large amplitude fluctuations.

Module configuration parameters:

  • source (default: "DetInfo(:Cspad)") – input source of data
  • key (default: "") – key for input data, for example, it might be "calibrated"
  • avefile (default: "cspad-ave.dat") – out file with averaged amplitudes
  • rmsfile (default: "cspad-rms.dat") – out file with rms
  • evts_stage1 (default: 1<<31U) – number of events before stage 1
  • evts_stage2 (default: 100) – additional number of events before stage 2
  • gate_width1 (default: 0) – gate_width for stage 1
  • gate_width2 (default: 0) – gate_width for stage 2
  • print_bits (default: 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.

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.

Module configuration parameters:

  • source (default: "DetInfo(:Cspad)" ) – input source of data for CSPad
  • inputKey (default: "calibrated" ) – key for input data, by default use raw data
  • outputKey (default: "bkgd_subtracted" ) – output key for the next data processing stage
  • Wiki Markup
    {{bkgd_fname}} (default: "cspad_background.dat" ) -- file with CSPad array \[4*8*185\]\[388\] of averaged background
  • norm_sector (default: 0) – CSPad sector in quad from 0 to 7
  • print_bits (default: 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.

...

  • expects data from cspad_mod.CsPadCalib
  • outputKey (default: "cm_subtracted" ) – output key for the next data processing stage
  • ampthr (default: 30 ) – threshold to exclude the large pixel amplitudes in average

Module ImgAlgos::CSPadBkgdSubtract

This module uses the CSPad array, defined specified 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. Wiki MarkupThe file {{mask_fnname}} has the same structure as files for pedestals and background with dimensions \[4*8*185 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

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

   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:

  • source (default: "DetInfo(:Cspad)") – input source of data
  • inkey inputKey (default: " " ) – key for input data, by default use raw data
  • outkey outputKey (default: "bkgd_subtracted" ) – output key for the next data processing stage
  • Wiki Markup
    {{maskbkgd_fname}} (default: "cspad_maskbackground.dat"  ) -- file with CSPad mask array \[4*8*185\]\[388\]] of averaged background
  • norm_sector masked_amp (default: 0) – this amplitude will replace the amplitude in each masked pixelCSPad sector in quad from 0 to 7
  • printmask_control_bits (default: 10) – control bits for applied maskmodule verbosity:
    • =0 - do not apply any maskprint nothing,
    • +1 - apply mask from fileinput pars,
    • +2 - mask two long edges of 2x1event ID,
    • +4 - mask two short edges of 2x1normalization factor for each event,
    • +8 - mask two short rows in the middle of 2x1 (rows with wide pixels).
  • print_bits (default: 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::ImgRadialCorrection

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

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

Module configuration parameters:

  • source (default: "DetInfo(:Cspad)" ) – input source of data
  • inkey (default: " " ) – key for input data, by default use raw data
  • outkey (default: "rad_corrected" ) – output key for further image processing
  • xcenter (default: 850) – x coordinate of the image center
  • ycenter (default: 850) – y coordinate of the image center
  • rmin (default: 10) – radius minimal image is not processed for r<rmin
  • rmax (default:1000) – radius maximal image is not processed for r>rmax
  • n_phi_bins (default: 12) – number of angular sectors for the background averaging.
  • by default use raw data
  • outkey (default: "bkgd_subtracted" ) – output key for the next data processing stage
  • Wiki Markup
    {{mask_fname}} (default: "cspad_mask.dat"  ) -- file with CSPad mask array \[4*8*185\]\[388\]
  • masked_amp (default: 0) – this amplitude will replace the amplitude in each masked pixel
  • mask_control_bits (default: 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).
    event (default: 0) – test event for print/save
  • print_bits (default: 0) – module verbosity:
    • =0 - print nothing,
    • +1 - input pars (in beginJob),
    • +2 - summaryevent ID (in event),
    • +4 - event IDmask statistics (in beginJob),
    • +8 - info about input image type (ndarray<double,2> or Image2D<double>).

...

    • part of the mask array (in beginJob).

Module ImgAlgos::CSPadArrNoise

...