forked from recotoolsbenchmarks/DelphesNtuplizer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreateManyJobs.sh
118 lines (99 loc) · 2.69 KB
/
createManyJobs.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
#!/bin/bash
###################################
# define paths
###################################
filelist="files_ttH.txt"
curDir="/afs/cern.ch/work/c/ckoraka/Delphes/DelphesNtuplizer"
#outputDir="/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/ckoraka/Delphes_1st-Step"
outputDir="/eos/cms/store/group/dpg_trigger/comm_trigger/L1Trigger/ckoraka/Delphes_1st-Step-ttH"
##################################
# cleaning & creating directories
##################################
if [[ ! -d "$outputDir" ]]
then
mkdir ${outputDir}
fi
if [[ -d "${curDir}/jobs" ]]
then
rm -rf ${curDir}/jobs
fi
if [[ ! -d "${curDir}/jobs" ]]
then
mkdir ${curDir}/jobs
fi
if [[ -d "${curDir}/jobs/err" ]]
then
rm -rf ${curDir}/jobs/err
fi
if [[ ! -d "${curDir}/jobs/err" ]]
then
mkdir ${curDir}/jobs/err
fi
if [[ -d "${curDir}/jobs/out" ]]
then
rm -rf ${curDir}/jobs/out
fi
if [[ ! -d "${curDir}/jobs/out" ]]
then
mkdir ${curDir}/jobs/out
fi
if [[ -d "${curDir}/jobs/log" ]]
then
rm -rf ${curDir}/jobs/log
fi
if [[ ! -d "${curDir}/jobs/log" ]]
then
mkdir ${curDir}/jobs/log
fi
n=1
while read line;do
# reading each line
input=$line
echo ===== Processing file $n : $input =====
################################
# create Condor job file
################################
echo ==== Creating condor job ======
jobfile=delphes_${n}.sh
condorfile=delphes_${n}.sub
echo --- creating executable file ${outputDir}/jobs/$jobfile ..
echo --- creating job ${outputDir}/jobs/$condorfile ..
cat > $jobfile <<@EOI
#!/bin/bash
source /cvmfs/cms.cern.ch/cmsset_default.sh
scp -r /afs/cern.ch/work/c/ckoraka/Delphes/DelphesNtuplizer .
cd DelphesNtuplizer/CMSSW_10_0_5/src
source set_env.sh
cd ../../delphes
rm -rf delphes.root
./DelphesCMSFWLite ../cards/CMS_PhaseII_200PU_Snowmass2021_v0.tcl delphes.root ${input}
mv delphes.root ${outputDir}/delphes_${n}.root
@EOI
echo ---created executable file---
cat > $condorfile <<@EOI
executable = $jobfile
output = out/$jobfile.out
error = err/$jobfile.err
log = log/$jobfile.log
+JobFlavour = "tomorrow"
use_x509userproxy = true
x509userproxy = $X509_USER_PROXY
should_transfer_files = YES
when_to_transfer_output = ON_EXIT
queue
@EOI
############################
#submit job
############################
echo ==== Submitting condor jobs ======
mv $jobfile ${curDir}/jobs
mv $condorfile ${curDir}/jobs
chmod ugo+rwx ${curDir}/jobs/$condorfile
chmod ugo+rwx ${curDir}/jobs/$jobfile
# Both executable & condor submission scripts must be in the same folder / cd to that folder every time if needed for proper submission
cd jobs
condor_submit $condorfile
cd ..
sleep 1s
n=$((n+1))
done < $filelist