forked from eic/epic-analysis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
exeDelphes.sh
executable file
·53 lines (44 loc) · 1.2 KB
/
exeDelphes.sh
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
#!/bin/bash
# wrapper script to execute delphes
# default card
cardfile=cards/ATHENA.tcl
# delphes executable
exeDelphes=$DELPHES_HOME/DelphesHepMC3
#####################################################
# check environment
if [ -z "$DELPHES_HOME" ]; then
echo "ERROR: you must source environ.sh first"
exit 1
fi
# arguments
if [ $# -lt 1 ]; then
echo "USAGE $0 [hepmc or hepmc.gz file] [(optional)output file name] [(optional)tcl card]"
exit 1
fi
infile=$1
if [ $# -ge 2 ]; then outfile=$2
else
if grep -qE '^datagen' <<< "$infile"; then
outfile=$(echo $infile|sed 's/^datagen/datarec/'|sed 's/.hepmc.*$/.root/g')
mkdir -p $(dirname $outfile)
else
outfile=$(echo $infile|sed 's/^.*\//datarec\//g'|sed 's/.hepmc.*$/.root/g')
fi
fi
if [ $# -ge 3 ]; then cardfile=$3; fi
echo "infile = $infile"
echo "outfile = $outfile"
echo "cardfile = $cardfile"
# cleanup
if [ -f "$outfile" ]; then
echo "output root file exists...remove before continuing..."
rm -i $outfile
fi
# run delphes
if [[ $infile == *"hepmc.gz"* ]]; then
echo "hepmc file is gunzipped"
cat $infile | gunzip | $exeDelphes $cardfile $outfile
else
echo "hepmc file is not gunzipped"
$exeDelphes $cardfile $outfile $infile
fi