8 from WMCore.Configuration
import Configuration
9 from CRABClient.UserUtilities
import getUsernameFromSiteDB
22 print (R+
"You need to provide the CMSSW python config and the samples file in this order"+W)
29 CAMPAIGN =
'Trigger17/80x_triggerstudies17_summer16_flatpu28to62_userv37' 35 psetname, pset_ext = os.path.splitext(PSET)
36 samplename, sample_ext = os.path.splitext(SAMPLE)
38 if not ( os.path.isfile(PSET)
and pset_ext ==
'.py' ):
39 print (R+
"The given python config does not exist or it is not a python file"+W)
42 if not ( os.path.isfile(SAMPLE)
and sample_ext ==
'.txt' ):
43 print (R+
"The given sample list file does not exist or it is not a txt file"+W)
48 PROCESS = samplename.split(
'/')[-1]
49 MYPATH =
'/store/user/%s/' % (getUsernameFromSiteDB())
50 BASEOUTDIR = MYPATH+
'Analysis/Ntuples/' + TYPE +
'/' + CAMPAIGN
52 dataset_list =
'samples/mc/' + PROCESS +
'.txt' 53 f_datasets = open(dataset_list,
'r') 54 datasets = f_datasets.readlines() 56 import FWCore.ParameterSet.Config
as cms
58 pset = PSET.split(
'.')[0]
59 process = __import__(pset).process
63 if __name__ ==
'__main__':
65 from CRABAPI.RawCommand
import crabCommand
66 from CRABClient.ClientExceptions
import ClientException
67 from httplib
import HTTPException
69 from Analysis.Ntuplizer.crabConfig
import crabConfig
73 config.General.workArea +=
'_' + PROCESS
76 config.Data.splitting =
'FileBased' 77 config.Data.unitsPerJob = UNITS_PER_JOB
78 config.Data.totalUnits = -1
79 config.Data.outLFNDirBase = BASEOUTDIR +
'/' 85 config.JobType.numCores = 4
87 for dataset
in datasets:
88 dataset=dataset.replace(
" ",
"")
90 if len(dataset.split(
',')) > 1:
91 cross_section = dataset.split(
',')[1].split(
'\n')[0]
92 dataset = dataset.split(
',')[0]
94 dataset = dataset.split(
'\n')[0]
96 dataset_name = dataset.split(
'/')[1]
97 dataset_cond = dataset.split(
'/')[2]
98 dataset_tier = dataset.split(
'/')[3]
103 config.Data.inputDataset = dataset
104 config.Data.outputDatasetTag = dataset_cond
106 config.General.requestName = dataset_name
112 process.MssmHbbTrigger.CrossSection = cms.double(cross_section)
113 psettmp = pset+
'_tmp.py' 114 f = open(psettmp,
'w')
115 f.write(process.dumpPython())
118 config.JobType.psetName = psettmp
120 outtext =
"Submitting dataset " + dataset +
"..." 121 print (O+str(outtext)+W)
122 crabCommand(
'submit', config = config)
123 print (O+
"--------------------------------"+W)