[Feedback][Day 1][Day 2][Welcome Page]
These instructions assume that you have already successfully completed the first two tutorials in this series.
In this example we will read some generator level events and make a few simple histograms. We will show the mechanics of running an analysis in JAS first, and in the next tutorial will give a slightly more detailed explanation so that you will be able to write your own analysis jobs.
The first thing to do is to open a data file. Choose File, Open File..., and select a stdhep file (you can download some from here). Once you have opened the file you should see your file under "Record Sources" is the JAS tree, and the "Run Control" toolbar should appear.
You now have a data set open, so now we have to load some analysis code. Choose File, New, Java File. The JAS Editor should now be open, with a blank document. Copy the following program into the editor.
import hep.physics.*; import hep.lcd.util.driver.*; import hep.lcd.event.*; import java.util.*; import hep.aida.*; public class MyAnalysis extends Driver { // Called by the framework to process each event public void process(LCDEvent event) { System.out.println(event); // Loop over the MC particles ParticleVector list = event.getMCParticles(); cloud1D("nMC").fill(list.size()); Enumeration e = list.particles(); double etot = 0; while (e.hasMoreElements()) { MCParticle mc = (MCParticle) e.nextElement(); // histogram particle energy double energy = mc.getEnergy(); cloud1D("Particle Energy").fill(energy); // reject non final state particles cloud1D("Particle Status").fill(mc.getStatusCode()); if (mc.getStatusCode() != mc.FINALSTATE) continue; // reject neutral particles ParticleType type = mc.getType(); int charge = (int) type.getCharge(); cloud1D("Particle Charge").fill(charge); if (charge == 0) continue; // Some more histograms String name = type.getName(); cloud1D(name + "-Energy").fill(energy); etot += energy; } cloud1D("etot").fill(etot); } }
Now select File, Save and you will be prompted to store the file. Store the
file into a new empty directory with the name MyAnalysis.java
. (Note:
Java requires that the filename by the same as the name of the class defined in
the file. Java is also case sensitive).
You can now compile the file by selecting File, Compile. The
console at the bottom of the JAS window will show the output from your
compilation. Hopefully there were no errors. Next we need to load the analysis
routine. Choose File, Load... In the dialog type MyAnalysis
and press OK.
A new icon representing the loaded program will appear in the tree on the left of the JAS window.
Once your analysis routine is loaded you are ready to run your analysis. Choose Go from the Run menu, or press the Go button (), and your analysis job should begin. You will see the progress box in the bottom right corner of the main window indicate how far the analysis has proceeded (). If you have selected a file containing a large number of events the analysis may take a long time, in which case you can stop the analysis at any point by pressing the Stop button (). A histogram folder should now appear in the JAS tree containing all of the resulting histograms. You can double-click on any icon to display the corresponding histogram.
Java Analysis Studio supports many features for viewing and manipulating histograms, for example you can:
At this point you may well be thinking, "this is all very well, but what did all that code I had to cut and paste do, and how would I know how to change it to produce my own analysis code". All will be explained in the next tutorial.