Page History
...
newrel ana-current myrel
cd myrel
newpkg mypkg
mkdir mypkg/src
sit_setup
Suppose we want to filter based on the photon count of the calibrated cspad from the CxiDs1.0:Cspad.0 source in the tutorial data. Rather then work with the quad's of the cspad, we will use an image producer module so that we can work with a 2D image. Further documentation on the various calibration modules, including image producers, can be found at psana - Module Catalog. We now add the following two files:
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
[psana] modules = cspad_mod.CsPadCalib \ CSPadPixCoords.CSPadImageProducer \ mypkg.mymod \ Translator.H5Output events = 10 files = exp=cxitut13:run=1150 [CSPadPixCoords.CSPadImageProducer] source = DetInfo(CxiDs1.0:Cspad.0) key = calibrated imgkey = image tiltIsApplied = false print_bits = 0 [Translator.H5Output] deflate=-1 shuffle=False overwrite=True output_file=cxitut13-run1150-filt.h5 |
...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
import psana class mymod(object): def __init__(self): self.threshold = self.configInt('threshold',176000000) srcStr = self.configStr('source','DetInfo(CxiDs1.0:Cspad.0)') self.source = psana.Source(srcStr) def event(self, evt, env): image = evt.get(psana.ndarray_int16_2, self.source, 'image') if image is None: return photonCount = image[:].sum() if photonCount < self.threshold: self.skip() |
...
The configuration file trans.cfg sets up a module chain with 4 modules: cspad_mod.CsPadCalib, CSPadPixCoords.CSPadImageProducer, mypkg.mymod, Translator.H5Output. The first module calibrates all cspad it finds. The second module turns a cspad from a specific source into an image - placing asics quads and ascics in the correct position based on geometry. After these two modules, we load our own module - mypkg.mymod. Finally the Translator module runs last.
Reading through trans.cfg you will see how the raw cspad moves through the event store. The default behavior of cspad_mod.CsPadCalib is to place calibrated cspad in the Event with the key "calibrated". The CSPadPixCoords.CSPadImageProducer module has been told to look for the "calibrated" input key, for the source DetInfo(CxiDs1.0:Cspad.0) and produce an image with the key "image".
...
one sees that only 5 events were translated. The other 5 were skipped.
Another point to make about this example is that the cspad is effectively getting translated twice. The Translator is going to see the event keys:
EventKey(type=psana.CsPad.DataV2, src='DetInfo(CxiDs1.0:Cspad.0)')
EventKey(type=psana.CsPad.DataV2, src='DetInfo(CxiDs1.0:Cspad.0)', key='calibrated')
EventKey(type=psana.ndarray_int16_2, src='DetInfo(CxiDs1.0:Cspad.0)', key='image')
The Translator's default behavior is to treat the key 'calibrated' as special. Since the two keys differ only by the keystring 'calibrated', the Translator will not translate the raw cspad. It only translated the calibrated cspad. However the Translator does not know that the ndarray with key 'image' is a copy of the cspad. If one is only going to work with the 'image' array data and not the 'calibrated' cspad data, one could add the filtering option
Cspad=exclude
To the Translator.H5Output section of the config file. Then none of the cspad data will be translated (including both the configuration as well as event data) while the 'image' array will still be translated.
Filtering Types
The psana.cfg file accepts a number of parameters that will filter out sets of psana types. For example setting
...