Versions Compared

Key

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

...

Here we cover topics specific to the offline TimeTool module. The TimeTool results can be obtained in one of two ways depending on the experimental setup. The first is through EPICs directly during data acquisition. For data recorded prior to Oct 13, 2014, the timetool results were always recorded as EPICS PV's that are calculated during data acquisition. The . After Oct 13, 2014, they are still recorded as EPICS PV's, but also recorded in their own data type: TimeTool::DataV1. The latter is the preferred way to access the data, EPICS PV's are provided for backward compatibility. The second is during offline analysis using the psana module TimeTool.Analyze. Similarly, this module puts a TimeTool::DataV1 object in the event store. Previously, it put a collection of floats, or ndarrays in the event store. Documentation on the psana TimeTool modules can be found in the psana - Module Catalog.

...

Below we go over a script for generated offline TimeTool data for an sxr experiment. For this experiment, run 144 was done with the beam blocked, and run 150 with the beam on. The laser is always on in both runs.

This requires some configuration of the TimeTool. We run the TimeTool.Analyze module on run 144 - telling it that the beam is always off. Analayze Analyze builds up a reference. We further configure Analyze to save the reference. We also save a averaged background image for our own interactive plotting later.

We then run TimeTool.Analyze on run 150. We save the resulting timetool values to an hdf5 file using the psana xtc to hdf5 translator, see The XTC-to-HDF5 Translator for details.

Finally, to check the work, we process run 150 in index mode, see psana - Python Script Analysis Manual for details on indexing mode (random access) to psana events. We load the time tool values from the h5 file and plot them against the opal, after subtracting our background image.Here are instructions for setting up to run on this sxr experiment. Users of other experiments will not be able to run on this data and will want to modify the scripts for their own experiments. These instructions will reference the following two files. First, the main driver script in the release directory can be found Here (filename ttanalyze.py).

Second, library code for a package in the release can be found Here (filename ttlib.py).

...

now copy ttanalyze.py above to myrel/ttanalyze.py
now copy ttlib.py to myrel/mypkg/src/ttlib.py

...

The example code is part of the package TimeToolExamples. The easiest way to access it is through the users svn repository at SLAC. If you do not have access to the repository, the code is available as attachments (see below). Assuming you are working on the SLAC system, to get started, do

newrel ana-current myrel
cd myrel
addpkg -u TimeToolExamples V00-00-02
scons

If you have any trouble with the addpkg -u command, you may need to do

kinit

to get a kerberos ticket to access the users svn repository. This tag (V00-00-02) has been tested with ana-0.13.3 and should work with later releases. This is the release when the TimeTool.Analyze package started to use the TimeTool::DataV1 object. For previous analysis releases, get tag V00-00-01 which uses the put_ndarrays option to get the data.

The package contains two files. The first is the script that designates the sxr experiment data to run on. It is the file TimeToolExamples/app/tt_sxrd5814. You can immediately take a look at the code here: tt_sxrd5814. The second is a library of functions called by the driver script: TimeToolExamples/src/ttlib.py that you can download here: ttlib.py. Instead of the addpkg command above, one can do

newpkg mypkg
mkdir mypkg/src
mkdir mypkg/app

and download the files into

mypkg/app/tt_sxrd5814
mypkg/src/ttlib.py

and run

scons

to build the code. The run the script, from the release directory do

tt_sxrd5814

Note, users of other experiments will not be able to access the data from this experiment. You will want to modify TimeToolExamples/app/tt_sxrd5814 to read your own data.
*IMPORTANT* after modifying tt_sxrd5814, you *MUST* run scons. This installs a copy of the script (with a modification to the #! line) in the myrel/arch directory. The file in myrel/arch is what is actually run.

After running the script as is, it should produce the files

Code Block
ttref_sxrd5814_r0144.txt       # reference that TimeTool.Analayze produced
ttref_sxrd5814_r0144.npy       # our own background reference for plotting
tt_sxrd5814_r0150.h5           # the h5 file with the timetool results for r150


This script builds a background from the first 300 events in run 144,
and processes the first 500 events in run 150.

A recursive listing of the h5 file should show, among other groups:

Code Block
h5ls -r tt_sxrd5814_r0150.h5 
/Configure:0000/Run:0000/CalibCycle:0000/TimeTool::DataV1/noSrc__TTANA/data Dataset {500/Inf}
/Configure:0000/Run:0000/CalibCycle:0000/TimeTool::DataV1/noSrc__TTANA/time Dataset {500/Inf}


The data dataset is the TimeTool::DataV1 objects. If you get a verbose listing of this dataset, you'll see something like:

Code Block
psanacs058:~/rel/TimeTool3 $ h5ls -v tt_sxrd5814_r0150.h5/Configure:0000/Run:0000/CalibCycle:0000/TimeTool::DataV1/noSrc__TTANA/data
data                     Dataset {500/Inf}
    Location:  1:8396
    Links:     1
    Chunks:    {2048} 114688 bytes
    Storage:   28000 logical bytes, 114688 allocated bytes, 24.41% utilization
    Type:      struct {
                   "event_type"       +0    enum native unsigned int {
                       Dark             = 0
                       Reference        = 1
                       Signal           = 2
                   }
                   "amplitude"        +8    native double
                   "position_pixel"   +16   native double
                   "position_time"    +24   native double
                   "position_fwhm"    +32   native double
                   "ref_amplitude"    +40   native double
                   "nxt_amplitude"    +48   native double
               } 56 bytes

This shows you the six fields with the TimeTool Data, and also the enum values for the first field that identifies the event type.

The time dataset stores the event id's for the data - the seconds, nanoseconds and fiducials.

After running the script once, the second time the script is run, it will produce
interactive plots.

 

 

...