Jpp 20.0.0-195-g190c9e876
the software that should make you happy
Loading...
Searching...
No Matches
putMechanics.sh
Go to the documentation of this file.
1#!/usr/bin/env zsh
2script=${0##*/}
3
4if [ -z $JPP_DIR ]; then
5 echo "Variable JPP_DIR undefined."
6 exit
7fi
8
9source $JPP_DIR/setenv.sh $JPP_DIR >& /dev/null
10
11set_variable WORKDIR ${TMPDIR:-/tmp}
12set_variable: DEBUG ACOUSTICS_DEBUG 2
13
14if do_usage $*; then
15 usage "$script <archive> <detector identifier> <version>"\
16 "\nAuxiliary script to add mechanical data to files of type \"positions\" (a.k.a. \"katoomba\") in archive."\
17 "\nNote that the version should exactly match; it is extended with \"+m\"."
18fi
19
20if (( $# != 3 )); then
21 fatal "Wrong number of arguments."
22fi
23
24set_variable ARCHIVE $argv[1]
25set_variable IDENTIFIER $argv[2]
26set_variable VERSION $argv[3]
27
28set_variable TYPE positions
29
30
31function clean()
32{
33 rm -f $WORKDIR/mechanics.txt >& /dev/null
34 rm -f $WORKDIR/$TYPE.root >& /dev/null
35 rm -f $WORKDIR/mechanics.root >& /dev/null
36}
37
38
39for RUN in `getLs.sh $ARCHIVE $IDENTIFIER $TYPE $VERSION`; do
40
41 clean
42
43 getFile.sh $JPP_ARCHIVE $IDENTIFIER $RUN mechanics \* $WORKDIR/mechanics >& /dev/null
44
45 if (( $? != 0)) || [[ ! -f $WORKDIR/mechanics.txt ]]; then
46 fatal "No mechanical data for detector $IDENTIFIER and run $RUN."
47 fi
48
49 getFile.sh $ARCHIVE $IDENTIFIER $RUN $TYPE $VERSION $WORKDIR/$TYPE
50
51 # check if file already contains mechanical data
52
53 if [[ -z `JPrintName -f $WORKDIR/$TYPE.root:JDetectorMechanics_t 2> /dev/null` ]]; then
54
55 putMechanics \
56 -f $WORKDIR/$TYPE.root \
57 -M $WORKDIR/mechanics.txt \
58 -o $WORKDIR/mechanics.root \
59 -d $DEBUG
60
61 RUNS=($RUN `getLs.sh $ARCHIVE $IDENTIFIER $TYPE $VERSION $RUN`)
62
63 putFile.sh $WORKDIR/mechanics.root $ARCHIVE $IDENTIFIER $RUNS[*] $TYPE ${VERSION}+m
64 else
65 notice "Mechanical data for detector $IDENTIFIER and run $RUN already available."
66 fi
67done
68
69clean