124 print(
"\n##################################################################")
125 print(
"## ATLAS Tier-0 Offline DQM Processing ##")
126 print(
"##################################################################\n")
128 print(
"\n##################################################################")
129 print(
"## STEP 1: creating file with list of root files ...")
130 print(
"##################################################################\n")
133 print(
"Using pickled file ", picklefile,
" for input parameters")
134 f =
open(picklefile,
'r')
135 parmap = pickle.load(f)
138 print(
"\nFull Tier-0 run options:\n")
139 pprint.pprint(parmap)
141 inputfilelist = parmap.get(
'inputHistFiles', [])
142 nfiles = len(inputfilelist)
143 histMergeCompressionLevel=parmap.get(
'histMergeCompressionLevel', 1)
144 histMergeDebugLevel=parmap.get(
'histMergeDebugLevel', 0)
147 dt =
int(time.time() - tstart)
149 acronym =
'TRF_NOINPUT'
150 txt =
'empty input file list'
151 reportmap = {
'prodsys': {
'trfCode': retcode,
152 'trfAcronym': acronym,
156 'more': {
'num1': 0,
'num2': dt,
'txt1': txt }
164 if isinstance(inputfilelist[0], str) :
165 histtmpdsname = (inputfilelist[0]).
split(
'#')[0]
166 for val
in inputfilelist :
167 histtmpflist.append(val.split(
'#')[1])
169 elif isinstance(inputfilelist[0], dict) :
170 histtmpdsname = inputfilelist[0][
'dsn']
171 for fdict
in inputfilelist :
172 histtmpflist.append(fdict[
'lfn'])
173 nevt = fdict.get(
'events', 0)
176 print(
"WARNING Can't get number of events from input pickle file")
179 f =
open(
'hist_merge.list',
'w')
181 for hf
in histtmpflist :
182 txtstr +=
"%s\n" % hf
186 cmd =
"cat hist_merge.list"
187 (s,o) = getstatusoutput(cmd)
188 print(
"\nContents of file hist_merge.list:\n")
192 print(
"\n##################################################################")
193 print(
"## STEP 2: determining job parameters...")
194 print(
"##################################################################\n")
197 histdsname = (parmap[
'outputHistFile']).
split(
'#')[0]
198 histfile = (parmap[
'outputHistFile']).
split(
'#')[1]
199 amitag = histfile.split(
'.')[5]
203 incr = parmap.get(
'incrementalMode',
'False')
206 postproc = parmap.get(
'postProcessing',
'True')
209 allowCOOLUpload = parmap.get(
'allowCOOLUpload',
'True')
212 doWebDisplay = parmap.get(
'doWebDisplay',
'True')
215 productionMode = parmap.get(
'productionMode',
'True')
216 if productionMode !=
'True' and incr ==
'True':
217 print(
"Production mode is not True, turning off incremental mode")
221 filepaths = parmap.get(
'filepaths',
None)
222 if filepaths
and isinstance(filepaths, dict):
223 if 'basename' not in filepaths:
224 print(
"Improperly formed 'filepaths' (no 'basename')")
226 for evtclass
in (
'Collisions',
'Cosmics',
'HeavyIons'):
227 if evtclass
not in filepaths:
228 print(
"Improperly formed 'filepaths' (no '%s')" % evtclass)
230 clinfo = filepaths[evtclass]
231 for timeclass
in (
'run',
'minutes10',
'minutes30'):
232 if timeclass
not in clinfo:
233 print(
"Improperly formed 'filepaths[%s]' (no '%s')" % (evtclass, timeclass))
235 dqcenvvar =
'DQC_HCFG_%s_%s' % (evtclass.upper(), timeclass.upper())
236 fpath = os.path.join(filepaths[
'basename'], clinfo[timeclass])
237 print(
"Setting %s = %s" % (dqcenvvar, fpath))
238 os.environ[dqcenvvar] = fpath
244 dqproject = histdsname.split(
'.')[0]
246 dqproject =
'data_test'
247 dqproject = parmap.get(
'projectTag', dqproject)
250 if 'runNumber' in parmap :
251 runnr = parmap[
'runNumber']
254 runnr =
int(histdsname.split(
'.')[1])
259 if 'streamName' in parmap :
260 stream = parmap[
'streamName']
263 stream = histdsname.split(
'.')[2]
265 stream =
'test_dummy'
269 if 'procNumber' in parmap :
270 procnumber = parmap[
'procNumber']
273 while n_xmlrpc_tries <= MAX_XMLRPC_TRIES :
276 xmlrpcserver = xmlrpclib.ServerProxy(
'http://atlasdqm.cern.ch:8888')
277 procnumber = xmlrpcserver.get_next_proc_pass(runnr, stream,
'tier0')
280 print(
'Web service connection failed, attempt', n_xmlrpc_tries,
'of', MAX_XMLRPC_TRIES)
282 if n_xmlrpc_tries <= MAX_XMLRPC_TRIES:
283 time.sleep(20*2**n_xmlrpc_tries)
285 print(
"Job parameters:\n")
286 print(
" Run number: ", runnr)
287 print(
" Stream name: ", stream)
288 print(
" Processing pass: ", procnumber)
289 print(
" Incremental mode:", incr)
290 print(
" Post-processing: ", postproc)
291 print(
" COOL uploads: ", allowCOOLUpload)
292 print(
" Production mode: ", productionMode)
295 print(
"\n##################################################################")
296 print(
"## STEP 3: running histogram merging procedure ...")
297 print(
"##################################################################\n")
300 os.environ[
'DQPRODUCTION'] =
'1' if productionMode ==
'True' else '0'
301 os.environ[
'DQ_STREAM'] = stream
302 print(
"Setting env variable DQPRODUCTION to %s\n" % os.environ[
'DQPRODUCTION'])
303 os.environ[
'COOLUPLOADS'] =
'1' if allowCOOLUpload ==
'True' and productionMode ==
'True' else '0'
304 print(
"Setting env variable COOLUPLOADS to %s\n" % os.environ[
'COOLUPLOADS'])
306 if postproc ==
'True' :
308 cmd =
"python -u `which DQHistogramMerge.py` hist_merge.list %s 1 1 %d %d " % (histfile,histMergeCompressionLevel,histMergeDebugLevel)
310 cmd =
"python -u `which DQHistogramMerge.py` hist_merge.list %s 1 0 %d %d" % (histfile,histMergeCompressionLevel,histMergeDebugLevel)
312 cmd =
"python -u `which DQHistogramMerge.py` hist_merge.list %s 0 0 %d %d" % (histfile,histMergeCompressionLevel,histMergeDebugLevel)
314 print(
"Histogram merging command:\n")
316 print(
"\n##################################################################\n")
318 print(
"## ... logfile from DQHistogramMerge.py: ")
319 print(
"--------------------------------------------------------------------------------")
321 retcode1 = os.system(cmd)
322 print(
"--------------------------------------------------------------------------------")
324 dt1 =
int(t1 - tstart)
326 print(
"\n## DQHistogramMerge.py finished with retcode = %s" % retcode1)
327 print(
"## ... elapsed time: ", dt1,
" sec")
330 if postproc ==
'True' and incr ==
'False':
331 print(
"\n##################################################################")
332 print(
"## STEP 3b: copying postprocessing output to AFS ...")
333 print(
"##################################################################\n")
335 cmd =
"python -u `which DQFileMove.py` %s %s_%s_%s" % (dqproject, runnr, stream, procnumber)
337 print(
"File move command:\n")
339 print(
"\n##################################################################\n")
341 print(
"## ... logfile from DQFileMove.py: ")
342 print(
"--------------------------------------------------------------------------------")
344 retcode1b = os.system(cmd)
345 print(
"--------------------------------------------------------------------------------")
350 print(
"\n## DQFileMove.py finished with retcode = %s" % retcode1b)
351 print(
"## ... elapsed time: ", dt1b,
" sec")
353 if doWebDisplay ==
'True':
354 print(
"\n##################################################################")
355 print(
"## STEP 4: running web-display creation procedure ...")
356 print(
"##################################################################\n")
358 cmd =
"python -u `which DQWebDisplay.py` %s %s %s %s stream=%s" % (histfile, dqproject, procnumber, incr, stream)
360 print(
"Web display creation command:\n")
362 print(
"\n##################################################################\n")
364 print(
"## ... logfile from DQWebDisplay.py: ")
365 print(
"--------------------------------------------------------------------------------")
367 retcode2 = os.system(cmd)
368 print(
'DO NOT REPORT "Error in TH1: cannot merge histograms" ERRORS! THESE ARE IRRELEVANT!')
369 print(
"--------------------------------------------------------------------------------")
373 print(
"\n## DQWebDisplay.py finished with retcode = %s" % retcode2)
374 print(
"## ... elapsed time: ", dt2,
" sec")
376 print(
"\n##################################################################")
377 print(
"## WEB DISPLAY CREATION SKIPPED BY USER REQUEST")
378 print(
"##################################################################\n")
382 print(
"\n##################################################################")
383 print(
"## STEP 5: finishing the job ...")
384 print(
"##################################################################\n")
392 txt =
'trf finished OK'
397 if (retcode2 >> 8)
in (0, 5) :
399 histmap =
getFileMap(histfile, histdsname, nevts=nevts)
402 if doWebDisplay ==
'True':
403 print(
'Publishing to message service')
404 publish_success_to_mq(runnr, dqproject, stream, incr=(incr==
'True'), ami=amitag, procpass=procnumber, hcfg=filepaths, isprod=(productionMode==
'True'))
406 print(
'Web display off, not publishing to message service')
408 txt =
'DQWebDisplay.py execution problem'
409 print(
"ERROR: DQWebDisplay.py execution problem!")
411 acronym =
'TRF_DQMDISPLAY_EXE'
413 infilelist=
open(
'hist_merge.list',
'r')
414 for infname
in infilelist:
420 print(
"ERROR: DQHistogramMerge.py execution problem!")
422 acronym =
'TRF_DQMHISTMERGE_EXE'
424 txt =
'DQHistogramMerge.py execution problem'
426 infilelist=
open(
'hist_merge.list',
'r')
427 for infname
in infilelist:
432 DQResFile=
"DQResourceUtilization.txt"
433 if os.path.exists(DQResFile):
434 print(
"dumping resource utilization log")
435 with open(DQResFile)
as resfile:
436 for resline
in resfile:
437 print(resline, end=
' ')
440 reportmap = {
'prodsys': {
'trfCode': retcode,
441 'trfAcronym': acronym,
442 'jobOutputs': outfiles,
443 'jobInputs': infiles,
444 'nevents':
int(nevts),
445 'more': {
'num1':
int(nevts),
'num2':
int(dt),
'txt1': txt }
450 f =
open(
'jobReport.gpickle',
'w')
451 pickle.dump(reportmap, f)
454 print(
"\n## ... job finished with retcode : %s" % reportmap[
'prodsys'][
'trfCode'])
455 print(
"## ... error acronym: ", reportmap[
'prodsys'][
'trfAcronym'])
456 print(
"## ... elapsed time: ", reportmap[
'prodsys'][
'more'][
'num2'],
"sec")
458 print(
"##################################################################")
459 print(
"## End of job.")
460 print(
"##################################################################\n")