- It is advisable to use the new program page wizard for creating an analysis file or event generator file.
- You must select a name for your class, and that name must be a legal java identifier.
Create a file with that name and a '.java' extension. For example, if your analysis
routine were called 'MyAnalysis' then the file would have to be called
'MyAnalysis.java'. In that file, import hep.analysis.* and define a public class
with a public, no-argument constructor. You can create or edit this in any text
editor, or in Java Analysis Studio itself. To create a blank program page, select
'Blank Program Page' from the 'New' submenu of the 'File' menu.
- Your class must extend hep.analysis.EventAnalyzer.
- Declare member variables for each of the histograms you wish to generate and initialize
them in the constructor. If I wanted only one histogram called 'result' then my file
so far would look like this:
import hep.analysis.*;
public class MyAnalysis extends EventAnalyzer
{
private Histogram result;
public MyAnalysis()
{
result = new Histogram("result");
}
}
Histograms can be sorted into folders (class hep.analysis.HistogramFolder).
In fact, folders can be stored in other folders.
- Override the following method:
public void processEvent(EventData ed)
In this method, perform calculations on a particular event. For example, if your
result is the product of mass, energy, and pi, your method definition should be:
public void processEvent(EventData ed)
{
result.fill( Math.PI * ed.getDouble("MASS") *
ed.getDouble("ENERGY") );
}
The method processEvent will be called for each event once you tell the
program to begin executing it. Thus, your result histogram will contain one entry
for each event, and will contain values as defined in the processEvent
method.
- There are other methods you may wish to take advantage of.
public void beforeFirstEvent()
If there is anything you want to have done just before the program begins, override this
method and include in it those things you want done before the first event.
Otherwise, do not override it.
public void afterLastEvent()
Similarly, override this method if you want to do something after the analysis is
complete.
public void sendMessage(String message)
This outputs a string in the lower left corner of the application frame.
Return to tutorial.
Page maintained by Jonas Gifford.
Last updated 01/14/04.