42def larMerge(dataMap) :
43
44 tstart = time.time()
45
46 print(
"\n##################################################################")
47 print(
"## ATLAS Tier0 LAr CAF file Merging ##")
48 print(
"##################################################################\n")
49
50
51 exitCode = 0
52 exitAcronym = 'OK'
53 exitMsg = 'trf finished OK'
54 dt=0
55 nEvents=0
56 outFiles = []
57 inFiles = []
58
59 print(
"\nFull Tier-0 run options:\n")
60 pprint.pprint(dataMap)
61
62 inputList = []
63 inputDSName = dataMap['inputLArFiles'][0]['dsn']
64
65 for fdict in dataMap['inputLArFiles'] :
66 inputList.append(fdict['lfn'])
67
68 print(
"\ninputLArFiles list:\n")
69 pprint.pprint(inputList)
70
71
72 outputDSName = dataMap[
'outputLArFile'].
split(
'#')[0]
73 outputFile = dataMap[
'outputLArFile'].
split(
'#')[1]
74
75 print(
'\nOutput file name:', outputFile)
76
77 cmdline=["LArSamplesMerge"]
78 for fileName in inputList:
79 if os.access(fileName,os.R_OK):
80 cmdline.append(fileName)
81 else:
82 print(
'ERROR : could not open file', fileName)
83 exitCode = 74001
84 exitAcronym = 'TRF_LAR_FILE_INPUT_ERROR'
85 exitMsg = 'LAr input file not accessible'
86 break
87 pass
88
89 if (exitCode==0):
90 writepath=os.path.split(outputFile)[0]
91 if writepath=="": writepath="./"
92 if (os.access(writepath,os.W_OK)):
93 cmdline.append(outputFile)
94 else:
95 print(
"ERROR, not allowed to write to oututfile", outputFile)
96 exitCode = 74002
97 exitAcronym = 'TRF_LAR_MERGE_ERROR'
98 exitMsg = 'LAR merging error'
99 pass
100
101 if (exitCode==0):
102
103 logfile=open("log.LArMerge","w")
104
105 try:
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'
112 exitCode=1
113
114 logfile.close()
115 logfile=open("log.LArMerge","r")
116
117 for line in logfile:
119 if line.startswith("Open file "):
120 linetok=line.split(" ")
121 inFiles.append(getSubFileMap(linetok[2],nevts=int(linetok[4])))
122 if line.startswith("Wrote output file "):
123 linetok=line.split(" ")
124 nEvents=int(linetok[5])
125 outFiles.append(getSubFileMap(linetok[3], nevts=nEvents))
126 logfile.close()
127 dt = int(time.time() - tstart)
128
129 outMap = { 'exitAcronym' : exitAcronym,
130 'exitCode' : exitCode,
131 'exitMsg' : exitMsg,
132 'files' : { 'output' : [{ 'dataset' : outputDSName,
133 'subFiles' : outFiles
134 },],
135 'input' : [{ 'dataset' : inputDSName,
136 'subFiles' : inFiles
137 }
138 ] },
139 'resource' : { 'transform' : { 'processedEvents' : int(nEvents), 'wallTime' : dt} }
140 }
141
142 f = open('jobReport.json', 'w')
143 json.dump(outMap, f)
144 f.close()
145
146 print(
"\n##################################################################")
147 print(
"## End of job.")
148 print(
"##################################################################\n")
149
151
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")