You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

A simple example of how to access the SimTrackerHits in an event.

Download the attachment for a compilable version of the following annotated code.

Explanation of the TrackerHitAccessDriver Driver Code

import java.util.List;
import org.lcsim.event.EventHeader;
import org.lcsim.event.EventHeader.LCMetaData;
import org.lcsim.event.SimTrackerHit;
import org.lcsim.geometry.IDDecoder;
import org.lcsim.util.Driver;
import org.lcsim.util.aida.AIDA;
import hep.aida.ITree;
/*
 * TrackerHitAccessDriver.java
 *
 * Created on July 31, 2005, 3:03 PM
 *
 */

/**
 *
 * @author Norman A. Graf
 */
public class TrackerHitAccessDriver extends Driver
{
    private AIDA aida = AIDA.defaultInstance();
    private ITree _tree;
 
    public TrackerHitAccessDriver()
    {
        _tree = aida.tree();
    }
    protected void process(EventHeader event)
    {
        List<List<SimTrackerHit>> simTrackerHitCollections = event.get(SimTrackerHit.class);
        for ( List<SimTrackerHit> simTrackerHits : simTrackerHitCollections )
        {
            LCMetaData meta = event.getMetaData(simTrackerHits);

            for (SimTrackerHit trackerHit : simTrackerHits)
            {
                IDDecoder decoder = meta.getIDDecoder();
                decoder.setID(trackerHit.getCellID() );
                int layer = decoder.getLayer();
                int cellId = trackerHit.getCellID();
                double[] pos = trackerHit.getPoint();
                aida.cloud2D(meta.getName()+" layer "+layer+" x vs y").fill(pos[0], pos[1]);
            }
        }
    }
}

First, as in all Java programs, there are the import statements:

import java.util.List;
import org.lcsim.event.EventHeader;
import org.lcsim.event.EventHeader.LCMetaData;
import org.lcsim.event.SimTrackerHit;
import org.lcsim.geometry.IDDecoder;
import org.lcsim.util.Driver;
import org.lcsim.util.aida.AIDA;
import hep.aida.ITree;

EventHeader provides access to the event data.
SimTrackerHit are the tracker detector hits.
LCMetaData and IDDecoder provide access to detector information encoded in the hit IDs.
Driver
The aida classes are used for histogramming.

Next is the declaration of the Driver class. A driver is a steering routine which can deal with event processing.

public class TrackerHitAccessDriver extends Driver

To be run from within JAS3, one needs a no-argument constructor.

public class TrackerHitAccessDriver extends Driver

In our case we use this to instantiate the aida tree.

Its single argument is the EventHeader of the current LCIO event. All collections in this event are accessible through the EventHeader interface.
We are interested in accessing the SimTrackerHits for the tracking detectors. We could use the method getSimTrackerHits(String name), but we choose not to in this example, since we do not, a priori, know the names of the collections in an arbitrary LCIO file.
Here is an example plot for a silicon strip barrel tracker layer:

Not too exiting, but now you know how to access tracker hits in the event.

  • No labels