CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_8_patch3/src/CalibMuon/DTCalibration/python/Workflow/DTTTrigProd.py

Go to the documentation of this file.
00001 from tools import loadCmsProcess,loadCrabCfg,loadCrabDefault,writeCfg,prependPaths
00002 from CrabTask import *
00003 import os
00004 
00005 class DTTTrigProd:
00006     def __init__(self, run, dir, config):
00007         self.pset_name = 'dtTTrigCalibration_cfg.py'
00008         self.outputfile = 'DTTimeBoxes.root'
00009         self.config = config
00010         self.dir = dir 
00011         self.pset_template = 'CalibMuon.DTCalibration.dtTTrigCalibration_cfg'
00012         self.process = None
00013         self.crab_cfg = None
00014 
00015         self.pset_template = 'CalibMuon.DTCalibration.dtTTrigCalibration_cfg'
00016         if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics:
00017             self.pset_template = 'CalibMuon.DTCalibration.dtTTrigCalibration_cosmics_cfg'
00018 
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.dtTTrigCalibration.rootFileName = self.outputfile
00027         self.process.dtTTrigCalibration.digiLabel = self.config.digilabel
00028 
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,'runOnRAW') and self.config.runOnRAW:
00039             if hasattr(self.config,'runOnMC') and self.config.runOnMC:
00040                 getattr(self.process,self.config.digilabel).inputLabel = 'rawDataCollector' 
00041             prependPaths(self.process,self.config.digilabel)
00042 
00043         if hasattr(self.config,'preselection') and self.config.preselection:
00044             pathsequence = self.config.preselection.split(':')[0]
00045             seqname = self.config.preselection.split(':')[1]
00046             self.process.load(pathsequence)
00047             prependPaths(self.process,seqname)
00048 
00049     def initCrab(self):
00050         crab_cfg_parser = loadCrabCfg()
00051         crab_cfg_parser = loadCrabDefault(crab_cfg_parser,self.config)
00052         crab_cfg_parser.set('CMSSW','pset',self.pset_name)
00053         crab_cfg_parser.set('CMSSW','output_file',self.outputfile) 
00054         self.crab_cfg = crab_cfg_parser
00055 
00056     def writeCfg(self):
00057         writeCfg(self.process,self.dir,self.pset_name)
00058         #writeCfgPkl(self.process,self.dir,self.pset_name) 
00059 
00060     def run(self):
00061         self.project = self.task.run() 
00062         return self.project