94def larMerge(dataMap) :
95
96 print ("\n##################################################################")
97 print ( "## ATLAS Tier0 LAr CAF file Merging ##")
98 print ( "##################################################################\n")
99
100 print ("\nFull Tier-0 run options:\n")
101 pprint.pprint(dataMap)
102
103 inputList = []
104
106
107 inFiles=dataMap['inputHistFiles']
108
109
110 if len(inFiles)>0:
111 firstFile=getPFN(inFiles[0])
112 runnumber=getRunLB(firstFile)[0]
113 if runnumber==-1:
114 print ("Encountered pre-merged file, no bad-LB checking done" )
115 else:
116 print ("Found run number",runnumber)
117 badLBs=getLBsToIgnore(runnumber)
118
119
120 for val in inFiles:
121 pfn=getPFN(val)
122 if len(badLBs)>0:
123 LB=getRunLB(pfn)[1]
124 if LB in badLBs:
125 print ("Ignoring bad LumiBlock",LB)
126 continue
127 inputList.append(pfn)
128 sys.stdout.flush()
129
130
131
132
133 templist=open("inputfiles.txt","w")
134 for infile in inputList:
135 templist.write(infile+"\n")
136 pass
137 templist.close()
138
139
140
141 outputDSName = dataMap[
'outputLArHistFile'].
split(
'#')[0]
142 outputFile = dataMap[
'outputLArHistFile'].
split(
'#')[1]
143
144 print ('\nOutput file name:', outputFile)
145
146 retcode = 0
147
148 cmd="LArQuickHistMerge.exe -i inputfiles.txt " + outputFile
149
150 try:
151 retcode = subprocess.call(cmd, shell=True)
152 print ('retcode =',retcode)
153 if retcode != 0 :
154 retcode = 62601
155 acronym = "LARQUICKHISTMEGE PROBLEM"
156 except OSError as e :
157 retcode = 62600
158 print (e)
159 acronym = "SUBPROCESS EXECUTION PROBLEM"
160 pass
161
162 if retcode==0:
163 cmd ="DQWebDisplay.py " + outputFile +" LArDisplay 111"
164 print ("Attempt to run",cmd)
165 try:
166 retcodeDQM = subprocess.call(cmd, shell=True)
167 print ('retcode =',retcodeDQM)
168 except Exception as e:
169 print ("Attempt failed with exception")
170 print (e)
171
172
173
174 if retcode == 0 :
175 outputMap = getFileMap(outputFile, outputDSName, nevts=0)
176 outFiles = [ outputMap ]
177 acronym = 'OK'
178 else:
179 outFiles = []
180 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'
186
187
188
189
190 outMap = { 'prodsys': { 'trfCode': retcode,
191 'trfAcronym': acronym,
192 'jobOutputs': outFiles,
193 'jobInputs': inFiles,
194 }
195 }
196 f = open('jobReport.gpickle', 'wb')
197 pickle.dump(outMap, f)
198 f.close()
199
200 print ("\n##################################################################")
201 print ( "## End of job.")
202 print ( "##################################################################\n")
203
204
205
std::vector< std::string > split(const std::string &s, const std::string &t=":")