test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTVDriftMeanTimerCalibration.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 = 'dtVDriftMeanTimerCalibration_cfg.py'
9  self.outputfile = 'DTTMaxHistos.root'
10  self.config = config
11  self.dir = dir
12 
13  self.pset_template = 'CalibMuon.DTCalibration.dtVDriftMeanTimerCalibration_cfg'
14  if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics:
15  self.pset_template = 'CalibMuon.DTCalibration.dtVDriftMeanTimerCalibration_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.dtVDriftMeanTimerCalibration.rootFileName = self.outputfile
27  # Update Event Setup
28  if hasattr(self.config,'inputDBTag') and self.config.inputDBTag:
29  tag = self.config.inputDBTag
30  record = self.config.inputDBRcd
31  connect = self.config.connectStrDBTag
32  moduleName = 'customDB%s' % record
33  addPoolDBESSource(process = self.process,
34  moduleName = moduleName,record = record,tag = tag,
35  connect = connect)
36 
37  if hasattr(self.config,'inputTTrigDB') and self.config.inputTTrigDB:
38  label = ''
39  if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics: label = 'cosmics'
40  addPoolDBESSource(process = self.process,
41  moduleName = 'tTrigDB',record = 'DTTtrigRcd',tag = 'ttrig',label = label,
42  connect = 'sqlite_file:%s' % os.path.basename(self.config.inputTTrigDB))
43 
44  if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
45  addPoolDBESSource(process = self.process,
46  moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift',
47  connect = 'sqlite_file:%s' % os.path.basename(self.config.inputVDriftDB))
48 
49  if hasattr(self.config,'inputT0DB') and self.config.inputT0DB:
50  addPoolDBESSource(process = self.process,
51  moduleName = 't0DB',record = 'DTT0Rcd',tag = 't0',
52  connect = 'sqlite_file:%s' % os.path.basename(self.config.inputT0DB))
53 
54  # Update sequences
55  # Prepend paths with unpacker if running on RAW
56  if hasattr(self.config,'runOnRAW') and self.config.runOnRAW:
57  if hasattr(self.config,'runOnMC') and self.config.runOnMC:
58  getattr(self.process,self.config.digilabel).inputLabel = 'rawDataCollector'
59  prependPaths(self.process,self.config.digilabel)
60 
61  # Prepend paths with custom selection sequence
62  if hasattr(self.config,'preselection') and self.config.preselection:
63  pathsequence = self.config.preselection.split(':')[0]
64  seqname = self.config.preselection.split(':')[1]
65  self.process.load(pathsequence)
66  prependPaths(self.process,seqname)
67 
68  def initCrab(self):
69  crab_cfg_parser = loadCrabCfg()
70  loadCrabDefault(crab_cfg_parser,self.config)
71  crab_cfg_parser.set('CMSSW','pset',self.pset_name)
72  crab_cfg_parser.set('CMSSW','output_file',self.outputfile)
73  crab_cfg_parser.remove_option('USER','additional_input_files')
74  if hasattr(self.config,'inputTTrigDB') and self.config.inputTTrigDB:
75  addCrabInputFile(crab_cfg_parser,self.config.inputTTrigDB)
76 
77  if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
78  addCrabInputFile(crab_cfg_parser,self.config.inputVDriftDB)
79 
80  if hasattr(self.config,'inputT0DB') and self.config.inputT0DB:
81  addCrabInputFile(crab_cfg_parser,self.config.inputT0DB)
82 
83  self.crab_cfg = crab_cfg_parser
84 
85  def writeCfg(self):
86  writeCfg(self.process,self.dir,self.pset_name)
87  #writeCfgPkl(self.process,self.dir,self.pset_name)
88 
89  def run(self):
90  self.project = self.task.run()
91  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