CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/CalibMuon/DTCalibration/python/Workflow/DTT0DBValidation.py

Go to the documentation of this file.
00001 import FWCore.ParameterSet.Config as cms
00002 from tools import loadCmsProcess,writeCfg,dqmWorkflowName,getDatasetStr
00003 from CmsswTask import *
00004 import os
00005 
00006 class DTT0DBValidation:
00007     def __init__(self, run, dir, input_files, output_dir, config=None):
00008         self.runnumber = int(run)
00009         self.dir = dir
00010         self.output_dir = output_dir
00011         self.config = config
00012         self.input_files = input_files
00013 
00014         self.pset_template = 'DQMOffline.CalibMuon.dtT0DBValidation_cfg'
00015 
00016         self.configs = []
00017         self.initProcess()
00018         self.task = CmsswTask(self.dir,self.configs)
00019 
00020     def initProcess(self):
00021         refDBTag = ''
00022         if hasattr(self.config,'refDBTag') and self.config.refDBTag: refDBTag = self.config.refDBTag
00023         connect = ''
00024         if hasattr(self.config,'config.connectStrRefDBTag') and self.config.config.connectStrRefDBTag: connect = self.config.config.connectStrRefDBTag
00025         runNumbersToFiles = []
00026         if hasattr(self.config,'dbValidRuns') and self.config.dbValidRuns and len(self.config.dbValidRuns) == len(self.input_files): runNumbersToFiles = self.config.dbValidRuns
00027 
00028         self.process = {}
00029         idx_file = 0
00030         for inputFile in self.input_files:
00031             file = os.path.abspath(inputFile)
00032             fileLabel = os.path.basename(file).split('.')[0] 
00033             pset_name = 'dtT0DBValidation_%s_Run%d_cfg.py' % (fileLabel,self.runnumber)
00034             self.process[pset_name] = loadCmsProcess(self.pset_template)
00035             self.process[pset_name].source.firstRun = self.runnumber
00036 
00037             self.process[pset_name].tzeroRef.toGet = cms.VPSet(
00038                 cms.PSet(
00039                     record = cms.string('DTT0Rcd'),
00040                     tag = cms.string(refDBTag),
00041                     label = cms.untracked.string('tzeroRef')
00042                     ),
00043                 cms.PSet(
00044                     record = cms.string('DTT0Rcd'),
00045                     tag = cms.string('t0'),
00046                     connect = cms.untracked.string('sqlite_file:%s' % file),
00047                     label = cms.untracked.string('tzeroToValidate')
00048                     )
00049                 )
00050             self.process[pset_name].tzeroRef.connect = connect
00051 
00052             if self.config:
00053                 label = 'dtT0DBValidation'
00054                 if hasattr(self.config,'label') and self.config.label: label = self.config.label 
00055                 workflowName = dqmWorkflowName(self.config.datasetpath,label,self.config.trial)
00056                 self.process[pset_name].dqmSaver.workflow = workflowName
00057 
00058             if runNumbersToFiles: self.process[pset_name].dqmSaver.forceRunNumber = runNumbersToFiles[idx_file]
00059             self.process[pset_name].dqmSaver.dirName = os.path.abspath(self.output_dir)
00060 
00061             self.configs.append(pset_name)
00062             writeCfg(self.process[pset_name],self.dir,pset_name) 
00063             idx_file += 1
00064 
00065     """
00066     def writeCfg(self):
00067         for cfg in self.configs:
00068             writeCfg(self.process[cfg],self.dir,cfg)
00069             #writeCfgPkl(self.process,self.dir,self.pset_name) 
00070     """
00071 
00072     def run(self):
00073         self.task.run()
00074         return