Versions Compared

Key

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

...

In HPS Java terminology, a Driver processes events and can read or add collection data.  A Driver can create histograms from physics data or implement a step of physics reconstruction.  Drivers are executed in order, and a Driver can have child Drivers to implement complex behavior.  A chain of Drivers is activated by the "mother of all drivers" which contains a list of the top level Drivers as children.

Driver

...

Example

Code Block
languagejava
package org.hps.users.jeremym;

import org.lcsim.event.EventHeader;
import org.lcsim.geometry.Detector;
import org.lcsim.util.Driver;

public class ExampleDriver extends Driver {

    private int value;
  
    public void process(EventHeader event) {        
    }

    protected void detectorChanged(Detector detector) {
    }
    
    protected void endOfData() {
    }

    protected void startOfData() {        
    }
 
    public void setValue(int value) {
        this.value = value;
    }
}
OrderMethodExplanation
1Driver constructorno argument constructor activated when Driver created
2Driver setters calledset methods called individually for different parameters (by JobManager)
3startOfDatadata processing has started but detector conditions not initialized yet
4detectorChangedactivates after detector conditions are initialized so Driver can perform any necessary setup
5process

called once for every event in the job

default behavior of parent class executes child drivers

6endOfData

end of data processing hook

histograms can be normalized/scaled in this method

...

The lcsim xml format can describe drivers and their parameters at runtime using an XML data description.  The Guidelines for Creating Compatible Drivers describes how to write a Driver so that it can be using in the XML steering files.

referencing a driver from xml (example snippet)
accessing event data
provide several examples with different types

Here is sample XML which calls the ExampleDriver and sets a parameter value on it.

Code Block
languagexml
themeMidnight
<lcsim xmlns:xs="http://www.w3.org/2001/XMLSchema-instance" xs:noNamespaceSchemaLocation="http://www.lcsim.org/schemas/lcsim/1.0/lcsim.xsd">       
    <execute>
        <driver name="ExampleDriver"/>
    </execute>    
    <drivers>
        <driver name="ExampleDriver" type="org.hps.users.jeremym.ExampleDriver">
            <value>1234</value>
        </driver>
    </drivers>
</lcsim>

 

reading event data
writing adding event data

writing out LCIO

...