-
Notifications
You must be signed in to change notification settings - Fork 2
/
Create_GEN_cfg.sh
executable file
·171 lines (110 loc) · 3.28 KB
/
Create_GEN_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
#!/bin/bash
PUReWeight=True
if [[ "$2" == "" ]]; then
JobsPerDataset=5
else
JobsPerDataset=$2
fi
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_GEN_${dir}" ]
then mkdir Submission_GEN_${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_GEN_${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 = 1000
process.MessageLogger.categories.append('UFHZZ4LAna')
process.load(\"Configuration.StandardSequences.MagneticField_cff\")
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
process.GlobalTag.globaltag='START53_V23::All'
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,
duplicateCheckMode = cms.untracked.string('noDuplicateCheck'),
)
process.TFileService = cms.Service(\"TFileService\",
fileName = cms.string(\""${txtFile}_${jobCounter}".root\")
)
process.GENAna = cms.EDAnalyzer('UFHZZ4LGenEvents')
process.p = cms.Path(process.GENAna)
" >> ${workDir}/${cfgFile}
files=""
tmpCounter=1
fi
done < $f
jobCounter=0
done
cd ../