47 print (
"\n##################################################################")
48 print (
"## ATLAS Tier0 LAr CAF file Merging ##")
49 print (
"##################################################################\n")
51 print (
"\nFull Tier-0 run options:\n")
52 pprint.pprint(dataMap)
57 for val
in dataMap[
'inputLArFiles'] :
58 inputList.append(val.split(
'#')[1])
60 inputDSName = val.split(
'#')[0]
62 print (
"\ninputLArFiles list:\n")
63 pprint.pprint(inputList)
66 outputDSName = dataMap[
'outputLArFile'].
split(
'#')[0]
67 outputFile = dataMap[
'outputLArFile'].
split(
'#')[1]
69 print (
'\nOutput file name:', outputFile)
78 cmdline=[
"LArSamplesMerge.exe"]
79 for fileName
in inputList:
80 if os.access(fileName,os.R_OK):
81 cmdline.append(fileName)
83 print (
'ERROR : could not open file', fileName)
85 acronym =
'TRF_LAR_FILE_INPUT_ERROR'
90 writepath=os.path.split(outputFile)[0]
93 if (os.access(writepath,os.W_OK)):
94 cmdline.append(outputFile)
96 print (
"ERROR, not allowed to write to oututfile", outputFile)
98 acronym =
'TRF_LAR_MERGE_ERROR'
104 logfile=
open(
"log.LArMerge",
"w")
107 subprocess.check_call(cmdline,stdout=logfile,stderr=subprocess.STDOUT)
108 except Exception
as e:
109 print (
"ERROR exectution of subprocess failed")
111 acronym =
'TRF_LAR_MERGE_ERROR'
115 logfile=
open(
"log.LArMerge",
"r")
119 if line.startswith(
"Open file "):
120 linetok=line.split(
" ")
121 inFiles.append(
getFileMap(linetok[2],
None, nevts=
int(linetok[4])))
123 if line.startswith(
"Wrote output file "):
124 linetok=line.split(
" ")
125 nEvents=
int(linetok[5])
126 outFiles=[
getFileMap(linetok[3], outputDSName, nevts=nEvents),]
134 outMap = {
'prodsys': {
'trfCode': retcode,
135 'trfAcronym': acronym,
136 'jobOutputs': outFiles,
137 'jobInputs': inFiles,
141 f =
open(
'jobReport.gpickle',
'wb')
142 pickle.dump(outMap, f)
145 print (
"\n##################################################################")
146 print (
"## End of job.")
147 print (
"##################################################################\n")