-
Notifications
You must be signed in to change notification settings - Fork 6
/
job.sh
executable file
·97 lines (68 loc) · 2.05 KB
/
job.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
#!/bin/bash
# Exit on error
set -e
echo "### Begin of job"
ID=$1
echo "ID:" $ID
PROCESS=$2
echo "Process:" $PROCESS
FILE=$3
echo "File:" $FILE
FIRST_LETTER=$(whoami | cut -c1)
echo "FIRST_LETTER:" $FIRST_LETTER
LOCAL_PLACE=OpenData
USERNAME=$(whoami)
echo "USERNAME: " $USERNAME
EOS_HOME=/eos/user/${FIRST_LETTER}/${USERNAME}
echo "EOS home:" $EOS_HOME
OUTPUT_DIR=${EOS_HOME}/opendata_files/
echo "Output directory:" $OUTPUT_DIR
CMSSW_BASE=/afs/cern.ch/work/${FIRST_LETTER}/${USERNAME}/${LOCAL_PLACE}/CMSSW_5_3_32
echo "CMSSW base:" $CMSSW_BASE
if [[ ${FILE} == *"Run2011A"* ]]; then
CONFIG=${CMSSW_BASE}/src/workspace/TagAndProbe/configs/TagAndProbe_Data.py
else
CONFIG=${CMSSW_BASE}/src/workspace/TagAndProbe/configs/TagAndProbe_MC.py
fi
echo "CMSSW config:" $CONFIG
echo "Hostname:" `hostname`
echo "How am I?" `id`
echo "Where am I?" `pwd`
echo "What is my system?" `uname -a`
echo "### Start working"
# Trigger auto mount of EOS
ls -la $EOS_HOME
echo $EOS_HOME
# Make output directory
mkdir -p ${OUTPUT_DIR}/${PROCESS}
echo ${OUTPUT_DIR} "/" ${PROCESS}
# Setup CMSSW
THIS_DIR=$PWD
cd $CMSSW_BASE
source /cvmfs/cms.cern.ch/cmsset_default.sh
eval `scramv1 runtime -sh`
cd $THIS_DIR
echo $THIS_DIR
# Copy config file
mkdir -p configs/
CONFIG_COPY=configs/cfg_${ID}.py
#echo "config: " $CONFIG
#echo "CONFIG_COPY: " $CONFIG_COPY
echo "Starting to Copy"
cp $CONFIG $CONFIG_COPY
echo "Ending to copy...."
# Modify CMSSW config to run only a single file
sed -i -e "s,^files =,files = ['"${FILE}"'] #,g" $CONFIG_COPY
sed -i -e 's,^files.extend,#files.extend,g' $CONFIG_COPY
# Modify CMSSW config to read lumi mask from EOS
sed -i -e 's,data/Cert,'${CMSSW_BASE}'/src/workspace/TagAndProbe/data/Cert,g' $CONFIG_COPY
# Modify config to write output directly to EOS
sed -i -e 's,output.root,'${PROCESS}_${ID}.root',g' $CONFIG_COPY
# Print config
cat $CONFIG_COPY
# Run CMSSW config
cmsRun $CONFIG_COPY
# Copy output file
xrdcp -f ${PROCESS}_${ID}.root root://eosuser.cern.ch/${OUTPUT_DIR}/${PROCESS}/${PROCESS}_${ID}.root
rm ${PROCESS}_${ID}.root
echo "### End of job"