-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbg_merge_bk_file.sh
More file actions
executable file
·65 lines (46 loc) · 1.27 KB
/
bg_merge_bk_file.sh
File metadata and controls
executable file
·65 lines (46 loc) · 1.27 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/bin/bash
# Returns a random background hipo file in the selected configuration
# example of command line:
# bg_merge_bk_file.sh rgk_fall2018_FTOff tor+1.00_sol-1.00 60nA_6535MeV get
# this script can be tested on cue machines
# exit codes defined in Submit documentation repo
# pelican usage:
# ls: pelican object ls osdf:///jlab-osdf/clas12/osgpool/backgroundfiles/rga_fall2018/tor+1.00_sol-1.00/40nA_10604MeV/10k/00095.hipo
configuration=$1
fields=$2
bkmerging=$3
getit=$4
pelican_path="osdf:///jlab-osdf/clas12/osgpool/"
xdir="$pelican_path/backgroundfiles/"$configuration"/"$fields"/"$bkmerging"/10k"
NFILES=$(pelican object ls $xdir | wc | awk '{print $1}')
if [[ $NFILES -eq 0 ]]; then
echo "wrong NFILES: " $NFILES " not found. exiting"
exit 221
fi
# works only if > 100 files
nzeros="00"
R=$(( $RANDOM % $NFILES + 1))
if [[ ! $? -eq 0 ]]; then
echo "bg_merge_bk_file.sh: RANDOM Number not valid: " $R
exit 223
fi
if (($R < 10))
then
nzeros="0000"
elif (($R < 100))
then
nzeros="000"
fi
bgfile="$xdir/"$nzeros$R".hipo"
if [[ ! $? -eq 0 ]]; then
echo "bg_merge_bk_file.sh: " $bgfile does not exist
exit 223
fi
echo $bgfile
if [ "$#" == 4 ]; then
if [ $getit == "get" ]; then
pelican object get "$bgfile" .
exit $?
fi
fi
exit 0