def miniNTuplise(sample): print("Executing command:\n{0}".format(sample)) subprocess.call(sample, shell=True) # Move output file(s) from job directory to the proper one, # but first, change the file name to be readable in KG's FW! knownDSID = False # Get output directory name from the executed command string outdir = sample[sample.find("--submitDir") + len("--submitDir") + 1:sample.find("--nevents") - 1] for s in sampledict: if outdir == s["ID"] or (outdir == "Data" and not s["ID"]): knownDSID = True outputfilepath = outdir + "/data-output" separator = "." if not s["ID"]: separator = "" INTREE = outputfilepath + "/" + outdir + ".root" INHIST = outdir + "/hist-" + outdir + ".root" if (outdir == "Data"): INTREE = outputfilepath + "/list-local-HTopGroupNTup.root" INHIST = outdir + "/hist-list-local-HTopGroupNTup.root" OUTTREE = motherdir + "/" + s["group"] + "/" + s[ "ID"] + separator + s["name"] + ".root" OUTHIST = motherdir + "/" + s["group"] + "/hist-" + s[ "ID"] + separator + s["name"] + ".root" print("Moving :\n{0}\nto:\n{1}".format(INTREE, OUTTREE)) print("Moving :\n{0}\nto:\n{1}".format(INHIST, OUTHIST)) shutil.move(INTREE, OUTTREE) shutil.move(INHIST, OUTHIST) normaliseTrees.applyWeight(OUTTREE, s, isdata=bool(outdir == "Data" and not s["ID"])) break if not knownDSID: print("Simply removing {0} b/c corresponding DSID is unknown...". format(outdir)) shutil.rmtree(os.path.abspath(os.path.curdir) + "/" + outdir)
def miniNTuplise(sample): print("Executing command:\n{0}".format(sample)) subprocess.call(sample,shell=True) # Move output file(s) from job directory to the proper one, # but first, change the file name to be readable in KG's FW! # knownDSID = False # Get output directory name from the executed command string # outdir = sample[sample.find("--submitDir")+len("--submitDir")+1:sample.find("--nevents")-1] for s in sampledict: if outdir == s["ID"] or ( outdir == "Data" and not s["ID"] ): knownDSID = True outputfilepath = outdir +"/data-output" separator = "." if not s["ID"]: separator = "" INTREE = outputfilepath + "/" + outdir + ".root" INHIST = outdir + "/hist-" + outdir + ".root" if ( outdir == "Data" ): INTREE = outputfilepath + "/list-local-HTopGroupNTup.root" INHIST = outdir + "/hist-list-local-HTopGroupNTup.root" OUTTREE = motherdir + "/" + s["group"] + "/" + s["ID"] + separator + s["name"] + ".root" OUTHIST = motherdir + "/" + s["group"] + "/hist-" + s["ID"] + separator + s["name"] + ".root" print("Moving :\n{0}\nto:\n{1}".format(INTREE,OUTTREE)) print("Moving :\n{0}\nto:\n{1}".format(INHIST,OUTHIST)) shutil.move(INTREE,OUTTREE) shutil.move(INHIST,OUTHIST) normaliseTrees.applyWeight(OUTTREE,s,isdata=bool(outdir == "Data" and not s["ID"])) break if not knownDSID: print("Simply removing {0} b/c corresponding DSID is unknown...".format(outdir)) shutil.rmtree(os.path.abspath(os.path.curdir) + "/" + outdir)
if args.DSID == s["ID"] or ( args.DSID == "Data" and not s["ID"] ): knownDSID = True separator = "." if not s["ID"]: separator = "" INTREE = args.DSID + "/data-output" + "/" + args.DSID + ".root" INHIST = args.DSID + "/hist-" + args.DSID + ".root" if ( args.DSID == "Data" ): INTREE = args.DSID +"/data-output" + "/list-local-HTopGroupNTup.root" INHIST = args.DSID + "/hist-list-local-HTopGroupNTup.root" OUTTREE = dest + "/" + s["group"] + "/" + s["ID"] + separator + s["name"] + ".root" OUTHIST = dest + "/" + s["group"] + "/hist-" + s["ID"] + separator + s["name"] + ".root" print("Moving :\n{0}\nto:\n{1}".format(INTREE,OUTTREE)) print("Moving :\n{0}\nto:\n{1}".format(INHIST,OUTHIST)) shutil.move(INTREE,OUTTREE) shutil.move(INHIST,OUTHIST) normaliseTrees.applyWeight(OUTTREE,s,isdata=bool(args.DSID == "Data" and not s["ID"])) break if not knownDSID: print("Simply removing {0} b/c corresponding DSID is unknown...".format(args.DSID)) shutil.rmtree(os.path.abspath(os.path.curdir) + "/" + args.DSID)
knownDSID = True outputfilepath = outdir +"/data-output" separator = "." if not s["ID"]: separator = "" INTREE = outputfilepath + "/" + outdir + ".root" INHIST = outdir + "/hist-" + outdir + ".root" if ( outdir == "Data" ): INTREE = outputfilepath + "/list-local-HTopGroupNTup.root" INHIST = outdir + "/hist-list-local-HTopGroupNTup.root" OUTTREE = motherdir + "/" + s["group"] + "/" + s["ID"] + separator + s["name"] + ".root" OUTHIST = motherdir + "/" + s["group"] + "/hist-" + s["ID"] + separator + s["name"] + ".root" print("Moving :\n{0}\nto:\n{1}".format(INTREE,OUTTREE)) print("Moving :\n{0}\nto:\n{1}".format(INHIST,OUTHIST)) shutil.move(INTREE,OUTTREE) shutil.move(INHIST,OUTHIST) normaliseTrees.applyWeight(OUTTREE,s,isdata=bool(outdir == "Data" and not s["ID"])) break if not knownDSID: print("Simply removing {0} b/c corresponding DSID is unknown...".format(outdir)) shutil.rmtree(os.path.abspath(os.path.curdir) + "/" + outdir)
INHIST = args.DSID + "/hist-" + args.DSID + ".root" if (str(args.DSID[0:2]) == "00"): OUTTREE = dest + "/Data/" + args.DSID + ".physics_Main.root" OUTHIST = dest + "/Data/hist-" + args.DSID + ".physics_Main.root" else: OUTTREE = dest + "/" + s["group"] + "/" + s[ "ID"] + separator + s["name"] + ".root" OUTHIST = dest + "/" + s["group"] + "/hist-" + s[ "ID"] + separator + s["name"] + ".root" print("Moving :\n{0}\nto:\n{1}".format(INTREE, OUTTREE)) print("Moving :\n{0}\nto:\n{1}".format(INHIST, OUTHIST)) shutil.move(INTREE, OUTTREE) shutil.move(INHIST, OUTHIST) normaliseTrees.applyWeight(OUTTREE, s, isdata=bool( str(args.DSID[0:2]) == "00" and not s["ID"])) break if not knownDSID: print( "Simply removing {0} b/c corresponding DSID is unknown...".format( args.DSID)) shutil.rmtree(os.path.abspath(os.path.curdir) + "/" + args.DSID)