CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/CalibMuon/DTCalibration/python/Workflow/DTDQMHarvesting.py

Go to the documentation of this file.
00001 from tools import loadCmsProcess,writeCfg,dqmWorkflowName
00002 from addPoolDBESSource import addPoolDBESSource
00003 from CmsswTask import *
00004 import os
00005 
00006 class DTDQMHarvesting:
00007     def __init__(self, run, dir, dqm_files, result_dir, config=None):
00008         self.runnumber = int(run)
00009         self.dir = dir
00010         self.result_dir = result_dir
00011         self.config = config
00012         self.dqm_files = dqm_files
00013 
00014         self.pset_name = 'dtDQMClient_cfg.py'
00015         self.pset_template = 'CalibMuon.DTCalibration.dtDQMClientAlca_cfg'
00016 
00017         self.process = None
00018         self.initProcess()
00019         self.configFiles = []
00020         self.configFiles.append(self.pset_name)
00021         self.task = CmsswTask(self.dir,self.configFiles)
00022 
00023     def initProcess(self):
00024         self.process = loadCmsProcess(self.pset_template)
00025         self.process.GlobalTag.globaltag = self.config.globaltag
00026 
00027         if hasattr(self.config,'inputTTrigDB') and self.config.inputTTrigDB:
00028             label = ''
00029             if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics: label = 'cosmics'
00030             addPoolDBESSource(process = self.process,
00031                               moduleName = 'tTrigDB',record = 'DTTtrigRcd',tag = 'ttrig',label = label,
00032                               connect = 'sqlite_file:%s' % os.path.abspath(self.config.inputTTrigDB))
00033 
00034         if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
00035             addPoolDBESSource(process = self.process,
00036                               moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift',
00037                               connect = 'sqlite_file:%s' % os.path.abspath(self.config.inputVDriftDB))
00038 
00039         if hasattr(self.config,'inputDBTag') and self.config.inputDBTag:
00040             tag = self.config.inputDBTag
00041             record = self.config.inputDBRcd
00042             connect = self.config.connectStrDBTag
00043             moduleName = 'customDB%s' % record 
00044             addPoolDBESSource(process = self.process,
00045                               moduleName = moduleName,record = record,tag = tag,
00046                               connect = connect)
00047 
00048         self.process.source.fileNames = self.dqm_files
00049         self.process.dqmSaver.dirName = os.path.abspath(self.result_dir)
00050         if self.config:
00051             label = 'dtDQMValidation'
00052             if hasattr(self.config,'label') and self.config.label: label = self.config.label 
00053             workflowName = dqmWorkflowName(self.config.datasetpath,label,self.config.trial)
00054             self.process.dqmSaver.workflow = workflowName
00055         if self.process.DQMStore.collateHistograms == True: self.process.dqmSaver.forceRunNumber = self.runnumber
00056 
00057     def writeCfg(self):
00058         writeCfg(self.process,self.dir,self.pset_name)   
00059         #writeCfgPkl(self.process,self.dir,self.pset_name) 
00060     
00061     def run(self):
00062         self.task.run()
00063         return
00064 
00065 def runDQM(run,dqmFile,result_dir):
00066     dqm_files = [dqmFile]
00067     runDir = '.'
00068 
00069     dtDqm = DTDQMHarvesting(run,runDir,dqm_files,result_dir)
00070     dtDqm.writeCfg()
00071     dtDqm.run()