45def larMerge(dataMap) :
46
47 print ("\n##################################################################")
48 print ( "## ATLAS Tier0 LAr CAF file Merging ##")
49 print ( "##################################################################\n")
50
51 print ("\nFull Tier-0 run options:\n")
52 pprint.pprint(dataMap)
53
54 inputList = []
55 inputDSName = None
56
57 for val in dataMap['inputLArFiles'] :
58 inputList.append(val.split('#')[1])
59 if not inputDSName :
60 inputDSName = val.split('#')[0]
61
62 print ("\ninputLArFiles list:\n")
63 pprint.pprint(inputList)
64
65
66 outputDSName = dataMap[
'outputLArFile'].
split(
'#')[0]
67 outputFile = dataMap[
'outputLArFile'].
split(
'#')[1]
68
69 print ('\nOutput file name:', outputFile)
70
71 retcode = 0
72 acronym = 'OK'
73
74 outFiles = []
75 inFiles = []
76 nEvents=0
77
78 cmdline=["LArSamplesMerge.exe"]
79 for fileName in inputList:
80 if os.access(fileName,os.R_OK):
81 cmdline.append(fileName)
82 else:
83 print ('ERROR : could not open file', fileName)
84 retcode = 74001
85 acronym = 'TRF_LAR_FILE_INPUT_ERROR'
86 break
87 pass
88
89 if (retcode==0):
90 writepath=os.path.split(outputFile)[0]
91 if writepath=="":
92 writepath="./"
93 if (os.access(writepath,os.W_OK)):
94 cmdline.append(outputFile)
95 else:
96 print ("ERROR, not allowed to write to oututfile", outputFile)
97 retcode = 74002
98 acronym = 'TRF_LAR_MERGE_ERROR'
99 pass
100 pass
101
102 if (retcode==0):
103
104 logfile=open("log.LArMerge","w")
105
106 try:
107 subprocess.check_call(cmdline,stdout=logfile,stderr=subprocess.STDOUT)
108 except Exception as e:
109 print ("ERROR exectution of subprocess failed")
110 print (e)
111 acronym = 'TRF_LAR_MERGE_ERROR'
112 pass
113
114 logfile.close()
115 logfile=open("log.LArMerge","r")
116
117 for line in logfile:
118 print (line, end='')
119 if line.startswith("Open file "):
120 linetok=line.split(" ")
121 inFiles.append(getFileMap(linetok[2], None, nevts=int(linetok[4])))
122 pass
123 if line.startswith("Wrote output file "):
124 linetok=line.split(" ")
125 nEvents=int(linetok[5])
126 outFiles=[getFileMap(linetok[3], outputDSName, nevts=nEvents),]
127 pass
128
129 logfile.close()
130
131
132
133
134 outMap = { 'prodsys': { 'trfCode': retcode,
135 'trfAcronym': acronym,
136 'jobOutputs': outFiles,
137 'jobInputs': inFiles,
138 'nevents': nEvents,
139 }
140 }
141 f = open('jobReport.gpickle', 'wb')
142 pickle.dump(outMap, f)
143 f.close()
144
145 print ("\n##################################################################")
146 print ( "## End of job.")
147 print ( "##################################################################\n")
148
149 print (outMap)
150
std::vector< std::string > split(const std::string &s, const std::string &t=":")