Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:47:44

0001 import os
0002 import logging
0003 
0004 import tools
0005 import FWCore.ParameterSet.Config as cms
0006 from DTWorkflow import DTWorkflow
0007 
0008 log = logging.getLogger(__name__)
0009 
0010 class DTT0WireWorkflow(DTWorkflow):
0011     """ This class creates and performce / submits vdrift workflow jobs"""
0012     def __init__(self, options):
0013         # call parent constructor
0014         super(DTT0WireWorkflow, self).__init__(options)
0015 
0016         self.outpath_command_tag = "T0WireCalibration"
0017         self.outpath_workflow_mode_dict = {"all" : "All"}
0018         self.output_file = 'DTTestPulses.root'
0019         self.output_files = ['t0.db', self.output_file, 'DQM.root']
0020 
0021     def prepare_workflow(self):
0022         """ Generalized function to prepare workflow dependent on workflow mode"""
0023         function_name = "prepare_" + self.options.workflow_mode + "_" + self.options.command
0024 
0025         try:
0026             fill_function = getattr(self, function_name)
0027         except AttributeError:
0028             errmsg = "Class `{}` does not implement `{}`"
0029             raise NotImplementedError(errmsg.format(my_cls.__class__.__name__,
0030                                                     method_name))
0031         log.debug("Preparing workflow with function %s" % function_name)
0032         # call chosen function
0033         fill_function()
0034 
0035     def prepare_all_submit(self):
0036         self.pset_name = 'dtT0WireCalibration_cfg.py'
0037         self.pset_template = 'CalibMuon.DTCalibration.dtT0WireCalibration_cfg'
0038 
0039         self.process = tools.loadCmsProcess(self.pset_template)
0040         self.process.GlobalTag.globaltag = self.options.globaltag
0041         self.process.dtT0WireCalibration.rootFileName = self.output_file
0042 
0043         self.prepare_common_submit()
0044         self.write_pset_file()
0045 
0046     def prepare_all_all(self):
0047         # individual prepare functions for all tasks will be called in
0048         # main implementation of all
0049         self.all_commands=["submit"]
0050 
0051     def submit(self):
0052         # Overload to run locally
0053         self.runCMSSWtask()
0054 
0055     ####################################################################
0056     #                           CLI creation                           #
0057     ####################################################################
0058     @classmethod
0059     def add_parser_options(cls, subparser_container):
0060         vdrift_parser = subparser_container.add_parser( "T0Wire",
0061         #parents=[mutual_parent_parser, common_parent_parser],
0062         help = "" ) # What does ttrig
0063 
0064         ################################################################
0065         #                Sub parser options for workflow modes         #
0066         ################################################################
0067         vdrift_subparsers = vdrift_parser.add_subparsers( dest="workflow_mode",
0068             help="Possible workflow modes",)
0069         ## Add all workflow modes for ttrig
0070         vdrift_segment_subparser = vdrift_subparsers.add_parser( "all",
0071             #parents=[mutual_parent_parser, common_parent_parser],
0072             help = "" )
0073         ################################################################
0074         #        Sub parser options for workflow mode segment          #
0075         ################################################################
0076         vdrift_segment_subparsers = vdrift_segment_subparser.add_subparsers( dest="command",
0077             help="Possible commands for all")
0078         vdrift_segment_submit_parser = vdrift_segment_subparsers.add_parser(
0079             "submit",
0080             parents=[super(DTT0WireWorkflow,cls).get_common_options_parser(),
0081                     super(DTT0WireWorkflow,cls).get_submission_options_parser(),
0082                     super(DTT0WireWorkflow,cls).get_local_input_db_options_parser(),
0083                     super(DTT0WireWorkflow,cls).get_input_db_options_parser()],
0084             help = "Run job locally as GRID submission is not supported for T0 Calibration")
0085 
0086         vdrift_segment_all_parser = vdrift_segment_subparsers.add_parser(
0087             "all",
0088             parents=[super(DTT0WireWorkflow,cls).get_common_options_parser(),
0089                      super(DTT0WireWorkflow,cls).get_submission_options_parser(),
0090                      super(DTT0WireWorkflow,cls).get_input_db_options_parser(),
0091                      super(DTT0WireWorkflow,cls).get_local_input_db_options_parser(),
0092                     ],
0093             help = "Perform all steps: submit, check in this order")