6 import sys, os, pickle, pprint, subprocess
8 from LArCafJobs.GetLBsToIgnore
import getLBsToIgnore
16 if os.path.isfile(fname) :
17 dataMap = {
'lfn': fname,
22 dataMap[
'GUID'] = guid
31 if isinstance(filespec,dict):
32 if "svcclass" in filespec:
33 os.environ[
"STAGE_SVCCLASS"]=filespec[
"svcclass"]
37 return filespec[
'pfn']
39 print (
"ERROR: Unknown file specification (dict):")
44 if isinstance(filespec,str):
45 names=filespec.split(
'#')
47 print (
"ERROR: Unexpected file specification (string):")
57 filename=fname.split(
"/")[-1]
58 elem=filename.split(
".")
62 print (
"ERROR: Invalid file name format. Expected at least six subfileds, got",filename)
72 if not rnStr.isdigit():
73 print (
"ERROR: Can't get run number, got",rnStr)
80 print (
"ERROR: Can't get LB number, got",LBStr)
85 if not LBStr.isdigit():
86 print (
"ERROR: Can't get LB number, got",LBStr)
96 print (
"\n##################################################################")
97 print (
"## ATLAS Tier0 LAr CAF file Merging ##")
98 print (
"##################################################################\n")
100 print (
"\nFull Tier-0 run options:\n")
101 pprint.pprint(dataMap)
107 inFiles=dataMap[
'inputHistFiles']
111 firstFile=
getPFN(inFiles[0])
114 print (
"Encountered pre-merged file, no bad-LB checking done" )
116 print (
"Found run number",runnumber)
125 print (
"Ignoring bad LumiBlock",LB)
127 inputList.append(pfn)
133 templist=
open(
"inputfiles.txt",
"w")
134 for infile
in inputList:
135 templist.write(infile+
"\n")
141 outputDSName = dataMap[
'outputLArHistFile'].
split(
'#')[0]
142 outputFile = dataMap[
'outputLArHistFile'].
split(
'#')[1]
144 print (
'\nOutput file name:', outputFile)
148 cmd=
"LArQuickHistMerge.exe -i inputfiles.txt " + outputFile
151 retcode = subprocess.call(cmd, shell=
True)
152 print (
'retcode =',retcode)
155 acronym =
"LARQUICKHISTMEGE PROBLEM"
156 except OSError
as e :
159 acronym =
"SUBPROCESS EXECUTION PROBLEM"
163 cmd =
"DQWebDisplay.py " + outputFile +
" LArDisplay 111"
164 print (
"Attempt to run",cmd)
166 retcodeDQM = subprocess.call(cmd, shell=
True)
167 print (
'retcode =',retcodeDQM)
168 except Exception
as e:
169 print (
"Attempt failed with exception")
175 outputMap =
getFileMap(outputFile, outputDSName, nevts=0)
176 outFiles = [ outputMap ]
181 print (
"ERROR: problem in LAr Histogram merging!")
182 if retcode == 62600 :
183 acronym =
'TRF_LAR_FILE_INPUT_ERROR'
184 elif retcode == 62601 :
185 acronym =
'TRF_LAR_MERGE_ERROR'
190 outMap = {
'prodsys': {
'trfCode': retcode,
191 'trfAcronym': acronym,
192 'jobOutputs': outFiles,
193 'jobInputs': inFiles,
196 f =
open(
'jobReport.gpickle',
'wb')
197 pickle.dump(outMap, f)
200 print (
"\n##################################################################")
201 print (
"## End of job.")
202 print (
"##################################################################\n")
210 if __name__ ==
"__main__":
212 if len(sys.argv) == 2
and sys.argv[1].startswith(
'--argdict=') :
213 picklefile = sys.argv[1][len(
'--argdict='):]
215 print (
"Using pickled file ", picklefile,
" for input parameters")
217 dataMap = pickle.load(f)
220 elif len(sys.argv) == 3
and sys.argv[1].startswith(
'--inputFiles=')
and sys.argv[2].startswith(
'--outputFile=') :
221 inputFiles = sys.argv[1][13:].
split(
',')
222 outputFile = sys.argv[2][13:]
224 dataMap[
'inputHistFiles'] = inputFiles
225 dataMap[
'outputLArHistFile'] = outputFile
228 print (
"Input format wrong --- either have: ")
229 print (
" --argdict=<pickled-dictionary containing input info> ")
230 print (
" with key/value pairs: ")
231 print (
" or (old way): ")
232 print (
" --inputFiles=file1,file2,...,fileN --outputFile=file")