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"}
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'
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
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,
109 self.
process.PoolDBOutputService.connect =
'sqlite_file:%s' % ttrig_timeboxes_db
111 if not self.
options.inputCalibDB:
115 log.warning(
"Options inputVDriftDB has no effect for timeboxes correction")
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'
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'
157 self.
process.dtResidualCalibration.Muons = cms.InputTag(
"muons")
159 self.
process.dtResidualCalibration.histogramRange = cms.double(
float(self.
options.histoRange))
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)
177 log.warning(
"Option inputT0DB not supported for residual corrections")
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'
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'
229 self.
pset_template =
'CalibMuon.DTCalibration.dtCalibValidationFromMuons_cfg'
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
252 if self.
process.DQMStore.collateHistograms ==
True:
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")