Page History
...
- pyxface_evr_bykick.py
- pyxface_calib_db_ref.py
- control_logic.py
The python interface contains extensive documentation in its docstrings. To access this, from a ipython session, do
...
This is an unsual use case. It happens when users are using EPICSs to move things around to drop the beam, rather than using an event code. In this case , or perhaps they decide that cutting on a Bld parameter will tell them if the laser and beam are interacting or not. But in these cases the user will want to look at the EPICS variables, Bld, or other things, and instruct the TimeTool of when the beam is off so that it can build up its reference.
To do this, do the following:
- set controlLogic=True in
...
- AnalyzeOptions
- call the controlLogic(evt, beamOn, laserOn) function for every event that you will have the TimeTool process.
When controlLogic is true, you must call this function for each event you subsequently call process on (if you forget, TimeTool will stop with an error or crash).
Below is a complete example. For the most up to date example, look in the ana-current/TimeTool/examples directory specified above.
Code Block | ||
---|---|---|
| ||
import sys
import os
import psana
import TimeTool
from mpi4py import MPI
rank = MPI.COMM_WORLD.Get_rank()
worldsize = MPI.COMM_WORLD.Get_size()
numevents=50
ttOptions = TimeTool.AnalyzeOptions(
get_key='TSS_OPAL',
controlLogic=True, ## KEY STEP
calib_poly='0 1 0',
sig_roi_x='0 1023',
sig_roi_y='425 724',
ref_avg_fraction=0.5)
ttAnalyze = TimeTool.PyAnalyze(ttOptions)
ds = psana.DataSource('exp=sxri0214:run=158', module=ttAnalyze)
for idx, evt in enumerate(ds.events()):
if (numevents > 0) and (idx >= numevents): break
## when idx is even, we'll call it a reference shot (laser on, but beam off)
## and when idx is odd, we'll call it a good shot (both laser and beam on)
## however this is where users will insert their own logic based on epics or bld
if idx % 2 == 0:
laserOn=True
beamOn=False
elif idx % 2 == 1:
laserOn=True
beamOn=True
ttAnalyze.controlLogic(evt, laserOn, beamOn) ## KEY STEP - call before any call to process
if ttAnalyze.isRefShot(evt):
print "rank=%3d event %d is ref shot" % (rank, idx)
ttAnalyze.process(evt)
if idx % worldsize != rank:
continue
ttdata = ttAnalyze.process(evt)
if ttdata is None: continue
print "rank=%3d event %4d has TimeTool results. Peak is at pixel_position=%6.1f with amplitude=%7.5f nxt_amplitude=%7.5f fwhm=%5.1f" % \
(rank, idx, ttdata.position_pixel(), ttdata.amplitude(), ttdata.nxt_amplitude(), ttdata.position_fwhm())
|
AnalyzeOptions
Specify configuration options for the TimeTool Analyze module.
...