#copy MC datasets file here so it can be used os.system("cp ../MCDatasets/map_MCdatasets_xs.py .") from map_MCdatasets_xs import datasetCrossSectionMap keepGoing = True nLoop = 0 max_layers = 10 lookhere = [] lookhere.append(opts.inDir) while (keepGoing): lh_buffer = [] for i in range(0, len(lookhere)): dirr = lookhere[i] ls_command = runCommand("ls " + dirr) stdout, stderr = ls_command.communicate() dataset = "" fileNames = "" for line in stdout.splitlines(): if ".root" in line: fileNames += ' "' + dirr + '/' + line + '",' + '\n' if dataset == "": lastSlash = dirr.rfind('/') for key in datasetCrossSectionMap.keys(): kkey = key.lstrip('/') if kkey.replace('/', '_') == dirr[lastSlash + 1:]: dataset = ' "' + dirr[lastSlash + 1:] + '"' break elif "log" in line: continue
import math import shlex import subprocess from aux import runCommand from optparse import OptionParser parser = OptionParser() parser.add_option( "-i", "--indir", dest="inDir", type="str", default= "/eos/cms/store/group/dpg_trigger/comm_trigger/TriggerStudiesGroup/STEAM/xulyu/menu_v4.2/HLTPhysics_PS1p5e34_new", help="DIR where the input files are located", metavar="DIR") opts, args = parser.parse_args() print 'input directory = %s' % opts.inDir outfile = open('filesInput.py', 'w') outfile.write("fileInputNames = [\n") ls_command = runCommand("ls " + opts.inDir) stdout, stderr = ls_command.communicate() for line in stdout.splitlines(): if ".root" in line: outfile.write('"' + opts.inDir + '/' + line + '",' + '\n') outfile.write(']')
dest="figures", help="Add this option for figures") opts, args = parser.parse_args() error_text = '\nError: wrong inputs\n' help_text = '\npython prepareMergeOutputsMC.py -t <lumitarget> -d <dir> -m <merging>\n -f' help_text += '(mandatory) <lumitarget> = VALUE corresponding to the target instant lumi for which you wish to calculate your rates\n' help_text += '(optional) <dir> = DIR where the output of the batch jobs are located' help_text += '\n(optional) <maps> = "nomaps" (default option, use none of the maps), "somemaps" (use all maps except those related to dataset merging), "allmaps" (use all maps, including dataset merging)\n' help_text += '\n(optional) -f : Adding this option merges the root files which are used to produce trigger-dataset and dataset-dataset correlation figures. By default root files are NOT merged\n' if opts.lumiTarget == -1: print error_text print help_text sys.exit(2) #copy MC datasets file here so it can be used os.system("cp ../MCDatasets/map_MCdatasets_xs.py .") merge_command = "python mergeOutputs.py -t %s -m %s" % (opts.lumiTarget, opts.maps) if opts.figures: merge_command += " -f" files_dir = opts.inDir ls_command = runCommand("ls " + files_dir) stdout, stderr = ls_command.communicate() for line in stdout.splitlines(): tmp_merge_command = merge_command + " -d %s/%s/Raw -w %s" % (opts.inDir, line, line) os.system(tmp_merge_command) if opts.figures: os.system("python Draw.py -d %s/%s" % (opts.inDir, line))