3 from __future__
import print_function
4 import sys,os,tempfile,shutil,subprocess,glob
7 if __name__ ==
"__main__":
10 parser = argparse.ArgumentParser(description=
"Harvest track validation plots")
11 parser.add_argument(
"files", metavar=
"file", type=str, nargs=
"+",
12 help=
"files to be harvested (convert edm DQM format to plain ROOT format")
13 parser.add_argument(
"-o",
"--outputFile", type=str, default=
"harvest.root",
14 help=
"output file (default: 'harvest.root')")
16 opts = parser.parse_args()
19 outputFile = os.path.abspath(opts.outputFile)
23 if not os.path.exists(f):
24 parser.error(
"DQM file %s does not exist" % f)
27 filelist =
",".
join([
"file:{0}".
format(os.path.abspath(_file))
for _file
in opts.files])
31 _tempdir = tempfile.mkdtemp()
35 cmsDriverCommand =
"cmsDriver.py harvest --scenario pp --filetype DQM --conditions auto:phase2_realistic --mc -s HARVESTING:@JetMETOnlyValidation+@HGCalValidation -n -1 --filein {0}".
format(filelist)
36 print(
"# running cmsDriver" +
"\n" + cmsDriverCommand)
39 subprocess.call(cmsDriverCommand.split(
" "))
42 ofiles = glob.glob(
"DQM*.root")
44 print(
"ERROR: expecting exactly one output file matching DQM*.root")
45 print(
" ls of current directory({0}):".
format(_tempdir))
48 shutil.move(ofiles[0],outputFile)
54 shutil.rmtree(_tempdir)
S & print(S &os, JobReport::InputFile const &f)
static std::string join(char **cmd)