LCLS Online Physics Applications Outline
From 20000 ft.
This document describes a possible architecture for physics applications for the LCLS. It outlines the existing support for accelerator optics modeling in XAL and in the online SLC control system, and includes recommendations for a technology track, the process for XAL modeling, how SLC and XAL modeling can be brought together to meet the commissioning schedule, and highlights issues that will require attention. It is assumed that both the SLC modeling environment and SCP applications will be replaced by XAL based equivalents over some period.
Desktop Hardware and Filesystem
Our target desktop processors will be x86 CPUs running RedHat linux, with the GTK window system (see details). The executables may be housed on either AFS or NFS filesystems, little difference. Each user (including control room heads) additionally requires their own configuration file area - the precise configuration seen by each head may be unique therefore. This is a feature of XAL and the other desktop technologies we'll use. That configuration file area will be NFS because a long-lived executable (>25hrs - the AFS token lifetime) must be able to write to it at any time.
X11
XAL (that is JFC/Swing) and SWT/Jface applications may be used on any X11 equipped workstation (Windows PC, Solaris) with some performance degradation since JFC/Swing performs poorly over X11. These apps could be run "natively" on Windows (Swing is pure Java, which is platform independent, and any SWT components could be delivered for Windows too, but the added complexity of synchronizing filesystem resources between the Unix filesystem and the Windows filesystem probably makes this option undesirable - see questions) and redflags.
Overall User Interface
Use Case: A user (physicst or operator) types "lips" (or iscp or any other name we like) at a Linux console - a GUI based application launches. This application can launch any EPICS display (DM, dm2k etc), any XAL application, the SCP (on MCC), or any EPICS extension application like archive browser, alarm handler watchdog, stripchart, cmlog browser etc. These are launched on the correct host for that application or display. The "local" messages generated by each application appear in a console window dedicated to that application - "global" messages appear in the jcmlog browser window.
Starting Applications
See figure 1, a screenshot of representative user applications for LCLS. This shows a minimally modified Eclipse Rich Client (that is, basically Eclipse out of the box) in the Resource Perspective where the Eclipse Workspace has been configured to launch various kinds of program. A number of execution modes are represented (in-process, out-of-process, using Swing and SWT GUI frameworks, plus EPICS display technologies):
#Eclipse external launching (epics displays, archive viewer, scp etc).
#Eclipse launching external java SWT/Jface application (jcmlog)
#Eclipse launching internal java SWT/Jface (same VM) application (aida probe)
#Eclipse launching external java JFC/Swing (XAL) application (NOT SHOWN YET)
Graphical User Interface (GUI)
XAL will provide the overall lattice modeling framework, interface to device control, and one GUI framework (based on JFC/Swing). All the existing XAL applications can be provided by "lips" such, such as Scan ("Correlation Plots"), SCORE ("configs"), XIO ("z-plots"), or just the XAL root application.
Additionally lips may include applications which use non-GUI aspects of XAL but use some other GUI framework, such as matlab applications, or applications the use SWT/Jface for implementing the user interface view and controls, for instance the jcmlog browser. These are run in a sub-process of the lips executable with no resource splitting.
The distinction the user sees between these applications is relatively minor as long as they are running on linux to a local display, so window repaints are relatively fast for Swing based apps.
Additionally applications may be written which leverage the Eclipse Rich Client Platform, in which case they run in-process and in the same VM as Eclipse. A trivial example shown is the Aida probe shown in bottom left, which was started from the "Controls" menu.
Basic Model Environment: Geometry, Lattice, Optics
Model Optics refers to the process by which we get from a beamline designer's view of the accelerator (geometry and lattice), to the description of the transport system and optics (R-matrices and twiss parameters) used in online model based applications.
Use Case: Beamline physicist will provide MAD, Parmela or Elegant files 3. Some designated person will update the Oracle db with relevant information from these files, and run some process (presumably a SQL script) which outputs an XAL lattice input file in XML - the file containing the lattice description of the machine Test page. Given this input lattice file, software in the XAL package library can then be used by applications to compute optics (Twiss, R-matrices, etc), which they can then use to calculate bumps, orbit corrections, beta-match settings etc.
Systematics
For LCLS, we will pre-compute the optics from the lattice, so each modeling application doesn't have to track a lattice for itself before starting. The online modeling "tracker" will XAL 1. XAL has a number of components, one part of which (primarily the gov.sns.xal.model package) can be used to "track" a lattice description (which XAL calls "probe"), defined in an XML file. The output of this phase will be the Courant-Snyder (Twiss) parameters of each element of the beamline. A second probe can calculate the transfer matrices (R-matrices) The Twiss param outputs will be captured in a series of second XAL files. There is presently no file-handling code in XAL for statically recording the R-matrices or global parameters, so new output files will be designed for that (XAL, or some other XML).
One can track an XAL beamline in either of 2 "modes", i) "design" or ii) "from EPICS PV" - which is to say using settings for each lattice element found either in the XAL input file ("design") or by accessing the EPICS Process Variables themselves at runtime. The latter produces a model of the optics of the extant machine. We should have file management capability to store a single recognized "design" lattice file, plus a "gold" lattice#td_GW1 (the inputs "from PV" that produced good optics), plus at least one experimental lattice file. This capability to switch easily between a lattice of the extant machine and an ad-hoc lattice was badly missed in the SLC modeling environment.
The results of tracking (twiss, R-matrices, global machine params, optical component settings) for each of these beamlines for each of the choices of model (design, gold, experimental) for each source of input data (design, PV), will have to be stored. This could all be handled by careful filenaming if it's sufficient to do tracking in the initialization stage of each modeling program's startup. But if that proves too slow then we'll need to persist the outputs into the Oracle DB and programs will go to the db to get optical parameters. See figure 2.
Beamline Descriptions
The number of beamline description input files we need depends on the number of beamline geometries the LCLS will be run in (for instance, how many modeled extraction lines for experiments will there be)? It additionally depends on how many energy profiles will there be? Also high-level applications that deal with beamlines (bpm orbit displays, steering etc) will initialize displays based on the end-points of an input XAL beamline description file. So the XAL orbit correction app for instance, will always initialize to steer the whole LCLS unless a separate beamline file is written for smaller regions of interest - such as injection separately from main linac.
It seems reasonable to assume we'll need to deal with at least the injector, main linac and wiggler separately. So, we'll need some way to manage beamline sets, possibly in a similar way to SLC, where a given named "beamline" is composed of conjoined sections, and each can be tracked or used independently or conjoinedly.
Short-term Optics Modeling Environment and Applications - using SLC modeling.
XAL is intended to provide much of the code-base of new applications of the LCLS. Until the XAL modeling environment is ready for use we're going to use the SLC modeling environment to model the optics of the LCLS injection. However, this need not stop us developing and deploying XAL based modeling applications (such as emittance measurement); since XAL uses an input XML file for both lattice description and to store the Twiss parameters following tracking, and it is this combined output file which is used as input by XAL applications, we can take an input XAL beamline description file, and insert the correct Twiss parameters from a corresponding model run on SLC via AIDA. See Fig 3. The resulting output file can be used by XAL applications before the XAL model system is ready.
Non XAL unix based applications in general (eg matlab) can also be developed ahead of the XAL modeling environment using Aida to get R-matrices and Twiss parameters etc from the SLC model environment.
ARCHITECTURE
Application Framework and GUI Framework
This section outlines how components of XAL and the Eclipse RPC can be used together to produce GUI applications with responsive user interfaces on any platform.
XAL has three largely distinct components: a modeling "code" or tracking engine (package gov.sns.xal.model); a javabean-oriented device control layer (classes extending gov.sns.xal.smf.AcceleratorNode), e.g. class Magnet and class BPM; and a set of classes to implement applications in a Graphical User Interface (GUI) based on Swing (packages gov.sns.application and gov.sns.tools). For LCLS applications we will initially use all 3 of these to create new applications.
Eclipse also has 3 distinct components: Firstly it's an integrated development environment for writing programs in java and C++. More importantly for LCLS applications, it includes a sophisticated skeleton for GUI based applications (the Rich Client Platform, or RCP). Applications integrated into the RPC use SWT/Jface as the GUI framework. XAL on the other hand extends the JFC/Swing GUI framework. So, one could not use the GUI components, esp widgets, of XAL in an Eclipse RPC application. Never-the-less one can use all of the non-GUI aspects of XAL for an RPC application, just like matlab XAL programs do, and conversely one can use the SWT/jface framework to write a graphical XAL application.
Therefore, depending on the application, a programmer can choose to write a given LCLS application that uses XAL, either using JCF/Swing, in which case they will be able to use the GUI framework of XAL, or SWT/Jface.
Eclipse Plugins, Software Development and Distribution
Eclipse includes an excellent facility for developing extensions to the basic Rich Client Platform. Eclipse is itself composed of a hierarchical system of plugins. Programmers can develop plugins adding their functionality (for instance an orbit correction plugin). The plugin self-describes the precise versioning requirements it has with the plugins on which it builds. Eclipse includes a facility for distributing plugins via an update site. This provides a framework in which we can develop and distribute new code, both internally and externally with the "EPICS Office collaboration".
TOOL SUMMARY
Tool |
Function |
---|---|
x86 Linux RH, KDE/GTK-2 window system |
(Native) Desktop O/S for applications. Note, Windows is NOT listed. As described in the architecture Windows clients will go through X11 See X11. x86 and GTK-2 specification is important so performance can be tuned. |
Matlab |
Ad-hoc analysis: acquiring data through aida, jca and XAL, performing computation and implementing results. Acquire hist data through Aida. |
XAL |
1) Modelling components (tracking); 2) OO device control, 3) Application framework, 4) Existing XAL applications. |
Eclipse RPC |
Integrated application launching. Rich Client Platform (RPC) for integrated applications shared with "EPICS Office" and gumtree. |
Eclipse SWT/Jface
High performance Interactive Applications
XAL (JCA), AIDA (CORBA), JCA/CAJ
Data Interoperability. Getting and setting device data. Aida can also get history and model data to unix apps from the SLC control system.
Jcmlog, cmlog, Err
Error handling, logging and browsing. See error handling.
Cvs, make
source repository, building. Distribution by simple "install" to an AFS or mounted NFS directory. See Filesystem
Oracle
Enterprise RDB. Stores the XAL geometry, and in architecture described here also the optics. Applications acquire optics from the db rather by tracking an XAL lattice at runtime.
OC4J, Jboss, Apache jakarta
Application Server. We're making heavy use of Oracle and XML, so displays based on contents of those datasources will go through an App server (AS). Should pick one.
Java
Programming Language
Linux, Solaris
Server Hosts O/S
NFS
Production Host Filesystem? See Filesystem
AFS
Development Host Filesystem
Integrated Development Environments
Not a good idea to prescribe these for everyone. Three good open source choices for our technology stack are emacs+jdee, Netbeans (including matisse) and the Eclipse IDE. All three include CVS integration.
RED FLAGS
If we do require native execution on Windows that decision should be made clearly and early, and resources assigned to implement the common executable and configuration file distribution so that Unix and Windows running applications are in sync and see the same configuration files. Java Web Start and Eclipse update site technology may be places to find solutions.
XAL Plane Coupled modeling. The existing XAL probes for calculating R-matrices, run on either the X-plane or Y-plane and returns only a 2x2 matrix for each element. That is, it's uncoupled. This is reflected in the fact that only the Twiss parameters can be stored into an XAL file - it only contains uncoupled optics. So, if plane coupled orbit correction is important for us, we need to add at least 4x4 and probably 6x6 tracking.
XAL Modelled acceleration and solenoid. XAL does not model acceleration (required for ???) nor solenoid field (required for ???). These have to be added.
Archiver.
REQUIRED ADDITIONS TO SLC CONTROL SYSTEM
An LCLS model beamline, associated sectors and db additions in support of it, must be added.
Pulse-id acquisition by Correlation Plots. Presently broken needs to be fixed.
REQUIRED SOLUTIONS
This section lists functional components of the LCLS modeling applications architecture which for which we need to decide on a vendor:
- Numerical Analysis package, for matrix manipulation and linear algebra. Some classes of XAL extend JAMA 4, this may be sufficient.
- J2EE compliant Application Server. Application Servers include technology for accessing databases (eg oracle) and displaying information to the web. This will be useful for displaying static control data, model information and other slow control configs etc, to the web and to the Integrated Control Program. Suggest Apache Jakarta, plus PHP, Xerces, Xalan, etc.
JOB LIST
SQL script and other munging to get from Oracle db description of geometry and devices to a lattice description in an XAL input file.
The XAL tracker. An XAL application which tracks the lattice and produces a 2nd XAL file containing the twiss parameters for each device, plus other per-element parameters see Test page.
Check XAL's linear algebra support. Done: it uses JAMA -see ref.
XAL tracking. To add acceleration and solenoid elements to XAL.
Create a Skills Matrix for applications, eg, XML and associated technologies (DOM, XSL etc), Oracle and associated technologies (SQL, PHP, persistence).
QUESTIONS
verify AFS client for Windows is not workable.
find best performing Windows X11 server for JFC/Swing clients.
Is this as simple as it sounds? Will the db contain enough to emit a lattice as opposed to only the geometry - what does Mark Woodley have to do now given a MAD geometry description to convert it to a lattice suitable for Dimad?
Does XAL really not model acceleration? If not how is it useful for SNS?
Verify that XAL does not model a plane coupled system.
Does XAL offer matrix manipulation, linear algebra and fitting adequate for the LCLS? Ans: yes, uses JAMA.
How long does XAL take to parse an XAL beamline? It has to build a DOM tree, which can't be negligible. Since that is a requirement of every XAL application at initialization its an important performance bottleneck.
How many beamline descriptions should there be?
What is the canonical list of XAL physics apps?
Does LCLS need SVD based orbit minimization? Is there an orbit minimization in XAL?
R&D
Matlab
See what applications are available in Accelerator Toolkit (AT). Use of matlab for applications depends on desirability of the functionality offered, responsiveness of the application in the context of a large accelerator's operations, and importantly, ability to secure licensing with manageable cost/benefit.
Specifically: Do AT applications appear to offer support for configurations necessary in a large machine (e.g. choosing from available bpms and correctors in an orbit correction package). How does it handle errors? Are bpm statuses communicated to the user interface and graphics?
Can Matlab be used as a general purpose charting engine? This would be very much more desirable than XAL's charting if having charted the data for a plot one could easily "drop into matlab" to further analyse the data just plotted.
Filesystem and distributing software releases
Should the production executables (XAL java jar files etc) and configuration files be on AFS or NFS? Operative points in the question are that both XAL and Eclipse require that the user specify a "workspace" at startup, which defines their particular configuration. This workspace must always be writable, so AFS token expiry after 25 hrs use, can be problematic. Simplest solution is makefile "install" to a mounted NFS directory - but that directory has to be accessible by all head nodes (that is, all linux desktops running the applications).
Eclipse includes two software distribution mechanisms: first requires "pull" (the user initiates the update), 2nd is Java Web Start, which checks for updates at predefined intervals.
DETAILS
To create a high performance user interface we should lock down the desktop hardware. We can support more than one such configuration, such as x86 Windows and x86 Linux with GTK, but for high performance UIs we need to build for specific desktops, so we have to know what they will be a-priori. Eg, when building SWT/Jface apps, one has to target a gives set of desktops so the appropriate libraries can be included in the build.
ERROR HANDLING, LOGGING AND VIEWING
A programmer spends half their time handling errors, so making that as easy as possible is a productivity priority. For LCLS we will use the following technology stack:
Err. Err makes the process of rigorously handling errors easy. It allows a programmer to define an error code in a structured, recorded global way; and to use that code to issue errors and associated diagnostics from or linux, solaris, windows platforms in either java or C/C++, and issue them directly to CMLOG (or some other message logger). It includes support for exception chaining ("caused-by") and exception translation, so the end user can see what systematic thing caused their functional problem (E.g. of a error logged by Err in cmlog might be "UnableToTrackBeamlineException: LCLS ; caused by FileNotFoundException: LCLS.XML when attempting to steer LCLS".
Cmlog. cmlog is a message logger that can be used for error messages. It includes components for receiving messages to log from programs running on the network (either in hosts or IOCs), logging those errors in a database, and a viewer for browsing the logged messges.
jcmlog. jcmlog is a sophisticated error log viewer for CMLOG developed at SLAC recently for LCLS. It is in general much faster and smother than the nominal CMLOG viewer from Jlab and includes facilities for handling the particular requirements of Err (above) such as horizontal scroll for long messages.
NAMES
LIPS LCLS integrated physics system
SIPS SLAC integrated/interactive physics system
iSCP Integrated SLAC Control System
SOMA SLAC online modeling applications.
TECHNOLOGY GLOSSARY
#Oracle: The enterprise db contains static data on devices and their beamline geometry.
#XAL: Existing software which contains a lattice tracker, java bean classes for programs to deal with accelerator devices in an object oriented way, and code for building GUI applications based on Swing.
#XML (see references): A computer language for writing files containing structured data. XML is used by XAL as the language of its input model files. Data in XML is trivially transformed via XSL into other forms, such as HTML for easy display on the web, or other XML files suitable for other programs or putting into a db.
#AIDA (Accelerator Independent Data Access), a Java API to EPICS Channel Access, SLC database device data, BPM and magnet data and control, EPICS and SLC history data, SLC modeling data.
- Err - a platform and language independent (java & c++) error handling framework for creating and logging error messages.
#global message: error or warning text message typically going to some log like cmlog, and viewed by a user through a browser like cmlog browser. A global message is on generated by a front-end computer or an application that thinks it's worth telling the world about. compare to local message
#local message: a message generated by an application that is intended only for viewing by the application's user at that time. Eg "0 is not a permitted number of iterations to average bpm readings".
REFERENCES
1 http://www.sns.gov/APGroup/appProg/xal/xal.htm
2 XML, http://en.wikipedia.org/wiki/XML
3 LCLS lattice files.
4 JAMA, http://math.nist.gov/javanumerics/jama/
To do
Add gold lattice to optics flowchart diagram
add to diagram