46 print(
"\n##################################################################")
47 print(
"## ATLAS Tier0 LAr CAF file Merging ##")
48 print(
"##################################################################\n")
53 exitMsg =
'trf finished OK'
59 print(
"\nFull Tier-0 run options:\n")
60 pprint.pprint(dataMap)
63 inputDSName = dataMap[
'inputLArFiles'][0][
'dsn']
65 for fdict
in dataMap[
'inputLArFiles'] :
66 inputList.append(fdict[
'lfn'])
68 print(
"\ninputLArFiles list:\n")
69 pprint.pprint(inputList)
72 outputDSName = dataMap[
'outputLArFile'].
split(
'#')[0]
73 outputFile = dataMap[
'outputLArFile'].
split(
'#')[1]
75 print(
'\nOutput file name:', outputFile)
77 cmdline=[
"LArSamplesMerge"]
78 for fileName
in inputList:
79 if os.access(fileName,os.R_OK):
80 cmdline.append(fileName)
82 print(
'ERROR : could not open file', fileName)
84 exitAcronym =
'TRF_LAR_FILE_INPUT_ERROR'
85 exitMsg =
'LAr input file not accessible'
90 writepath=os.path.split(outputFile)[0]
91 if writepath==
"": writepath=
"./"
92 if (os.access(writepath,os.W_OK)):
93 cmdline.append(outputFile)
95 print(
"ERROR, not allowed to write to oututfile", outputFile)
97 exitAcronym =
'TRF_LAR_MERGE_ERROR'
98 exitMsg =
'LAR merging error'
103 logfile=
open(
"log.LArMerge",
"w")
106 subprocess.check_call(cmdline,stdout=logfile,stderr=subprocess.STDOUT)
107 except Exception
as e:
108 print(
"ERROR exectution of subprocess failed")
110 exitAcronym =
'TRF_LAR_MERGE_ERROR'
111 exitMsg =
'LAR merging error'
115 logfile=
open(
"log.LArMerge",
"r")
119 if line.startswith(
"Open file "):
120 linetok=line.split(
" ")
122 if line.startswith(
"Wrote output file "):
123 linetok=line.split(
" ")
124 nEvents=
int(linetok[5])
127 dt =
int(time.time() - tstart)
129 outMap = {
'exitAcronym' : exitAcronym,
130 'exitCode' : exitCode,
132 'files' : {
'output' : [{
'dataset' : outputDSName,
133 'subFiles' : outFiles
135 'input' : [{
'dataset' : inputDSName,
139 'resource' : {
'transform' : {
'processedEvents' :
int(nEvents),
'wallTime' : dt} }
142 f =
open(
'jobReport.json',
'w')
146 print(
"\n##################################################################")
147 print(
"## End of job.")
148 print(
"##################################################################\n")