Because critical experimental decisions must be made while an LCLS experiment is in progress, it is import to be able to analyze your data while it is being taken.  The DAQ supports an online GUI that can handle common tasks that is called AMI.  However, often this is not specialized enough for particular experiments.  To handle this case, psana-python allows you to run your analysis code while data is being taken in two different ways, using MPI-parallelization for performance.

Real-Time Analysis Using "DAQ Small Data"

This approach (supported as of October 2015) is simplest, but has the disadvantage that it is not guaranteed to be able to keep up with the data (but in most cases it does when using MPI as shown in the example here).  It requires using 3 extra keywords when constructing your DataSource:

ds = DataSource('exp=xpptut15:run=54:smd:dir=/reg/d/ffb/xpp/xpptut15/xtc:live')

This analysis can be submitted to the batch system as usual, but should use the appropriate "prioq" batch queue as described here (only when your experiment is actively running).

Real-Time Analysis Using "Shared Memory"

This approach is somewhat more complex, but is guaranteed to analyze only "recent" events.  It has the disadvantage that it is not guaranteed to analyze every event in a run.  This approach is best when you need guaranteed real-time feedback, e.g. for tuning experiment/accelerator settings based on real-time plots.  To use this mode, create a DataSource object this like:

ds = DataSource('shmem=psana.0:stop=no')

There are other complications starting the code and gathering results from the MPI processes.  Contact the analysis group or your hutch Point Of Contact if you wish to use this mode.