This page provides examples for selected modules from Psana Module Catalog.
Auxiliary scripts
A few python scripts in ImgPixSpectra/data/
show how to process/plot the spectral array stored in the file.
PlotSpectralArrayFromFile.py
- allows to plot content of the spectral array as a 2-d plot.SpectralArray.py
- provides access to the spectral array stored in the file. Theclass SpectralArray
defined in this script is used in thePlotSpectralArrayFromFile.py
.
MergeArrays.py
- sums the arrays from different files defined in the list and saves resulting array in a single file with the same shape. In this script the list of files is hardwired in theget_list_of_input_file_names()
method. The output file name,out_fname
, is also hardwired in the call tospectra_merging(out_fname)
.
A few auxiliary scripts for example are located in the directory ImgAlgos/data
:
psana.cfg
- set non-default parameters to runpsana
forImgAlgos::ImgPeakFinder
andImgAlgos::ImgPeakFilter
Thepsana
running this script saves images and peaks for event 115 in text files.PlotCameraImageFromFile.py
- Plots image and spectrum for image saved in file.PlotCameraImageAndPeaks.py
- Plots image with found peaks and spectrum.
Example for Package CSPadPixCoords
How to write the CSPad image in text file:
[psana] files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc events = 5 modules = cspad_mod.CsPadCalib CSPadPixCoords.CSPadImageProducer ImgAlgos.ImgSaveInFile [cspad_mod.CsPadCalib] inputKey = outputKey = calibrated doPedestals = yes doPixelStatus = no doCommonMode = no #[CSPadPixCoords.CSPadInterpolImageProducer] [CSPadPixCoords.CSPadImageProducer] calibDir = /reg/d/psdm/<instrument>/<experiment>/calib typeGroupName = CsPad::CalibV1 source = CxiDs1.0:Cspad.0 key = calibrated imgkey = Image2D tiltIsApplied = true [ImgAlgos.ImgSaveInFile] source = CxiDs1.0:Cspad.0 #eventSave = 1 saveAll = true
Example for Module CSPadPixCoords::CSPad2x2ImageProducer
See Module CSPadPixCoords::CSPad2x2ImageProducer
Example of the configuration script for psana (cspad2x2-test.cfg):
[psana] files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc events = 5 modules = CSPadPixCoords.CSPad2x2ImageProducer ImgAlgos.ImgSaveInFile [CSPadPixCoords.CSPad2x2ImageProducer] source = DetInfo(:Cspad2x2) inkey = outimgkey = Image tiltIsApplied = true print_bits = 15 [ImgAlgos.ImgSaveInFile] source = DetInfo(:Cspad2x2) key = Image fname = cspad2x2 saveAll = true #eventSave = 5
Command to run:
psana -c cspad2x2-test.cfg
One of the saved files cspad2x2-<run>-<timestamp>.txt
is plotted as an image by the command
./PlotCameraImageFromFile.py cspad2x2-<run>-<timestamp>.txt 0 1200
Example for Package ImgPixSpectra
Modules:
- ImgPixSpectra::CSPadPixSpectra
- ImgPixSpectra::MiniCSPadPixSpectra
- ImgPixSpectra::CameraPixSpectra
Configuration file example for MiniCSPadPixSpectra
:
[psana] files = /reg/d/psdm/<instrument>/<experiment>/<file-name>.xtc modules = ImgPixSpectra.MiniCSPadPixSpectra [ImgPixSpectra.MiniCSPadPixSpectra] source = CxiSc1.0:Cspad2x2.0 amin = 500. amax = 1000. nbins = 100 arr_fname = mini-cspad-pix-spectra.txt
To get images from saved file one may execute the auxiliary script:
ImgPixSpectra/data/PlotSpectralArrayFromFile.py mini-cspad-pix-spectra.txt
generates image for limited range of pixels for CSPad, MiniCSPad, or Camera, respectively:
Examples for Package ImgAlgos
See Package ImgAlgos
Example for Module ImgAlgos::Tahometer
See Module ImgAlgos::Tahometer
Example of the psana configuration file:
[psana] files = /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-1>.xtc\ /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-2>.xtc modules = ImgAlgos.Tahometer [ImgAlgos.Tahometer] dn = 10 print_bits = 7
Example for Module ImgAlgos::PnccdImageProducer
See Module ImgAlgos::PnccdImageProducer
Example of the psana configuration file:
[psana] files = /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-1>.xtc\ /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-2>.xtc #skip-events = 100 events = 5 modules = ImgAlgos.PnccdImageProducer ImgAlgos.ImgSaveInFile [ImgAlgos.PnccdImageProducer] source = DetInfo(:pnCCD) inkey = outimgkey = imgpnccd print_bits = 1 [ImgAlgos.ImgSaveInFile] source = DetInfo(:pnCCD) key = imgpnccd fname = pnccd-img-ev saveAll = true #eventSave = 82 print_bits = 1
This script saves text files with images like pnccd-img-ev-<run-date-time.nsec>.txt
, which can be presented as:
Example for Module ImgAlgos::CameraImageProducer
See Module ImgAlgos::CameraImageProducer
Example of the psana configuration file:
[psana] files = /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-1>.xtc modules = ImgAlgos.CameraImageProducer ImgAlgos.ImgSaveInFile events = 5 [ImgAlgos.CameraImageProducer] source = DetInfo(:Opal1000) key_in = key_out = img subtract_offset = true print_bits = 15 [ImgAlgos.ImgSaveInFile] source = DetInfo(:Opal1000) key = img fname = img-from-my-experiment saveAll = true #eventSave = 1
This script saves text files with images like img-from-my-experiment-<run-date-time.nsec>.txt
, which can be drawn by the python script
./ImgAlgos/data/PlotCameraImageFromFile.py <filename>.txt <Amin> <Amax>
Example for Module ImgAlgos::PrincetonImageProducer
See Module ImgAlgos::PrincetonImageProducer
Example of the psana configuration file:
[psana] files = /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-1>.xtc\ /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/<file-name-2>.xtc modules = ImgAlgos.PrincetonImageProducer \ ImgAlgos.ImgSaveInFile events = 3 [ImgAlgos.PrincetonImageProducer] source = DetInfo(:Princeton) key_in = key_out = img subtract_offset = true print_bits = 31 [ImgAlgos.ImgSaveInFile] source = DetInfo(:Princeton) key = img fname = img-xcs saveAll = true print_bits = 31
Example for Module ImgAlgos::ImgAverage
See Module ImgAlgos::ImgAverage
The ImgAverage
module can be used for evaluation of averaged pedestals or background using dedicated runs. Typical configuration file may looks like this:
[psana] files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name>.xtc modules = ImgAlgos.CameraImageProducer \ ImgAlgos.ImgAverage events = 1000 [ImgAlgos.CameraImageProducer] source = DetInfo(:Opal1000) key_in = key_out = img subtract_offset = true print_bits = 1 [ImgAlgos.ImgAverage] source = DetInfo(:Opal1000) key = img avefile = img-ave.dat rmsfile = img-rms.dat print_bits = 31 evts_stage1 = 100 evts_stage2 = 100 gate_width1 = 200 gate_width2 = 20
Example for Module ImgAlgos::ImgCalib
[ImgAlgos.CameraImageProducer] source = DetInfo(:Opal1000) key_in = key_out = img subtract_offset = true print_bits = 1 [ImgAlgos.ImgCalib] source = DetInfo(:Opal1000) key_in = img key_out = calibrated fname_peds = <pedestal-file-name> fname_mask = <mask-file-name> fname_bkgd = fname_gain = print_bits = 31
Example of the mask file and resulting image:
Example for Module ImgAlgos::ImgRadialCorrection
See Module ImgAlgos::ImgRadialCorrection
[psana] files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \ /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-2>.xtc \ ... /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc skip-events = 500 events = 10 modules = cspad_mod.CsPadCalib \ # ImgAlgos.CSPadBkgdSubtract \ CSPadPixCoords.CSPadImageProducer \ ImgAlgos.ImgRadialCorrection \ ImgAlgos.ImgSaveInFile:1 [cspad_mod.CsPadCalib] inputKey = outputKey = calibrated doPedestals = yes doPixelStatus = no doCommonMode = no [ImgAlgos.CSPadBkgdSubtract] source = DetInfo(CxiDs1.0:Cspad.0) inputKey = calibrated outputKey = bkgd_subtracted_arr bkgd_fname = <the-file-name-with-background-array> norm_sector = 0 print_bits = 0 [CSPadPixCoords.CSPadImageProducer] calibDir = /reg/d/psdm/<instrument>/<experiment>/calib typeGroupName = CsPad::CalibV1 source = CxiDs1.0:Cspad.0 key = calibrated imgkey = current_img #tiltIsApplied = true [ImgAlgos.ImgRadialCorrection] source = DetInfo(CxiDs1.0:Cspad.0) inkey = current_img outkey = r_cor_img xcenter = 866 ycenter = 857 rmin = 100 rmax = 810 n_phi_bins = 60 event = 0 print_bits = 3 [ImgAlgos.ImgSaveInFile:1] source = CxiDs1.0:Cspad.0 key = r_cor_img fname = <file-name-for-image-array> #saveAll = true eventSave = 8
Note: the option of the background subtraction (ImgAlgos.CSPadBkgdSubtract
) is commented out in this configuration file . In order to evoke this option, the comment sign (#) should be removed from the list of modules
and the key=bkgd_subtracted_arr
should be used in CSPadPixCoords.CSPadImageProducer
.
Calibrated image and spectrum:
Calibrated and radial-corrected image, spectrum, and subtracted r-phi65 distribution for n_phi_bins
=65:
Calibrated and radial-corrected image, spectrum, and subtracted r-phi12 distribution for n_phi_bins
=12:
Example for Module ImgAlgos::ImgPeakFinder
See Module ImgAlgos::ImgPeakFinder
Configuration file example:
[psana] files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \ /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-2>.xtc \ ... /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc modules = ImgAlgos.ImgPeakFinder PrintSeparator #skip-events = 500 events = 120 [ImgAlgos.ImgPeakFinder] source = DetInfo(:Opal1000) key = peaksKey = peaks threshold_low = 20 threshold_high = 50 sigma = 1.5 smear_radius = 2 peak_radius = 3 xmin = 200 xmax = 800 ymin = 100 ymax = 900 testEvent = 115 print_bits = 0 finderIsOn = true
- 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).
Image on different stages of this algorithm:
- raw image,
- image in the window with amplitudes above the
threshold_low
- few peaks at the edges were discarded by the window limits,
- image still contains many 1-photon pixels, which need to be eliminated,
- smeared image,
- raw image with found peaks (marked by the red circles)
- zoom of the previous plot.
Example for Module ImgAlgos::ImgPeakFilter
[ImgAlgos.ImgPeakFilter] source = DetInfo(:Opal1000) key = peaks threshold_peak = 5 threshold_total= 0 n_peaks_min = 10 print_bits = 11 fname = img selection_mode = SELECTION_ON
Example for Module ImgAlgos::ImgPeakFinderAB
See Module ImgAlgos::ImgPeakFinderAB
Configuration file example:
[psana] files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name>.xtc modules = ImgAlgos.CameraImageProducer \ ImgAlgos.ImgPeakFinderAB events = 10 [ImgAlgos.CameraImageProducer] source = DetInfo(:Opal1000) key_in = key_out = img subtract_offset = true print_bits = 1 [ImgAlgos.ImgPeakFinderAB] source = DetInfo(:Opal1000) key = img key_peaks_out = peaks #key_signal_out = signal-arr #hot_pix_mask_inp_file = ana-misc-exp/mask.dat #hot_pix_mask_out_file = noise-mask-out.dat #frac_noisy_evts_file = noise-frac-out.dat evt_file_out = tmp/img- rmin = 10 dr = 1 SoNThr_noise = 3 SoNThr_signal = 3 frac_noisy_imgs = 0.9 peak_npix_min = 3 peak_npix_max = 100 peak_amp_tot_thr = 0. peak_SoN_thr = 4. event_npeak_min = 5 event_npeak_max = 1000 event_amp_tot_thr = 0. nevents_mask_update = 0 nevents_mask_accum = 50 selection_mode = SELECTION_ON out_file_bits = 15 print_bits = 513
Results:
Example for Module ImgAlgos::ImgSaveInFile
modules = ... ImgAlgos.ImgSaveInFile:1 ... [ImgAlgos.ImgSaveInFile:1] source = DetInfo(:Opal1000) # or CxiDs1.0:Cspad.0 key = img fname = my-img #eventSave = 5 saveAll = true
See Module ImgAlgos::ImgSaveInFile
Example for Module ImgPeakFinder and ImgPeakFilter for CSPad
Module ImgAlgos::ImgPeakFinder
works on image. In order to apply this algorithm to CSPad the image should be produced. In next example the image is produced using consequtive modules cspad_mod.CsPadCalib
, ImgAlgos.CSPadMaskApply
, and CSPadPixCoords.CSPadImageProducer
:
[psana] files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \ ... /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc events = 1000 experiment = cxii0212 calib-dir = ana-cxii0212/calib modules = cspad_mod.CsPadCalib \ ImgAlgos.CSPadMaskApply \ CSPadPixCoords.CSPadImageProducer \ ImgAlgos.ImgPeakFinder \ ImgAlgos.ImgPeakFilter \ ImgAlgos.ImgSaveInFile:1 [cspad_mod.CsPadCalib] inputKey = outputKey = calibrated doPedestals = yes doPixelStatus = no doCommonMode = yes [ImgAlgos.CSPadMaskApply] source = DetInfo(CxiDs1.0:Cspad.0) inkey = calibrated outkey = masked_arr mask_fname = <your-local-directory>/<mask-file-name>.dat masked_amp = 0 print_bits = 5 mask_control_bits = 15 [CSPadPixCoords.CSPadImageProducer] calibDir = /reg/d/psdm/<instrument>/<experiment>/calib typeGroupName = CsPad::CalibV1 source = CxiDs1.0:Cspad.0 key = masked_arr imgkey = img print_bits = 0 #tiltIsApplied = true [ImgAlgos.ImgPeakFinder] source = DetInfo(CxiDs1.0:Cspad.0) key = img peaksKey = peaks threshold_low = 2 threshold_high = 5 sigma = 1.5 smear_radius = 5 peak_radius = 7 xmin = 20 xmax = 1700 ymin = 20 ymax = 1700 #testEvent = 5 print_bits = 3 #finderIsOn = true [ImgAlgos.ImgPeakFilter] source = DetInfo(CxiDs1.0:Cspad.0) key = peaks threshold_peak = 5 threshold_total= 0 n_peaks_min = 10 print_bits = 11 fname = cspad-img selection_mode = SELECTION_ON [ImgAlgos.ImgSaveInFile:1] source = CxiDs1.0:Cspad.0 key = img fname = cspad-img #eventSave = 1 saveAll = true
Example for Module ImgAlgos::CSPadArrAverage
See Module ImgAlgos::CSPadArrAverage
Configuration file example for evaluation of pedestals:
[psana] modules = ImgAlgos.CSPadArrAverage files = <path-to-the-dark-run-file>.xtc [ImgAlgos.CSPadArrAverage] source = DetInfo(CxiDs1.0:Cspad.0) key = avefile = cspad-pedestals-ave.dat rmsfile = cspad-pedestals-rms.dat print_bits = 15 evts_stage1 = 100 evts_stage2 = 100 gate_width1 = 100 gate_width2 = 10
Configuration file example for evaluation of background:
[psana] files = <path-to-the-background-run-file>.xtc modules = cspad_mod.CsPadCalib ImgAlgos.CSPadArrAverage skip-events = 500 events = 1000000 [cspad_mod.CsPadCalib] inputKey = outputKey = calibrated doPedestals = yes doPixelStatus = no doCommonMode = no [ImgAlgos.CSPadArrAverage] source = DetInfo(CxiDs1.0:Cspad.0) key = calibrated avefile = cspad-background-ave.dat rmsfile = cspad-background-rms.dat print_bits = 15
Images of the CSPad arrays for averaged and rms values, respectively, in one of the CXI runs:
Example for Module ImgAlgos::CSPadBkgdSubtract
See Module ImgAlgos::CSPadBkgdSubtract
[psana] files = /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-1>.xtc \ /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-2>.xtc \ ... /reg/d/psdm/<instrument>/<experiment>/xtc/<file-name-N>.xtc skip-events = 500 events = 10 modules = cspad_mod.CsPadCalib ImgAlgos.CSPadBkgdSubtract [cspad_mod.CsPadCalib] inputKey = outputKey = calibrated doPedestals = yes doPixelStatus = no doCommonMode = no [ImgAlgos.CSPadBkgdSubtract] source = DetInfo(CxiDs1.0:Cspad.0) inputKey = calibrated outputKey = bkgd_subtracted bkgd_fname = <the-file-name-with-background-array> norm_sector = 0 print_bits = 3
The file with the background array, bkgd_fname
, was obtained by averaging 1000 events using module CSPadArrAverage. Subtraction is done with normalization for norm_sector=0
.
Event image and pixel amplitude spectrum before and after the background subtraction are shown in plots:
Other event with better subtracted background:
Example for Module ImgAlgos::CSPadMaskApply
See Module ImgAlgos::CSPadMaskApply
The array for mask contains zeros and ones for masked and passed pixels, respectively, and has a shape of full-size CSPad array 4*8*185388.
For example, it can be generated by the command
./MakePixelMask.py <input-background-cspad-arr-file-name> <threshold> <output-file-name>
for the averaged background amplitude array <input-background-cspad-arr-file-name>
abtained as a result of ImgAlgos::CSPadArrAverage
module.
Plots show the averaged background, and the mask arrays generated from this background for three thresholds 10, 20, and 30 EDU:
The best results in filtering can be achieved in combination of modiles:
modules = cspad_mod.CsPadCalib \ ImgAlgos.CSPadBkgdSubtract \ ImgAlgos.CSPadMaskApply \ ... [cspad_mod.CsPadCalib] inputKey = outputKey = calibrated_arr doPedestals = yes doPixelStatus = no doCommonMode = no [ImgAlgos.CSPadBkgdSubtract] source = DetInfo(CxiDs1.0:Cspad.0) inputKey = calibrated_arr outputKey = bkgd_subtracted_arr bkgd_fname = ana-cxi49012/cspad-cxi49012-r0025-background-ave.dat norm_sector = 0 print_bits = 0 [ImgAlgos.CSPadMaskApply] source = DetInfo(CxiDs1.0:Cspad.0) inkey = bkgd_subtracted_arr outkey = masked_arr mask_fname = ana-cxi49012/cspad-cxi49012-r0025-mask-40.dat masked_amp = 0 print_bits = 3 mask_control_bits = 1
where
cspad_mod.CsPadCalib
- subtracts the pedestals from raw CSPad data,ImgAlgos.CSPadBkgdSubtract
- subtracts the background,ImgAlgos.CSPadMaskApply
- apply the mask.
In the test with images for background represented by the water and solvent rings this filter provides the background suppression factor about 100.
The background images that still pass this filter have significantly larger intensity with respect to averaged background:
Input parameter mask_control_bits
allows to control masking regions of 2x1. For example, if all edges need to be masked, then use mask_control_bits = 15
, which gives image array like:
where red regions/lines of pixels of amplitude=8 are masked.
Example for Module ImgAlgos::CSPadArrNoise
See Module ImgAlgos::CSPadArrNoise
[psana] modules = cspad_mod.CsPadCalib ImgAlgos.CSPadArrNoise files = /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s00-c00.xtc \ /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s01-c00.xtc \ /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s02-c00.xtc \ /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s03-c00.xtc \ /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s04-c00.xtc \ /reg/d/psdm/cxi/cxi49012/xtc/e158-r0020-s05-c00.xtc #skip-events = 1000 events = 10 [cspad_mod.CsPadCalib] inputKey = outputKey = calibrated doPedestals = yes doPixelStatus = no doCommonMode = no [ImgAlgos.CSPadArrNoise] source = DetInfo(CxiDs1.0:Cspad.0) key = calibrated statusfile = ana-cxi49012/cspad-cxi49012-r0020-noise-status.dat maskfile = ana-cxi49012/cspad-cxi49012-r0200-noise-mask.dat print_bits = 255 rmin = 3 dr = 1 SoNThr = 3 frac_noisy_imgs = 0.15
Index map in median algorithm for rmin=3, dr=1:
CSPadArrNoise::printMatrixOfIndexesForMedian(): 0 0 0 0 1 0 0 0 0 0 0 1 1 1 1 1 0 0 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 1 1 0 0 + 0 0 1 1 0 1 0 0 0 0 0 1 0 0 1 0 0 0 0 0 1 0 0 0 1 1 1 1 1 0 0 0 0 0 0 1 0 0 0 0
Pixel status (fraction of events where S/N > SoNThr
):
For cspad-cxi49012-r0020 with parameters from confguration file (frac_noisy_imgs=0.15
) we get, depending on number of events:
Nnoisy, Ntotal, Nnoisy/Ntotal pixels =94585 2296960 0.041
for 10 events
Nnoisy, Ntotal, Nnoisy/Ntotal pixels =2112 2296960 0.00092
for 100 events
Pixel mask for noisy pixels with |S/N| > SoNThr
:
Example for Module ImgAlgos::CSPadArrPeakFinder
See Module ImgAlgos::CSPadArrPeakFinder
[psana] files = \ /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s00-c00.xtc \ /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s01-c00.xtc \ /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s02-c00.xtc \ /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s03-c00.xtc \ # /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s04-c00.xtc \ suddenly it became unavailable... /reg/d/psdm/cxi/cxi49012/xtc/e158-r0150-s05-c00.xtc #skip-events = 1000 #events = 200 modules = cspad_mod.CsPadCalib \ ImgAlgos.CSPadMaskApply \ ImgAlgos.CSPadArrPeakFinder [cspad_mod.CsPadCalib] inputKey = outputKey = calibrated doPedestals = yes doPixelStatus = no doCommonMode = no [ImgAlgos.CSPadMaskApply] source = DetInfo(CxiDs1.0:Cspad.0) inkey = calibrated outkey = masked_arr mask_fname = ana-cxi49012/cspad-cxi49012-r0150-mask-badregs.dat #mask_fname = ana-cxi49012/cspad-cxi49012-r0150-mask-bkgd.dat #mask_fname = ana-cxi49012/cspad-cxi49012-r0150-mask-rects.dat masked_amp = 8 print_bits = 1 mask_control_bits = 15 [ImgAlgos.CSPadArrPeakFinder] source = DetInfo(CxiDs1.0:Cspad.0) key = masked_arr key_peaks_out = peaks hot_pix_mask_inp_file = ana-cxi49012/cspad-cxi49012-r0150-noise-mask.dat hot_pix_mask_out_file = ana-cxi49012/cspad-cxi49012-r0150-noise-mask-out.dat frac_noisy_evts_file = ana-cxi49012/cspad-cxi49012-r0150-noise-frac.dat evt_file_out = tmp/cspad-ev- rmin = 3 dr = 1 SoNThr = 3 frac_noisy_imgs = 0.1 peak_npix_min = 4 peak_npix_max = 25 peak_amp_tot_thr = 100. event_npeak_min = 10 event_amp_tot_thr = 1000. nevents_mask_update = 100 nevents_mask_accum = 50 selection_mode = SELECTION_ON out_file_bits = 15 print_bits = 512
Results:
[info:TimeInterval::startTime] Start time: 2012-06-12 15:32:02 [info:ImgAlgos.CSPadArrPeakFinder] N processed events = 1000 N selected = 55 Fraction of selected = 0.055 [info:ImgAlgos.CSPadArrPeakFinder] N processed events = 2000 N selected = 62 Fraction of selected = 0.031 [info:ImgAlgos.CSPadArrPeakFinder] N processed events = 3000 N selected = 81 Fraction of selected = 0.027 [info:ImgAlgos.CSPadArrPeakFinder] N processed events = 4000 N selected = 95 Fraction of selected = 0.02375 [info:ImgAlgos.CSPadArrPeakFinder] N processed events = 5000 N selected = 150 Fraction of selected = 0.03 [info:ImgAlgos.CSPadArrPeakFinder] N processed events = 6000 N selected = 265 Fraction of selected = 0.0441667 [info:ImgAlgos.CSPadArrPeakFinder] N processed events = 7000 N selected = 404 Fraction of selected = 0.0577143 [info:ImgAlgos.CSPadArrPeakFinder] ===== JOB SUMMARY ===== [info:TimeInterval::stopTime] Time to process 7945 events is 3747.48 sec, or 0.471678 sec/event
Selected events
ev-007713:
ev-008944:
Example for Module ImgAlgos::CSPadArrPeakAnalysis
See Module ImgAlgos::CSPadArrPeakAnalysis
Example of the psana configuration file:
modules = cspad_mod.CsPadCalib \ ImgAlgos.CSPadMaskApply \ ImgAlgos.CSPadArrPeakFinder \ ImgAlgos.CSPadArrPeakAnalysis # ...configuration parameters of other modules... [ImgAlgos.CSPadArrPeakAnalysis] source = DetInfo(CxiDs1.0:Cspad.0) key = peaks print_bits = 7 fname_root = file.root
After execution in psana the file.root
containing histogram(s) and ntuple(s) will be produced. Then, auxiliary script in root, running by the commend
root -q -f proc.C
produces the plots with histograms:
Example for TimeStampFilter and XtcOutputModule
This example demonstrates how to run psana with the time stamp filter and event writer in xtc file.
Both modules are available in psana library and they need only to be described in the configuration file. For example, the configuration file tstamp-filter-and-event-writer.cfg
may looks like:
[psana] files = /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s00-c00.xtc \ /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s01-c00.xtc \ /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s02-c00.xtc \ /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s03-c00.xtc \ /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s04-c00.xtc \ /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s05-c00.xtc skip-events = 10 events = 100 modules = ImgAlgos.TimeStampFilter PSXtcOutput.XtcOutputModule [PSXtcOutput.XtcOutputModule] dirName = ./test_out [ImgAlgos.TimeStampFilter] tsinterval = 2012-02-02 18:17:00.409143728 / 2012-02-02 18:17:00.525853474 filterIsOn = true print_bits = 11
Command to run psana is:
psana -c ./tstamp-filter-and-event-writer.cfg
For this configuration file psana will skip 10 events and loop over the next 100 events from the /reg/d/psdm/<INSTRUMENT>/<experiment>/xtc/e158-r0021-s0*-c00.xtc
files and run consecutively modules = ImgAlgos.TimeStampFilter PSXtcOutput.XtcOutputModule
. Parameters of these modules are described in the bottom part of the configuration file. Module TimeStampFilter
passes events from the specified time interval and prints some useful information. Module XtcOutputModule
will write passed events in the file with auto-generated name ./test_out/e158-r0021.xtcf
.
See also: Module ImgAlgos::TimeStampFilter and PSXtcOutput::PSXtcOutput