File indexing completed on 2023-03-17 11:27:53
0001
0002
0003 from __future__ import print_function
0004 import sys,os,tempfile,shutil,subprocess,glob
0005 import argparse
0006
0007 if __name__ == "__main__":
0008
0009
0010 parser = argparse.ArgumentParser(description="Harvest track validation plots")
0011 parser.add_argument("files", metavar="file", type=str, nargs="+",
0012 help="files to be harvested (convert edm DQM format to plain ROOT format")
0013 parser.add_argument("-o", "--outputFile", type=str, default="harvest.root",
0014 help="output file (default: 'harvest.root')")
0015
0016 opts = parser.parse_args()
0017
0018
0019 outputFile = os.path.abspath(opts.outputFile)
0020
0021
0022 for f in opts.files:
0023 if not os.path.exists(f):
0024 parser.error("DQM file %s does not exist" % f)
0025
0026
0027 filelist = ",".join(["file:{0}".format(os.path.abspath(_file)) for _file in opts.files])
0028
0029
0030 _cwd = os.getcwd()
0031 _tempdir = tempfile.mkdtemp()
0032 os.chdir(_tempdir)
0033
0034
0035 cmsDriverCommand = "cmsDriver.py harvest --scenario pp --filetype DQM --conditions auto:phase2_realistic --mc -s HARVESTING:@JetMETOnlyValidation+@HGCalValidation -n -1 --filein {0}".format(filelist)
0036 print("# running cmsDriver" + "\n" + cmsDriverCommand)
0037
0038
0039 subprocess.call(cmsDriverCommand.split(" "))
0040
0041
0042 ofiles = glob.glob("DQM*.root")
0043 if len(ofiles) != 1:
0044 print("ERROR: expecting exactly one output file matching DQM*.root")
0045 print(" ls of current directory({0}):".format(_tempdir))
0046 os.system("ls -lt")
0047 sys.exit()
0048 shutil.move(ofiles[0],outputFile)
0049
0050
0051 os.chdir(_cwd)
0052
0053
0054 shutil.rmtree(_tempdir)