CMS 3D CMS Logo

DTDQMValidation.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  def __init__(self, run, dir, config):
9  self.outputfile = 'DQM.root'
10  self.config = config
11  self.dir = dir
12  #self.inputdb = input_db
13 
14  self.pset_name = 'dtDQM_cfg.py'
15  self.pset_template = 'CalibMuon.DTCalibration.dtDQMAlca_cfg'
16  if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics:
17  self.pset_template = 'CalibMuon.DTCalibration.dtDQMAlca_cosmics_cfg'
18 
19  self.process = None
20  self.crab_cfg = None
21  self.initProcess()
22  self.initCrab()
23  self.task = CrabTask(self.dir,self.crab_cfg)
24 
25  def initProcess(self):
27  self.process.GlobalTag.globaltag = self.config.globaltag
28 
29  if hasattr(self.config,'inputDBTag') and self.config.inputDBTag:
30  tag = self.config.inputDBTag
31  record = self.config.inputDBRcd
32  connect = self.config.connectStrDBTag
33  moduleName = 'customDB%s' % record
34  addPoolDBESSource(process = self.process,
35  moduleName = moduleName,record = record,tag = tag,
36  connect = connect)
37 
38  if hasattr(self.config,'inputTTrigDB') and self.config.inputTTrigDB:
39  label = ''
40  if hasattr(self.config,'runOnCosmics') and self.config.runOnCosmics: label = 'cosmics'
41  addPoolDBESSource(process = self.process,
42  moduleName = 'tTrigDB',record = 'DTTtrigRcd',tag = 'ttrig',label = label,
43  connect = 'sqlite_file:%s' % os.path.basename(self.config.inputTTrigDB))
44 
45  if hasattr(self.config,'inputVDriftDB') and self.config.inputVDriftDB:
46  addPoolDBESSource(process = self.process,
47  moduleName = 'vDriftDB',record = 'DTMtimeRcd',tag = 'vDrift',
48  connect = 'sqlite_file:%s' % os.path.basename(self.config.inputVDriftDB))
49 
50  if hasattr(self.config,'inputT0DB') and self.config.inputT0DB:
51  addPoolDBESSource(process = self.process,
52  moduleName = 't0DB',record = 'DTT0Rcd',tag = 't0',
53  connect = 'sqlite_file:%s' % os.path.basename(self.config.inputT0DB))
54 
55  if hasattr(self.config,'runOnRAW') and self.config.runOnRAW:
56  if hasattr(self.config,'runOnMC') and self.config.runOnMC:
57  getattr(self.process,self.config.digilabel).inputLabel = 'rawDataCollector'
58  prependPaths(self.process,self.config.digilabel)
59 
60  if hasattr(self.config,'preselection') and self.config.preselection:
61  pathsequence = self.config.preselection.split(':')[0]
62  seqname = self.config.preselection.split(':')[1]
63  self.process.load(pathsequence)
64  prependPaths(self.process,seqname)
65 
66  def initCrab(self):
67  crab_cfg_parser = loadCrabCfg()
68  loadCrabDefault(crab_cfg_parser,self.config)
69  crab_cfg_parser.set('CMSSW','pset',self.pset_name)
70  crab_cfg_parser.set('CMSSW','output_file',self.outputfile)
71  crab_cfg_parser.remove_option('USER','additional_input_files')
72  #if self.inputdb:
73  # addCrabInputFile(crab_cfg_parser,self.inputdb)
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 loadCrabCfg(cfgName=None)
Definition: tools.py:178
def loadCrabDefault(crabCfg, config)
Definition: tools.py:195
def prependPaths(process, seqname)
Definition: tools.py:154
def loadCmsProcess(psetPath)
Definition: tools.py:144
def addCrabInputFile(crabCfg, inputFile)
Definition: tools.py:183
def __init__(self, run, dir, config)