# Presentation: 256318

## XAL at J-PARCHiroyuki Sako, G. Shen, JAEAC. K. Allen, ORNL

- Contents
- Why did we introduce XAL?
- Installing XAL
- Developing XAL
- Achievements with XAL
- Summary

## Why did we introduce XAL to J-PARC?

- All functions necessary for commissioning apps are there
- EPICS CA (with a wrapper “Channel” class)
- GUI (a template for GUI application)
- Online model
- RDB interface
- Implemented in Java
- Easy development/maintenance in OO language with IDE
- Code organization seemed clear and good. Each code is understandable.
- Close relation between model and device control
- Read a channel and set the value to the model
- Read data from the model and set it to a channel
- “Virtual Accelerator” seemed attractive
- Testing apps with simulation in CA without beam
- There are many apps which may be used in J-PARC.

## Installing XAL

- Building XAL (Linux, Windows)
- Installation of java SDK, ant, JCA/CAJ, (EPICS, PCAS)
- Building XAL had no problem. Successful in the first attempt.
- Setup
- JCA/CAJ configuration
- PCAS (for virtual accelerator)
- Development of XAL input files
- Base for all XAL tools
- Developed a RDB and an automatic generation tool input files
- XAL lattice data structure is easy to map to RDB
- Each element is located at a z-position. No need to fill drift between elements.

## ER diagram of Commissioning DB (for lattice info)

- PostgreSQL 8.1
- Beam table
- Twiss/emittance/energy
- Generation of Probe file
- Lattice data
- Geometry table (static)
- Device parameter table (many sets of data with tags)
- Different tables for each device type
- Dipole magnet
- Quad magnet
- RF
- monitor

## Lattice Data Manager

- GUI tool for lattice related tables
- Save a lattice data set with a tag and comments
- Generation of XAL and Trace3D lattice files
- Both calculated sets and corrected sets with beam are stored with different tags

## Developing XAL

- Extension and test of the online model
- Detailed comparison of the online model with TRACE3D
- Because we use also TRACE3D
- As a result, we have fixed XAL bugs
- Space charge calculations
- RF gap transfer matrix
- Finally difference from Trace3D becomes less than 1% (Thanks Chris)
- PMQ (QM with fringe field) element added
- Emittance growth effect at RF gap
- Interface for PostgreSQL
- PostgreSQL I/O class (PgsqlDatabaseAdaptor) implemented
- DB tables created with same definitions from ORACLE ones.
- It took only a few days.
- PVlogger and SCORE work

## Version control

- Short history
- May 04	First installation of XAL (got tar file from XAL web page)
- 			Updates of XAL were done by downloading tar file
- Dec 04	J-PARC version control started with CVS
- Jun 05	Updated (merged) with newest SNS code
- Aug 06	Moved to SVN (then we updated again with newest 			SNS version from SourceForge)
- Found SVN is much nicer than CVS
- Version control as a whole set of codes
- Problem: hard to synchronize our version with SNS version
- We customize our codes very much for J-PARC.
- To update our version from SNS, we compared and merged every code manually.
- Takes a week.
- Any better way?

## Issues

- No official document. Only Javadoc.
- There is no tutorial how to write a XAL application
- Merging version of each institute may be necessary in near future
- JCA or CAJ? (not XAL problem)
- JCA is stable but slow when treating many channels (more than a few hundreds)
- CAJ1.1.3 is fast, but has problems in disconnection and “caput”
- We identified bugs and fixed with Matej.
- We still use JCA but could move to the next CAJ version.

## PVlogger or SCORE?

- SCORE
- Convenient for comparison and restoring functions
- But heavy
- In J-PARC LINAC (RF/magnets/monitors), we save ~ 9K channels
- There is no periodic logging function
- In J-PARC, some groups want to take a snapshot periodically
- PVlogger
- Can take a snapshot periodically
- Also has a function to take a snapshot with comments
- Parameters can be read from applications (such as MPX)
- Connection with the model is there!
- But restore function is not there
- We added corresponding set point record entry in the DB table
- Save and Restore application (like SCORE) must be implemented
- Can we use PVloggger instead of SCORE?
- We’d like to have your suggestions

## Our achievements with XAL

- XAL applications for LINAC beam commissioning
- iTuning (RF tuning)
- BBC (Beam Based Calibration)
- Orbitcorrect (orbit correction)
- EnergyMaster (beam energy analyzer)
- SCORE (Save and Restore DB)
- PVlogger
- Reference:
- ICALEPCS2007, Oct 18(Th) 17:40
- H. Sako, et al, Beam commissioning software and database for J-PARC LINAC

## RF Tuning (iTuning)

- Tune RF amplitude and phase to get a designed energy gain by measuring time-of-flight with Fast Current Transformers

- Energy vs RF phase
- And fit to a model

- 2 of fit to a model (Parmila)
-  as a function of RF amplitude

## Beam Based Alignment (BBC)

- Change QM and steering field and measure beam positions with BPM
- Find center of QM

- MEBT1 BPM05

- Downstream BPM positions
- vs QM field at each steerer field

- Center BPM positions as a function of the slopes (left plot)

- QM field

- Slope (Q vs BPM)

- BPM

- Steering field

## Orbit Correction (orbitcorrect)

- Measured BPM positions (horizontal)
- Prediction by online simulator

- After correction, Measured positions agrees well with prediction

- After correction

- Before correction (SDTL)

## First Injection to RCS (H0 dump) 5 Oct 2007

- 1

- %

- CM

- Carbon plate
- (thermometer)

- Beam profiles measured by MWPMs

## Summary

- XAL was developed in J-PARC and successfully applied as LINAC commissioning tools
- More active collaboration sharing information is useful for development of XAL

## Acknowledgements

- We thank collaborators for successful beam commissioning of J-PARC LINAC with XAL
- Especially
- John Galambos, Chris Allen, Tom Pelaia, Paul Chu, and Andrej Shishlo

## Save and Restore DB (SCORE)

- SCORE application with PostgreSQL
- Save, Compare and Restore a set of channels
- RF, magnets, monitors (~9k channels in total).

## EnergyMaster

- Collection of information
- Beam destination
- Beam current
- RF timing
- RF on/off
- Choose a proper FCT pair and calculate energy depending on RF acceleration

- Energy evolution during
- RF tuning (PVlogger)

- Energy measurement status

## First acceleration to 181 MeV24 Jan 2007

- First acceleration to 181 MeV24 Jan 2007

- Design Energy

- Measured Energy

- 181MeV

## We thought we can use XAL apps but actually developed most of them by ourselves	- different hardware and tuning algorithms 

| Applications for commissioning | May06 @ collab. mtg. at Tsukuba
XAL apps to be used (or to be modified for J-PARC) | Oct07 (actually implemented) |
| --- | --- | --- |
| RF phase/amp tuning | PASTA | iTuning (new XAL app) |
| Transverse matching with WS | AOC | matcher (no XAL) |
| Emittance/Twiss measurements with WS | AOC, emittanceCalc.py | WS profile measurer (no XAL)
 |
| Orbit correction with steering magnets | Orbitcorrect | Orbitcorrect |
| Beam Based Alignment | find_beam_center.py | BBC (new XAL) |
| Save and Restore tools | SCORE | SCORE |

- Applications

## Some functions which may be useful (we could contribute)

- Back propagation tracker
- Starting with Twiss/emittance at downstream, calculate those at an upstream position
- Newton-Raphson method with Response matrix
- Much faster optimizing method than Simplex
- A few 10 iterations converge instead of ~ 100 with Simplex
- Proved to work in the transverse matching
- Calculate Response matrix with online model
- Applications

## Newton-Raphson method