-
Notifications
You must be signed in to change notification settings - Fork 9
/
LHEtoDelphes.sh
executable file
·165 lines (132 loc) · 4.88 KB
/
LHEtoDelphes.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
153
154
155
156
157
158
159
160
161
162
163
164
165
#!/bin/bash
#################################### Wrapper submit script for Upgrade production
#Written by Alexis Kalogeropoulos - July 2014
#Adapted by Julie Hogan - summer 2016. [email protected]
source /cvmfs/cms.cern.ch/cmsset_default.sh
export SCRAM_ARCH=slc6_amd64_gcc530
startTime=`date +%s`
# Condor arguments
DIRECTORY=$1
OUTPUT=$2
FILENAME=$3
QCUT=$4
JETS=$5
PILEUP=$6
echo "Starting job on " `date`
echo "Running on " `uname -a`
echo "System release " `cat /etc/redhat-release`
# Set variables
runEvents=-1
skipEvents=0
detCard=CMS_PhaseII_${PILEUP}_v03.tcl
energy=14
DelphesVersion=tags/3.4.2pre15
nPU=`echo $detCard | cut -d '_' -f 2`
process=`echo $FILENAME | cut -d '_' -f 1-2`
phase=`echo $detCard | cut -d '_' -f 1`
configuration=`echo $detCard | cut -d '_' -f 3 | cut -d '.' -f 1`
DelphesOutput=`echo $FILENAME | cut -d '.' -f 1`_${phase}_${configuration}_${nPU}.root
metaData=`echo $DelphesOutput | sed s/root/txt/`
# make the CMSSW release, compile, and copy
scram project CMSSW_9_1_0_pre3
cd CMSSW_9_1_0_pre3/src
eval `scram runtime -sh`
cd -
echo "xrdcp source tarball and pileup file"
xrdcp -f root://cmseos.fnal.gov//store/user/snowmass/DelphesSubmissionLPCcondor/Delphes342pre15.tar . #CHECK ME!
XRDEXIT=$?
if [[ $XRDEXIT -ne 0 ]]; then
echo "exit code $XRDEXIT, failure in xrdcp of Delphes.tar"
exit $XRDEXIT
fi
tar -xf Delphes342pre15.tar
rm Delphes342pre15.tar
cd delphes
#./configure
#make -j 4
xrdcp -f root://cmseos.fnal.gov//store/user/snowmass/DelphesSubmissionLPCcondor/MinBias_100k.pileup . #CHECK ME!
XRDEXIT=$?
if [[ $XRDEXIT -ne 0 ]]; then
echo "exit code $XRDEXIT, failure in xrdcp of MinBias_100k.pileup"
exit $XRDEXIT
fi
echo "xrdcp input LHE zip"
xrdcp -f root://cmseos.fnal.gov/${DIRECTORY}/${FILENAME} .
XRDEXIT=$?
if [[ $XRDEXIT -ne 0 ]]; then
echo "exit code $XRDEXIT, failure in xrdcp of LHE file"
exit $XRDEXIT
fi
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# Run DelphesPythia8
lhefile=events.lhe
echo "Swapping weight index in LHE file ${FILENAME}, unzipping to ${lhefile}"
noweightstring="2212 2212 0.70000000000E+04 0.70000000000E+04 0 0 10042 10042 3 3"
weightstring="2212 2212 0.70000000000E+04 0.70000000000E+04 0 0 10042 10042 4 3"
#gunzip -c ${FILENAME} > ${lhefile}
cp ${FILENAME} ${lhefile}
sed -i "s/$noweightstring/$weightstring/" ${lhefile}
nEventsIn=`grep -c '<event>' ${lhefile}`
echo "=================== There are $nEventsIn events for $lhefile ============================="
rm ${FILENAME}
cp configLHE_jetmatching.cmnd hadronizer.cmnd
sed -i "s|RUNEVENTS|${nEventsIn}|g" hadronizer.cmnd
sed -i "s|SETQCUT|${QCUT}|g" hadronizer.cmnd
sed -i "s|SETMAXJETS|${JETS}|g" hadronizer.cmnd
setupTime=`date +%s`
./DelphesPythia8 cards/CMS_PhaseII/$detCard hadronizer.cmnd $DelphesOutput
if [ $? -ne 0 ]; then
exit 16
fi
rm ${lhefile}
DelphesTime=`date +%s`
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
#metadata
echo "User: " `eval whoami` > $metaData
echo "Date: " `date` >> $metaData
echo >> $metaData
echo "Process: " $process >> $metaData
echo "Pileup Conditions: " $nPU >> $metaData
echo "Phase: " $phase >> $metaData
echo "Configuration: " $configuration >> $metaData
echo "Energy: " $energy >> $metaData
echo >> $metaData
echo "Input LHE: " $FILENAME >> $metaData
echo "Input Events: " $nEventsIn >> $metaData
echo >> $metaData
echo "Delphes Output: " $DelphesOutput >> $metaData
echo "Delphes Version: " $DelphesVersion >> $metaData
echo "Detector Card: " $detCard >> $metaData
echo >> $metaData
echo "Minutes spent setting up job: " `expr $setupTime / 60 - $startTime / 60` >> $metaData
echo "Minutes spent running Delphes: " `expr $DelphesTime / 60 - $startTime / 60` >> $metaData
echo >> $metaData
echo "Pythia Card:" >> $metaData
cat hadronizer.cmnd >> $metaData
echo >> $metaData
echo "Delphes Card:" >> $metaData
cat cards/CMS_PhaseII/$detCard >> $metaData
echo >> $metaData
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
# copy output to eos
echo "xrdcp -f ${DelphesOutput} ${eosOutDir}/${DelphesOutput}"
xrdcp -f ${DelphesOutput} root://cmseos.fnal.gov/${OUTPUT}/${DelphesOutput} 2>&1
XRDEXIT=$?
if [[ $XRDEXIT -ne 0 ]]; then
echo "exit code $XRDEXIT, failure in xrdcp of ROOT"
exit $XRDEXIT
fi
xrdcp -f ${metaData} root://cmseos.fnal.gov/${OUTPUT}/metaData/${metaData} 2>&1
XRDEXIT=$?
if [[ $XRDEXIT -ne 0 ]]; then
echo "exit code $XRDEXIT, failure in xrdcp of metaData"
exit $XRDEXIT
fi
#- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
endTime=`date +%s`
echo "Time spent copying output (s): " `expr $endTime - $DelphesTime`
echo "Total runtime (m): " `expr $endTime / 60 - $startTime / 60`
echo "removing inputs from condor"
rm -f ${DelphesOutput}
rm -f ${metaData}
rm -f ../*.tar *.lhe *.gz hadronizer.cmnd MinBias_100k.pileup