In this page:

Introduction

LCLS Data Analysis frameworks are under development. The currently supported approaches for analysis of LCLS data are:

This document attempts to explain the names and functions found in the myana code and give some working examples on how to set up your analysis software. And we try to explain the structure of the data file and how to extract useful information from your data.

In several of these examples, we fill root histograms or NTuples. For more information on root, see http://root.cern.ch.

If you have questions or requests related to this user guide, feel free to send me an email (ofte at slac.stanford.edu).

The data file format: xtc

The data recorded from the LCLS experiments are stored in xtc (eXtended Tagged Container) files. This online format consists of "datagrams", structures that have fileds like TypeId, Damage, source (Src) and extent (size). Xtc files are not indexed and does not provide random access. The data file contains only data, no metadata, so you depend on the pdsdata library (or similar) to make sense of the files. The only way to read it is using a special iterator (XtcIterator) and read the events seqencially, one shot at a time. The myana application does this loop for you, and you can customize the event() function to read out the information you want from the xtc file.

You can explore the contents of an xtc file by using the xtcreader or pyxtcreader utilities:

pslogin ~ >  xtcreader -f myxtcfile.xtc | less
pslogin ~ >  pyxtcreader  myxtcfile.xtc | less

Reading through the output, you may see sections describing the various transitions in datataking. Look for these "headings" in the text output:

A new tool to list the contents of the file:

pslogin ~ >  xtcsummary.py

lists all detector and epics information found in Configure and L1Accept (event data) sections, and lists number of events per calibration cycle. Can be helpful when putting together your myana or pyana analysis script. Example output.

You can analyze the xtc data with the offline tools, myana and pyana. You also have the option of using the hdf5 data format (hierarchical data format 5), but you will have to wait for the xtc -> hdf5 translation which may take some time. Also, there is no support for hdf5 analysis by the offline group quite yet. hdf5 will be the standard offline LCLS data format, and tools are under development for analyzing these files. More about data formats and where to find the experiment data files, see Analysis Workbook. Data Formats

The pdsdata library

See also pdsdata Reference Manual.

Myana uses the pdsdata library to access the datagrams in the xtc files, thus in this context pdsdata defines the data structure. pds = photon data system. In your analysis directory you'll find it in release/pdsdata/. The header files are in the top level directories of each package, and the implementation files are in the src directory of each package. Here's very briefly what the library contains:

package

description

ipimb

Intensity position, intensity monitor board (IPIMB)
Four diodes positioned around the beam measure scattered X-rays. Based on the output voltage from the four sensors, we can determine pulse intensity and position of the beam. Note, that the lusi package contains methods to get feature-extracted / background subtracted output from the IPIMB.

encoder

SXR SLE Info (Laser Mirror Position Encoder)

pnCCD

for the two CCD detectors used by the CAMP collaboration

acqiris

DAQ interface to the Acqiris digitizer hardware. Waveform data.

camera

General structure to read camera frames, configurations, feature extracted info

evr

EVent Receiver (event code / beam code)

opal1k

Specialized interface for Opal1000 camera. Depends on the camera package

pulnix

for Pulnix TM6740CL monochrome camera used to read out the YAG screens

control

utility for DAQ control, PV (process variable) control and monitoring

xtc

This package defines all the datagrams for the xtc file.

epics

DAQ interface to epics (process variables (PV))

bld

DAQ interface to BeamLine Data, e.g. FeeGasDetEnergy, EBeam, PhaseCavity

princeton

DAQ interface to the Princeton camera

fccd

LBNL/ANL Fast CCD monochrome camera

cspad

CXI CsPad detector

lusi

LCLS Ultrafast Science Instruments Configs for diode, ipm, pim.

app

Xtc and Epics readers

myana.cc .... an example C++ program to extract information from xtc file

This example fetches data for each event and writes it to a root histogram and stores the histogram in a root file. You may want to store your data differently, e.g. one histogram for each event, or everything in a root ntuple for further processing. Or you can write some other format that you'd like to work with (ascii file, ... ).

myana.cc - example code that makes a simple averaging histogram
main.cc - defines the functions used by myana.cc

myana_morefeatures.cc - example code that does a little more than myana.cc
examples/myana_cspad.cc - example code to read out data from the CsPad XPP detector.

The examples above are meant to show you how you can make your own code.  With different experiments using different hardware and having different goals, these examples might not apply to your particular experiment / datafile. If so, you'll need to search the main code and libraries a bit to find something more suitable. Here's a brief description of the functions of the myana.cc example and main.cc:

myana.hh and myana.cc:

This is the "user analysis module". This is where you fill in your own code to extract the information that you want from your experiment's xtc file. This module contain only the following functions:

beginjob()   // called at the beginning of an analysis job. You can for instance book histograms here.
beginrun()   // called at the beginning of a run (the analysis job might analyze several runs)
begincalib() // called for each calibration cycle
event()      // this is where you fetch, process and store information about each event (shot).
endcalib()
endrun()
endjob()

In the example, a profile histogram is booked in beginjob() and voltage vs. time is filled in each event. The profile histogram displays the average value of all events.

main.hh and main.cc

This is the main control of the analysis, but you should avoid editing this file. When all the utility functions (in main) and user functions (in myana) have been read, main() is executed and controls the flow of the analysis. For each xtc file it calls

anafile(xtcname, maxevt, skip, iDebugLevel);

which uses a special iterator to loop through all the datagrams in the file, and makes sure to execute the beginjob() and event() functions that you implemented in myana.cc.

All the functionality needed to get data from the xtc file is (or should be) defined in main.cc and in the files it includes (including the pdsdata library). You just need to call the appropriate functions from your myana.cc to extract the information you need from the file. Get an uppdated list of all the available functions by looking at main.hh (implementations are in main.cc).

More examples

Configuration and Event Data retrieval functions:

The following contains a few lines of explanation for some of the functions defined in main.
But first some general remarks:

Acquiris digitizer
int getAcqConfig(AcqDetector det, int& numChannels, int& numSamples, double& sampleInterval);

Fetches the configuration information for any of the Acquiris devices. Returns 1 if the requested detector does not exist, and 2 if it was not in use. Tells you the number of channels used for this device, the number of samples collected and the sample interval. This is typically done in the beginjob() or beginrun() functions.

int getAcqValue(AcqDetector det, int channel, double*& time, double*& voltage);
int getAcqValue(AcqDetector det, int channel, double*& time, double*& voltage, double& trigtime);

Fetches waveform data from any of the Acquiris devices. Fills your arrays with the waveform time and voltage, and optionally gives you the trigger time. This should be called from within the event() function.

In the myana.cc example, we fetch data from the AmoITof device (AMO Ion Time-of-flight).
Other Acquiris devices (see main.hh for an up-to-date list):

AMO:
   AmoIms      - ion momentum spectrometer (2 detectors, 7 channels)
   AmoGasdet   - gas detector (in the Front End Enclusure)
   AmoETof     - electron time-of-flight (5 detectors)
   AmoMbes     - magnetic bottle electron spectrometer
   AmoVmiAcq   - (Vmi = Velocity map imaging)
   AmoBpsAcq   - (Bps = Beam position screen)
   Camp        - for the CAMP experimental setup
SXR:
   SxrBeamlineAcq1
   SxrBeamlineAcq2
   SxrEndstationAcq1
   SxrEndstationAcq2
Image data

There are several getters for fetching image data from the xtc file. Depending on which camera was in use, one of these should be appropriate:

Other functions:

Several other functions are available to get information from other monitors around the experimental setup. They may or may not be of importance to your data quality...

Further analysis help

CSPad analysis page