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:
76 self.add_local_custom_db()
77 self.prepare_common_submit()
78 self.write_pset_file()
81 self.load_options_command(
"submit")
85 if isinstance(self.
output_db_dict[self.options.workflow_mode], dict):
87 self.prepare_common_write()
88 merged_file = os.path.join(self.result_path, self.
output_file)
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))
97 self.write_pset_file()
100 self.load_options_command(
"submit")
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")
118 self.add_local_calib_db(local=
True)
119 self.write_pset_file()
122 self.
pset_name =
'dumpDBToFile_ResidCorr_cfg.py'
123 self.
pset_template =
'CalibMuon.DTCalibration.dumpDBToFile_ttrig_cfg'
124 if self.options.input_dumpDB:
126 test = self.result_path
127 self.load_options_command(
"correction")
130 dbpath = os.path.abspath(self.options.input_dumpDB)
132 dbpath = os.path.abspath( os.path.join(self.result_path,
135 self.prepare_common_dump(dbpath)
136 self.write_pset_file()
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
155 self.prepare_common_submit()
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:
161 self.add_local_calib_db()
162 self.write_pset_file()
165 self.load_options_command(
"submit")
168 self.
pset_name =
"dtTTrigResidualCorrection_cfg.py"
169 self.
pset_template =
'CalibMuon.DTCalibration.dtTTrigResidualCorrection_cfg'
171 self.load_options_command(
"submit")
172 self.process.source.firstRun = cms.untracked.uint32(self.options.run)
173 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
175 tag = self.prepare_common_write()
176 if self.options.inputT0DB:
177 log.warning(
"Option inputT0DB not supported for residual corrections")
179 if self.options.inputDBTag:
180 self.add_local_custom_db(local=
True)
181 if self.options.inputVDriftDB:
182 self.add_local_vdrift_db(local=
True)
183 if self.options.inputCalibDB:
184 self.add_local_calib_db(local=
True)
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
192 rootfile_path = os.path.abspath( os.path.join(self.result_path, self.
output_file))
193 merged_file = os.path.join(self.result_path, self.
output_file)
194 self.process.dtTTrigResidualCorrection.correctionAlgoConfig.residualsRootFile = merged_file
195 self.write_pset_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)
204 test = self.result_path
205 self.load_options_command(
"write")
208 dbpath = os.path.abspath( os.path.join(self.result_path,
211 self.prepare_common_dump(dbpath)
212 self.write_pset_file()
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))
232 self.prepare_common_submit()
233 if self.options.inputCalibDB:
234 self.add_local_calib_db()
235 self.write_pset_file()
238 self.load_options_command(
"submit")
242 self.
pset_template =
'CalibMuon.DTCalibration.dtDQMClient_cfg'
244 self.prepare_common_write(do_hadd =
False)
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
254 self.write_pset_file()
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(
293 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
294 super(DTttrigWorkflow,cls).get_submission_options_parser(),
295 super(DTttrigWorkflow,cls).get_input_db_options_parser()],
296 help =
"Submit job to the GRID via crab3")
298 ttrig_timeboxes_check_parser = ttrig_timeboxes_subparsers.add_parser(
300 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
301 super(DTttrigWorkflow,cls).get_check_options_parser(),],
302 help =
"Check status of submitted jobs")
304 ttrig_timeboxes_write_parser = ttrig_timeboxes_subparsers.add_parser(
306 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
307 super(DTttrigWorkflow,cls).get_write_options_parser()
309 help =
"Write result from root output to text file")
311 ttrig_timeboxes_correction_parser = ttrig_timeboxes_subparsers.add_parser(
313 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
314 super(DTttrigWorkflow,cls).get_local_input_db_options_parser()
316 help =
"Perform correction on uncorrected ttrig database")
318 ttrig_timeboxes_dump_parser = ttrig_timeboxes_subparsers.add_parser(
320 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
321 super(DTttrigWorkflow,cls).get_dump_options_parser()],
322 help =
"Dump database to text file")
324 ttrig_timeboxes_all_parser = ttrig_timeboxes_subparsers.add_parser(
326 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
327 super(DTttrigWorkflow,cls).get_submission_options_parser(),
328 super(DTttrigWorkflow,cls).get_check_options_parser(),
329 super(DTttrigWorkflow,cls).get_input_db_options_parser(),
330 super(DTttrigWorkflow,cls).get_local_input_db_options_parser(),
331 super(DTttrigWorkflow,cls).get_write_options_parser(),
332 super(DTttrigWorkflow,cls).get_dump_options_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(
344 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
345 super(DTttrigWorkflow,cls).get_submission_options_parser(),
346 super(DTttrigWorkflow,cls).get_check_options_parser(),
347 super(DTttrigWorkflow,cls).get_local_input_db_options_parser(),
348 super(DTttrigWorkflow,cls).get_input_db_options_parser()],
349 help =
"Submit job to the GRID via crab3")
351 ttrig_residuals_check_parser = ttrig_residuals_subparsers.add_parser(
353 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
354 super(DTttrigWorkflow,cls).get_check_options_parser(),],
355 help =
"Check status of submitted jobs")
357 ttrig_residuals_correct_parser = ttrig_residuals_subparsers.add_parser(
359 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
360 super(DTttrigWorkflow,cls).get_write_options_parser(),
361 super(DTttrigWorkflow,cls).get_local_input_db_options_parser(),
362 super(DTttrigWorkflow,cls).get_input_db_options_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(
369 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
370 super(DTttrigWorkflow,cls).get_dump_options_parser()],
371 help =
"Dump database to text file")
373 ttrig_residuals_all_parser = ttrig_residuals_subparsers.add_parser(
375 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
376 super(DTttrigWorkflow,cls).get_submission_options_parser(),
377 super(DTttrigWorkflow,cls).get_check_options_parser(),
378 super(DTttrigWorkflow,cls).get_write_options_parser(),
379 super(DTttrigWorkflow,cls).get_local_input_db_options_parser(),
380 super(DTttrigWorkflow,cls).get_dump_options_parser(),
381 super(DTttrigWorkflow,cls).get_input_db_options_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(
392 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
393 super(DTttrigWorkflow,cls).get_submission_options_parser(),
394 super(DTttrigWorkflow,cls).get_check_options_parser(),
395 super(DTttrigWorkflow,cls).get_local_input_db_options_parser(),
396 super(DTttrigWorkflow,cls).get_input_db_options_parser()],
397 help =
"Submit job to the GRID via crab3")
400 ttrig_validation_check_parser = ttrig_validation_subparsers.add_parser(
402 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
403 super(DTttrigWorkflow,cls).get_check_options_parser(),],
404 help =
"Check status of submitted jobs")
406 ttrig_validation_write_parser = ttrig_validation_subparsers.add_parser(
408 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
409 super(DTttrigWorkflow,cls).get_write_options_parser()],
410 help =
"Create summary for validation")
412 ttrig_validation_all_parser = ttrig_validation_subparsers.add_parser(
414 parents=[super(DTttrigWorkflow,cls).get_common_options_parser(),
415 super(DTttrigWorkflow,cls).get_submission_options_parser(),
416 super(DTttrigWorkflow,cls).get_check_options_parser(),
417 super(DTttrigWorkflow,cls).get_write_options_parser(),
418 super(DTttrigWorkflow,cls).get_local_input_db_options_parser(),
419 super(DTttrigWorkflow,cls).get_input_db_options_parser()],
420 help =
"Perform all steps: submit, check, summary")
outpath_workflow_mode_dict
def prepare_validation_check
def prepare_residuals_submit
prepare functions for residuals #
def prepare_residuals_check
def prepare_residuals_dump
def add_parser_options
CLI creation #.
def prepare_timeboxes_all
def prepare_timeboxes_correction
def prepare_residuals_correction
def prepare_timeboxes_submit
Prepare functions for timeboxes #.
def prepare_validation_all
def prepare_timeboxes_check
def prepare_timeboxes_dump
def prepare_residuals_all
def prepare_validation_write
def prepare_timeboxes_write
def prepare_validation_submit
prepare functions for validation #