CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DTT0DBValidation.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 from tools import loadCmsProcess,writeCfg,dqmWorkflowName,getDatasetStr
3 from CmsswTask import *
4 import os
5 
7  def __init__(self, run, dir, input_files, output_dir, config=None):
8  self.runnumber = int(run)
9  self.dir = dir
10  self.output_dir = output_dir
11  self.config = config
12  self.input_files = input_files
13 
14  self.pset_template = 'DQMOffline.CalibMuon.dtT0DBValidation_cfg'
15 
16  self.configs = []
17  self.initProcess()
18  self.task = CmsswTask(self.dir,self.configs)
19 
20  def initProcess(self):
21  refDBTag = ''
22  if hasattr(self.config,'refDBTag') and self.config.refDBTag: refDBTag = self.config.refDBTag
23  connect = ''
24  if hasattr(self.config,'config.connectStrRefDBTag') and self.config.config.connectStrRefDBTag: connect = self.config.config.connectStrRefDBTag
25  runNumbersToFiles = []
26  if hasattr(self.config,'dbValidRuns') and self.config.dbValidRuns and len(self.config.dbValidRuns) == len(self.input_files): runNumbersToFiles = self.config.dbValidRuns
27 
28  self.process = {}
29  idx_file = 0
30  for inputFile in self.input_files:
31  file = os.path.abspath(inputFile)
32  fileLabel = os.path.basename(file).split('.')[0]
33  pset_name = 'dtT0DBValidation_%s_Run%d_cfg.py' % (fileLabel,self.runnumber)
34  self.process[pset_name] = loadCmsProcess(self.pset_template)
35  self.process[pset_name].source.firstRun = self.runnumber
36 
37  self.process[pset_name].tzeroRef.toGet = cms.VPSet(
38  cms.PSet(
39  record = cms.string('DTT0Rcd'),
40  tag = cms.string(refDBTag),
41  label = cms.untracked.string('tzeroRef')
42  ),
43  cms.PSet(
44  record = cms.string('DTT0Rcd'),
45  tag = cms.string('t0'),
46  connect = cms.untracked.string('sqlite_file:%s' % file),
47  label = cms.untracked.string('tzeroToValidate')
48  )
49  )
50  self.process[pset_name].tzeroRef.connect = connect
51 
52  if self.config:
53  label = 'dtT0DBValidation'
54  if hasattr(self.config,'label') and self.config.label: label = self.config.label
55  workflowName = dqmWorkflowName(self.config.datasetpath,label,self.config.trial)
56  self.process[pset_name].dqmSaver.workflow = workflowName
57 
58  if runNumbersToFiles: self.process[pset_name].dqmSaver.forceRunNumber = runNumbersToFiles[idx_file]
59  self.process[pset_name].dqmSaver.dirName = os.path.abspath(self.output_dir)
60 
61  self.configs.append(pset_name)
62  writeCfg(self.process[pset_name],self.dir,pset_name)
63  idx_file += 1
64 
65  """
66  def writeCfg(self):
67  for cfg in self.configs:
68  writeCfg(self.process[cfg],self.dir,cfg)
69  #writeCfgPkl(self.process,self.dir,self.pset_name)
70  """
71 
72  def run(self):
73  self.task.run()
74  return
def loadCmsProcess
Definition: tools.py:144
def writeCfg
Definition: tools.py:158
def dqmWorkflowName
Definition: tools.py:23
double split
Definition: MVATrainer.cc:139