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