forked from mflechl/ProductionFromNano
-
Notifications
You must be signed in to change notification settings - Fork 0
/
submitJobsMakeAndConvert2016.py
executable file
·158 lines (128 loc) · 6.04 KB
/
submitJobsMakeAndConvert2016.py
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
#!/usr/bin/env python
import os, re
import commands
import math
import urllib
from crab3 import *
from mergeROOTFiles import *
submitJobs = True
mergeJobs = not submitJobs
#########################################
#########################################
def prepareCrabCfg(dataset,
inputDBS,
crabCfgName,
eventsPerJob,
jsonFile,
storage_element,
publish_data_suffix):
workdir = publish_data_suffix
shortName = dataset.split("/")[1]
if dataset.split("/")[2].find("Run201")!=-1:
shortName += "_"+dataset.split("/")[2]
shortName = shortName.replace("-","_")
shortName = shortName.split("_")[0]+shortName.split("_")[1]+shortName.split("_")[2]
if dataset.find("PromptReco-v")!=-1:
shortName+= "_v"+dataset[dataset.find("PromptReco-v")+12:dataset.find("PromptReco-v")+13]
if dataset.find("23Sep2016-v")!=-1:
shortName+= "_v"+dataset[dataset.find("23Sep2016-v")+11:dataset.find("23Sep2016-v")+12]
if dataset.find("03Feb2017")!=-1:
patternEnd = dataset.find("/MINIAOD")
shortName+= dataset[dataset.find("03Feb2017")+9:patternEnd]
if dataset.find("ext")!=-1:
shortName+= "_"+dataset[dataset.find("ext"):dataset.find("ext")+4]
if dataset.find("part")!=-1:
shortName+= "_"+dataset[dataset.find("part"):dataset.find("part")+6]
if dataset.find("t-channel")!=-1:
shortName+= "_"+dataset[dataset.find("channel")+7:dataset.find("channel")+15]
shortName = shortName.rstrip("-")
shortName+="_"+publish_data_suffix
##Modify CRAB3 configuration
config.JobType.psetName = 'PSet.py'
isWZH = False
if dataset.split("/")[1].find("JetsToLL")!=-1 or dataset.split("/")[1].find("JetsToLNu")!=-1 or dataset.split("/")[1].find("HToTauTau")!=-1:
isWZH = True
if isWZH:
config.JobType.scriptExe = 'convertNano_recoil.py' #RECOIL
else:
config.JobType.scriptExe = 'convertNano_no-recoil.py' #No-RECOIL
config.JobType.disableAutomaticOutputCollection = True
config.JobType.outputFiles = ['HTTMT_HTauTauAnalysis.root', 'HTTTT_HTauTauAnalysis.root']
config.JobType.inputFiles = [
'NanoEventsSkeleton.C', 'NanoEventsSkeleton.h',
'HTauTauTreeFromNanoBase.C', 'HTauTauTreeFromNanoBase.h',
'HMuTauhTreeFromNano.C', 'HMuTauhTreeFromNano.h',
'HTauhTauhTreeFromNano.C', 'HTauhTauhTreeFromNano.h',
'HTTEvent.cxx', 'HTTEvent.h',
'AnalysisEnums.h', 'PropertyEnum.h', 'TriggerEnum.h', 'SelectionBitsEnum.h', 'JecUncEnum.h',
'zpt_weights_summer2016.root', 'zpt_weights_2016_BtoH.root',
'Summer16_23Sep2016V4_MC_UncertaintySources_AK4PFchs.txt'
]
config.Site.storageSite = storage_element
config.General.requestName = shortName
config.Data.inputDataset = dataset
config.Data.outLFNDirBase = "/store/user/bluj/WAWNTupleFromNanoAOD/"+publish_data_suffix+"/"
config.Data.outputDatasetTag = shortName
config.Data.inputDBS = inputDBS
#DYJets
if dataset.split("/")[2].find("Jets")!=-1:
eventsPerJob = 40000
#DY and W 3,4 Jets
if dataset.split("/")[2].find("3Jets")!=-1 or dataset.split("/")[2].find("4Jets")!=-1:
eventsPerJob = 1000
config.Data.splitting = 'EventAwareLumiBased'
config.Data.unitsPerJob = eventsPerJob
#config.Data.splitting = 'FileBased'
#config.Data.unitsPerJob = 1 #number of files per jobs
config.Data.totalUnits = -1
config.Data.lumiMask=""
if dataset.split("/")[2].find("Run201")!=-1:
command = "wget "+jsonFile
os.system(command)
config.Data.lumiMask=jsonFile.split("/")[-1]
config.JobType.psetName = 'analyzerData.py'
out = open('crabTmp.py','w')
out.write(config.pythonise_())
out.close()
os.system("crab submit -c crabTmp.py")
os.system("rm -f "+jsonFile.split("/")[-1])
#########################################
#########################################
eventsPerJob = 100000 #Wjets and DYJets hardoced in code above
#eventsPerJob = 200000#4Mu analysis
#FIXME: datasets refer to MiniAOD for now, kept as a placeholder!!!
from datasetsMoriond17 import datasets
##TEST
datasets = [
"/VBFHToTauTau_M125_13TeV_powheg_pythia8/RunIISummer16NanoAOD-PUMoriond17_05Feb2018_94X_mcRun2_asymptotic_v2-v1/NANOAODSIM"
]
###############
jsonFileReReco = "https://cms-service-dqm.web.cern.ch/cms-service-dqm/CAF/certification/Collisions16/13TeV/ReReco/Final/Cert_271036-284044_13TeV_23Sep2016ReReco_Collisions16_JSON.txt"
########################################################
if submitJobs:
for dataset in datasets:
jsonFile2016 = jsonFileReReco
prepareCrabCfg(crabCfgName="crab3.py",
dataset=dataset,
inputDBS = 'global',
#inputDBS = 'phys03',
eventsPerJob=eventsPerJob,
jsonFile=jsonFile2016,
storage_element="T2_PL_Swierk",
publish_data_suffix = "test_v4")
########################################################
########################################################
## Merge output ROOT files.
########################################################
if mergeJobs:
for dataset in datasets:
mergeDataset(dataset=dataset, publish_data_suffix = "test_v4",
outputDir="/mnt/home/mbluj/work/data/WAWNTuples/FromNano/2016/NTUPLES_16_03_2018/")
#for a in v1/*v7_SM*; do crab resubmit -d $a; doneQ
#for a in v1/*Run2016*v7_SM*; do crab report -d $a; done
#mergeJSON.py crab_SingleMuonRun2016*23*/results/processedLumis.json crab_SingleMuonRun2016H*/results/processedLumis.json > processedLumis_SingleMuon.json
#mergeJSON.py crab_TauRun2016*23*/results/processedLumis.json crab_TauRun2016H*/results/processedLumis.json > processedLumis_Tau.json
#for a in *json; do echo $a >> lumi.out; ~/.local/bin/brilcalc lumi --normtag /afs/cern.ch/user/l/lumipro/public/normtag_file/normtag_DATACERT.json -i $a; done >> lumi.out
#grep -A 5 'Summary\|Run2016' lumi.out
'''
'''