test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTVDriftSegmentWriter.py
Go to the documentation of this file.
1 from tools import loadCmsProcess,writeCfg
2 from addPoolDBESSource import addPoolDBESSource
3 from CmsswTask import CmsswTask
4 import os
5 
7  def __init__(self, run, dir, input_file, output_dir, config):
8  self.runnumber = int(run)
9  self.config = config
10  self.dir = dir
11  self.input_file = input_file
12  self.output_dir = output_dir
13 
14  self.configs = ['dtVDriftSegmentWriter_cfg.py',
15  'dumpDBToFile_vdrift_cfg.py']
16 
17  self.pset_templates = {}
18  self.pset_templates['dtVDriftSegmentWriter_cfg.py'] = 'CalibMuon.DTCalibration.dtVDriftSegmentWriter_cfg'
19  self.pset_templates['dumpDBToFile_vdrift_cfg.py'] = 'CalibMuon.DTCalibration.dumpDBToFile_vdrift_cfg'
20 
21  self.initProcess()
22  self.task = CmsswTask(self.dir,self.configs)
23 
24  def initProcess(self):
25  vDrift_segment = self.output_dir + '/' + 'vDrift_segment_' + str(self.runnumber)
26  vDrift_segment_db = os.path.abspath(vDrift_segment + '.db')
27  vDrift_segment_txt = os.path.abspath(vDrift_segment + '.txt')
28 
29  self.process = {}
30  # dtVDriftSegmentWriter
31  self.process['dtVDriftSegmentWriter_cfg.py'] = loadCmsProcess(self.pset_templates['dtVDriftSegmentWriter_cfg.py'])
32  self.process['dtVDriftSegmentWriter_cfg.py'].source.firstRun = self.runnumber
33  self.process['dtVDriftSegmentWriter_cfg.py'].GlobalTag.globaltag = self.config.globaltag
34 
35  # Input vDrift db
36  if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
37  addPoolDBESSource(process = self.process['dtVDriftSegmentWriter_cfg.py'],
38  moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift',
39  connect = 'sqlite_file:%s' % self.config.inputVDriftDB)
40 
41  self.process['dtVDriftSegmentWriter_cfg.py'].PoolDBOutputService.connect = 'sqlite_file:%s' % vDrift_segment_db
42  self.process['dtVDriftSegmentWriter_cfg.py'].dtVDriftSegmentWriter.vDriftAlgoConfig.rootFileName = self.input_file
43 
44  # dumpDBToFile
45  self.process['dumpDBToFile_vdrift_cfg.py'] = loadCmsProcess(self.pset_templates['dumpDBToFile_vdrift_cfg.py'])
46  self.process['dumpDBToFile_vdrift_cfg.py'].calibDB.connect = 'sqlite_file:%s' % vDrift_segment_db
47  self.process['dumpDBToFile_vdrift_cfg.py'].dumpToFile.outputFileName = vDrift_segment_txt
48 
49  def writeCfg(self):
50  for cfg in self.configs:
51  writeCfg(self.process[cfg],self.dir,cfg)
52  #writeCfgPkl(self.process[cfg],self.dir,cfg)
53 
54  def run(self):
55  self.task.run()
56  return
def loadCmsProcess
Definition: tools.py:144