CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_2_SLHC4_patch1/src/CalibMuon/DTCalibration/python/Workflow/DTVDriftSegmentCalibration.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 DTVDriftSegmentCalibration:
00007     def __init__(self, run, dir, config):
00008         self.pset_name = 'dtVDriftSegmentCalibration_cfg.py'
00009         self.outputfile = 'DTVDriftHistos.root'
00010         self.config = config
00011         self.dir = dir
00012 
00013         self.pset_template = 'CalibMuon.DTCalibration.dtVDriftSegmentCalibration_cfg'
00014         if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics:
00015             self.pset_template = 'CalibMuon.DTCalibration.dtVDriftSegmentCalibration_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.dtVDriftSegmentCalibration.rootFileName = self.outputfile
00027         # Update Event Setup
00028         if hasattr(self.config,'inputDBTag') and self.config.inputDBTag:
00029             tag = self.config.inputDBTag
00030             record = self.config.inputDBRcd
00031             connect = self.config.connectStrDBTag
00032             moduleName = 'customDB%s' % record 
00033             addPoolDBESSource(process = self.process,
00034                               moduleName = moduleName,record = record,tag = tag,
00035                               connect = connect)
00036 
00037         if hasattr(self.config,'inputTTrigDB') and self.config.inputTTrigDB:
00038             label = ''
00039             if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics: label = 'cosmics'
00040             addPoolDBESSource(process = self.process,
00041                               moduleName = 'tTrigDB',record = 'DTTtrigRcd',tag = 'ttrig',label = label,
00042                               connect = 'sqlite_file:%s' % os.path.basename(self.config.inputTTrigDB))
00043 
00044         if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
00045             addPoolDBESSource(process = self.process,
00046                               moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift',
00047                               connect = 'sqlite_file:%s' % os.path.basename(self.config.inputVDriftDB))
00048 
00049         if hasattr(self.config,'inputT0DB') and self.config.inputT0DB:
00050             addPoolDBESSource(process = self.process,
00051                               moduleName = 't0DB',record = 'DTT0Rcd',tag = 't0',
00052                               connect = 'sqlite_file:%s' % os.path.basename(self.config.inputT0DB))
00053 
00054         # Update sequences
00055         # Prepend paths with unpacker if running on RAW
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         # Prepend paths with custom selection sequence
00062         if hasattr(self.config,'preselection') and self.config.preselection:
00063             pathsequence = self.config.preselection.split(':')[0]
00064             seqname = self.config.preselection.split(':')[1]
00065             self.process.load(pathsequence)
00066             prependPaths(self.process,seqname)
00067 
00068     def initCrab(self):
00069         crab_cfg_parser = loadCrabCfg()
00070         loadCrabDefault(crab_cfg_parser,self.config)
00071         crab_cfg_parser.set('CMSSW','pset',self.pset_name)
00072         crab_cfg_parser.set('CMSSW','output_file',self.outputfile)
00073         crab_cfg_parser.remove_option('USER','additional_input_files')
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