CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTVDriftSegmentCalibration.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, config):
8  self.pset_name = 'dtVDriftSegmentCalibration_cfg.py'
9  self.outputfile = 'DTVDriftHistos.root'
10  self.config = config
11  self.dir = dir
12 
13  self.pset_template = 'CalibMuon.DTCalibration.dtVDriftSegmentCalibration_cfg'
14  if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics:
15  self.pset_template = 'CalibMuon.DTCalibration.dtVDriftSegmentCalibration_cosmics_cfg'
16 
17  self.process = None
18  self.crab_cfg = None
19  self.initProcess()
20  self.initCrab()
21  self.task = CrabTask(self.dir,self.crab_cfg)
22 
23  def initProcess(self):
25  self.process.GlobalTag.globaltag = self.config.globaltag
26  self.process.dtVDriftSegmentCalibration.rootFileName = self.outputfile
27  # Add tTrig and vDrift DB's, if requested
28  if hasattr(self.config,'inputTTrigDB') and self.config.inputTTrigDB:
29  label = ''
30  if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics: label = 'cosmics'
31  addPoolDBESSource(process = self.process,
32  moduleName = 'tTrigDB',record = 'DTTtrigRcd',tag = 'ttrig',label = label,
33  connect = 'sqlite_file:%s' % os.path.basename(self.config.inputTTrigDB))
34 
35  if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
36  addPoolDBESSource(process = self.process,
37  moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift',
38  connect = 'sqlite_file:%s' % os.path.basename(self.config.inputVDriftDB))
39 
40  if hasattr(self.config,'inputDBTag') and self.config.inputDBTag:
41  tag = self.config.inputDBTag
42  record = self.config.inputDBRcd
43  connect = self.config.connectStrDBTag
44  moduleName = 'customDB%s' % record
45  addPoolDBESSource(process = self.process,
46  moduleName = moduleName,record = record,tag = tag,
47  connect = connect)
48 
49  # Prepend paths with unpacker if running on RAW
50  if hasattr(self.config,'runOnRAW') and self.config.runOnRAW:
51  if hasattr(self.config,'runOnMC') and self.config.runOnMC:
52  getattr(self.process,self.config.digilabel).inputLabel = 'rawDataCollector'
53  prependPaths(self.process,self.config.digilabel)
54 
55  # Prepend paths with custom selection sequence
56  if hasattr(self.config,'preselection') and self.config.preselection:
57  pathsequence = self.config.preselection.split(':')[0]
58  seqname = self.config.preselection.split(':')[1]
59  self.process.load(pathsequence)
60  prependPaths(self.process,seqname)
61 
62  def initCrab(self):
63  crab_cfg_parser = loadCrabCfg()
64  loadCrabDefault(crab_cfg_parser,self.config)
65  crab_cfg_parser.set('CMSSW','pset',self.pset_name)
66  crab_cfg_parser.set('CMSSW','output_file',self.outputfile)
67  crab_cfg_parser.remove_option('USER','additional_input_files')
68  if hasattr(self.config,'inputTTrigDB') and self.config.inputTTrigDB:
69  addCrabInputFile(crab_cfg_parser,self.config.inputTTrigDB)
70 
71  if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
72  addCrabInputFile(crab_cfg_parser,self.config.inputVDriftDB)
73 
74  self.crab_cfg = crab_cfg_parser
75 
76  def writeCfg(self):
77  writeCfg(self.process,self.dir,self.pset_name)
78  #writeCfgPkl(self.process,self.dir,self.pset_name)
79 
80  def run(self):
81  self.project = self.task.run()
82  return self.project
def addCrabInputFile
Definition: tools.py:183
def loadCrabDefault
Definition: tools.py:195
def loadCmsProcess
Definition: tools.py:144
def loadCrabCfg
Definition: tools.py:178
def prependPaths
Definition: tools.py:154