CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/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         # Add tTrig and vDrift DB's, if requested
00028         if hasattr(self.config,'inputTTrigDB') and self.config.inputTTrigDB:
00029             label = ''
00030             if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics: label = 'cosmics'
00031             addPoolDBESSource(process = self.process,
00032                               moduleName = 'tTrigDB',record = 'DTTtrigRcd',tag = 'ttrig',label = label,
00033                               connect = 'sqlite_file:%s' % os.path.basename(self.config.inputTTrigDB))
00034 
00035         if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
00036             addPoolDBESSource(process = self.process,
00037                               moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift',
00038                               connect = 'sqlite_file:%s' % os.path.basename(self.config.inputVDriftDB))
00039 
00040         if hasattr(self.config,'inputDBTag') and self.config.inputDBTag:
00041             tag = self.config.inputDBTag
00042             record = self.config.inputDBRcd
00043             connect = self.config.connectStrDBTag
00044             moduleName = 'customDB%s' % record 
00045             addPoolDBESSource(process = self.process,
00046                               moduleName = moduleName,record = record,tag = tag,
00047                               connect = connect)
00048 
00049         # Prepend paths with unpacker if running on RAW
00050         if hasattr(self.config,'runOnRAW') and self.config.runOnRAW:
00051             if hasattr(self.config,'runOnMC') and self.config.runOnMC:
00052                 getattr(self.process,self.config.digilabel).inputLabel = 'rawDataCollector' 
00053             prependPaths(self.process,self.config.digilabel)
00054 
00055         # Prepend paths with custom selection sequence
00056         if hasattr(self.config,'preselection') and self.config.preselection:
00057             pathsequence = self.config.preselection.split(':')[0]
00058             seqname = self.config.preselection.split(':')[1]
00059             self.process.load(pathsequence)
00060             prependPaths(self.process,seqname)
00061 
00062     def initCrab(self):
00063         crab_cfg_parser = loadCrabCfg()
00064         loadCrabDefault(crab_cfg_parser,self.config)
00065         crab_cfg_parser.set('CMSSW','pset',self.pset_name)
00066         crab_cfg_parser.set('CMSSW','output_file',self.outputfile)
00067         crab_cfg_parser.remove_option('USER','additional_input_files')
00068         if hasattr(self.config,'inputTTrigDB') and self.config.inputTTrigDB:
00069             addCrabInputFile(crab_cfg_parser,self.config.inputTTrigDB)
00070 
00071         if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
00072             addCrabInputFile(crab_cfg_parser,self.config.inputVDriftDB)
00073 
00074         self.crab_cfg = crab_cfg_parser
00075 
00076     def writeCfg(self):
00077         writeCfg(self.process,self.dir,self.pset_name)
00078         #writeCfgPkl(self.process,self.dir,self.pset_name)
00079 
00080     def run(self):
00081         self.project = self.task.run()
00082         return self.project