So I've Opened A Job... Now How Do I Analyze It?

Now that you have a data set open, you may wish to write an analysis routine.  In this example I will use the new program page wizard to generate a source file.  The wizard will prompt you to specify what kind of analysis you want, and will create a source file missing only the calculations for your analysis.  Comments in the source file indicate where to insert the calculations.

You may write a source file without using the wizard.  Be aware of the guidelines for writing analysis files, which the wizard normally takes care of for you.

To open the program page wizard, select 'Program Using Wizard...' from the 'New' submenu of the 'File' menu.   On the first page, enter a name for your class.  This must be a legal java identifier (the wizard will notify you if the text you entered is not legal).   This will be used as the name for the file and for the class.  The 'Next' button will not be enabled if there is text in the class name field.  Below, select the EventAnalyzer option, which allows you to write an analysis routine.  (If you want an event generator, read the step-by-step example for event generators.)  Click on 'Next' to go to the EventAnalyzer setup page.  If there are multiple event sources open, the wizard will not go directly to the setup page, but will first take you to a page that asks you to select which event source to use.

The first line prompts you for the histograms you wish to generate.  These must be legal java identifiers separated with spaces.  The wizard will notify you of an illegal identifier.

Next, you must decide how you want to access the data.  (If you don't have a data set open, this option will not be available.)  The choice here is largely a matter of programming style.  Click on 'Show preview of selected option' to see how each style would look for your specifications.  Brief descriptions of the options follow.

When you click on 'Finish', the wizard will offer to save the file.  It is a good idea to save it now because you cannot compile it until it is saved, and Java language rules require that the file name be the same as the class name if the class is public, and the class must be public in order to be readable from the application.

In my example, I will use the first option to ananlyze these data.  I will create two histograms: 'r1' and 'r2'.  I only want to use two of the fields: 'N' and 'C'.   The setup page will look like this:
wpe162.jpg (27648 bytes)

I have chosen to call the class 'MyAnalysis', so the wizard will offer to save the file as 'MyAnalysis.java' when I click on the 'Finish' button.  You may want your file protected with timed backups.  See printing to print the page.

A new page is created with the source file in it.  I have a processEvent method that now looks like this:
public void processEvent(EventData d)
{
    N = d.getInt("N");
    C = d.getDouble("C");

    r1.fill( /* Enter calculation for this histogram here. */ );
    r2.fill( /* Enter calculation for this histogram here. */ );
}
The wizard created member variables 'N' and 'C' and added the code to set them for each event.

This file will not compile as it is because I have not supplied calculations for the histograms.  When I substitute calculations for the comments, I will have a syntactically correct source file:
public void processEvent(EventData d)
{
    N = d.getInt("N");
    C = d.getDouble("C");

    r1.fill( N * Math.random() * Math.PI );
    r2.fill( C / 6.0 );
}
Of course, these numbers are meaningless, but are used just for illustration.

Now we must compile the source file into a class file and load the class.

I click on the 'Run' button of the toolbar and show the histogram 'r1' on the plot, and below is the result of my analysis.  Now I can add functions and fitters to my heart's content.
wpe164.jpg (28659 bytes)

Return to tutorial.


Page maintained by Jonas Gifford.   Last updated 01/14/04.