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)
37 if PSET.find(
'nano') >= 0:
39 print "Producing NanoAOD ntuples..." 41 print "Producing Ntuplizer ntuples..." 44 psetname, pset_ext = os.path.splitext(PSET)
47 samplename, sample_ext = os.path.splitext(SAMPLE)
48 CAMPAIGN = ARGS[3] +
'/' + psetname
50 UNITS_PER_JOB =
int(ARGS[4])
53 if not ( os.path.isfile(PSET)
and pset_ext ==
'.py' ):
54 print (R+
"The given python config does not exist or it is not a python file"+W)
57 if not ( os.path.isfile(SAMPLE)
and sample_ext ==
'.txt' ):
58 print (R+
"The given sample list file does not exist or it is not a txt file"+W)
62 PROCESS = samplename.split(
'/')[-1]
63 MYPATH =
'/store/user/rwalsh/' 65 BASEOUTDIR = MYPATH+
'Analysis/Ntuples/' + TYPE +
'/' + CAMPAIGN
67 dataset_list =
'samples/data/' + PROCESS +
'.txt' 68 f_datasets = open(dataset_list,
'r') 69 datasets = f_datasets.readlines() 73 if __name__ ==
'__main__':
75 from CRABAPI.RawCommand
import crabCommand
76 from CRABClient.ClientExceptions
import ClientException
77 from httplib
import HTTPException
79 from Analysis.Ntuplizer.crabConfig
import crabConfig
83 config.General.workArea +=
'_' + PROCESS
90 config.Data.outLFNDirBase = BASEOUTDIR +
'/' 95 config.Data.runRange = RUN_RANGE
99 config.JobType.psetName = PSET
100 config.JobType.numCores = 4
101 config.JobType.maxMemoryMB = 10000
106 config.JobType.outputFiles = [
'nano.root']
108 for dataset
in datasets:
109 dataset=dataset.replace(
" ",
"")
110 if dataset[0] ==
'#':
112 dataset = dataset.split(
'\n')[0]
113 dataset_name = dataset.split(
'/')[1]
114 dataset_cond = dataset.split(
'/')[2]
115 dataset_tier = dataset.split(
'/')[3]
117 config.Data.inputDataset = dataset
118 config.Data.outputDatasetTag = dataset_cond
120 config.General.requestName = dataset_name
121 config.General.requestName +=
'_'+dataset_cond
123 config.General.requestName +=
'_'+RUN_RANGE
125 outtext =
"Submitting dataset " + dataset +
"..." 126 print (O+str(outtext)+W)
129 crabCommand(
'submit', config = config)
130 print (O+
"--------------------------------"+W)