8 from WMCore.Configuration
import Configuration
9 from CRABClient.UserUtilities
import getUsernameFromSiteDB
22 print (R+
"You need to provide the CMSSW python config, the samples file and the campaign, e.g Fall17, in this order."+W)
23 print (R+
"Optionally you can provide the max number of events (def. -1)"+W)
40 if PSET.find(
'nano') >= 0:
42 print "Producing NanoAOD ntuples..." 44 print "Producing Ntuplizer ntuples..." 47 psetname, pset_ext = os.path.splitext(PSET)
51 samplename, sample_ext = os.path.splitext(SAMPLE)
52 CAMPAIGN = ARGS[3] +
'/' + psetname
54 TOTAL_EVENTS =
int(ARGS[4])
57 if not ( os.path.isfile(PSET)
and pset_ext ==
'.py' ):
58 print (R+
"The given python config does not exist or it is not a python file"+W)
61 if not ( os.path.isfile(SAMPLE)
and sample_ext ==
'.txt' ):
62 print (R+
"The given sample list file does not exist or it is not a txt file"+W)
67 PROCESS = samplename.split(
'/')[-1]
69 MYPATH =
'/store/user/rwalsh/' 70 BASEOUTDIR = MYPATH+
'Analysis/Ntuples/' + TYPE +
'/' + CAMPAIGN
72 dataset_list =
'samples/mc/' + PROCESS +
'.txt' 73 f_datasets = open(dataset_list,
'r') 74 datasets = f_datasets.readlines() 76 import FWCore.ParameterSet.Config
as cms
78 pset = PSET.split(
'.')[0]
79 process = __import__(pset).process
84 if __name__ ==
'__main__':
86 from CRABAPI.RawCommand
import crabCommand
87 from CRABClient.ClientExceptions
import ClientException
88 from httplib
import HTTPException
90 from Analysis.Ntuplizer.crabConfig
import crabConfig
94 config.General.workArea +=
'_' + PROCESS
99 config.Data.totalUnits = TOTAL_EVENTS
100 config.Data.outLFNDirBase = BASEOUTDIR +
'/' 107 config.JobType.numCores = 4
108 config.JobType.maxMemoryMB = 10000
112 config.JobType.outputFiles = [
'nano.root']
114 for dataset
in datasets:
115 dataset=dataset.replace(
" ",
"")
116 if dataset[0] ==
'#' or dataset[0] !=
'/':
119 if len(dataset.split(
',')) > 1:
120 cross_section = dataset.split(
',')[1].split(
'\n')[0]
121 dataset = dataset.split(
',')[0]
123 dataset = dataset.split(
'\n')[0]
125 print " oioi ", dataset
126 dataset_name = dataset.split(
'/')[1]
127 dataset_cond = dataset.split(
'/')[2]
128 dataset_tier = dataset.split(
'/')[3]
131 config.Data.inputDataset = dataset
132 config.Data.outputDatasetTag = dataset_cond
134 config.General.requestName = dataset_name
142 config.JobType.psetName = PSET
145 process.MssmHbb.CrossSection = cms.double(cross_section)
146 except AttributeError:
148 psettmp = pset+
'_tmp.py' 149 f = open(psettmp,
'w')
150 f.write(process.dumpPython())
153 config.JobType.psetName = psettmp
155 outtext =
"Submitting dataset " + dataset +
"..." 156 print (O+str(outtext)+W)
159 crabCommand(
'submit', config = config)
160 print (O+
"--------------------------------"+W)