CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTResidualCalibration.py
Go to the documentation of this file.
1 from tools import loadCmsProcess,loadCrabCfg,loadCrabDefault,addCrabInputFile,writeCfg,prependPaths
2 from addPoolDBESSource import addPoolDBESSource
3 from CrabTask import *
4 import os
5 
7  def __init__(self, run, dir, input_db, config):
8  self.pset_name = 'dtResidualCalibration_cfg.py'
9  self.outputfile = 'residuals.root'
10  self.config = config
11  self.dir = dir
12  self.inputdb = input_db
13 
14  self.pset_template = 'CalibMuon.DTCalibration.dtResidualCalibration_cfg'
15  if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics:
16  self.pset_template = 'CalibMuon.DTCalibration.dtResidualCalibration_cosmics_cfg'
17 
18  self.process = None
19  self.crab_cfg = None
20  self.initProcess()
21  self.initCrab()
22  self.task = CrabTask(self.dir,self.crab_cfg)
23 
24  def initProcess(self):
26  self.process.GlobalTag.globaltag = self.config.globaltag
27  self.process.dtResidualCalibration.rootFileName = self.outputfile
28 
29  if(self.inputdb):
30  label = ''
31  if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics: label = 'cosmics'
32  addPoolDBESSource(process = self.process,
33  moduleName = 'calibDB',record = 'DTTtrigRcd',tag = 'ttrig',label = label,
34  connect = 'sqlite_file:%s' % os.path.basename(self.inputdb))
35 
36  if hasattr(self.config,'inputVdriftDB') and self.config.inputVdriftDB:
37  addPoolDBESSource(process = self.process,
38  moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift',
39  connect = 'sqlite_file:%s' % os.path.basename(self.config.inputVdriftDB))
40 
41  if hasattr(self.config,'runOnRAW') and self.config.runOnRAW:
42  prependPaths(self.process,self.config.digilabel)
43 
44  if hasattr(self.config,'preselection') and self.config.preselection:
45  pathsequence = self.config.preselection.split(':')[0]
46  seqname = self.config.preselection.split(':')[1]
47  self.process.load(pathsequence)
48  prependPaths(self.process,seqname)
49 
50  def initCrab(self):
51  crab_cfg_parser = loadCrabCfg()
52  loadCrabDefault(crab_cfg_parser,self.config)
53  crab_cfg_parser.set('CMSSW','pset',self.pset_name)
54  crab_cfg_parser.set('CMSSW','output_file',self.outputfile)
55  crab_cfg_parser.remove_option('USER','additional_input_files')
56  if self.inputdb:
57  addCrabInputFile(crab_cfg_parser,self.inputdb)
58 
59  if hasattr(self.config,'inputVdriftDB') and self.config.inputVdriftDB:
60  addCrabInputFile(crab_cfg_parser,self.config.inputVdriftDB)
61 
62  self.crab_cfg = crab_cfg_parser
63 
64  def writeCfg(self):
65  writeCfg(self.process,self.dir,self.pset_name)
66  #writeCfgPkl(self.process,self.dir,self.pset_name)
67 
68  def run(self):
69  self.project = self.task.run()
70  return self.project
def addCrabInputFile
Definition: tools.py:147
def loadCrabDefault
Definition: tools.py:159
def loadCmsProcess
Definition: tools.py:110
def loadCrabCfg
Definition: tools.py:142
perl if(1 lt scalar(@::datatypes))
Definition: edlooper.cc:31
def prependPaths
Definition: tools.py:118