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 DTResidualCalibration:
00007 def __init__(self, run, dir, input_db, config):
00008 self.pset_name = 'dtResidualCalibration_cfg.py'
00009 self.outputfile = 'residuals.root'
00010 self.config = config
00011 self.dir = dir
00012 self.inputdb = input_db
00013
00014 self.pset_template = 'CalibMuon.DTCalibration.dtResidualCalibration_cfg'
00015 if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics:
00016 self.pset_template = 'CalibMuon.DTCalibration.dtResidualCalibration_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.dtResidualCalibration.rootFileName = self.outputfile
00028
00029 if(self.inputdb):
00030 label = ''
00031 if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics: label = 'cosmics'
00032 addPoolDBESSource(process = self.process,
00033 moduleName = 'calibDB',record = 'DTTtrigRcd',tag = 'ttrig',label = label,
00034 connect = 'sqlite_file:%s' % os.path.basename(self.inputdb))
00035
00036 if hasattr(self.config,'inputVdriftDB') and self.config.inputVdriftDB:
00037 addPoolDBESSource(process = self.process,
00038 moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift',
00039 connect = 'sqlite_file:%s' % os.path.basename(self.config.inputVdriftDB))
00040
00041 if hasattr(self.config,'runOnRAW') and self.config.runOnRAW:
00042 prependPaths(self.process,self.config.digilabel)
00043
00044 if hasattr(self.config,'preselection') and self.config.preselection:
00045 pathsequence = self.config.preselection.split(':')[0]
00046 seqname = self.config.preselection.split(':')[1]
00047 self.process.load(pathsequence)
00048 prependPaths(self.process,seqname)
00049
00050 def initCrab(self):
00051 crab_cfg_parser = loadCrabCfg()
00052 loadCrabDefault(crab_cfg_parser,self.config)
00053 crab_cfg_parser.set('CMSSW','pset',self.pset_name)
00054 crab_cfg_parser.set('CMSSW','output_file',self.outputfile)
00055 crab_cfg_parser.remove_option('USER','additional_input_files')
00056 if self.inputdb:
00057 addCrabInputFile(crab_cfg_parser,self.inputdb)
00058
00059 if hasattr(self.config,'inputVdriftDB') and self.config.inputVdriftDB:
00060 addCrabInputFile(crab_cfg_parser,self.config.inputVdriftDB)
00061
00062 self.crab_cfg = crab_cfg_parser
00063
00064 def writeCfg(self):
00065 writeCfg(self.process,self.dir,self.pset_name)
00066
00067
00068 def run(self):
00069 self.project = self.task.run()
00070 return self.project