-
Notifications
You must be signed in to change notification settings - Fork 2
/
Create_DY_cfg.sh
executable file
·230 lines (163 loc) · 7.83 KB
/
Create_DY_cfg.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
#!/bin/bash
JobsPerDataset=5
weightEvents=True #True or False
if [ "$1" == "" ]; then
echo "Please pass a dir with txt files for datasets to be processed!"
exit 1;
fi
dir=${1}
if [ ! -d "Submission_${dir}" ]
then mkdir Submission_${dir}
fi
cd $dir
for f in $(ls *.txt)
do
patTuples=$(cat $f)
txtFile=${f%%.txt*}
mH=$(../bin/getHiggsMass.exe ${txtFile} )
if [[ "$mH" == "0" ]]; then
isSignal="False"
else
isSignal="True"
fi
CrossSect=$(../bin/getCrossSection.exe ${txtFile} )
FilterEff=$(../bin/getFilterEff.exe ${txtFile} )
nEvents=$(../bin/getNEvents.exe ${txtFile} )
workDir=../Submission_${dir}
cfgSRC2=../${cfgSRC}
echo $f
nJobsPerDataset=${JobsPerDataset}
nLines=$(cat $f | wc -l)
nFilesPerJob=$( echo "scale=0;${nLines}/${nJobsPerDataset}" | bc)
nFilesLeftover=$( echo "${nLines}%${nJobsPerDataset}" | bc)
nJobsPerDataset=${JobsPerDataset}
if(( $nLines < $nJobsPerDataset)); then
nJobsPerDataset=$nLines
nFilesPerJob=1
nFilesLeftover=0
fi
if [[ "$nFilesLeftover" == "0" ]]; then
totalJobs=${nJobsPerDataset}
for(( i=0; i<${totalJobs}; i++ ));
do
counterArray[$i]=${nFilesPerJob}
done
else
let totalJobs=${nJobsPerDataset}+1
let lastJob=${nJobsPerDataset}
for(( i=0; i<${totalJobs}; i++ ));
do
if [[ "$i" == "$lastJob" ]]; then
counterArray[$i]=${nFilesLeftover}
else
counterArray[$i]=${nFilesPerJob}
fi
done
fi
tmpCounter=1
arrayCounter=0
jobCounter=0
files=""
while read line
do
if [[ "$tmpCounter" != "${counterArray[arrayCounter]}" ]]; then
files+=$line,
let tmpCounter=${tmpCounter}+1
else
files+=$line
let arrayCounter=${arrayCounter}+1
cfgFile=${txtFile}_cfg_${jobCounter}.py
let jobCounter=${jobCounter}+1
echo "import FWCore.ParameterSet.Config as cms
process = cms.Process(\"UFHZZ4LAnalysis\")
process.load(\"FWCore.MessageService.MessageLogger_cfi\")
process.MessageLogger.cerr.FwkReport.reportEvery = 10000
process.MessageLogger.categories.append('UFHZZ4LAna')
process.load(\"Configuration.StandardSequences.MagneticField_cff\")
process.Timing = cms.Service(\"Timing\",
summaryOnly = cms.untracked.bool(True)
)
process.maxEvents = cms.untracked.PSet( input = cms.untracked.int32(-1) )
myfilelist = cms.untracked.vstring()
myfilelist.extend( [
" >> ${workDir}/${cfgFile}
echo $files >> ${workDir}/${cfgFile}
echo "
]
)
process.source = cms.Source(\"PoolSource\",fileNames = myfilelist)
process.TFileService = cms.Service(\"TFileService\",
fileName = cms.string(\""${txtFile}_${jobCounter}".root\")
)
process.Ana = cms.EDAnalyzer('UFHZZ4LAna',
photonSrc = cms.untracked.InputTag(\"cleanPatPhotons\"),
electronSrc = cms.untracked.InputTag(\"cleanPatElectrons\"),
muonSrc = cms.untracked.InputTag(\"cleanPatMuons\"),
jetSrc = cms.untracked.InputTag(\"cleanPatJets\"),
metSrc = cms.untracked.InputTag(\"patMETsPF\"),
vertexSrc = cms.untracked.InputTag(\"goodOfflinePrimaryVertices\"), #or selectedVertices
isMC = cms.untracked.bool(True),
isSignal = cms.untracked.bool("$isSignal"),
mH = cms.untracked.uint32("$mH"),
CrossSection = cms.untracked.double("$CrossSect" ),
FilterEff = cms.untracked.double("$FilterEff"),
weightEvents = cms.untracked.bool("$weightEvents"),
rhoSrc = cms.untracked.InputTag(\"kt6PFJetsForIsolation\", \"rho\")
# mZ1Low = cms.untracked.double(40),
# reweightForPU = cms.untracked.bool(False)
)
process.AnaAfterHlt = cms.EDAnalyzer('UFHZZ4LAna',
photonSrc = cms.untracked.InputTag(\"cleanPatPhotons\"),
electronSrc = cms.untracked.InputTag(\"cleanPatElectrons\"),
muonSrc = cms.untracked.InputTag(\"cleanPatMuons\"),
jetSrc = cms.untracked.InputTag(\"cleanPatJets\"),
metSrc = cms.untracked.InputTag(\"patMETsPF\"),
vertexSrc = cms.untracked.InputTag(\"goodOfflinePrimaryVertices\"), #or selectedVertices
isMC = cms.untracked.bool(True),
isSignal = cms.untracked.bool("$isSignal"),
mH = cms.untracked.uint32("$mH"),
CrossSection = cms.untracked.double("$CrossSect" ),
FilterEff = cms.untracked.double("$FilterEff"),
weightEvents = cms.untracked.bool("$weightEvents"),
rhoSrc = cms.untracked.InputTag(\"kt6PFJetsForIsolation\", \"rho\")
# mZ1Low = cms.untracked.double(40),
# reweightForPU = cms.untracked.bool(False)
)
# Trigger
process.hltHighLevel = cms.EDFilter(\"HLTHighLevel\",
TriggerResultsTag = cms.InputTag(\"TriggerResults\",\"\",\"HLT\"),
HLTPaths = cms.vstring( 'HLT_Mu13_Mu8*',
'HLT_Mu17_Mu8*',
#'HLT_DoubleMu7_v*',
#'HLT_DoubleMu3_v*',
#'HLT_Ele10_LW_LR1',
#'HLT_Ele15_SW_LR1',
#'HLT_Ele15_SW_CaloEleId_L1R',
#'HLT_Ele17_SW_TightEleId_L1R_v*',
#'HLT_Ele17_SW_TighterEleIdIsol_L1R_v*',
#'HLT_Ele17_CaloIdL_CaloIsoVL_Ele8_CaloIdL_CaloIsoVL_v*',
#'HLT_Mu17_Ele8_CaloIdT_CaloIsoVL*',
'HLT_Ele17_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL_Ele8_CaloIdT_CaloIsoVL_TrkIdVL_TrkIsoVL*'
),
# provide list of HLT paths (or patterns) you want
eventSetupPathsKey = cms.string(''), # not empty => use read paths from AlCaRecoTriggerBitsRcd via this key
andOr = cms.bool(True), # how to deal with multiple triggers: True (OR) accept if ANY is true, False (AND) accept if ALL are true
throw = cms.bool(False) # throw exception on unknown path names
)
process.load('HZZAnalysis.UFHZZ4LAna.LheNup6Nup7Filter_cfi')
process.load('HZZAnalysis.UFHZZ4LAna.LHEFilterByPartonIDUP_cfi')
#process.p = cms.Path(process.Ana)
process.p = cms.Path(process.LheNup6Nup7Filter
*process.LHEFilterByPartonIDUP
*process.Ana
*process.hltHighLevel
*process.AnaAfterHlt
)
" >> ${workDir}/${cfgFile}
files=""
tmpCounter=1
fi
done < $f
jobCounter=0
done
cd ../