ATLAS Offline Software
Loading...
Searching...
No Matches
BeamSpotPostProcessing.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4
5"""
6Beam spot postprocessing library.
7"""
8__author__ = 'Juerg Beringer'
9__version__ = '$Id $'
10
11
12import os
13
14from InDetBeamSpotExample.PostProcessing import PostProcessingStep, PostProcessingError, PostponeProcessing, runPostProcStep
15from InDetBeamSpotExample.TaskManager import TaskManager
16from InDetBeamSpotExample import COOLUtils
17
18import subprocess
19
20linkTemplates = {
21 'PlotBeamSpot.gif': '<a href="../files?u=%s/%s/%s">Summary</a>',
22 'PlotBeamSpot.pdf': '(<a href="/jobfiles/%s/%s/%s">pdf</a>)',
23 'PlotBeamSpotMon.gif': '<a href="../files?u=%s/%s/%s">Monitoring</a>',
24 'PlotBeamSpotMon.pdf': '(<a href="/jobfiles/%s/%s/%s">pdf</a>)',
25 'PlotGlobalMon.gif': '<a href="../files?u=%s/%s/%s">Globalmon</a>',
26 'PlotGlobalMon.pdf': '(<a href="/jobfiles/%s/%s/%s">pdf</a>)',
27 'PlotBeamSpotCompareReproc.gif': '<a href="../files?u=%s/%s/%s">Compare</a>',
28 'PlotBeamSpotCompareReproc.pdf': '(<a href="/jobfiles/%s/%s/%s">pdf</a>)',
29 'PlotBeamSpotCompareReproc.html': '(<a href="/jobfiles/%s/%s/%s">html</a>)',
30 'PlotBCID-data.txt': '<a href="../files?u=%s/%s/%s">BCID data</a>',
31 'PlotBCID-vsLb.gif': '<a href="../files?u=%s/%s/%s">vsLb</a>',
32 'PlotBCID-vsLb.pdf': None, # suppress linking until we get better quality PDF
33 #'PlotBCID-vsLb.pdf': '(<a href="/jobfiles/%s/%s/%s">pdf</a>)',
34 'PlotBCID-vsTime.gif': '<a href="../files?u=%s/%s/%s">vsTime</a>',
35 'PlotBCID-vsTime.pdf': None, # suppress linking until we get better quality PDF
36 #'PlotBCID-vsTime.pdf': '(<a href="/jobfiles/%s/%s/%s">pdf</a>)',
37 'PlotBCID-vsBCID.gif': '<a href="../files?u=%s/%s/%s">vsBCID</a>',
38 'PlotBCID-vsBCID.pdf': None, # suppress linking until we get better quality PDF
39 'PlotBCID-vsBunchPos.gif': '<a href="../files?u=%s/%s/%s">vsBunchPos</a>',
40 'PlotBCID-vsBunchPos.pdf': None,
41 #'PlotBCID-vsBCID.pdf': '(<a href="/jobfiles/%s/%s/%s">pdf</a>)',
42 'MergeNt-nt.root': None, # suppress linking
43 'BeamSpotNt-nt.root': None, # suppress linking
44 'AveBeamSpot-beamspot.db': None, # suppress linking
45 #'AveBeamSpot-dqflags.db' : None, # suppress linking
46 #'AveBeamSpot-dqflags.txt' : None, # suppress linking
47 'DQBeamSpot-dqflags.db' : None, # suppress linking
48 'DQBeamSpot-dqflags.txt' : None, # suppress linking
49 'DQBeamSpotReproc-dqflags.db' : None, # suppress linking
50 'PlotOnlineOfflineCompare.gif': None,
51 'PlotOnlineOfflineCompare.pdf': None
52}
53
54# Beamspot tag is now taken from "current" BLK tag alias
55#beamspottag = 'IndetBeampos-ES1-UPD2'
56dqtag = 'HEAD'
57beamspottagonline = 'IndetBeamposOnl-LiveMon-001-00'
58
59class TaskPostProcessing(PostProcessingStep):
60 def run(self):
61 postProcSteps = self.taskDict['TASKPOSTPROCSTEPS'].split()
62 for step in postProcSteps:
63 self.log('Running postprocessing step: %s' % step)
64 self.executedSteps = runPostProcStep(self.taskman,self.taskDict,self.oldStatus,self.executedSteps,step,self.postprocLib,self.jobName)
65
66
67class JobPostProcessing(PostProcessingStep):
68 def run(self):
69
71 print('Jobname: ',self.jobName)
72 try:
73 postProcSteps = self.getJobConfig(self.jobName)['jobpostprocsteps'].split()
74 except Exception:
75 self.log('Warning: No config file or jobpostprocsteps parameter found for %s/%s' % (self.dsName,self.taskName))
76 self.log('Continue anyway with the steps: PlotBeamSpotMon LinkResults')
77 steps = 'PlotBeamSpotMon LinkResults'
78 postProcSteps = steps.split()
79 #raise PostProcessingError('ERROR: No config file or jobpostprocsteps parameter found for %s/%s' % (self.dsName,self.taskName),self.executedSteps)
80 for step in postProcSteps:
81 self.log('Running postprocessing step: %s' % step)
82 self.executedSteps = runPostProcStep(self.taskman,self.taskDict,self.oldStatus,self.executedSteps,step,self.postprocLib,self.jobName)
83
84
85class T0VertexDefaultProcessing(PostProcessingStep):
86 def run(self):
87 postProcSteps = 'PlotBeamSpotMon MergeNt BeamSpotNt PlotBeamSpot LinkResults PlotOnlineOfflineCompare AveBeamSpot CheckT0Status UploadBeamSpot DQBeamSpot UploadDataQuality BeamSpotGlobalNt '
88 for step in postProcSteps.split():
89 self.log('Running postprocessing step: %s' % step)
90 self.executedSteps = runPostProcStep(self.taskman,self.taskDict,self.oldStatus,self.executedSteps,step,self.postprocLib,self.jobName)
91
92class T0VertexTestProcessing(PostProcessingStep):
93 def run(self):
94 postProcSteps = 'PlotBeamSpotMon MergeNt BeamSpotNt PlotBeamSpot LinkResults PlotOnlineOfflineCompare AveBeamSpot CheckT0Status DQBeamSpot BeamSpotGlobalNt '
95 for step in postProcSteps.split():
96 self.log('Running postprocessing step: %s' % step)
97 self.executedSteps = runPostProcStep(self.taskman,self.taskDict,self.oldStatus,self.executedSteps,step,self.postprocLib,self.jobName)
98
99class ReprocVertexDefaultProcessing(PostProcessingStep):
100 def run(self):
101 postProcSteps = 'PlotBeamSpotMon MergeNt BeamSpotNt PlotBeamSpot PlotBeamSpotCompareReproc LinkResults AveBeamSpot DQBeamSpotReproc'
102 for step in postProcSteps.split():
103 self.log('Running postprocessing step: %s' % step)
104 self.executedSteps = runPostProcStep(self.taskman,self.taskDict,self.oldStatus,self.executedSteps,step,self.postprocLib,self.jobName)
105
106
107class BCIDDefaultProcessing(PostProcessingStep):
108 def run(self):
109 postProcSteps = 'MergeNt BeamSpotNtNoAve PlotBCID LinkResults'
110 for step in postProcSteps.split():
111 self.log('Running postprocessing step: %s' % step)
112 self.executedSteps = runPostProcStep(self.taskman,self.taskDict,self.oldStatus,self.executedSteps,step,self.postprocLib,self.jobName)
113
114
115class PlotBeamSpotMon(PostProcessingStep):
116 def run(self):
117 outFileNameGIF = self.getFileName('.gif')
118 outFileNamePDF = self.getFileName('.pdf')
119 histFileName = self.getFileName('-beamspotmonitoring.root')
120 if os.path.exists('/'.join([self.taskDir,histFileName])):
121 self.logExec('cd %s; rm -f %s %s %s' % (self.taskDir,histFileName,outFileNameGIF,outFileNamePDF))
122 postProcFiles = self.taskFileList('*-beamspotmonitoring.root','POSTPROCESSING',self.jobName)
123 self.log(text='Found %i monitoring files from POSTPROCESSING jobs ...' % len(postProcFiles))
124 completedFiles = self.taskFileList('*-beamspotmonitoring.root','COMPLETED',self.jobName)
125 self.log(text='Found %i monitoring files from COMPLETED jobs ...' % len(completedFiles))
126 histFiles = sorted(postProcFiles+completedFiles)
127 if len(histFiles)>0:
128 #self.logExec('cd %s; hadd -f %s %s' % (self.taskDir,histFileName,' '.join(histFiles)))
129 self.hadd(self.taskDir,histFileName,histFiles)
130 self.logExec('cd %s; plotBeamSpotMon.py -b -o %s,%s %s' % (self.taskDir,outFileNameGIF,outFileNamePDF,histFileName))
131 self.addResult(outFileNameGIF)
132 self.addResult(outFileNamePDF)
133 else:
134 self.log(text='No monitoring files yet ...')
135
136
137class PlotBeamSpotCompareReproc(PostProcessingStep):
138 def run(self):
139 outFileNameGIF = self.getFileName('.gif')
140 outFileNamePDF = self.getFileName('.pdf')
141 ntFileName = self.getFileName('-nt.root','BeamSpotNt')
142
143 # Resolve beamspot tag. Since reprocessing results will be uploaded to the "next" tag, the "current"
144 # tag will be the one containing the best results to date and hence we compare to that
145 try:
146 beamspottag = COOLUtils.resolveCurrentBeamSpotFolder()
147 except Exception:
148 raise PostProcessingError('ERROR: Unable to resolve beamspot folder tag',self.executedSteps,TaskManager.StatusCodes['POSTPROCFAILED'])
149
150 if os.path.exists('/'.join([self.taskDir,ntFileName])):
151 self.logExec('cd %s; plotBeamSpotCompare.py -b -o %s,%s --config="Reproc" %s %s' % (self.taskDir, outFileNameGIF,outFileNamePDF,beamspottag,ntFileName))
152 self.addResult(outFileNameGIF)
153 self.addResult(outFileNamePDF)
154 self.logExec('cd %s; mkdir -p %s' % (self.taskDir, self.getFileName('-compplots')))
155 self.logExec('cd %s; plotBeamSpotCompare.py -b --outtag="%s/repro_" --output=".pdf,.png" --config="Reproc" --multicanv --html %s %s' % (self.taskDir, self.getFileName('-compplots'), beamspottag,ntFileName))
156 self.addResult(self.getFileName('.html'))
157
158class PlotOnlineOfflineCompare(PostProcessingStep):
159 def run(self):
160 outFileNameGIF = self.getFileName('.gif')
161 outFileNamePDF = self.getFileName('.pdf')
162 ntFileName = self.getFileName('-nt.root','BeamSpotNt')
163 if os.path.exists('/'.join([self.taskDir,ntFileName])):
164 cmd = 'cd %s; plotBeamSpotCompare.py -b -o %s,%s --online2 --config="OnlineOffline" %s %s' % (self.taskDir, outFileNameGIF, outFileNamePDF, ntFileName, beamspottagonline)
165 status=self.logExec(cmd,doPrint=True,abortOnError=False)
166 resultLinks = self.taskDict['RESULTLINKS']
167 if status==0:
168 self.addResult(outFileNameGIF)
169 self.addResult(outFileNamePDF)
170 link = '<a class="ok" href="../files/?u=%s/%s/%s.gif">vsOnline</a>' % (self.dsName,self.taskName,self.baseNameStep)
171 if resultLinks.find(link)==-1:
172 resultLinks = ' '.join([resultLinks,link])
173 link = '(<a class="ok" href="/jobfiles/%s/%s/%s.pdf">pdf</a>)' % (self.dsName,self.taskName,self.baseNameStep)
174 if resultLinks.find(link)==-1:
175 resultLinks = ' '.join([resultLinks,link])
176 else:
177 link = '<a class="warn" href="../files/?u=%s/%s/%s.log">No vsOnline</a>' % (self.dsName,self.taskName,self.baseNameStep)
178 if resultLinks.find(link)==-1:
179 resultLinks = ' '.join([resultLinks,link])
180 self.taskman.setValue(self.dsName,self.taskName,'RESULTLINKS',resultLinks)
181
182# Still to be tested
183class PlotGlobalMon(PostProcessingStep):
184 def run(self):
185 outFileNameGIF = self.getFileName('.gif')
186 outFileNamePDF = self.getFileName('.pdf')
187 # Get monitoring file name from jobConfig?
188 self.logExec('cd %s; hadd -f %s-globalmonitoring.root */*-globalmonitoring.root' % (self.taskDir,self.baseName))
189 self.logExec('cd %s; plotBeamSpotMon.py -b -o %s,%s %s-globalmonitoring.root' % (self.taskDir,outFileNameGIF,outFileNamePDF,self.baseName))
190 self.addResult(outFileNameGIF)
191 self.addResult(outFileNamePDF)
192
193
194class MergeNt(PostProcessingStep):
195 def run(self):
196 ntFileName = self.getFileName('-nt.root')
197 if os.path.exists('/'.join([self.taskDir,ntFileName])):
198 self.logExec('cd %s; rm -f %s' % (self.taskDir,ntFileName))
199 postProcFiles = self.taskFileList('*-nt.root','POSTPROCESSING',self.jobName)
200 self.log(text='Found %i ntuple files from POSTPROCESSING jobs ...' % len(postProcFiles))
201 completedFiles = self.taskFileList('*-nt.root','COMPLETED',self.jobName)
202 self.log(text='Found %i ntuple files from COMPLETED jobs ...' % len(completedFiles))
203 ntFiles = sorted(postProcFiles+completedFiles)
204 if len(ntFiles)>0:
205 #self.logExec('cd %s; hadd -f %s %s' % (self.taskDir,ntFileName,' '.join(ntFiles)))
206 self.hadd(self.taskDir,ntFileName,ntFiles)
207 self.addResult(ntFileName)
208 else:
209 raise PostProcessingError('WARNING: No beam spot ntuple files to merge',self.executedSteps)
210
211
212class PlotBeamSpot(PostProcessingStep):
213 def run(self):
214 ntFileName = self.getFileName('-nt.root','BeamSpotNt')
215 outFileNameGIF = self.getFileName('.gif')
216 outFileNamePDF = self.getFileName('.pdf')
217 if os.path.exists('/'.join([self.taskDir,ntFileName])):
218 self.logExec('cd %s; beamspotnt.py -b -o %s,%s -f %s summary' % (self.taskDir,outFileNameGIF,outFileNamePDF,ntFileName))
219 self.addResult(outFileNameGIF)
220 self.addResult(outFileNamePDF)
221 else:
222 raise PostProcessingError('ERROR: No ntuple file %s - did BeamSpotNt step run?\n' % ntFileName,self.executedSteps)
223
224
225class LinkResults(PostProcessingStep):
226 def run(self):
227 resultFiles = self.taskDict['RESULTFILES']
228 resultLinks = ''
229 if 'AveBeamSpot' in self.executedSteps:
230 self.log(text='WARNING: You should always run AveBeamSpot after LinkResults to avoid overwriting results\n',doPrint=True)
231 if not resultFiles:
232 return
233 for r in resultFiles.split():
234 what = '.'.join(r.split('.')[-2:])
235 if what in linkTemplates:
236 if linkTemplates[what]:
237 resultLinks = ' '.join([resultLinks, linkTemplates[what] % (self.dsName,self.taskName,r)])
238 else:
239 resultLinks = ' '.join([resultLinks,'<a href="../files?u=%s/%s/%s">%s</a>' % (self.dsName,self.taskName,r,what)])
240 self.taskman.setValue(self.dsName,self.taskName,'RESULTLINKS',resultLinks)
241
242
243class AveBeamSpot(PostProcessingStep):
244 def run(self):
245 ntFileName = self.getFileName('-nt.root','BeamSpotNt')
246 beamSpotDbFileName = self.getFileName('-beamspot.db')
247 #dataQualityDbFileName = self.getFileName('-dqflags.db')
248
249 if os.path.exists('/'.join([self.taskDir,beamSpotDbFileName])):
250 self.logExec('cd %s; rm -f %s' % (self.taskDir,beamSpotDbFileName))
251 #if os.path.exists('/'.join([self.taskDir,dataQualityDbFileName])):
252 # self.logExec('cd %s; rm -f %s' % (self.taskDir,dataQualityDbFileName))
253
254 if os.path.exists('/'.join([self.taskDir,ntFileName])):
255 cmd = 'cd %s; beamspotnt.py --tag=%s -f %s --newave ave' % (self.taskDir,beamSpotDbFileName[:-3],ntFileName)
256 #cmd = 'cd %s; aveBeamSpot.py -b -o %s %s' % (self.taskDir,beamSpotDbFileName,ntFileName)
257 #cmd = 'cd %s; aveBeamSpot.py -b -o %s -d %s %s' % (self.taskDir,beamSpotDbFileName,dataQualityDbFileName,ntFileName)
258 status = self.logExec(cmd,doPrint=True,abortOnError=False)
259 if status and status!=2 and status!=3:
260 # Some other error than simply no beam spot data
261 raise PostProcessingError('ERROR in postprocessing step AveBeamSpot while executing:\n\n%s\n' % (cmd),self.executedSteps)
262 resultLinks = self.taskDict['RESULTLINKS']
263 if status==0:
264 self.addResult(beamSpotDbFileName)
265 link = '<a class="ok" href="../files/?u=%s/%s/%s.log">Beam spot</a>' % (self.dsName,self.taskName,self.baseNameStep)
266 if resultLinks.find(link)==-1:
267 resultLinks = ' '.join([link,resultLinks])
268 if status==2:
269 link = '<a class="warn" href="../files/?u=%s/%s/%s.log">No beam spot</a>' % (self.dsName,self.taskName,self.baseNameStep)
270 if resultLinks.find(link)==-1:
271 resultLinks = ' '.join([link,resultLinks])
272 if status==3:
273 link = '<a class="warn" href="../files/?u=%s/%s/%s.log">No vtx/beam spot</a>' % (self.dsName,self.taskName,self.baseNameStep)
274 if resultLinks.find(link)==-1:
275 resultLinks = ' '.join([link,resultLinks])
276
277# # Add DQ flags to results and do linking
278# self.addResult(dataQualityDbFileName)
279#
280# dataQualityTxtFileName = dataQualityDbFileName.replace('.db','.txt')
281# stat,out = subprocess.getstatusoutput('grep -c "ID_BS_NOBEAMSPOT" %s/%s' % (self.taskDir, dataQualityTxtFileName) )
282#
283# # Catch errors (do it this way as the exit codes from grep are nasty)
284# try:
285# nRed=int(out)
286# except ValueError:
287# raise PostProcessingError('ERROR in postprocessing step AveBeamSpot while executing:\n\n%s\n' % (cmd),self.executedSteps)
288#
289# if nRed==0:
290# link='<a class="ok" href="../files?u=%s/%s/%s-dqflags.txt">DQFlags</a>' % (self.dsName,self.taskName,self.baseNameStep)
291# else:
292# link='<a class="bad" href="../files?u=%s/%s/%s-dqflags.txt">DQFlags</a>' % (self.dsName,self.taskName,self.baseNameStep)
293#
294# if resultLinks.find(link)==-1:
295# resultLinks = ' '.join([resultLinks, link])
296
297 # Set links by hand
298 self.taskman.setValue(self.dsName,self.taskName,'RESULTLINKS',resultLinks)
299 else:
300 raise PostProcessingError('ERROR: No ntuple file %s - did BeamSpotNt step run?\n' % ntFileName,self.executedSteps)
301
302
303class CheckT0Status(PostProcessingStep):
304 """Check in T0 task DB if T0 processing is done, if not raise PostponeProcessing exception."""
305 def run(self):
306 filter = 'AOD' # T0 uses AODs by default (at least for pp running)
307 try:
308 f = self.getJobConfig(self.jobName)['inputfiles'][0]
309 if 'ESD' in f:
310 filter = 'ESD'
311 except Exception:
312 self.log('WARNING: Unable to determine input file type - will assume default (%s)\n' % filter, doPrint=True)
313 cmd = 'beamspotman.py -n -f %s queryT0 %s %s' % (filter,self.dsName,self.taskName)
314 status = self.logExec(cmd,doPrint=True,abortOnError=False)
315 if status:
316 # The task is either not finished or there was a problem
317 if status==2:
318 # Task still running
319 raise PostponeProcessing('Tier-0 processing still in progress - restart postprocessing later',self.executedSteps)
320 else:
321 # Unable to determine status
322 raise PostProcessingError('ERROR: Unable to determine Tier-0 task status',self.executedSteps)
323
324
325class UploadBeamSpot(PostProcessingStep):
326 def run(self):
327 beamSpotDbFileName = self.getFileName('-beamspot.db','AveBeamSpot')
328 cooltags = self.taskDict['COOLTAGS']
329 if not cooltags: cooltags = ''
330
331 # Resolve beamspot tag
332 try:
333 beamspottag = COOLUtils.resolveCurrentBeamSpotFolder()
334 except Exception:
335 raise PostProcessingError('ERROR: Unable to resolve beamspot folder tag',self.executedSteps,TaskManager.StatusCodes['POSTPROCFAILED'])
336
337 # Check that we haven't uploaded yet
338 if beamspottag in cooltags.split():
339 self.log('WARNING: Beam spot already uploaded to COOL: %s - continue anyway' % beamspottag)
340 # This command is kept for possible future use: raise PostProcessingError('ERROR: Beam spot already uploaded to COOL - if this is intentional, please upload manually.',
341 # self.executedSteps,TaskManager.StatusCodes['POSTPROCFAILED'])
342
343 # Check that this is the express stream
344 if self.dsName.split('.')[-1] != 'express_express' and self.dsName.split('.')[-1] != 'calibration_BeamSpot':
345 print (self.dsName.split('.')[-1] )
346 self.log(text="WARNING: Not running on the express or BeamSpot stream, so won't upload anything - if this is intentional, please upload manually\n",doPrint=True)
347 return
348 if os.path.exists('/'.join([self.taskDir,beamSpotDbFileName])):
349 # Dumping of the beam spot SQLite file is done by beamspotman
350 #self.logExec('cd %s; dumpBeamSpot.py %s' % (self.taskDir,beamSpotDbFileName))
351 self.logExec('beamspotman.py -b -n -t %s upload %s %s' % (beamspottag,self.dsName,self.taskName))
352 else:
353 #raise PostProcessingError('ERROR: No beam spot COOL SQLite file %s - did AveBeamSpot succeed?\n' % beamSpotDbFileName,self.executedSteps)
354 self.log(text='ERROR: No beam spot COOL SQLite file %s\n Nothing to upload - was beam spot determination successful?\n' % beamSpotDbFileName,doPrint=True)
355
356# # Once uploaded the beamspot can upload the DQ flags
357# dataQualityDbFileName = self.getFileName('-dqflags.db','AveBeamSpot')
358# if os.path.exists('/'.join([self.taskDir,dataQualityDbFileName])):
359# self.logExec('beamspotman.py -b -n --dqtag %s dqflag %s %s' % (dqtag,self.dsName,self.taskName))
360# else:
361# self.log(text='ERROR: No beam spot DQ flag SQLite file %s\n Nothing to upload - was beam spot or DQ determination successful?\n' % dqDbFileName,doPrint=True)
362
363class DQBeamSpot(PostProcessingStep):
364 """Automatically determine DQ info (after uploading beamspot)"""
365 def run(self, absent=False):
366 ntFileName = self.getFileName('-nt.root','BeamSpotNt')
367 dataQualityDbFileName = self.getFileName('-dqflags.db')
368
369 if os.path.exists('/'.join([self.taskDir,dataQualityDbFileName])):
370 self.logExec('cd %s; rm -f %s' % (self.taskDir,dataQualityDbFileName))
371
372 if os.path.exists('/'.join([self.taskDir,ntFileName])):
373 cmd = 'cd %s; dqBeamSpot.py -b %s -o %s %s' % (self.taskDir,'-a' if absent else '',dataQualityDbFileName,ntFileName)
374 status = self.logExec(cmd,doPrint=True,abortOnError=False)
375
376 if status:
377 raise PostProcessingError('ERROR in postprocessing step DQBeamSpot while executing:\n\n%s\n' % (cmd),self.executedSteps)
378
379 # Add DQ flags to results and do linking
380 self.addResult(dataQualityDbFileName)
381
382 dataQualityTxtFileName = dataQualityDbFileName.replace('.db','.txt')
383 cmd = 'grep -c "ID_BS_NOBEAMSPOT" %s/%s' % (self.taskDir, dataQualityTxtFileName)
384 status,out = subprocess.getstatusoutput(cmd)
385
386 # Catch errors (do it this way as the exit codes from grep are nasty)
387 try:
388 nRed=int(out)
389 except ValueError:
390 raise PostProcessingError('ERROR in postprocessing step DQBeamSpot while executing:\n\n%s\n' % (cmd),self.executedSteps)
391
392 if nRed==0:
393 link='<a class="ok" href="../files?u=%s/%s/%s-dqflags.txt">DQFlags</a>' % (self.dsName,self.taskName,self.baseNameStep)
394 else:
395 link='<a class="bad" href="../files?u=%s/%s/%s-dqflags.txt">DQFlags</a>' % (self.dsName,self.taskName,self.baseNameStep)
396
397 resultLinks = self.taskDict['RESULTLINKS']
398 if resultLinks.find(link)==-1:
399 resultLinks = ' '.join([resultLinks, link])
400
401 # Set links by hand
402 self.taskman.setValue(self.dsName,self.taskName,'RESULTLINKS',resultLinks)
403 else:
404 raise PostProcessingError('ERROR: No ntuple file %s - did BeamSpotNt step run?\n' % ntFileName,self.executedSteps)
405
407 """Automatically determine DQ info (after uploading beamspot). For reprocessing also upload absent defects to remove previosuly set ones"""
408 def run(self):
409 return DQBeamSpot.run(self, absent=True)
410
411class UploadDataQuality(PostProcessingStep):
412 """Upload beampsot data quality info"""
413 def run(self):
414 dataQualityDbFileName = self.getFileName('-dqflags.db', 'DQBeamSpot')
415
416 # Upload the DQ flags
417 if os.path.exists('/'.join([self.taskDir,dataQualityDbFileName])):
418 self.logExec('beamspotman.py -b -n --dqtag %s dqflag %s %s' % (dqtag,self.dsName,self.taskName))
419 else:
420 self.log(text='ERROR: No beam spot DQ flag SQLite file %s\n Nothing to upload - was DQ determination successful?\n' % dataQualityDbFileName,doPrint=True)
421
422
423class BeamSpotNtNoAve(PostProcessingStep):
424 def run(self):
425 ntFileName = self.getFileName('-nt.root','MergeNt')
426 bsNtFileName = self.getFileName('-nt.root','BeamSpotNt')
427 if os.path.exists('/'.join([self.taskDir,ntFileName])):
428 self.logExec("cd %s; rm -f %s; beamspotnt.py -f %s --status '' --fillCOOL --addScanVars merge %s" % (self.taskDir,bsNtFileName,bsNtFileName,ntFileName))
429 self.addResult(bsNtFileName)
430 else:
431 raise PostProcessingError('ERROR: No merged ntuple file %s - did MergeNt step run?\n' % ntFileName,self.executedSteps)
432
433
434
435class BeamSpotNt(PostProcessingStep):
436 def run(self):
437 ntFileName = self.getFileName('-nt.root','MergeNt')
438 bsNtFileName = self.getFileName('-nt.root')
439 if os.path.exists('/'.join([self.taskDir,ntFileName])):
440 self.logExec("cd %s; rm -f %s; beamspotnt.py -f %s --status '' --fillCOOL --useAve merge %s" % (self.taskDir,bsNtFileName,bsNtFileName,ntFileName))
441 self.addResult(bsNtFileName)
442 else:
443 raise PostProcessingError('ERROR: No merged ntuple file %s - did MergeNt step run?\n' % ntFileName,self.executedSteps)
444
445
446class BeamSpotGlobalNt(PostProcessingStep):
447 def run(self):
448 # Don't merge into global ntuple if no beamspot uploaded to COOL
449 cooltags = self.taskDict['COOLTAGS']
450 if not cooltags: cooltags = ''
451
452 # Check if the task has uploded to COOL
453 # if not beamspottag in cooltags.split():
454 if not cooltags:
455 self.log(text='WARNING: Beam spot not uploaded - result not merged to global ntuple\n',doPrint=True)
456 return
457
458 ntFileName = self.getFileName('-nt.root','MergeNt')
459 globalNtDir = '/afs/cern.ch/user/a/atlidbs/nt/t0'
460 beamspottag = cooltags.split()[len(cooltags.split())-1]
461 globalNtFileName = '%s/beamspotnt-%s.root' % (globalNtDir,beamspottag)
462 if not os.path.exists(globalNtDir):
463 raise PostProcessingError('ERROR: Cannot access directory with global beam spot ntuple: %s' % globalNtDir, self.executedSteps)
464 if os.path.exists('/'.join([self.taskDir,ntFileName])):
465 self.logExec("cd %s; beamspotnt.py -f %s --status '' --fillCOOL --useAve merge %s" % (self.taskDir,globalNtFileName,ntFileName))
466 # self.logExec("cd %s; beamspotnt.py -f %s --status '' --fillCOOL --useAve merge %s" % (self.taskDir,globalNtFileName2,ntFileName))
467 else:
468 raise PostProcessingError('ERROR: No merged ntuple file %s - did MergeNt step run?\n' % ntFileName, self.executedSteps)
469
470
471class PlotBCID(PostProcessingStep):
472 def run(self):
473 bsNtFileName = self.getFileName('-nt.root','BeamSpotNt')
474 dumpFileName = self.getFileName('-data.txt')
475 outFileNameLbGIF = self.getFileName('-vsLb.gif')
476 outFileNameLbPDF = self.getFileName('-vsLb.pdf')
477 outFileNameTimeGIF = self.getFileName('-vsTime.gif')
478 outFileNameTimePDF = self.getFileName('-vsTime.pdf')
479 outFileNameBCIDGIF = self.getFileName('-vsBCID.gif')
480 outFileNameBCIDPDF = self.getFileName('-vsBCID.pdf')
481 outFileNameTrainGIF = self.getFileName('-vsBunchPos.gif')
482 outFileNameTrainPDF = self.getFileName('-vsBunchPos.pdf')
483 if os.path.exists('/'.join([self.taskDir,bsNtFileName])):
484 self.logExec("cd %s; rm -f %s; beamspotnt.py -v -f %s dump > %s" % (self.taskDir,dumpFileName,bsNtFileName,dumpFileName))
485 self.addResult(dumpFileName)
486 self.logExec("cd %s; beamspotnt.py --batch -o %s,%s -f %s summary" % (self.taskDir,outFileNameLbGIF,outFileNameLbPDF,bsNtFileName))
487 self.addResult(outFileNameLbGIF)
488 self.addResult(outFileNameLbPDF)
489 self.logExec("cd %s; beamspotnt.py --batch --time -o %s,%s -f %s summary" % (self.taskDir,outFileNameTimeGIF,outFileNameTimePDF,bsNtFileName))
490 self.addResult(outFileNameTimeGIF)
491 self.addResult(outFileNameTimePDF)
492 self.logExec("cd %s; beamspotnt.py --batch -m 0.2 --perbcid -o %s,%s -f %s summary" % (self.taskDir,outFileNameBCIDGIF,outFileNameBCIDPDF,bsNtFileName))
493 self.addResult(outFileNameBCIDGIF)
494 self.addResult(outFileNameBCIDPDF)
495 self.logExec("cd %s; beamspotnt.py --batch --vsbunchpos -o %s,%s -f %s summary" % (self.taskDir,outFileNameTrainGIF,outFileNameTrainPDF,bsNtFileName))
496 self.addResult(outFileNameTrainGIF)
497 self.addResult(outFileNameTrainPDF)
498 else:
499 raise PostProcessingError('ERROR: No beam spot ntuple file %s - did BeamSpotNt step run?\n' % bsNtFileName,self.executedSteps)
void print(char *figname, TCanvas *c1)
jobName
JobPostProcessing runs only on completed tasks in status POSTPROCESSING if self.oldStatus==TaskManage...
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
Definition run.py:1