def mergeSample(sample_directory, output_file, runmode='condor', rmunmerged=False): # submit a merging job for one sample # input arguments: # - sample_directory: directory containing root files for one sample # (the files are assumed to be one level down) # - output_file: path to the output root file # - runmode: either "condor", "qsub" or "local" # - rmunmerged: remove the unmerged sample directory cmds = [] cmds.append(mergeCommand(sample_directory, output_file)) if rmunmerged: cmds.append('rm -r {}'.format(sample_directory)) if runmode == 'local': for cmd in cmds: os.system(cmd) elif runmode == 'qsub': script_name = 'qjob_mergedTuples.sh' with open(script_name, 'w') as script: initializeJobScript(script) for cmd in cmds: script.write(cmd) submitQsubJob(script_name) elif runmode == 'condor': ct.submitCommandsAsCondorJob('cjob_mergeTuples', cmds, cmssw_version=CMSSW_VERSION)
def mergeSample( sample_directory, output_directory ): script_name = 'mergedTuples.sh' with open( script_name, 'w' ) as script: initializeJobScript( script ) #merge sample script.write( '{}\n'.format( mergeCommand( sample_directory, output_directory ) ) ) #remove unmerged directory script.write( 'rm -r {}\n'.format( sample_directory ) ) submitQsubJob( script_name )
cmds = [] for year in years: for flavour in flavours: for process in processes: # retrieve the correct samplelist samplelist = os.path.join( samplelistdirectory, 'samples_closureTest_' + process + '_' + year + '.txt') # make the command command = './fillMCClosureTest {} {} {} {} {} {} {} {}'.format( isMCFR, use_mt, process, year, flavour, sampledirectory, samplelist, istestrun) cmds.append(command) # loop over commands and submit jobs if (runmode == 'qsub' or runmode == 'local'): for cmd in cmds: script_name = 'qsub_fillMCClosureTest.sh' with open(script_name, 'w') as script: initializeJobScript(script) script.write('cd {}\n'.format(cwd)) script.write(cmd + '\n') if runmode == 'qsub': submitQsubJob(script_name) else: os.system('bash ' + script_name) elif (runmode == 'condor'): ct.submitCommandsAsCondorCluster('cjob_fillMCClosureTest', cmds, docmsenv=True, cmssw_version='CMSSW_10_2_25')
prompthist.Write() nonprompthist.Write() datahist.Write() f.Close() prefitnp = nonprompthist.Integral() ### run combine fit # make the datacard datacard = thisbin + '_datacard.txt' makedatacard(tempfilename, datacard, ftype, var, year, flavour, ptbinstr, etabinstr) # run combine script_name = datacard.replace('.txt', '.sh') impactfig = '' # empty string means no impact plot will be made with open(script_name, 'w') as script: initializeJobScript(script, cmssw_version='CMSSW_10_2_16_patch1') addcombinecommands(script, datacard, impactfig=impactfig) os.system('bash ' + script_name) resfile = datacard.replace('.txt', '_out_signalstrength_obs.txt') if fitfailed(resfile): print( '### WARNING ###: fit for this bin seems to have failed....' ) print('continuing to next bin without postfit processing.') continue ### process results (r, uperror, downerror) = readr(resfile) print('measured signal strength: {} + {} - {}'.format( r, uperror, downerror))
for leptonmva in sorted(mvadict.keys()): for flavour in sorted(mvadict[leptonmva].keys()): for wpname in sorted(mvadict[leptonmva][flavour].keys()): wpvalue = mvadict[leptonmva][flavour][wpname] # loop over samples for i in range(samplecounter): # make the command command = exe +' {} {} {} {} {} {} {} {}'.format( flavour, year, leptonmva, wpname, wpvalue, sampledirectory, samplelist, i) commands.append(command) print('added job for year "{}",'.format(year) +' lepton MVA "{}",'.format(leptonmva) +' flavour "{}",'.format(flavour) +' working point "{}" ({})'.format(wpname, wpvalue) +' sample {}/{}'.format(i+1,samplecounter)) # run local or submit using qsub if( runmode=='local' or runmode=='qsub' ): script_name = 'qjob_fillConeCorrectionFactor.sh' with open(script_name,'w') as script: initializeJobScript(script, cmssw_version='CMSSW_10_6_29') script.write('cd {}\n'.format(cwd)) script.write(command+'\n') if runmode=='qsub': submitQsubJob(script_name) elif runmode=='local': os.system('bash '+script_name) # submit using condor if runmode=='condor': ct.submitCommandsAsCondorCluster('cjob_fillConeCorrectionFactor', commands, cmssw_version=CMSSW_VERSION)