Beispiel #1
0
def createCrabConfig(SampleFileInfoDict, sampleinfo,options):
    global runOnMC
    global runOnData
    global runOnGen
    # Parse user input
    from crabConfigParser import CrabConfigParser
    config = CrabConfigParser()
    if runOnData:
        (name,sample,lumi_mask,lumisPerJob) = sampleinfo
    else:
        (name,sample) = sampleinfo

    ### General section
    config.add_section('General')
    config.set( 'General', 'requestName', name )
    if options.workingArea:
        config.set( 'General', 'workArea', options.workingArea )
    if options.transferOutputs:
        config.set( 'General', 'transferOutputs', 'True')
    if options.nolog:
        config.set( 'General', 'transferLogs', 'False' )
    else:
        config.set( 'General', 'transferLogs', 'True' )

    ### JobType section
    config.add_section('JobType')
    config.set( 'JobType', 'pluginName', 'Analysis' )
    config.set( 'JobType', 'psetName', SampleFileInfoDict['pset'] )


    if options.failureLimit:
        try:
            config.set( 'JobType', 'failureLimit', "%.2f"%float(options.failureLimit) )
        except:
            log.error('No failureLimit set. failureLimit needs float')
    # add name, datasetpath, globalTag (optional) and custom Params (optional)
    # arguments starting with '-' or '--' are not allowed, because they
    # are interpreted as cmsRun options
    paramlist = ['name=%s'%name,'datasetpath=%s'%sample]
    #~ if options.globalTag:
        #~ paramlist.extend(['--psglobalTag',options.globalTag])
    paramlist.extend(['globalTag=%s'%SampleFileInfoDict['globalTag']])
    if options.pyCfgParams:
        paramlist.append(options.pyCfgParams)
    config.set( 'JobType', 'pyCfgParams', paramlist )
    if options.inputFiles:
        config.set( 'JobType', 'inputFiles', options.inputFiles )
    if options.outputFiles:
        config.set( 'JobType', 'outputFiles', options.outputFiles )
    else:
        config.set( 'JobType', 'outputFiles', [name+".pxlio"]  )
    if options.allowUndistributedCMSSW:
        config.set( 'JobType', 'allowUndistributedCMSSW', 'True' )
    if options.maxmemory:
        try:
            config.set( 'JobType', 'maxmemory', "%d"%int(options.maxmemory ) )
        except:
            log.error('Option maxmemory not used. maxmemory needs integer')
    if options.maxJobRuntimeMin:
        try:
            config.set( 'JobType', 'maxJobRuntimeMin', "%d"%int(options.maxJobRuntimeMin ) )
        except:
            log.error('Option maxJobRuntimeMin not used. maxJobRuntimeMin needs integer')
    if options.numcores:
        try:
            config.set( 'JobType', 'numcores', "%d"%int(options.numcores ) )
        except:
            log.error('Option numcores not used. numcores needs integer')



    #####This is a dirty hack to get the JEC
    #when the JEC is in the global tag remove this part!!!
    files_to_copy=['Summer15_50nsV5_DATA.db', 'Summer15_50nsV5_MC.db', 'Summer15_25nsV5_DATA.db', 'Summer15_25nsV5_DATA_Uncertainty_AK4PF.txt', 'Summer15_25nsV5_DATA_Uncertainty_AK4PFchs.txt']
    for era in files_to_copy:
        shutil.copyfile(os.path.abspath(os.environ['CMSSW_BASE']+"/src/PxlSkimmer/Skimming/data/"+era), os.path.abspath("./"+era))
    config.set( 'JobType','inputFiles', files_to_copy)
    #up to here
    #by the way if anyone finds a way to get an abs path into a cmssw python file tell me!!! ggrrr!

    ### Data section
    config.add_section('Data')
    config.set( 'Data', 'inputDataset', sample )
    config.set( 'Data', 'inputDBS', options.inputDBS)
    config.set( 'Data', 'publication', 'False' )
    config.set( 'Data','publishDBS','phys03')
    config.set( 'Data','publishDataName',name)

    if runOnData:
        config.set( 'Data', 'splitting', 'LumiBased' )
        config.set( 'Data', 'unitsPerJob', lumisPerJob )
        if ".json" in lumi_mask:
            config.set( 'Data', 'lumiMask', os.path.join(options.lumi_dir , lumi_mask) )
        else:
            config.set( 'Data', 'lumiMask', SampleFileInfoDict['DCSOnly_json'] )
            config.set( 'Data', 'runRange', lumi_mask )
    else:
        config.set( 'Data', 'splitting', 'FileBased' )
        dasHelper = dbutilscms.dasClientHelper()
        DatasetSummary = dasHelper.getDatasetSummary( sample )
        SampleFileInfoDict.update({'dasInfos':DatasetSummary})
        try:
            #~ print DatasetSummary
            filesPerJob =  int((float(options.eventsPerJob) * int(DatasetSummary['nfiles'])) /  int(DatasetSummary['nevents']) )
            if filesPerJob < 1:
                filesPerJob = 1
        except:
            log.error("events per job needs an integer")
            sys.exit(1)
        config.set( 'Data', 'splitting', 'FileBased' )
        config.set( 'Data', 'unitsPerJob', '%d'%filesPerJob)

    if options.outLFNDirBase:
        outdir = os.path.join( '/store/user/', options.user, options.outLFNDirBase )
    else:
        outdir = os.path.join( '/store/user/', options.user, options.name, SampleFileInfoDict['gitTag'], name )
    config.set( 'Data', 'outLFNDirBase', outdir )

    ## set default for now, will change later
    config.set( 'Data', 'publishDataName', SampleFileInfoDict['globalTag'] )
    if options.publish:
        config.set( 'Data', 'publication', 'True')
        # seems to be the only valid choice at the moment
        config.set( 'Data', 'publishDBS', 'phys03')

    if options.ignoreLocality:
        config.set( 'Data', 'ignoreLocality', 'True')

    ### Site section
    config.add_section('Site')
    config.set( 'Site', 'storageSite', 'T2_DE_RWTH' )

    if options.whitelist:
        whitelists = options.whitelist.split(',')
        config.set( 'Site', 'whitelist', whitelists )

    if options.blacklist:
        blacklists = options.blacklist.split(',')
        config.set( 'Site', 'blacklist', blacklists )


    ### User section
    config.add_section('User')
    config.set( 'User', 'voGroup', 'dcms' )

    return config

from crabConfigParser import CrabConfigParser

#variables to be set in previous part of script
requestName = 'ParserTestName'
workArea = '/user/pook/crab/'
#The python config file cmsRun will use as an argument
mypset = 'testpset.py'
datasetpath = '/T_tW-channel-DR_Tune4C_13TeV-CSA14-powheg-tauola/Spring14miniaod-PU20bx25_POSTLS170_V5-v1/MINIAODSIM'
unitsPerJob = 10

config = CrabConfigParser()


config.add_section('General')
config.set( 'General', 'requestName', requestName )
config.set( 'General', 'workArea', workArea )

config.add_section('JobType')
config.set( 'JobType', 'pluginName', 'Analysis' )
# For MC production with crab
# config.set( 'JobType', 'pluginName', 'PrivateMC' )
config.set( 'JobType', 'psetName', mypset )

config.add_section('Data')
config.set( 'Data', 'inputDataset', datasetpath )
config.set( 'Data', 'dbsUrl', 'global' )
config.set( 'Data', 'splitting', 'FileBased' )
config.set( 'Data', 'unitsPerJob', '%d'%unitsPerJob )
config.set( 'Data', 'publication', 'False' )
from crabConfigParser import CrabConfigParser

#variables to be set in previous part of script
requestName = 'ParserTestName'
workArea = '/user/pook/crab/'
#The python config file cmsRun will use as an argument
mypset = 'testpset.py'
datasetpath = '/T_tW-channel-DR_Tune4C_13TeV-CSA14-powheg-tauola/Spring14miniaod-PU20bx25_POSTLS170_V5-v1/MINIAODSIM'
unitsPerJob = 10

config = CrabConfigParser()

config.add_section('General')
config.set('General', 'requestName', requestName)
config.set('General', 'workArea', workArea)

config.add_section('JobType')
config.set('JobType', 'pluginName', 'Analysis')
# For MC production with crab
# config.set( 'JobType', 'pluginName', 'PrivateMC' )
config.set('JobType', 'psetName', mypset)

config.add_section('Data')
config.set('Data', 'inputDataset', datasetpath)
config.set('Data', 'dbsUrl', 'global')
config.set('Data', 'splitting', 'FileBased')
config.set('Data', 'unitsPerJob', '%d' % unitsPerJob)
config.set('Data', 'publication', 'False')

config.add_section('Site')
config.set('Site', 'storageSite', 'T2_DE_RWTH')