-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmcmsim.sh
executable file
·152 lines (123 loc) · 4.03 KB
/
mcmsim.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#!/bin/bash
function show_help() {
echo "MCM simulation script"
echo " Usage: `basename $0` [options] <inputdir>"
echo " Options:"
echo " -q <q> Specify batch queue to submit to"
echo " -l Run on local machine (useful for testing)"
echo " -o <o> Specify output directory"
echo " -m <i> Limit maximum number of jobs (=chunks) to submit to <i>"
echo " -n <i> Process <i> events per chunk, starting from <s>"
echo " -s <i> Specify start event <s>"
echo " -v <c> Specify aliroot version to use (default: dev)"
echo " -h Show this help"
}
#--------------------------------------------------------------------------------
scriptpath=`dirname $(readlink -f $0)`
[[ -f ${scriptpath}/batch.sh ]] && source ${scriptpath}/batch.sh || exit -1
farm=`farm`
alirootversion="dev"
nevents=10001
startevent=0
maxjobs=10
#queue=alice-t3_2h
queue=norun
trklconfig=real-notc
inputdir=.
while getopts "c:hlq:m:Nn:o:s:v:" OPTION
do
case $OPTION in
h) show_help
exit 0
;;
c) trklconfig=$OPTARG
;;
q) queue=$OPTARG
;;
l) queue="runlocal"
;;
m) maxjobs=$OPTARG
;;
n) nevents=$OPTARG
;;
N) queue="norun"
;;
o) outputdir=$OPTARG
;;
s) startevent=$OPTARG
;;
v) alirootversion=$OPTARG
;;
?) show_help
exit 1
;;
esac
done
shift $(($OPTIND - 1))
[[ $# > 0 ]] && inputdir=$(readlink -f $1 | sed -e 's/\/SAT//')
[[ x$outputdir == x ]] && outputdir=$inputdir
#--------------------------------------------------------------------------------
echo "#-------------------------------------------------------------------"
echo "# RunNumber: $runnr"
echo "# Queue: $queue"
echo "# MaxJobs: $maxjobs"
echo "# AliRootVersion: $alirootversion"
echo "# Input Directory: $inputdir"
echo "# Output Directory: $outputdir"
echo "# nevents: $nevents startevent: $startevent"
echo "#-------------------------------------------------------------------"
#--------------------------------------------------------------------------------
run=`printf %09d $runnr`
#sleep 2;
# count jobs already submitted
njobs=0;
jobtype=mcmsim
for file in `find $inputdir -iname "TRD.Digits.root"`; do
inpath=$(dirname $file)
outpath=$(perl -e "\$fi=\"$inpath\"; \$fi =~ s%$inputdir%$outputdir/%; print \"\$fi\";")
# if max no of jobs not yet exceeded submit the job
if [ $njobs -ge $maxjobs ]; then
break;
fi;
# skip if we don't find the data
[[ -e $inpath/galice.root ]] || continue;
[[ -e $inpath/TRD.Digits.root ]] || continue;
# skip if the job in queued or output is available
[[ -e $outpath/.queued_${jobtype} ]] && continue;
echo "inpath = $inpath"
echo "outpath = $outpath"
mkdir -p $outpath
for i in `find $inpath -name *.root`; do
#cp $inpath/$i $outpath;
ln -sf $i $outpath;
done
# copy tracklets instead of symlinking
rm -f $outpath/TRD.Tracklets.root
cp $inpath/TRD.Tracklets.root $outpath
# prepare mcmsim.C
m4 \
-D ___TRACKLET_CONFIG___=$trklconfig\
-D ___NEVENTS___=$nevents\
$scriptpath/macros/mcmsim.C.m4 > $outpath/mcmsim.C
cp *.datx $outpath/
# prepare run script
m4 \
-D ___SCRIPTPATH___=${scriptpath} \
-D ___ALIROOT_VERSION___=${alirootversion} \
-D ___WORKDIR___=${outpath} \
${scriptpath}/scripts/run${jobtype}.sh.m4 > ${outpath}/run${jobtype}.sh
chmod u+x $outpath/run${jobtype}.sh
# copy the script to setup the environment
cp ${scriptpath}/alisetup.${farm} ${outpath}/alisetup
if [ "x$queue" == "xnorun" ] ; then
echo "not executing MCM simulator"
elif [ "x$queue" == "xrunlocal" ] ; then
echo "Executing locally..."
( ${outpath}/run${jobtype}.sh > "${outpath}/${jobtype}.local.log" 2>&1 )
else
submit ${jobtype} ${outpath}/${chunk} run${jobtype}.sh ${queue}
touch $outpath/.queued_${jobtype}
fi
echo "#-------------------------------------------------------------------"
njobs=$(($njobs + 1));
done