6 import FWCore.ParameterSet.Config
as cms
7 from DTWorkflow
import DTWorkflow
9 log = logging.getLogger(__name__)
12 """ This class creates and performce / submits ttrig workflow jobs""" 15 super( DTttrigWorkflow, self ).
__init__( options )
19 output_file_dict ={
"timeboxes" :
"DTTimeBoxes.root",
20 "residuals" :
'residuals.root',
21 "validation" :
"DQM.root" 25 "timeboxes" :
"TimeBoxes",
26 "residuals" :
"Residuals",
27 "validation" :
"TtrigValidation" 31 "write":
"ttrig_timeboxes_uncorrected_" 34 "correction":
"ttrig_timeboxes_" 38 "residuals" :
"ttrig_residuals_" + self.
tag +
".db"}
39 self.
output_file = output_file_dict[self.options.workflow_mode]
43 """ Generalized function to prepare workflow dependent on workflow mode""" 44 function_name =
"prepare_" + self.options.workflow_mode +
"_" + self.options.command
46 fill_function = getattr(self, function_name)
47 except AttributeError:
48 errmsg =
"Class `{}` does not implement `{}`" 49 raise NotImplementedError( errmsg.format(self.__class__.__name__,
51 log.debug(
"Preparing workflow with function %s" % function_name)
57 if type(output_db_file) == dict:
58 return output_db_file[command]
66 if self.options.datasettype ==
"Cosmics":
67 self.
pset_template =
'CalibMuon.DTCalibration.dtTTrigCalibration_cosmics_cfg' 70 self.process.GlobalTag.globaltag = self.options.globaltag
71 self.process.dtTTrigCalibration.rootFileName = self.
output_file 72 self.process.dtTTrigCalibration.digiLabel = self.
digilabel 74 if self.options.inputDBTag:
88 ttrig_uncorrected_db = os.path.join(self.
result_path,
91 self.
pset_template =
"CalibMuon.DTCalibration.dtTTrigWriter_cfg" 93 self.process.dtTTrigWriter.rootFileName =
"file:///" + merged_file
94 self.process.PoolDBOutputService.connect =
'sqlite_file:%s' % ttrig_uncorrected_db
95 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
100 self.
pset_name =
'dtTTrigCorrection_cfg.py' 101 self.
pset_template =
"CalibMuon.DTCalibration.dtTTrigCorrection_cfg" 102 ttrig_timeboxes_db =
"ttrig_timeboxes_"+ self.
tag +
".db" 103 ttrig_timeboxes_db = os.path.join(self.
result_path,
106 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
107 self.process.source.firstRun = self.options.run
108 self.process.PoolDBOutputService.connect =
'sqlite_file:%s' % ttrig_timeboxes_db
110 if not self.options.inputCalibDB:
111 self.options.inputCalibDB = os.path.join(self.
result_path,
113 if self.options.inputVDriftDB:
114 log.warning(
"Options inputVDriftDB has no effect for timeboxes correction")
115 if self.options.inputT0DB:
116 log.warning(
"Options inputT0DB has no effect for timeboxes correction")
121 self.
pset_name =
'dumpDBToFile_ResidCorr_cfg.py' 122 self.
pset_template =
'CalibMuon.DTCalibration.dumpDBToFile_ttrig_cfg' 123 if self.options.input_dumpDB:
129 dbpath = os.path.abspath(self.options.input_dumpDB)
131 dbpath = os.path.abspath( os.path.join(self.
result_path,
146 self.
pset_name =
'dtResidualCalibration_cfg.py' 147 self.
pset_template =
'CalibMuon.DTCalibration.dtResidualCalibration_cfg' 148 if self.options.datasettype ==
"Cosmics":
149 self.
pset_template =
'CalibMuon.DTCalibration.dtResidualCalibration_cosmics_cfg' 152 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
153 self.process.dtResidualCalibration.rootFileName = self.
output_file 155 if self.options.histoRange:
156 self.process.dtResidualCalibration.histogramRange = cms.double(
float(self.options.histoRange))
157 if self.options.inputCalibDB:
165 self.
pset_name =
"dtTTrigResidualCorrection_cfg.py" 166 self.
pset_template =
'CalibMuon.DTCalibration.dtTTrigResidualCorrection_cfg' 169 self.process.source.firstRun = cms.untracked.uint32(self.options.run)
170 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
173 if self.options.inputT0DB:
174 log.warning(
"Option inputT0DB not supported for residual corrections")
176 if self.options.inputDBTag:
178 if self.options.inputVDriftDB:
180 if self.options.inputCalibDB:
183 if self.options.datasettype ==
"Cosmics":
184 self.process.dtTTrigResidualCorrection.dbLabel =
'cosmics' 185 self.process.dtTTrigResidualCorrection.correctionAlgoConfig.dbLabel =
'cosmics' 186 ttrig_ResidCorr_db = os.path.abspath( os.path.join(self.
result_path,
188 self.process.PoolDBOutputService.connect =
'sqlite_file:%s' % ttrig_ResidCorr_db
191 self.process.dtTTrigResidualCorrection.correctionAlgoConfig.residualsRootFile = merged_file
195 self.
pset_name =
'dumpDBToFile_ResidCorr_cfg.py' 196 self.
pset_template =
'CalibMuon.DTCalibration.dumpDBToFile_ttrig_cfg' 197 if self.options.input_dumpDB:
198 dbpath = os.path.abspath(self.options.input_dumpDB)
205 dbpath = os.path.abspath( os.path.join(self.
result_path,
214 self.
all_commands=[
"submit",
"check",
"correction",
"dump"]
221 self.
pset_name =
'dtCalibValidation_cfg.py' 222 self.
pset_template =
'CalibMuon.DTCalibration.dtCalibValidation_cfg' 223 if self.options.datasettype ==
"Cosmics":
224 self.
pset_template =
'CalibMuon.DTCalibration.dtCalibValidation_cosmics_cfg' 226 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
236 self.
pset_template =
'CalibMuon.DTCalibration.dtDQMClient_cfg' 239 dqm_files = glob.glob(os.path.join( self.
local_path,
242 dqm_files[:] = [
"file://"+txt
for txt
in dqm_files]
243 self.process.source.fileNames = dqm_files
244 self.process.dqmSaver.dirName = os.path.abspath(self.
result_path)
245 self.process.dqmSaver.workflow =
str(self.options.datasetpath)
246 if self.process.DQMStore.collateHistograms ==
True:
247 self.process.dqmSaver.forceRunNumber = self.options.run
256 self.all_commands=[
"submit",
"check",
"write"]
263 ttrig_parser = subparser_container.add_parser(
"ttrig",
271 ttrig_subparsers = ttrig_parser.add_subparsers( dest=
"workflow_mode",
272 help=
"Possible workflow modes",)
274 ttrig_timeboxes_subparser = ttrig_subparsers.add_parser(
"timeboxes",
276 ttrig_residuals_subparser = ttrig_subparsers.add_parser(
"residuals",
278 ttrig_validation_subparser = ttrig_subparsers.add_parser(
"validation",
283 ttrig_timeboxes_subparsers = ttrig_timeboxes_subparser.add_subparsers( dest=
"command",
284 help=
"Possible commands for timeboxes")
285 ttrig_timeboxes_submit_parser = ttrig_timeboxes_subparsers.add_parser(
290 help =
"Submit job to the GRID via crab3")
292 ttrig_timeboxes_check_parser = ttrig_timeboxes_subparsers.add_parser(
296 help =
"Check status of submitted jobs")
298 ttrig_timeboxes_write_parser = ttrig_timeboxes_subparsers.add_parser(
303 help =
"Write result from root output to text file")
305 ttrig_timeboxes_correction_parser = ttrig_timeboxes_subparsers.add_parser(
310 help =
"Perform correction on uncorrected ttrig database")
312 ttrig_timeboxes_dump_parser = ttrig_timeboxes_subparsers.add_parser(
316 help =
"Dump database to text file")
318 ttrig_timeboxes_all_parser = ttrig_timeboxes_subparsers.add_parser(
328 help =
"Perform all steps: submit, check, write, correction,"\
329 "dump in this order")
334 ttrig_residuals_subparsers = ttrig_residuals_subparser.add_subparsers( dest=
"command",
335 help=
"Possible commands for residuals")
336 ttrig_residuals_submit_parser = ttrig_residuals_subparsers.add_parser(
343 help =
"Submit job to the GRID via crab3")
345 ttrig_residuals_check_parser = ttrig_residuals_subparsers.add_parser(
349 help =
"Check status of submitted jobs")
351 ttrig_residuals_correct_parser = ttrig_residuals_subparsers.add_parser(
357 help =
"Perform residual corrections")
358 ttrig_residuals_correct_parser.add_argument(
"--globaltag",
359 help=
"Alternative globalTag. Otherwise the gt for sunmission is used")
361 ttrig_residuals_dump_parser = ttrig_residuals_subparsers.add_parser(
365 help =
"Dump database to text file")
367 ttrig_residuals_all_parser = ttrig_residuals_subparsers.add_parser(
376 help =
"Perform all steps: submit, check, correct, dump")
381 ttrig_validation_subparsers = ttrig_validation_subparser.add_subparsers( dest=
"command",
382 help=
"Possible commands for residuals")
384 ttrig_validation_submit_parser = ttrig_validation_subparsers.add_parser(
391 help =
"Submit job to the GRID via crab3")
394 ttrig_validation_check_parser = ttrig_validation_subparsers.add_parser(
398 help =
"Check status of submitted jobs")
400 ttrig_validation_write_parser = ttrig_validation_subparsers.add_parser(
404 help =
"Create summary for validation")
406 ttrig_validation_all_parser = ttrig_validation_subparsers.add_parser(
414 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)