1 from __future__
import absolute_import
7 import FWCore.ParameterSet.Config
as cms
8 from .DTWorkflow
import DTWorkflow
10 log = logging.getLogger(__name__)
13 """ This class creates and performce / submits ttrig workflow jobs""" 16 super( DTttrigWorkflow, self ).
__init__( options )
20 output_file_dict ={
"timeboxes" :
"DTTimeBoxes.root",
21 "residuals" :
'residuals.root',
22 "validation" :
"DQM.root" 26 "timeboxes" :
"TimeBoxes",
27 "residuals" :
"Residuals",
28 "validation" :
"TtrigValidation" 32 "write":
"ttrig_timeboxes_uncorrected_" 35 "correction":
"ttrig_timeboxes_" 39 "residuals" :
"ttrig_residuals_" + self.
tag +
".db"}
40 self.
output_file = output_file_dict[self.options.workflow_mode]
44 """ Generalized function to prepare workflow dependent on workflow mode""" 45 function_name =
"prepare_" + self.options.workflow_mode +
"_" + self.options.command
47 fill_function = getattr(self, function_name)
48 except AttributeError:
49 errmsg =
"Class `{}` does not implement `{}`" 50 raise NotImplementedError( errmsg.format(self.__class__.__name__,
52 log.debug(
"Preparing workflow with function %s" % function_name)
58 if isinstance(output_db_file, dict):
59 return output_db_file[command]
67 if self.options.datasettype ==
"Cosmics":
68 self.
pset_template =
'CalibMuon.DTCalibration.dtTTrigCalibration_cosmics_cfg' 71 self.process.GlobalTag.globaltag = self.options.globaltag
72 self.process.dtTTrigCalibration.rootFileName = self.
output_file 73 self.process.dtTTrigCalibration.digiLabel = self.
digilabel 75 if self.options.inputDBTag:
85 if isinstance(self.
output_db_dict[self.options.workflow_mode], dict):
89 ttrig_uncorrected_db = os.path.join(self.
result_path,
92 self.
pset_template =
"CalibMuon.DTCalibration.dtTTrigWriter_cfg" 94 self.process.dtTTrigWriter.rootFileName =
"file:///" + merged_file
95 self.process.PoolDBOutputService.connect =
'sqlite_file:%s' % ttrig_uncorrected_db
96 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
101 self.
pset_name =
'dtTTrigCorrection_cfg.py' 102 self.
pset_template =
"CalibMuon.DTCalibration.dtTTrigCorrection_cfg" 103 ttrig_timeboxes_db =
"ttrig_timeboxes_"+ self.
tag +
".db" 104 ttrig_timeboxes_db = os.path.join(self.
result_path,
107 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
108 self.process.source.firstRun = self.options.run
109 self.process.PoolDBOutputService.connect =
'sqlite_file:%s' % ttrig_timeboxes_db
111 if not self.options.inputCalibDB:
112 self.options.inputCalibDB = os.path.join(self.
result_path,
114 if self.options.inputVDriftDB:
115 log.warning(
"Options inputVDriftDB has no effect for timeboxes correction")
116 if self.options.inputT0DB:
117 log.warning(
"Options inputT0DB has no effect for timeboxes correction")
122 self.
pset_name =
'dumpDBToFile_ResidCorr_cfg.py' 123 self.
pset_template =
'CalibMuon.DTCalibration.dumpDBToFile_ttrig_cfg' 124 if self.options.input_dumpDB:
130 dbpath = os.path.abspath(self.options.input_dumpDB)
132 dbpath = os.path.abspath( os.path.join(self.
result_path,
147 self.
pset_name =
'dtResidualCalibration_cfg.py' 148 self.
pset_template =
'CalibMuon.DTCalibration.dtResidualCalibration_cfg' 149 if self.options.datasettype ==
"Cosmics":
150 self.
pset_template =
'CalibMuon.DTCalibration.dtResidualCalibration_cosmics_cfg' 153 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
154 self.process.dtResidualCalibration.rootFileName = self.
output_file 156 if self.options.fromMuons:
157 self.process.dtResidualCalibration.Muons = cms.InputTag(
"muons")
158 if self.options.histoRange:
159 self.process.dtResidualCalibration.histogramRange = cms.double(
float(self.options.histoRange))
160 if self.options.inputCalibDB:
168 self.
pset_name =
"dtTTrigResidualCorrection_cfg.py" 169 self.
pset_template =
'CalibMuon.DTCalibration.dtTTrigResidualCorrection_cfg' 172 self.process.source.firstRun = cms.untracked.uint32(self.options.run)
173 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
176 if self.options.inputT0DB:
177 log.warning(
"Option inputT0DB not supported for residual corrections")
179 if self.options.inputDBTag:
181 if self.options.inputVDriftDB:
183 if self.options.inputCalibDB:
186 if self.options.datasettype ==
"Cosmics":
187 self.process.dtTTrigResidualCorrection.dbLabel =
'cosmics' 188 self.process.dtTTrigResidualCorrection.correctionAlgoConfig.dbLabel =
'cosmics' 189 ttrig_ResidCorr_db = os.path.abspath( os.path.join(self.
result_path,
191 self.process.PoolDBOutputService.connect =
'sqlite_file:%s' % ttrig_ResidCorr_db
194 self.process.dtTTrigResidualCorrection.correctionAlgoConfig.residualsRootFile = merged_file
198 self.
pset_name =
'dumpDBToFile_ResidCorr_cfg.py' 199 self.
pset_template =
'CalibMuon.DTCalibration.dumpDBToFile_ttrig_cfg' 200 if self.options.input_dumpDB:
201 dbpath = os.path.abspath(self.options.input_dumpDB)
208 dbpath = os.path.abspath( os.path.join(self.
result_path,
217 self.
all_commands=[
"submit",
"check",
"correction",
"dump"]
224 self.
pset_name =
'dtCalibValidation_cfg.py' 225 self.
pset_template =
'CalibMuon.DTCalibration.dtCalibValidation_cfg' 226 if self.options.datasettype ==
"Cosmics":
227 self.
pset_template =
'CalibMuon.DTCalibration.dtCalibValidation_cosmics_cfg' 228 if self.options.fromMuons:
229 self.
pset_template =
'CalibMuon.DTCalibration.dtCalibValidationFromMuons_cfg' 231 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
233 if self.options.inputCalibDB:
242 self.
pset_template =
'CalibMuon.DTCalibration.dtDQMClient_cfg' 245 dqm_files = glob.glob(os.path.join( self.
local_path,
248 dqm_files[:] = [
"file://"+txt
for txt
in dqm_files]
249 self.process.source.fileNames = dqm_files
250 self.process.dqmSaver.dirName = os.path.abspath(self.
result_path)
251 self.process.dqmSaver.workflow =
str(self.options.datasetpath)
252 if self.process.DQMStore.collateHistograms ==
True:
253 self.process.dqmSaver.forceRunNumber = self.options.run
262 self.all_commands=[
"submit",
"check",
"write"]
269 ttrig_parser = subparser_container.add_parser(
"ttrig",
277 ttrig_subparsers = ttrig_parser.add_subparsers( dest=
"workflow_mode",
278 help=
"Possible workflow modes",)
280 ttrig_timeboxes_subparser = ttrig_subparsers.add_parser(
"timeboxes",
282 ttrig_residuals_subparser = ttrig_subparsers.add_parser(
"residuals",
284 ttrig_validation_subparser = ttrig_subparsers.add_parser(
"validation",
289 ttrig_timeboxes_subparsers = ttrig_timeboxes_subparser.add_subparsers( dest=
"command",
290 help=
"Possible commands for timeboxes")
291 ttrig_timeboxes_submit_parser = ttrig_timeboxes_subparsers.add_parser(
296 help =
"Submit job to the GRID via crab3")
298 ttrig_timeboxes_check_parser = ttrig_timeboxes_subparsers.add_parser(
302 help =
"Check status of submitted jobs")
304 ttrig_timeboxes_write_parser = ttrig_timeboxes_subparsers.add_parser(
309 help =
"Write result from root output to text file")
311 ttrig_timeboxes_correction_parser = ttrig_timeboxes_subparsers.add_parser(
316 help =
"Perform correction on uncorrected ttrig database")
318 ttrig_timeboxes_dump_parser = ttrig_timeboxes_subparsers.add_parser(
322 help =
"Dump database to text file")
324 ttrig_timeboxes_all_parser = ttrig_timeboxes_subparsers.add_parser(
334 help =
"Perform all steps: submit, check, write, correction,"\
335 "dump in this order")
340 ttrig_residuals_subparsers = ttrig_residuals_subparser.add_subparsers( dest=
"command",
341 help=
"Possible commands for residuals")
342 ttrig_residuals_submit_parser = ttrig_residuals_subparsers.add_parser(
349 help =
"Submit job to the GRID via crab3")
351 ttrig_residuals_check_parser = ttrig_residuals_subparsers.add_parser(
355 help =
"Check status of submitted jobs")
357 ttrig_residuals_correct_parser = ttrig_residuals_subparsers.add_parser(
363 help =
"Perform residual corrections")
364 ttrig_residuals_correct_parser.add_argument(
"--globaltag",
365 help=
"Alternative globalTag. Otherwise the gt for sunmission is used")
367 ttrig_residuals_dump_parser = ttrig_residuals_subparsers.add_parser(
371 help =
"Dump database to text file")
373 ttrig_residuals_all_parser = ttrig_residuals_subparsers.add_parser(
382 help =
"Perform all steps: submit, check, correct, dump")
387 ttrig_validation_subparsers = ttrig_validation_subparser.add_subparsers( dest=
"command",
388 help=
"Possible commands for residuals")
390 ttrig_validation_submit_parser = ttrig_validation_subparsers.add_parser(
397 help =
"Submit job to the GRID via crab3")
400 ttrig_validation_check_parser = ttrig_validation_subparsers.add_parser(
404 help =
"Check status of submitted jobs")
406 ttrig_validation_write_parser = ttrig_validation_subparsers.add_parser(
410 help =
"Create summary for validation")
412 ttrig_validation_all_parser = ttrig_validation_subparsers.add_parser(
420 help =
"Perform all steps: submit, check, summary")
outpath_workflow_mode_dict
def prepare_timeboxes_all(self)
def add_local_vdrift_db(self, local=False)
def prepare_timeboxes_check(self)
def prepare_residuals_dump(self)
def prepare_validation_check(self)
def prepare_validation_all(self)
def add_local_calib_db(self, local=False)
def load_options_command(self, command)
def __init__(self, options)
def get_common_options_parser(cls)
def get_dump_options_parser(cls)
def prepare_common_write(self, do_hadd=True)
def get_input_db_options_parser(cls)
def prepare_residuals_submit(self)
prepare functions for residuals #
def prepare_timeboxes_submit(self)
Prepare functions for timeboxes #.
def get_local_input_db_options_parser(cls)
def prepare_residuals_all(self)
def prepare_timeboxes_write(self)
def prepare_residuals_check(self)
def prepare_residuals_correction(self)
def prepare_common_submit(self)
def prepare_common_dump(self, db_path)
def prepare_timeboxes_dump(self)
def prepare_validation_write(self)
def get_output_db(self, workflow_mode, command)
def prepare_validation_submit(self)
prepare functions for validation #
def write_pset_file(self)
def get_submission_options_parser(cls)
def add_parser_options(cls, subparser_container)
CLI creation #.
def get_write_options_parser(cls)
def add_local_custom_db(self)
def prepare_workflow(self)
def get_check_options_parser(cls)
def prepare_timeboxes_correction(self)