3 import sys,os,tempfile,shutil,subprocess,glob
6 if __name__ ==
"__main__":
10 parser.add_argument(
"files", metavar=
"file", type=str, nargs=
"+",
11 help=
"files to be harvested (convert edm DQM format to plain ROOT format")
12 parser.add_argument(
"-o",
"--outputFile", type=str, default=
"harvest.root",
13 help=
"output file (default: 'harvest.root')")
15 opts = parser.parse_args()
18 outputFile = os.path.abspath(opts.outputFile)
22 if not os.path.exists(f):
23 parser.error(
"DQM file %s does not exist" % f)
26 filelist =
",".
join([
"file:{0}".
format(os.path.abspath(_file))
for _file
in opts.files])
30 _tempdir = tempfile.mkdtemp()
34 cmsDriverCommand =
"cmsDriver.py harvest --scenario pp --filetype DQM --conditions auto:run2_mc --mc -s HARVESTING:@trackingOnlyValidation+@trackingOnlyDQM+postProcessorHLTtrackingSequence -n -1 --filein {0}".
format(filelist)
35 print "# running cmsDriver" +
"\n" + cmsDriverCommand
38 subprocess.call(cmsDriverCommand.split(
" "))
41 ofiles = glob.glob(
"DQM*.root")
43 print "ERROR: expecting exactly one output file matching DQM*.root" 44 print " ls of current directory({0}):".
format(_tempdir)
47 shutil.move(ofiles[0],outputFile)
53 shutil.rmtree(_tempdir)
static std::string join(char **cmd)