6 from WMCore.Configuration
import Configuration
7 from CRABClient.UserUtilities
import getUsernameFromSiteDB
20 print (R+
"You need to provide the CMSSW python config, the samples file and the campaign, e.g Run2017, in this order."+W)
21 print (R+
"Optionally you can provide the UNITS_PER_JOB (def. 500)"+W)
35 psetname, pset_ext = os.path.splitext(PSET)
37 samplename, sample_ext = os.path.splitext(SAMPLE)
38 CAMPAIGN = ARGS[3] +
'/' + psetname
40 UNITS_PER_JOB =
int(ARGS[4])
42 if not ( os.path.isfile(PSET)
and pset_ext ==
'.py' ):
43 print (R+
"The given python config does not exist or it is not a python file"+W)
46 if not ( os.path.isfile(SAMPLE)
and sample_ext ==
'.txt' ):
47 print (R+
"The given sample list file does not exist or it is not a txt file"+W)
51 PROCESS = samplename.split(
'/')[-1]
52 MYPATH =
'/store/user/%s/' % (getUsernameFromSiteDB())
53 BASEOUTDIR = MYPATH+
'Analysis/Ntuples/' + TYPE +
'/' + CAMPAIGN
55 dataset_list =
'samples/data/' + PROCESS +
'.txt' 56 f_datasets = open(dataset_list,
'r') 57 datasets = f_datasets.readlines() 61 if __name__ ==
'__main__':
63 from CRABAPI.RawCommand
import crabCommand
64 from CRABClient.ClientExceptions
import ClientException
65 from httplib
import HTTPException
67 from Analysis.Ntuplizer.crabConfig
import crabConfig
71 config.General.workArea +=
'_' + PROCESS
72 config.General.transferLogs =
True 76 config.Data.splitting =
'LumiBased' 77 config.Data.unitsPerJob = UNITS_PER_JOB
78 config.Data.totalUnits = -1
79 config.Data.outLFNDirBase = BASEOUTDIR +
'/' 80 config.Data.useParent =
True 82 config.Data.lumiMask =
'json_rates.txt' 86 config.Data.runRange = RUN_RANGE
92 config.JobType.numCores = 4
93 config.JobType.psetName = PSET
97 for dataset
in datasets:
98 dataset=dataset.replace(
" ",
"")
101 dataset = dataset.split(
'\n')[0]
102 dataset_name = dataset.split(
'/')[1]
103 dataset_cond = dataset.split(
'/')[2]
104 dataset_tier = dataset.split(
'/')[3]
106 config.Data.inputDataset = dataset
107 config.Data.outputDatasetTag = dataset_cond
109 config.General.requestName = dataset_name
110 config.General.requestName +=
'_'+dataset_cond
112 config.General.requestName +=
'_'+RUN_RANGE
114 outtext =
"Submitting dataset " + dataset +
"..." 115 print (O+str(outtext)+W)
118 crabCommand(
'submit', config = config)
119 print (O+
"--------------------------------"+W)