00001 from CalibMuon.DTCalibration.Workflow.DTTTrigProd import DTTTrigProd
00002 from CalibMuon.DTCalibration.Workflow.DTTTrigTimeBoxesWriter import DTTTrigTimeBoxesWriter
00003 from CalibMuon.DTCalibration.Workflow.DTResidualCalibration import DTResidualCalibration
00004 from CalibMuon.DTCalibration.Workflow.DTTTrigResidualCorr import DTTTrigResidualCorr
00005 from CalibMuon.DTCalibration.Workflow.DTTTrigValid import DTTTrigValid
00006 from CalibMuon.DTCalibration.Workflow.DTValidSummary import DTValidSummary
00007 from CalibMuon.DTCalibration.Workflow.DTVDriftSegmentCalibration import DTVDriftSegmentCalibration
00008 from CalibMuon.DTCalibration.Workflow.DTVDriftSegmentWriter import DTVDriftSegmentWriter
00009 from CalibMuon.DTCalibration.Workflow.DTVDriftMeanTimerCalibration import DTVDriftMeanTimerCalibration
00010 from CalibMuon.DTCalibration.Workflow.DTVDriftMeanTimerWriter import DTVDriftMeanTimerWriter
00011 from CalibMuon.DTCalibration.Workflow.DTNoiseCalibration import DTNoiseCalibration
00012 from CalibMuon.DTCalibration.Workflow.DTDQMValidation import DTDQMValidation
00013 from CalibMuon.DTCalibration.Workflow.DTDQMMerge import DTDQMMerge
00014 from CalibMuon.DTCalibration.Workflow.DTDQMHarvesting import DTDQMHarvesting
00015 from CalibMuon.DTCalibration.Workflow.DTDqm import DTDqm
00016 from CalibMuon.DTCalibration.Workflow.DTT0DBValidation import DTT0DBValidation
00017 from CalibMuon.DTCalibration.Workflow.CrabWatch import CrabWatch
00018 from CalibMuon.DTCalibration.Workflow.tools import listFilesInCastor,haddInCastor,listFilesLocal,haddLocal,copyFilesFromCastor,copyFilesLocal,parseInput,getDatasetStr
00019 import sys,os,time,optparse
00020
00021 class DTCalibrationWorker:
00022 def __init__(self,run,config):
00023 self.config = config
00024 self.refRun = run
00025
00026 def run(self,type,mode,execute):
00027 config = None
00028 if self.config: config = self.config
00029 refRun = 1
00030 if self.refRun: refRun = self.refRun
00031
00032 if type == 'ttrig': self.runTtrigWorkflow(mode,refRun,config,execute)
00033 elif type == 'vdrift': self.runVDriftWorkflow(mode,refRun,config,execute)
00034 elif type == 'noise': self.runNoiseWorkflow(mode,refRun,config,execute)
00035 elif type == 't0': self.runT0Workflow(mode,refRun,config,execute)
00036 elif type == 'validation': self.runValidationWorkflow(mode,refRun,config,execute)
00037 elif type == 'dbvalidation':
00038 inputFiles = []
00039 if config.dbFiles: inputFiles = config.dbFiles
00040 self.runDBValidationWorkflow(mode,refRun,inputFiles,config,execute)
00041
00042 return 0
00043
00044 def dqmOutputDir(self,type,dirLabel,config):
00045 dqm_output_dir = ''
00046 if config.stageOutLocal:
00047 from crab_util import findLastWorkDir
00048 cwd = os.getcwd()
00049 crab_task_dir = config.base_dir + '/' + dirLabel
00050 os.chdir(crab_task_dir)
00051 crabdir = findLastWorkDir('crab_0_')
00052 if not crabdir: raise RuntimeError,'Could not find CRAB dir in %s' % crab_task_dir
00053 os.chdir(cwd)
00054 dqm_output_dir = crabdir + "/res"
00055 elif config.stageOutCAF:
00056 datasetstr = getDatasetStr(config.datasetpath)
00057 dqm_output_dir = config.castorpath + '/DTCalibration/' + datasetstr + '/Run' + str(run) + '/' + type + '/' + dirLabel + '/' + 'v' + str(trial)
00058
00059 return dqm_output_dir
00060
00061 def runTtrigProd(self,run,runselection,trial,config,runStep=True):
00062
00063 print "Processing tTrig production"
00064
00065 datasetstr = getDatasetStr(config.datasetpath)
00066 config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/TTrigCalibration/' + 'TimeBoxes' + '/' + 'v' + str(trial)
00067
00068 task_dir = config.base_dir + '/TimeBoxes'
00069 dtTtrigProd = DTTTrigProd(run,task_dir,config)
00070 dtTtrigProd.writeCfg()
00071
00072 if runStep:
00073 project_prod = dtTtrigProd.run()
00074
00075 print "Sent calibration jobs with project",project_prod
00076 print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold
00077
00078 crabProd = CrabWatch(project_prod)
00079 crabProd.setThreshold(config.jobsFinishedThreshold)
00080 crabProd.start()
00081 crabProd.join()
00082
00083 result_file = config.result_dir + '/DTTimeBoxes_%s.root'%run
00084 if config.stageOutLocal:
00085 output_dir = project_prod + "/res"
00086 haddLocal(output_dir,result_file)
00087 elif config.stageOutCAF:
00088 castor_dir = config.castorpath + "/" + config.userdircaf
00089 haddInCastor(castor_dir,result_file,'DTTimeBoxes','rfio://castorcms/','?svcClass=cmscafuser')
00090
00091 return project_prod
00092
00093 return None
00094
00095 def runTtrigWriter(self,run,config,runStep=True):
00096
00097 print "Processing tTrig correction"
00098 dtTtrigWriter = DTTTrigTimeBoxesWriter(run,config.run_dir,config.result_dir,config)
00099 dtTtrigWriter.writeCfg()
00100
00101 if runStep:
00102 dtTtrigWriter.run()
00103
00104 print "Finished processing:"
00105 for pset in dtTtrigWriter.configs: print "--->",pset
00106
00107 def runResidualCalib(self,run,runselection,trial,input_db,label,result_file,config,runStep=True):
00108
00109 print "Processing tTrig calibration"
00110
00111 datasetstr = getDatasetStr(config.datasetpath)
00112 config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/TTrigCalibration/' + label + '/' + 'v' + str(trial)
00113
00114 task_dir = config.base_dir + '/' + label
00115 dtResidualCalib = DTResidualCalibration(run=run,
00116 dir=task_dir,
00117 input_db=input_db,
00118 config=config)
00119 dtResidualCalib.writeCfg()
00120
00121 if runStep:
00122 project_residualCalib = dtResidualCalib.run()
00123
00124 print "Sent calibration jobs with project",project_residualCalib
00125 print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold
00126
00127 crabResidualCalib = CrabWatch(project_residualCalib)
00128 crabResidualCalib.setThreshold(config.jobsFinishedThreshold)
00129 crabResidualCalib.start()
00130 crabResidualCalib.join()
00131
00132 if config.stageOutLocal:
00133 output_dir = project_residualCalib + "/res"
00134 haddLocal(output_dir,result_file,'residuals')
00135 elif config.stageOutCAF:
00136 castor_dir = config.castorpath + "/" + config.userdircaf
00137 haddInCastor(castor_dir,result_file,'residuals','rfio://castorcms/','?svcClass=cmscafuser')
00138
00139 return project_residualCalib
00140
00141 return None
00142
00143 def runTtrigResidualCorr(self,run,input_db,root_file,config,runStep=True):
00144
00145 print "Processing tTrig residual correction"
00146 dtTtrigResidualCorr = DTTTrigResidualCorr(run=run,
00147 dir=config.run_dir,
00148 input_db=input_db,
00149 residuals=root_file,
00150 result_dir=config.result_dir,
00151 config=config)
00152 dtTtrigResidualCorr.writeCfg()
00153
00154 if runStep:
00155 dtTtrigResidualCorr.run()
00156
00157 print "Finished processing:"
00158 for pset in dtTtrigResidualCorr.configs: print "--->",pset
00159
00160 def runTtrigValid(self,run,runselection,trial,input_db,label,config,runStep=True):
00161
00162 print "Processing tTrig validation"
00163
00164 datasetstr = getDatasetStr(config.datasetpath)
00165 config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/TTrigValidation/' + label + '/' + 'v' + str(trial)
00166
00167 task_dir = config.base_dir + '/' + label
00168 dtTtrigValid = DTTTrigValid(run=run,
00169 dir=task_dir,
00170 input_db=input_db,
00171 config=config)
00172 dtTtrigValid.writeCfg()
00173
00174 if runStep:
00175 project_valid = dtTtrigValid.run()
00176
00177 print "Sent validation jobs with project",project_valid
00178 print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold
00179
00180 crabValid = CrabWatch(project_valid)
00181 crabValid.setThreshold(config.jobsFinishedThreshold)
00182 crabValid.start()
00183 crabValid.join()
00184
00185 """
00186 if config.stageOutLocal:
00187 output_dir = project_valid + "/res"
00188 haddLocal(output_dir,result_file,'residuals')
00189 elif config.stageOutCAF:
00190 castor_dir = config.castorpath + "/" + config.userdircaf
00191 haddInCastor(castor_dir,result_file,'residuals','rfio://castorcms/','?svcClass=cmscafuser')
00192 """
00193
00194 return project_valid
00195
00196 return None
00197
00198 def runTtrigValidSummary(self,run,input_file,output_file,config,runStep=True):
00199
00200 print "Processing Validation Summary"
00201 dtTtrigValidSummary = DTValidSummary(run,config.run_dir,input_file,output_file,config)
00202 dtTtrigValidSummary.writeCfg()
00203
00204 if runStep:
00205 dtTtrigValidSummary.run()
00206
00207 print "...Validation Summary finished"
00208
00209 def runVDriftSegmentCalib(self,run,runselection,trial,label,result_file,config,runStep=True):
00210
00211 print "Processing vDrift calibration"
00212
00213 datasetstr = getDatasetStr(config.datasetpath)
00214 config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/VDriftCalibration/' + label + '/' + 'v' + str(trial)
00215
00216 task_dir = config.base_dir + '/' + label
00217 dtVDriftSegment = DTVDriftSegmentCalibration(run=run,
00218 dir=task_dir,
00219 config=config)
00220 dtVDriftSegment.writeCfg()
00221
00222 if runStep:
00223 project_segment = dtVDriftSegment.run()
00224
00225 print "Sent validation jobs with project",project_segment
00226 print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold
00227
00228 crabVDriftSegment = CrabWatch(project_segment)
00229 crabVDriftSegment.setThreshold(config.jobsFinishedThreshold)
00230 crabVDriftSegment.start()
00231 crabVDriftSegment.join()
00232
00233 if config.stageOutLocal:
00234 output_dir = project_segment + "/res"
00235 haddLocal(output_dir,result_file,'DTVDriftHistos')
00236 elif config.stageOutCAF:
00237 castor_dir = config.castorpath + "/" + config.userdircaf
00238 haddInCastor(castor_dir,result_file,'DTVDriftHistos','rfio://castorcms/','?svcClass=cmscafuser')
00239
00240 return project_segment
00241
00242 return None
00243
00244 def runVDriftSegmentWriter(self,run,root_file,config,runStep=True):
00245
00246 print "Processing vDrift writer"
00247 dtVDriftSegmentWriter = DTVDriftSegmentWriter(run=run,
00248 dir=config.run_dir,
00249 input_file=root_file,
00250 output_dir=config.result_dir,
00251 config=config)
00252 dtVDriftSegmentWriter.writeCfg()
00253
00254 if runStep:
00255 dtVDriftSegmentWriter.run()
00256
00257 print "Finished processing:"
00258 for pset in dtVDriftSegmentWriter.configs: print "--->",pset
00259
00260 def runVDriftMeanTimerCalib(self,run,runselection,trial,label,result_file,config,runStep=True):
00261
00262 print "Processing vDrift calibration"
00263
00264 datasetstr = getDatasetStr(config.datasetpath)
00265 config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/VDriftCalibration/' + label + '/' + 'v' + str(trial)
00266
00267 task_dir = config.base_dir + '/' + label
00268 dtVDriftMeanTimer = DTVDriftMeanTimerCalibration(run=run,
00269 dir=task_dir,
00270 config=config)
00271 dtVDriftMeanTimer.writeCfg()
00272
00273 if runStep:
00274 project_meantimer = dtVDriftMeanTimer.run()
00275
00276 print "Sent validation jobs with project",project_meantimer
00277 print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold
00278
00279 crabVDriftMeanTimer = CrabWatch(project_meantimer)
00280 crabVDriftMeanTimer.setThreshold(config.jobsFinishedThreshold)
00281 crabVDriftMeanTimer.start()
00282 crabVDriftMeanTimer.join()
00283
00284 if config.stageOutLocal:
00285 output_dir = project_meantimer + "/res"
00286 haddLocal(output_dir,result_file,'DTTMaxHistos')
00287 elif config.stageOutCAF:
00288 castor_dir = config.castorpath + "/" + config.userdircaf
00289 haddInCastor(castor_dir,result_file,'DTTMaxHistos','rfio://castorcms/','?svcClass=cmscafuser')
00290
00291 return project_meantimer
00292
00293 return None
00294
00295 def runVDriftMeanTimerWriter(self,run,root_file,config,runStep=True):
00296
00297 print "Processing vDrift writer"
00298 dtVDriftMeanTimerWriter = DTVDriftMeanTimerWriter(run=run,
00299 dir=config.run_dir,
00300 input_file=root_file,
00301 output_dir=config.result_dir,
00302 config=config)
00303 dtVDriftMeanTimerWriter.writeCfg()
00304
00305 if runStep:
00306 dtVDriftMeanTimerWriter.run()
00307
00308 print "Finished processing:"
00309 for pset in dtVDriftMeanTimerWriter.configs: print "--->",pset
00310
00311 def runDQMClient(self,run,output_dir,config,runStep=True):
00312
00313 print "Processing DQM Merge"
00314
00315 if runStep:
00316 dqm_files = []
00317 if config.stageOutLocal:
00318 dqm_files = listFilesLocal(output_dir,'DQM')
00319 dqm_files = ['file:%s' % item for item in dqm_files]
00320 dtDqmFinal = DTDqm(run,config.run_dir,dqm_files,config.result_dir,config)
00321 dtDqmFinal.writeCfg()
00322 dtDqmFinal.run()
00323 elif config.stageOutCAF:
00324 dqm_files = listFilesInCastor(output_dir,'DQM','')
00325 dqm_files = [file.replace('/castor/cern.ch/cms','') for file in dqm_files]
00326 dtDqmFinal = DTDqm(run,config.run_dir,dqm_files,config.result_dir,config)
00327 dtDqmFinal.writeCfg()
00328 dtDqmFinal.run()
00329
00330 print "...DQM Merge finished"
00331 else:
00332 dqm_files = []
00333 dtDqmFinal = DTDqm(run,config.run_dir,dqm_files,config.result_dir,config)
00334 dtDqmFinal.writeCfg()
00335
00336 def runDQMHarvesting(self,run,output_dir,config,runStep=True):
00337
00338 print "Processing DQM harvesting"
00339
00340 if runStep:
00341 dqm_files = []
00342 if config.stageOutLocal:
00343 dqm_files = listFilesLocal(output_dir,'DQM')
00344 dqm_files = ['file:%s' % item for item in dqm_files]
00345 dtDqmFinal = DTDQMHarvesting(run,config.run_dir,dqm_files,config.result_dir,config)
00346 dtDqmFinal.writeCfg()
00347 dtDqmFinal.run()
00348 elif config.stageOutCAF:
00349 dqm_files = listFilesInCastor(output_dir,'DQM','')
00350 dqm_files = [file.replace('/castor/cern.ch/cms','') for file in dqm_files]
00351 dtDqmFinal = DTDQMHarvesting(run,config.run_dir,dqm_files,config.result_dir,config)
00352 dtDqmFinal.writeCfg()
00353 dtDqmFinal.run()
00354
00355 print "...DQM harvesting finished"
00356 else:
00357 dqm_files = []
00358 dtDqmFinal = DTDQMHarvesting(run,config.run_dir,dqm_files,config.result_dir,config)
00359 dtDqmFinal.writeCfg()
00360
00361 def runDQMMerge(self,run,output_dir,config,runStep=True):
00362
00363 print "Processing DQM merge"
00364
00365 if runStep:
00366 dqm_files = []
00367 if config.stageOutLocal:
00368 dqm_files = listFilesLocal(output_dir,'DQM')
00369 dqm_files = ['file:%s' % item for item in dqm_files]
00370 dtDQMMerge = DTDQMMerge(run,config.run_dir,dqm_files,config.result_dir,config)
00371 dtDQMMerge.writeCfg()
00372 dtDQMMerge.run()
00373 elif config.stageOutCAF:
00374 dqm_files = listFilesInCastor(output_dir,'DQM','')
00375 dqm_files = [file.replace('/castor/cern.ch/cms','') for file in dqm_files]
00376 dtDQMMerge = DTDQMMerge(run,config.run_dir,dqm_files,config.result_dir,config)
00377 dtDQMMerge.writeCfg()
00378 dtDQMMerge.run()
00379
00380 print "...DQM merge finished"
00381 else:
00382 dqm_files = []
00383 dtDQMMerge = DTDQMMerge(run,config.run_dir,dqm_files,config.result_dir,config)
00384 dtDQMMerge.writeCfg()
00385
00386
00387
00388
00389 def runTtrigWorkflow(self,mode,run,config,execute=True):
00390 trial = config.trial
00391 runselection = config.runselection
00392 ttrig_input_db = None
00393 if hasattr(config,'inputTTrigDB') and config.inputTTrigDB: ttrig_input_db = os.path.abspath(config.inputTTrigDB)
00394 result_dir = config.result_dir
00395 if mode == 'timeboxes':
00396 timeBoxes = os.path.abspath(result_dir + '/' + 'DTTimeBoxes_' + run + '.root')
00397 ttrig_timeboxes_db = os.path.abspath(result_dir + '/' + 'ttrig_timeboxes_' + run + '.db')
00398 residualsFirst = os.path.abspath(result_dir + '/' + 'DTResidualValidation_' + run + '.root')
00399 ttrig_residuals_db = os.path.abspath(result_dir + '/' + 'ttrig_residuals_' + run + '.db')
00400 residualsResidCorr = os.path.abspath(result_dir + '/' + 'DTResidualValidation_ResidCorr_' + run + '.root')
00401 summaryResiduals = os.path.abspath(result_dir + '/' + 'SummaryResiduals_' + run + '.root')
00402
00403 if not execute:
00404 print "Writing configuration files.."
00405 self.runTtrigProd(run,runselection,trial,config,False)
00406 self.runTtrigWriter(run,config,False)
00407 self.runResidualCalib(run,runselection,trial,ttrig_timeboxes_db,'Residuals',residualsFirst,config,False)
00408 self.runTtrigResidualCorr(run,ttrig_timeboxes_db,residualsFirst,config,False)
00409 self.runTtrigValid(run,runselection,trial,ttrig_residuals_db,'ResidualsResidCorr',config,False)
00410
00411 self.runDQMClient(run,'',config,False)
00412
00413 sys.exit(0)
00414
00415
00416 if not os.path.exists(timeBoxes): self.runTtrigProd(run,runselection,trial,config)
00417 if not os.path.exists(timeBoxes): raise RuntimeError,'Could not produce %s' % timeBoxes
00418
00419
00420 if not os.path.exists(ttrig_timeboxes_db): self.runTtrigWriter(run,config)
00421 if not os.path.exists(ttrig_timeboxes_db): raise RuntimeError,'Could not produce %s' % ttrig_timeboxes_db
00422
00423
00424 if not os.path.exists(residualsFirst):
00425 self.runResidualCalib(run,runselection,trial,ttrig_timeboxes_db,'Residuals',residualsFirst,config)
00426 if not os.path.exists(residualsFirst): raise RuntimeError,'Could not produce %s' % residualsFirst
00427
00428
00429 if not os.path.exists(ttrig_residuals_db): self.runTtrigResidualCorr(run,ttrig_timeboxes_db,residualsFirst,config)
00430 if not os.path.exists(ttrig_residuals_db): raise RuntimeError,'Could not produce %s' % ttrig_residuals_db
00431
00432
00433 self.runTtrigValid(run,runselection,trial,ttrig_residuals_db,'ResidualsResidCorr',config)
00434
00435 """
00436 # Summary of validation
00437 if not os.path.exists(summaryResiduals): self.runTtrigValidSummary(run,residualsResidCorr,summaryResiduals,config)
00438 if not os.path.exists(summaryResiduals): raise RuntimeError,'Could not produce %s' % summaryResiduals
00439 """
00440
00441 dqm_output_dir = self.dqmOutputDir('TTrigValidation','ResidualsResidCorr',config)
00442 self.runDQMClient(run,dqm_output_dir,config)
00443
00444 elif mode == 'residuals':
00445 residualsFirst = os.path.abspath(result_dir + '/' + 'DTResidualValidation_' + run + '.root')
00446 ttrig_residuals_db = os.path.abspath(result_dir + '/' + 'ttrig_residuals_' + run + '.db')
00447 residualsResidCorr = os.path.abspath(result_dir + '/' + 'DTResidualValidation_ResidCorr_' + run + '.root')
00448 summaryResiduals = os.path.abspath(result_dir + '/' + 'SummaryResiduals_' + run + '.root')
00449
00450 if not execute:
00451 print "Writing configuration files.."
00452 if ttrig_input_db:
00453 self.runResidualCalib(run,runselection,trial,ttrig_input_db,'Residuals',residualsFirst,config,False)
00454 self.runTtrigResidualCorr(run,ttrig_input_db,residualsFirst,config,False)
00455 else:
00456 self.runResidualCalib(run,runselection,trial,None,'Residuals',residualsFirst,config,False)
00457 self.runTtrigResidualCorr(run,None,residualsFirst,config,False)
00458
00459 self.runTtrigValid(run,runselection,trial,ttrig_residuals_db,'ResidualsResidCorr',config,False)
00460
00461 self.runDQMClient(run,'',config,False)
00462
00463 sys.exit(0)
00464
00465
00466 if not os.path.exists(residualsFirst):
00467 if ttrig_input_db:
00468 self.runResidualCalib(run,runselection,trial,ttrig_input_db,'Residuals',residualsFirst,config)
00469 else:
00470 self.runResidualCalib(run,runselection,trial,None,'Residuals',residualsFirst,config)
00471 if not os.path.exists(residualsFirst): raise RuntimeError,'Could not produce %s' % residualsFirst
00472
00473
00474 if not os.path.exists(ttrig_residuals_db):
00475 if ttrig_input_db: self.runTtrigResidualCorr(run,ttrig_input_db,residualsFirst,config)
00476 else: self.runTtrigResidualCorr(run,None,residualsFirst,config)
00477 if not os.path.exists(ttrig_residuals_db): raise RuntimeError,'Could not produce %s' % ttrig_residuals_db
00478
00479
00480 self.runTtrigValid(run,runselection,trial,ttrig_residuals_db,'ResidualsResidCorr',config)
00481
00482 """
00483 # Summary of validation
00484 if not os.path.exists(summaryResiduals):
00485 self.runTtrigValidSummary(run,residualsResidCorr,summaryResiduals,config)
00486 if not os.path.exists(summaryResiduals): raise RuntimeError,'Could not produce %s' % summaryResiduals
00487 """
00488
00489 dqm_output_dir = self.dqmOutputDir('TTrigValidation','ResidualsResidCorr',config)
00490 self.runDQMClient(run,dqm_output_dir,config)
00491
00492 elif mode == 'validation':
00493 residualsValid = os.path.abspath(result_dir + '/' + 'DTResidualValidation_' + run + '.root')
00494 summaryResiduals = os.path.abspath(result_dir + '/' + 'SummaryResiduals_' + run + '.root')
00495
00496 if not execute:
00497 print "Writing configuration files.."
00498 if ttrig_input_db:
00499 self.runTtrigValid(run,runselection,trial,ttrig_input_db,'Residuals',config,False)
00500 else:
00501 self.runTtrigValid(run,runselection,trial,None,'Residuals',config,False)
00502
00503
00504 self.runDQMClient(run,'',config,False)
00505
00506 sys.exit(0)
00507
00508
00509 if ttrig_input_db:
00510 self.runTtrigValid(run,runselection,trial,ttrig_input_db,'Residuals',config)
00511 else:
00512 self.runTtrigValid(run,runselection,trial,None,'Residuals',config)
00513
00514 """
00515 # Summary of validation
00516 if not os.path.exists(summaryResiduals):
00517 self.runTtrigValidSummary(run,residualsValid,summaryResiduals,config)
00518 if not os.path.exists(summaryResiduals): raise RuntimeError,'Could not produce %s' % summaryResiduals
00519 """
00520
00521
00522 dqm_output_dir = self.dqmOutputDir('TTrigValidation','Residuals',config)
00523 self.runDQMClient(run,dqm_output_dir,config)
00524
00525 return 0
00526
00527
00528
00529
00530 def runVDriftWorkflow(self,mode,run,config,execute=True):
00531 trial = config.trial
00532 runselection = config.runselection
00533 result_dir = config.result_dir
00534 if mode == 'segment':
00535 vDriftHistos = os.path.abspath(result_dir + '/' + 'DTVDriftHistos_' + run + '.root')
00536 vDrift_segment_db = os.path.abspath(result_dir + '/' + 'vDrift_segment_' + run + '.db')
00537
00538 if not execute:
00539 print "Writing configuration files.."
00540 self.runVDriftSegmentCalib(run,runselection,trial,'VDriftHistos',vDriftHistos,config,False)
00541 self.runVDriftSegmentWriter(run,vDriftHistos,config,False)
00542
00543 sys.exit(0)
00544
00545
00546 if not os.path.exists(vDriftHistos):
00547 self.runVDriftSegmentCalib(run,runselection,trial,'VDriftHistos',vDriftHistos,config)
00548 if not os.path.exists(vDriftHistos): raise RuntimeError,'Could not produce %s' % vDriftHistos
00549
00550
00551 if not os.path.exists(vDrift_segment_db): self.runVDriftSegmentWriter(run,vDriftHistos,config)
00552 if not os.path.exists(vDrift_segment_db): raise RuntimeError,'Could not produce %s' % vDrift_segment_db
00553
00554 elif mode == 'meantimer':
00555 vDriftTMaxHistos = os.path.abspath(result_dir + '/' + 'DTTMaxHistos_' + run + '.root')
00556 vDrift_meantimer_db = os.path.abspath(result_dir + '/' + 'vDrift_meantimer_' + run + '.db')
00557
00558 if not execute:
00559 print "Writing configuration files.."
00560 self.runVDriftMeanTimerCalib(run,runselection,trial,'VDriftTMaxHistos',vDriftTMaxHistos,config,False)
00561 self.runVDriftMeanTimerWriter(run,vDriftTMaxHistos,config,False)
00562
00563 sys.exit(0)
00564
00565
00566 if not os.path.exists(vDriftTMaxHistos):
00567 self.runVDriftMeanTimerCalib(run,runselection,trial,'VDriftTMaxHistos',vDriftTMaxHistos,config)
00568 if not os.path.exists(vDriftTMaxHistos): raise RuntimeError,'Could not produce %s' % vDriftTMaxHistos
00569
00570
00571 if not os.path.exists(vDrift_meantimer_db): self.runVDriftMeanTimerWriter(run,vDriftTMaxHistos,config)
00572 if not os.path.exists(vDrift_meantimer_db): raise RuntimeError,'Could not produce %s' % vDrift_meantimer_db
00573
00574 return 0
00575
00576
00577
00578
00579 def runNoiseWorkflow(self,mode,run,config,execute=True):
00580 print "Processing noise calibration"
00581
00582 trial = config.trial
00583 runselection = config.runselection
00584 result_dir = config.result_dir
00585 result_file = os.path.abspath(result_dir + '/' + 'dtNoiseCalib_' + run + '.root')
00586 noise_db = os.path.abspath(result_dir + '/' + 'noise_' + run + '.db')
00587 noise_txt = os.path.abspath(result_dir + '/' + 'noise_' + run + '.txt')
00588
00589 datasetstr = getDatasetStr(config.datasetpath)
00590 config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/NoiseCalibration/' + label + '/' + 'v' + str(trial)
00591
00592 task_dir = config.base_dir + '/NoiseCalib'
00593 dtNoiseCalibration = DTNoiseCalibration(run=run,
00594 dir=task_dir,
00595 config=config)
00596 if not execute:
00597 dtNoiseCalibration.writeCfg()
00598 sys.exit(0)
00599 else:
00600 dtNoiseCalibration.writeCfg()
00601 project_noise = dtNoiseCalibration.run()
00602
00603 print "Sent calibration jobs with project",project_noise
00604 print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold
00605
00606 crabNoiseCalibration = CrabWatch(project_noise)
00607 crabNoiseCalibration.setThreshold(config.jobsFinishedThreshold)
00608 crabNoiseCalibration.start()
00609 crabNoiseCalibration.join()
00610
00611 if config.stageOutLocal:
00612 crab_output_dir = project_noise + "/res"
00613 retcode = copyFilesLocal(crab_output_dir,result_dir,'dtNoiseCalib')
00614 retcode = copyFilesLocal(crab_output_dir,result_dir,'noise')
00615 elif config.stageOutCAF:
00616 castor_dir = config.castorpath + "/" + config.userdircaf
00617 retcode = copyFilesFromCastor(castor_dir,result_dir,'dtNoiseCalib')
00618 retcode = copyFilesFromCastor(castor_dir,result_dir,'noise')
00619
00620 return 0
00621
00622
00623
00624
00625 def runT0Workflow(self,mode,run,config,execute=True):
00626
00627 return 0
00628
00629
00630
00631
00632 def runValidationWorkflow(self,mode,run,config,execute=True):
00633 print "Processing DQM validation"
00634 trial = config.trial
00635 runselection = config.runselection
00636 result_dir = config.result_dir
00637 datasetstr = getDatasetStr(config.datasetpath)
00638 dirLabel = 'DQM'
00639 config.userdircaf = 'DTCalibration/' + datasetstr + '/Run' + str(run) + '/DQMValidation/' + dirLabel + '/' + 'v' + str(trial)
00640
00641 task_dir = config.base_dir + '/' + dirLabel
00642 dtDQMValid = DTDQMValidation(run=run,
00643 dir=task_dir,
00644 config=config)
00645 if not execute:
00646 dtDQMValid.writeCfg()
00647 self.runDQMMerge(run,'',config,False)
00648 self.runDQMHarvesting(run,'',config,False)
00649
00650 sys.exit(0)
00651 else:
00652 dtDQMValid.writeCfg()
00653 project_valid = dtDQMValid.run()
00654
00655 print "Sent validation jobs with project",project_valid
00656 print "%.0f%% of jobs are required to finish" % config.jobsFinishedThreshold
00657
00658 crabValid = CrabWatch(project_valid)
00659 crabValid.setThreshold(config.jobsFinishedThreshold)
00660 crabValid.start()
00661 crabValid.join()
00662
00663
00664 dqm_output_dir = self.dqmOutputDir('DQMValidation',dirLabel,config)
00665 self.runDQMMerge(run,dqm_output_dir,config)
00666
00667 dqm_merge_dir = os.path.abspath(result_dir)
00668 self.runDQMHarvesting(run,dqm_merge_dir,config)
00669
00670 return 0
00671
00672
00673
00674
00675 def runDBValidationWorkflow(self,mode,run,inputFiles,config,execute=True):
00676 print "Processing DB validation"
00677
00678 dtDBValidation = None
00679 if mode == 't0DB':
00680 dtDBValidation = DTT0DBValidation(run=run,
00681 dir=config.run_dir,
00682 input_files=inputFiles,
00683 output_dir=config.result_dir,
00684 config=config)
00685
00686
00687 if execute:
00688 dtDBValidation.run()
00689
00690 print "Finished processing:"
00691 for pset in dtDBValidation.configs: print "--->",pset
00692
00693 return 0