[Feedback][Tutorial Contents][hep.lcd Home]

shoeline2[1].gif (1488 bytes)

Running Analysis outside of Java Analysis Studio

It is sometimes useful to run your analysis program outside of the Java Analysis Studio framework, as a batch job or interactively (the latter is useful for some types of debugging as well as performance analysis).

It is easy to run any of the examples in this tutorial as a standalone Java job. To do so you need to add a main method to the class that extends EventAnalyzer (or Driver). The main method has to:

  1. Create a new hep.analysis.Job(in the API reference documentation) object.
  2. Add an EventSource to the job, usually an instance of hep.lcd.io.jas.LCDEventSource (if you will be reading a .lcd file as input) or jas.jds.module.hepevt.HepEventSource (if you will be reading a StdHep file).
  3. Create an instance of your EventAnalyzer and add it to the Job.
  4. Call the Job's go method to run the analysis.

Note that although histograms can still be defined and filled in a standalone job there is currently no way to view them. This capability will be added to a future version of Java Analysis Studio.

The following example shows how to run the cluster finding as a standalone job:

import hep.analysis.*;

import hep.lcd.util.driver.*;
import hep.lcd.recon.cluster.simple.*;
import hep.lcd.io.jas.*;

final public class LCDDriver extends Driver
{ 
   public LCDDriver()
   {
      add(new SimpleClusterBuilder());
      add(new ClusterAnalyzer());
   }
   public static void main(String[] argv)
   {
      try 
      {
         Job job = new Job("LCDDriver Job");
         // Assume the command line argument is the file to read
         job.setEventSource(new LCDEventSource(argv[0]));
         job.addEventAnalyzer(new LCDDriver());
         job.go();
      }
      catch (Exception x) { x.printStackTrace(); }
   }
}

To run this routine from the command line make sure your CLASSPATH environment variable points to both the jas.jar file and the lcd.jar file and issue the command:

       java LCDDriver <data-file>