Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Here is a table of supported parameter types.

type

array1d

array2d

expression

int

yes

yes

yes

String

yes

no

no

double

yes

yes

yes

float

yes

no

yes

boolean

yes

no

no

Hep3Vector

no

no

no

File

no

no

no

URL

no

no

no

Types with a yes in the array1d or array2d columns support arrays of those dimensions. Arrays beyond two dimensions are not supported and would need to be read in manually by user code, perhaps using a method with a File or URL argument. Types that support expression evaluation have a yes in that column.

...

type

...

array1d

...

array2d

...

expression

...

int

...

yes

...

yes

...

yes

...

String

...

yes

...

no

...

no

...

double

...

yes

...

yes

...

yes

...

float

...

yes

...

no

...

yes

...

boolean

...

yes

...

no

...

no

...

Hep3Vector

...

no

...

no

...

no

...

File

...

no

...

no

...

no

Driver Example

The easiest way to understand how the driver parameter conversion works is to study a simple example.

Here is an example Driver class.

No Format

public class MyDriver
{
    public void setX(int x);
    public void setX1(int[] x);
    public void setX2(int[][] x);
  
    public void setFile(File f);
    public void setUrl(URL url);
    public void setVector(Hep3Vector vec);
}

In a real Driver, the methods would be defined to set private variables to the argument values, but this is left out of the example for brevity.

This is the corresponding XML code in <drivers> that would set values for these parameters.

No Format

<driver name="MyDriver" type="org.lcsim.example.MyDriver">
    <x>1</x>
    <x1>1 2 3</x1>
    <x2>1 2 3; 4 5 6</x2>
    <file>/path/to/a/file.txt</file>
    <url>http://example.org/file.txt</url>
    <vector>1.0 2.0 3.0</vector>
</driver>

There are several important things to notice in this example.

By Javabeans' convention, the set methods are transformed into parameter names by removing the "set" string from the method name and making the first letter of the parameter lower case. Driver methods must begin with "set" or will not be accessible from LCSim XML.

Multi-dimensional arguments are space delimited, meaning String arguments should not have spaces. The rows in 2D arrays are separated by semicolons.

In the above example, integers are used for the 1D and 2D arrays, but other types support arrays, also. See the types table above for specifics.

...

URL

...

no

...

no

...

Expression Evaluation

Guidelines for Creating Compatible Drivers

...