CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/src/CalibMuon/DTCalibration/python/Workflow/DTAnalysisResiduals.py

Go to the documentation of this file.
00001 from tools import loadCmsProcess,loadCrabCfg,loadCrabDefault,addCrabInputFile,writeCfg,prependPaths
00002 from addPoolDBESSource import addPoolDBESSource
00003 from CrabTask import *
00004 import os
00005 
00006 class DTAnalysisResiduals:
00007     def __init__(self, run, dir, config):
00008         self.pset_name = 'dtAnalysisResiduals_cfg.py'
00009         self.outputfile = 'residuals.root'
00010         self.config = config
00011         self.dir = dir
00012 
00013         self.pset_template = 'CalibMuon.DTCalibration.dtResidualCalibration_cfg'
00014         if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics:
00015             self.pset_template = 'CalibMuon.DTCalibration.dtResidualCalibration_cosmics_cfg'
00016 
00017         self.process = None  
00018         self.crab_cfg = None
00019         self.initProcess()
00020         self.initCrab()
00021         self.task = CrabTask(self.dir,self.crab_cfg)
00022 
00023     def initProcess(self):
00024         self.process = loadCmsProcess(self.pset_template)
00025         self.process.GlobalTag.globaltag = self.config.globaltag
00026         self.process.dtResidualCalibration.rootFileName = self.outputfile 
00027         self.process.dtResidualCalibration.detailedAnalysis = True
00028         # Update Event Setup
00029         if hasattr(self.config,'inputDBTag') and self.config.inputDBTag:
00030             tag = self.config.inputDBTag
00031             record = self.config.inputDBRcd
00032             connect = self.config.connectStrDBTag
00033             moduleName = 'customDB%s' % record 
00034             addPoolDBESSource(process = self.process,
00035                               moduleName = moduleName,record = record,tag = tag,
00036                               connect = connect)
00037 
00038         if hasattr(self.config,'inputTTrigDB') and self.config.inputTTrigDB:
00039             label = ''
00040             if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics: label = 'cosmics'
00041             addPoolDBESSource(process = self.process,
00042                               moduleName = 'tTrigDB',record = 'DTTtrigRcd',tag = 'ttrig',label = label,
00043                               connect = 'sqlite_file:%s' % os.path.basename(self.config.inputTTrigDB))
00044 
00045         if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
00046             addPoolDBESSource(process = self.process,
00047                               moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift',
00048                               connect = 'sqlite_file:%s' % os.path.basename(self.config.inputVDriftDB))
00049 
00050         if hasattr(self.config,'inputT0DB') and self.config.inputT0DB:
00051             addPoolDBESSource(process = self.process,
00052                               moduleName = 't0DB',record = 'DTT0Rcd',tag = 't0',
00053                               connect = 'sqlite_file:%s' % os.path.basename(self.config.inputT0DB))
00054 
00055         # Update sequences
00056         if hasattr(self.config,'runOnRAW') and self.config.runOnRAW:
00057             if hasattr(self.config,'runOnMC') and self.config.runOnMC:
00058                 getattr(self.process,self.config.digilabel).inputLabel = 'rawDataCollector' 
00059             prependPaths(self.process,self.config.digilabel)
00060  
00061         if hasattr(self.config,'preselection') and self.config.preselection:
00062             pathsequence = self.config.preselection.split(':')[0]
00063             seqname = self.config.preselection.split(':')[1]
00064             self.process.load(pathsequence)
00065             prependPaths(self.process,seqname)
00066 
00067     def initCrab(self):
00068         crab_cfg_parser = loadCrabCfg()
00069         loadCrabDefault(crab_cfg_parser,self.config)
00070         crab_cfg_parser.set('CMSSW','pset',self.pset_name)
00071         crab_cfg_parser.set('CMSSW','output_file',self.outputfile)
00072         crab_cfg_parser.remove_option('USER','additional_input_files')
00073 
00074         if hasattr(self.config,'inputTTrigDB') and self.config.inputTTrigDB:
00075             addCrabInputFile(crab_cfg_parser,self.config.inputTTrigDB)
00076 
00077         if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
00078             addCrabInputFile(crab_cfg_parser,self.config.inputVDriftDB)
00079 
00080         if hasattr(self.config,'inputT0DB') and self.config.inputT0DB:
00081             addCrabInputFile(crab_cfg_parser,self.config.inputT0DB)
00082 
00083         self.crab_cfg = crab_cfg_parser
00084 
00085     def writeCfg(self):
00086         writeCfg(self.process,self.dir,self.pset_name)
00087         #writeCfgPkl(self.process,self.dir,self.pset_name)
00088 
00089     def run(self):
00090         self.project = self.task.run()
00091         return self.project