CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/CalibMuon/DTCalibration/python/Workflow/DTNoiseCalibration.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 DTNoiseCalibration:
00007     def __init__(self, run, dir, config):
00008         self.pset_name = 'dtNoiseCalibration_cfg.py'
00009         self.outputROOT = 'dtNoiseCalib.root'
00010         self.outputDB = 'noise.db'
00011         self.config = config
00012         self.dir = dir
00013 
00014         self.pset_template = 'CalibMuon.DTCalibration.dtNoiseCalibration_cfg'
00015         #if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics:
00016         #    self.pset_template = 'CalibMuon.DTCalibration.dtNoiseCalibration_cosmics_cfg'
00017 
00018         self.process = None  
00019         self.crab_cfg = None
00020         self.initProcess()
00021         self.initCrab()
00022         self.task = CrabTask(self.dir,self.crab_cfg)
00023 
00024     def initProcess(self):
00025         self.process = loadCmsProcess(self.pset_template)
00026         self.process.GlobalTag.globaltag = self.config.globaltag
00027         self.process.dtNoiseCalibration.rootFileName = self.outputROOT 
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         loadCrabDefault(crab_cfg_parser,self.config)
00052         crab_cfg_parser.set('CMSSW','pset',self.pset_name)
00053         crab_cfg_parser.set('CMSSW','output_file','%s,%s' % (self.outputDB,self.outputROOT))
00054         crab_cfg_parser.remove_option('USER','additional_input_files')
00055 
00056         self.crab_cfg = crab_cfg_parser
00057 
00058     def writeCfg(self):
00059         writeCfg(self.process,self.dir,self.pset_name)
00060         #writeCfgPkl(self.process,self.dir,self.pset_name)
00061 
00062     def run(self):
00063         self.project = self.task.run()
00064         return self.project