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.
Warning, important 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.
Warning, important 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
Edit | Attach | Watch | Print version | History: r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r2 - 2010-07-10 - ChristianGrefe
 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CLIC All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2018 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback