TWiki
>
CLIC Web
>
Detector
>
CLICSoftwareComputing
>
Software
>
SiDSoftware
>
SiDTutorials
>
LCSimDriver
(2010-07-09,
ChristianGrefe
)
(raw view)
E
dit
A
ttach
P
DF
---+ How to write an LCSim Driver A driver is something which is executed by LCSim. While LCSim is looping over an event sample it calls the existing driver(s) and allows them to access the information stored in the LCIO event. Digitization, reconstruction and analysis code is written in the form of drivers. %TOC{depth="2"}% ---++ Methods The following functions get called by the framework during the event loop. In order to execute code during certain stages of the loop process you have to overwrite the respective method. %SYNTAX{syntax="java" numbered="off" style="emacs"}% protected void process(EventHeader)%ENDSYNTAX%: This method gets called on every event. It is the core of each driver. It passes the event header of the current event which allows to access all information stored in the LCIO event. %SYNTAX{syntax="java" numbered="off" style="emacs"}% protected void startOfData()%ENDSYNTAX%: This method gets called once before the first event. %SYNTAX{syntax="java" numbered="off" style="emacs"}% protected void endOfData()%ENDSYNTAX%: This method gets called once after the last event. %SYNTAX{syntax="java" numbered="off" style="emacs"}% protected void suspend()%ENDSYNTAX%: This method gets called when the event loop is interrupted. %SYNTAX{syntax="java" numbered="off" style="emacs"}% protected void resume()%ENDSYNTAX%: This method gets called when the event loop is resumed. %SYNTAX{syntax="java" numbered="off" style="emacs"}% protected void detectorChanged(Detector)%ENDSYNTAX%: This method gets called whenever the detector changes between two events and once before the first event. It passes the new detector and should be used to querry detector information required by the driver. ---++ Example This example driver writes out the number of mc particles in each event.%BR% %TWISTY{ mode="div" showlink="Show..." hidelink="Hide" showimgleft="%ICONURLPATH{toggleopen-small}%" hideimgleft="%ICONURLPATH{toggleclose-small}%" class="twikiHelp" }% %SYNTAX{syntax="java" numbered="off" style="emacs"}% // import the required classes import java.util.List; import org.lcsim.event.EventHeader; import org.lcsim.event.MCParticle; import org.lcsim.util.Driver; // the class has to be derived from the driver class public class MyDriver extends Driver { // constructor public MyDriver() { } // overwrite the process method protected void process(EventHeader event) { // Get the list of mc particles from the event List<MCParticle> mcParticles = event.getMCParticles(); // Print out the number of mc particles System.out.println("Event " + event.getEventNumber() + " contains " + mcParticles.size() + " mc particles."); } } %ENDSYNTAX% %ENDTWISTY% ---++ Driver for XML Steering In order to use your driver from the xml steering file you have to obey some rules * The class must have a constructor which takes no arguments * Only _public_ methods without a return, which take only a single argument and start with _set_ are available from the xml steering file, i.e. _public void setMyParameter(double x)_
E
dit
|
A
ttach
|
Watch
|
P
rint version
|
H
istory
: r2
<
r1
|
B
acklinks
|
V
iew topic
|
WYSIWYG
|
M
ore topic actions
Topic revision: r2 - 2010-07-09
-
ChristianGrefe
Log In
CLIC
CLIC Web
Create New Topic
Index
Search
Changes
Notifications
Statistics
Preferences
Accelerator
Detector
Cern Search
TWiki Search
Google Search
CLIC
All webs
Copyright &© 2008-2022 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
or Ideas, requests, problems regarding TWiki? use
Discourse
or
Send feedback