3 from __future__
import print_function
4 import sys,os,tempfile,shutil,subprocess,glob
7 if __name__ ==
"__main__":
9 print(
"Warning: this script is deprecated and will be removed in the future. Please use the step4_HARVESTING.py step provided by cmsDriver in your workflow instead.")
11 parser = argparse.ArgumentParser(description=
"Harvest track validation plots")
12 parser.add_argument(
"files", metavar=
"file", type=str, nargs=
"+",
13 help=
"files to be harvested (convert edm DQM format to plain ROOT format")
14 parser.add_argument(
"-o",
"--outputFile", type=str, default=
"harvest.root",
15 help=
"output file (default: 'harvest.root')")
17 opts = parser.parse_args()
20 outputFile = os.path.abspath(opts.outputFile)
24 if not os.path.exists(f):
25 parser.error(
"DQM file %s does not exist" % f)
28 filelist =
",".
join([
"file:{0}".
format(os.path.abspath(_file))
for _file
in opts.files])
32 _tempdir = tempfile.mkdtemp()
36 cmsDriverCommand =
"cmsDriver.py harvest --scenario pp --filetype DQM --conditions auto:phase2_realistic --mc -s HARVESTING:@JetMETOnlyValidation+@HGCalValidation -n -1 --filein {0}".
format(filelist)
37 print(
"# running cmsDriver" +
"\n" + cmsDriverCommand)
40 subprocess.call(cmsDriverCommand.split(
" "))
43 ofiles = glob.glob(
"DQM*.root")
45 print(
"ERROR: expecting exactly one output file matching DQM*.root")
46 print(
" ls of current directory({0}):".
format(_tempdir))
49 shutil.move(ofiles[0],outputFile)
55 shutil.rmtree(_tempdir)
void print(TMatrixD &m, const char *label=nullptr, bool mathematicaFormat=false)
static std::string join(char **cmd)