How to use your own Driver in LCSim XML
This tutorial will explain how to use a driver that is not in the LCSim main trunk with the XML steering file. It shows how to compile your driver, pack it in a
jar file and make it visible in LCSim.
Basics
First of all you need a driver. A tutorial on writing a driver for LCSim can be found
here.
This driver should be in the
src directory of some project directory, i.e.
~/myProject/src/myDriver.java
. If your driver is part of a
package the path could look like
~/myProject/src/myPackage/myDriver.java
.
Compiling
Now you have to compile the driver. The compiled driver should go into the
bin directory of your project, i.e.
~/myProject/bin/myPackage/myDriver.class
.

Before compiling you have to add LCSim to the classpath because your driver will be depending on LCSim.
export CLASSPATH = $CLASSPATH:/PathToLCSim/target/lcsim-*-bin.jar
Now you can compile your driver:
javac -J-Xmx256m -d ~/myProject/bin/ -sourcepath ~/myProject/src/ -classpath $CLASSPATH myPackage/myDriver
Creating a jar archive
LCSim expects your driver to be stored in a
jar archive. Go to the directory which holds the compiled code and pack everything.
cd ~/myProject/bin
jar cvf ../myProject.jar ./
Running LCSim with the driver
Before running you have to create a steering XML.

Do not forget to add your
jar to the list of jars.
<lcsim xmlns:lcsim="http://www.lcsim.org/schemas/lcsim/1.0"
xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">
<inputFiles>
<file>myEvents.slcio</file>
</inputFiles>
<control>
<numberOfEvents>-1</numberOfEvents>
</control>
<classpath>
<jar>~/myProject/myProject.jar</jar>
</classpath>
<execute>
<driver name="myDriver" />
</execute>
<drivers>
<driver name="myDriver"
type="myPackage.myDriver" />
</drivers>
</lcsim>
Run LCSim:
java -jar /pathToLCSim/target/lcsim-*-bin.jar mySteering.xml