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

Compare with Current View Page History

« Previous Version 22 Next »

Distribution Jar

It is assumed in the instructions below that hps-distribution-bin.jar refers to a local copy of the HPS Java distribution from the target dir with an actual version.  

For instance, after building the HPS Java project locally, my distribution jar can be found here.

cd hps-java-trunk; ls distribution/target/hps-distribution-3.6-SNAPSHOT-bin.jar

In the commands below, the version, here "3.6-SNAPSHOT", is left out for brevity, but when executing commands you need to point to an actual distribution jar you have built or downloaded.

The jar file contains all of the project's dependencies in a distribution that can be run standalone using the java command.

Running the Jar File

Assuming you have followed the instructions at Installing HPS Java, you can run the standalone jar file two ways.

Running the Default Main

Using the -jar switch from the command line will run the main from the class JobManager, which is listened in the manifest inside the jar.

java -jar ./distribution/target/hps-distribution-bin.jar [args]

Without any arguments it will print the command line options and then exit.

Running a Specified Class's Main

You can also run the main method from any class in the jar.

java -cp ./distribution/target/hps-distribution-bin.jar org.hps.evio.EvioToLcio [args]

Some XML steering files have variables that need to be resolved with command line arguments.

Steering File Variables

For instance, suppose the XML file has this variable definition.

<driver name="MyDriver" type="org.example.MyDriver">
    <someNumber>${numVar}</someNumber>
</driver>

The var would need to be resolved with a command like this.

 java -cp ./distribution/target/hps-distribution-bin.jar org.hps.evio.EvioToLcio -DnumVar=1234 [...]

All variables defined in the XML files must be resolved from the command line or an error will occur.

System Properties

The command line tools are affected by different environment settings which are set through Java system properties.

This is a table of the system properties that can affect HPS Java.

NameDescriptionValues
java.util.logging.config.fileJava logging config filedefined in logging package doc
java.util.logging.config.classJava logging config classdefined in logging package doc
hep.aida.IAnalysisFactoryAIDA backend factory class
  • hep.aida.ref.AnalysisFactory - default
  • hep.aida.jfree.AnalysisFactory - JFree backend
  • hep.aida.ref.BatchAnalysisFactory - batch mode (no plot display)
disableSvtAlignmentConstantsDisables reading of SVT alignment constants from conditions dbtrue
org.hps.conditions.connection.fileProperties file with connection settings for conditions database 
org.hps.conditions.connection.resourceResource that points to properties file with connection settings for conditions database
  • /org/hps/conditions/config/jlab_connection.prop - default connection

These values are set as system properties in Java itself.

java -DdisableSvtAlignmentConstants=true [...]

When set in this way, these values are accessible as Java system properties at runtime.

Java Arguments

The JVM accepts a number of command line arguments that alter its behavior.

In particular, you will likely want to increase the default heap space, as the default is too low for running HPS Java.

java -Xmx2g [...]

That will change the heap space to 2 gigabytes.

Also, you may want to run the JVM in server mode.

java -server [...]

The server VM has been optimized for peak operating speed rather than responsiveness.

Job Manager

The JobManager runs a series of Drivers defined in an lcsim xml file on input events from one or more LCIO files.  The job manager's is listed in the distribution jar's manifest file, making it the default program which will run when using the -jar switch.

The job manager has the following command line arguments.

[1026 $] java -jar ./hps-java-trunk/distribution/target/hps-distribution-3.6-SNAPSHOT-bin.jar
Feb 18, 2016 4:02:27 PM org.lcsim.job.JobControlManager printHelp
INFO: java org.lcsim.job.JobControlManager [options] steeringFile.xml
usage:
 -b,--batch               Run in batch mode in which plots will not be
                          shown.
 -D,--define <arg>        Define a variable with form [name]=[value]
 -d,--detector <arg>      user supplied detector name (careful!)
 -e,--event-print <arg>   Event print interval
 -h,--help                Print help and exit
 -i,--input-file <arg>    Add an LCIO input file to process
 -n,--nevents <arg>       Set the max number of events to process
 -p,--properties <arg>    Load a properties file containing variable
                          definitions
 -r,--resource            Use a steering resource rather than a file
 -R,--run <arg>           user supplied run number (careful!)
 -s,--skip <arg>          Set the number of events to skip
 -w,--rewrite <arg>       Rewrite the XML file with variables resolved
 -x,--dry-run             Perform a dry run which does not process events

This table explains all of the available options.

SwitchDescriptionNotes
-bActivates batch mode plotting so plots will not be shown when running job. 
-DAdd a variable definition that applies to the input steering file. 
-dSet the name of the detector model. 
-ePrint out an informational message every N events. 
-hPrint help and exit. 
-iAdd an LCIO input file. 
-nMaximum number of events to run in job. 
-pLoad a properties file containing steering file variable definitions. 
-rTreat the supplied steering as a classpath resource rather than a file. 
-RSet the run number to be used when initializing the conditions system. 
-sSkip N events at the beginning of the job. 
-wRewrite the XML steering file with the variables resolved. 
-xExecute in dry run mode which means actual job will not execute.Can be used to check for initialization errors.

The steering file is supplied as an extra argument rather than with a command switch.

Here is an example using many of these command line arguments.

java -jar ./hps-java-trunk/distribution/target/hps-distribution-bin.jar -b -DoutputFile=output -d HPS-EngRun2015-Nominal-v3 -e 100 -i input.slcio -n 1000 -p myvars.prop -r -R 5772 -s 10 -w myjob.xml -x /org/hps/steering/dummy.lcsim

This will not actually work (just provided to show all command line options at once).

EvioToLcio

Run Scripts

Using your own steering file

All instructions given here assume you're using the steering files included with the release. If you write your own, you can point hps-java to it by omitting the "-r" and using the file path of your .lcsim file:

java -jar hps-distribution.jar -i recon.slcio my_steering_files/MyAnalysis.lcsim -DoutputFile=analysis_plots

The standard steering files are in trunk/steering-files/src/main/resources/org/hps/steering/.

Logging and Debugging

Logging Config

HPS Java uses the built-in logging facilities of Java described in the logging package documentation.

Every package in HPS Java has a default level which is set in the following config file.

hps-java-trunk/logging/src/main/resources/org/hps/logging/config/logging.properties

This config, or any other custom logging config file, can be activated from the command line by setting the config file property to its path.

cd hps-java-trunk; java -Djava.util.logging.config.file=logging/src/main/resources/org/hps/logging/config/logging.properties

Each logger is configured for an entire package rather than individual classes.

# evio
org.hps.evio.level = CONFIG

In this config, any class in the org.hps.evio package will have a log level of CONFIG.

Log Levels

These are the available log levels, in descending order.

LevelDescriptionUse
SEVEREsevere error message usually meaning program should haltunrecoverable errors that halt the program
WARNINGwarning message indicating a non-fatal error or problemwarning messages
INFOinformational messagesinformational messages that should usually print when the program runs
CONFIGconfiguration messagesprinting out config information for a class or tool
FINEdebug print outshigh level debugging messages that should not typically be active
FINERmore verbose debug print outsmore verbose debugging messages
FINESTmost verbose debug messagesthe most verbose debugging messages
ALLprint all error messageswhen logger should always print all messages
OFFdisable all messageswhen logger should be completely disabled from printing

Each logger inherits by default from the global log setting.

This is defined in the config file as follows.

# default global level
.level = WARNING

So if a package is not explicitly configured, it will inherit the WARNING log level from the global logger.

Defining Loggers

A logger should typically be defined as follows in an HPS Java class.

package org.example;
 
import java.util.logging.Logger;
 
class MyClass {
 
    static private final Logger LOGGER = Logger.getLogger(MyClass.class.getPackage().getName());
 
    void someMethod() {
        LOGGER.info("some method was called");
    }
}

The class uses a package rather than class logger.

The handler and the level should not be assigned in the code, as this will instead be configured in the logging config file.

  • No labels