Jpp  master_rocky-37-gf0c5bc59d
the software that should make you happy
JConvertDusj.sh
Go to the documentation of this file.
1 #!/bin/zsh
2 #
3 # \author mdejong
4 #
5 script=${0##*/}
6 
7 # ------------------------------------------------------------------------------------------
8 #
9 # Auxiliary script to convert files to DUSJ format.
10 #
11 # ------------------------------------------------------------------------------------------
12 
13 if [ -z $JPP_DIR ]; then
14  echo "Variable JPP_DIR undefined."
15  exit
16 fi
17 
18 source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
19 
20 set_variable DEBUG 2
21 set_variable WORKDIR ${TMPDIR:-/tmp}/
22 
23 if do_usage $*; then
24  usage "$script <input file> <detector file> <output file> [working directory]"
25 fi
26 
27 case $# in
28  4) set_variable WORKDIR $4;&
29  3) set_variable OUTPUT_FILE $3;
30  set_variable DETECTOR $2;
31  set_variable INPUT_FILE $1;;
32  *) fatal "Wrong number of arguments."
33 esac
34 
35 if [[ ${OUTPUT_FILE##*\.} == "evt" ]]; then
36 
37  JConvertDusj \
38  -f $INPUT_FILE \
39  -a $DETECTOR \
40  -o $WORKDIR/dusj.evt \
41  -d $DEBUG
42 
43  awk '
44  /primarylepton:/ { $1="track_in:"; print $0; next }
45  /weights:/ { if (NF > 1) print $0; next }
46  /w2list:/ { if (NF > 1) print $0; next }
47  /w3list:/ { if (NF > 1) print $0; next }
48  // { print $0; next }
49  ' $WORKDIR/dusj.evt > $OUTPUT_FILE
50 
51  rm -f $WORKDIR/dusj.evt
52 
53 else
54 
55  JConvertDusj \
56  -f $INPUT_FILE \
57  -a $DETECTOR \
58  -o $OUTPUT_FILE \
59  -d $DEBUG
60 
61 fi