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

Compare with Current View Page History

« Previous Version 6 Next »

Working with a Sample Driver

Drivers are for processing events one-by-one and doing some work on the data. This may include performing some physics analysis or creating plots. A driver can contain additional, "child" drivers, so the complexity of the processing algorithm can be segmented into several different logical functions.

Opening the LCIO File

Start JAS3 and open the file from the LCSim Event Browser Tutorial using the File -> Open command.

You should now see the record loop commands and the name of the file displayed in the record source drop-down box.

Opening the Sample Driver

Open a sample driver by going to Help -> Examples and navigating to org.lcsim Examples. Click on Analysis101 to load the sample driver in a new window.

Compiling

Loading

Running some Events

Viewing Histograms

Explanation of Driver Code

Below is the complete text of the Analysis101 Driver, stripped of comments.

import org.lcsim.util.aida.AIDA;
import hep.physics.vec.VecOp;
import java.util.List;
import org.lcsim.event.EventHeader;
import org.lcsim.event.MCParticle;
import org.lcsim.util.Driver;

public class Analysis101 extends Driver
{
   private AIDA aida = AIDA.defaultInstance();
   
   protected void process(EventHeader event)
   {
      List<MCParticle> particles = event.get(MCParticle.class,event.MC_PARTICLES);

      aida.cloud1D("nTracks").fill(particles.size());
      
      for (MCParticle particle : particles)
      {
         aida.cloud1D("energy").fill(particle.getEnergy());
         aida.cloud1D("cosTheta").fill(VecOp.cosTheta(particle.getMomentum()));
         aida.cloud1D("phi").fill(VecOp.phi(particle.getMomentum()));
      }
   }
}

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

import org.lcsim.util.aida.AIDA;
import hep.physics.vec.VecOp;
import java.util.List;
import org.lcsim.event.EventHeader;
import org.lcsim.event.MCParticle;
import org.lcsim.util.Driver;

This includes code libraries into the Driver that are needed to do the analysis.

For instance, methods of org.lcsim.util.aida.AIDA are used to book and fill the plots.

The hep.physics.vec.VecOp package is for doing math operations on vectors.

Next is the declaration of the Driver class.

public class Analysis101 extends Driver
  • No labels