Skip to content

Commit

Permalink
Merge branch 'development' into iss59-detChangedHook2
Browse files Browse the repository at this point in the history
  • Loading branch information
baltzell committed Oct 18, 2024
2 parents 7906a83 + 90f57f1 commit 9c58328
Show file tree
Hide file tree
Showing 78 changed files with 1,223 additions and 321 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/maven.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ defaults:
shell: bash

env:
java_version: 11
java_version: 17
java_distribution: zulu
groovy_version: 4.0.3

Expand Down
8 changes: 0 additions & 8 deletions bin/hipo-add

This file was deleted.

15 changes: 15 additions & 0 deletions bin/hipo-merge-histograms
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/env bash

. `dirname $0`/../libexec/env.sh
cmd="java -Xms1024m -cp $CLAS12DIR/lib/clas/*:$CLAS12DIR/lib/plugins/* org.jlab.groot.data.TDirectory"

if [ $# -eq 0 ]; then
echo """
hipo-merge-histograms
- merge histogram HIPO files
- to merge HIPO data files, use 'hipo-utils -merge' instead"""
$cmd | sed 's;\<hadd\>;hipo-merge-histograms;g'
exit 2
fi

$cmd $*
156 changes: 156 additions & 0 deletions bin/run-clara
Original file line number Diff line number Diff line change
@@ -0,0 +1,156 @@
#!/bin/bash -f

ulimit -u 49152 >& /dev/null
export JAVA_OPTS="${JAVA_OPTS} -XX:+IgnoreUnrecognizedVMOptions"
set -e

usage="Usage: run-clara -y YAML [-h] [-m] [-t #] [-n #] [-o DIR] [-p PREFIX] [-c CLARA_HOME] FILE..."
info='\nRequired Arguments:\n
\tFILE... (input data files)\n
\t-y YAML file\n
Options:\n
\t-o output directory (default=.)\n
\t-p output prefix (default=rec_)\n
\t-c CLARA installation (default=$CLARA_HOME)\n
\t-t number of threads (default=2)\n
\t-n number of events (default=-1)\n
\t-m merge output files (see dependencies below)\n
\t-h print this help and exit\n\n
Merging outputs (-m) requires hipo-utils and yq (https://github.com/mikefarah/yq).'

function error() {
echo -e "\n$usage\n\nERROR: $@." && exit 1
}

# Interpret command line:
threads=2
prefix=rec_
CLARA_USER_DATA=.
while getopts y:o:p:c:t:n:mh opt
do
case $opt in
y) yaml=$OPTARG ;;
o) CLARA_USER_DATA=$OPTARG ;;
p) prefix=$OPTARG ;;
c) CLARA_HOME=$OPTARG ;;
t) threads=$OPTARG && echo $threads | grep -q -E '^[0-9]+$' || error "-t must be an integer, threads" ;;
n) nevents="-e $OPTARG" && echo $nevents | grep -q -E '^-e [0-9]+$' || error "-n must be an integer, events" ;;
m) merge=1 ;;
h) echo -e "\n$usage" && echo -e $info && exit 0 ;;
esac
done
shift $((OPTIND-1))
inputs=$@

# Check configuration:
[ $# -lt 1 ] && error "Input data files are required"
[ -z ${yaml+x} ] && error "-y YAML is required"
[ -f $yaml ] && [ -r $yaml ] || error "YAML file does not exist: $yaml"
[ -z ${CLARA_HOME+x} ] && error "-c must be specified or \$CLARA_HOME set"
[ -d $CLARA_HOME ] || error "Invalid CLARA_HOME: $CLARA_HOME"
[ $threads -eq 0 ] && threads=`grep -c ^processor /proc/cpuinfo`
! [ -z ${merge+x} ] && ! command -v hipo-utils >& /dev/null && error "Merging requested, but hipo-utils is not in \$PATH"
yaml=$(cd $(dirname $yaml) && pwd)/$(basename $yaml)

# Create the environment variables and directories required by CLARA:
[ -e $CLARA_USER_DATA ] && echo "WARNING: Using existing directory: $CLARA_USER_DATA"
mkdir -p -v $CLARA_USER_DATA || error "Cannot create -o output directory: $CLARA_USER_DATA"
mkdir -p $CLARA_USER_DATA/log $CLARA_USER_DATA/config $CLARA_USER_DATA/data/output
export CLARA_USER_DATA=$(cd $CLARA_USER_DATA && pwd)
export CLARA_HOME=$(cd $CLARA_HOME && pwd)
export CLAS12DIR=$CLARA_HOME/plugins/clas12
unset CLARA_MONITOR_FE

# Generate the file for CLARA containing a list of file basenames:
rm -f $CLARA_USER_DATA/filelist.txt && touch $CLARA_USER_DATA/filelist.txt
for x in $inputs
do
test -f $x && test -r $x || error "Invalid input file: $x"
echo $(basename $x) >> $CLARA_USER_DATA/filelist.txt
test -f $CLARA_USER_DATA/$(basename $x) || ln -sf $(cd $(dirname $x) && pwd)/$(basename $x) $CLARA_USER_DATA
done
[ $(cat $CLARA_USER_DATA/filelist.txt | wc -l) -gt 0 ] || error "Found no input files"

function get_host_ip() {
if command -v ip >/dev/null 2>&1
then
ip route get 1 | awk '{print $7; exit}' && return 0
elif command -v ifconfig >/dev/null 2>&1
then
while IFS=$': \t' read -r -a line
do
if [ -z "${line%inet}" ]
then
ip=${line[${#line[1]}>4?1:2]}
[ "${ip#127.0.0.1}" ]
echo $ip && return 0
fi
done< <(LANG=C ifconfig)
fi
return 1
}
function get_dpe_port() {
local ports
ports=$(seq 7000 20 8000)
command -v shuf >/dev/null 2>&1 && ports=$(echo "$ports" | shuf)
for port in $ports
do
local ctrl_port=$((port + 2))
if ! eval "exec 6<>/dev/tcp/127.0.0.1/$ctrl_port" 2> /dev/null
then
echo $port
return 0
fi
done
return 1
}

# Finally, run CLARA:
if [ $(uname) == "Darwin" ]
then
ip=$(get_host_ip) || error "Unknown IP address"
port=$(get_dpe_port) || error "Unknown DPE port"
set -v
$CLARA_HOME/bin/j_dpe \
--host $ip --port $port \
--session recon --max-cores $threads \
--max-sockets 5120 --report 5 \
2>&1 | tee $CLARA_USER_DATA/log/dpe.log &
set +v
#echo "Sleeping 7 ......." && sleep 7
unset JAVA_OPTS
set -v
$CLARA_HOME/bin/clara-orchestrator \
-F -f ${ip}%${port}_java -s recon \
-i $CLARA_USER_DATA -o $CLARA_USER_DATA -z $prefix \
-p $threads -t $threads \
$yaml $CLARA_USER_DATA/filelist.txt
set +v
else
set -v
$CLARA_HOME/lib/clara/run-clara \
-i $CLARA_USER_DATA \
-o $CLARA_USER_DATA \
-z $prefix \
-x $CLARA_USER_DATA/log \
-t $threads \
$nevents \
-s recon \
$yaml $CLARA_USER_DATA/filelist.txt
set +v
fi

# Merge outputs:
if ! [ -z ${merge+x} ]
then
if grep -q org.jlab.jnp.grapes $yaml >& /dev/null
then
for id in $(yq .configuration.services.*.id $yaml | sort -n | uniq)
do
hipo-utils -merge -o $CLARA_USER_DATA/$prefix$id.hipo $CLARA_USER_DATA/$prefix*$id.hipo
done
else
outfiles=$(sed "s#^#$CLARA_USER_DATA/$prefix#" $CLARA_USER_DATA/filelist.txt)
hipo-utils -merge -o $CLARA_USER_DATA/$prefix.hipo $outfiles
fi
fi
4 changes: 2 additions & 2 deletions common-tools/clara-io/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jlab.clas</groupId>
<artifactId>clara-io</artifactId>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.jlab.clas</groupId>
<artifactId>clas12rec</artifactId>
<relativePath>../../parent/pom.xml</relativePath>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
</parent>

<dependencies>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import org.jlab.clara.std.services.EventWriterException;
import org.jlab.jnp.hipo4.data.Bank;
import org.jlab.jnp.hipo4.data.Event;
import org.jlab.jnp.hipo4.data.SchemaFactory;
import org.jlab.jnp.hipo4.io.HipoWriter;
import org.jlab.jnp.hipo4.io.HipoWriterSorted;
import org.jlab.jnp.utils.file.FileUtils;
Expand All @@ -25,6 +26,8 @@ public class HipoToHipoWriter extends AbstractEventWriterService<HipoWriterSorte
private static final String CONF_COMPRESSION = "compression";
private static final String CONF_SCHEMA_DIR = "schema_dir";
private static final String CONF_SCHEMA_FILTER = "schema_filter";
private static final String CONF_SCHEMA_WILDCARD = "wildcard";

private final List<Bank> schemaBankList = new ArrayList<Bank>();
private final StringSubstitutor envSubstitutor = new StringSubstitutor(System.getenv());

Expand Down Expand Up @@ -56,9 +59,19 @@ private void configure(HipoWriterSorted writer, JSONObject opts) {
schemaDir = envSubstitutor.replace(schemaDir);
System.out.printf("%s service: schema directory = %s%n", getName(), schemaDir);
}
writer.getSchemaFactory().initFromDirectory(schemaDir);

if (opts.has(CONF_SCHEMA_DIR)) {
SchemaFactory factory = new SchemaFactory();
factory.initFromDirectory(schemaDir);

if(opts.has(CONF_SCHEMA_WILDCARD)==true){
String wildcard = opts.getString("wildcard");
SchemaFactory f2 = factory.reduce(wildcard);
writer.getSchemaFactory().copy(f2);
} else {
writer.getSchemaFactory().copy(factory);
}

if (opts.has(CONF_SCHEMA_DIR)==true||opts.has(CONF_SCHEMA_WILDCARD)==true) {
boolean useFilter = opts.optBoolean(CONF_SCHEMA_FILTER, true);
System.out.printf("%s service: schema filter = %b%n", getName(), useFilter);
if(useFilter==true){
Expand All @@ -69,6 +82,10 @@ private void configure(HipoWriterSorted writer, JSONObject opts) {
}
}
}

System.out.printf("SERVICE WRITER :: [filter] %s\n",opts.has(HipoToHipoWriter.CONF_SCHEMA_FILTER));
System.out.printf("SERVICE WRITER :: [dir] %s\n",opts.has(HipoToHipoWriter.CONF_SCHEMA_DIR));
System.out.printf("SERVICE WRITER :: [wildcard] %s\n",opts.has(HipoToHipoWriter.CONF_SCHEMA_WILDCARD));
}

private Method getSchemaFilterSetter() throws NoSuchMethodException, SecurityException {
Expand Down
20 changes: 10 additions & 10 deletions common-tools/clas-analysis/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,63 +3,63 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-analysis</artifactId>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
<packaging>jar</packaging>

<parent>
<groupId>org.jlab.clas</groupId>
<artifactId>clas12rec</artifactId>
<relativePath>../../parent/pom.xml</relativePath>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
</parent>

<dependencies>
<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-utils</artifactId>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-physics</artifactId>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-io</artifactId>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-geometry</artifactId>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-jcsg</artifactId>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>swim-tools</artifactId>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-detector</artifactId>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
</dependency>

<dependency>
<groupId>org.jlab.clas</groupId>
<artifactId>clas-reco</artifactId>
<version>11.0.0-SNAPSHOT</version>
<version>11.0.3-SNAPSHOT</version>
</dependency>
</dependencies>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ private void printOrders() {
public void mergeEvents(DataEvent event, DataEvent bg1, DataEvent bg2) {

if(!event.hasBank("RUN::config") || !bg1.hasBank("RUN::config") || !bg2.hasBank("RUN::config")) {
System.out.println("Missing RUN::config bank");
return;
}

Expand Down
Loading

0 comments on commit 9c58328

Please sign in to comment.