1 from __future__
import absolute_import
6 import FWCore.ParameterSet.Config
as cms
7 from .DTWorkflow
import DTWorkflow
9 log = logging.getLogger(__name__)
12 """ This class creates and performce / submits vdrift workflow jobs"""
15 super( DTvdriftWorkflow, self ).
__init__( options )
18 output_file_dict = {
"segment" :
"DTVDriftHistos.root",
19 "meantimer" :
"DTTMaxHistos.root",
22 "meantimer" :
"MeanTimer",
24 self.
output_file = output_file_dict[self.options.workflow_mode]
28 """ Generalized function to prepare workflow dependent on workflow mode"""
29 function_name =
"prepare_" + self.options.workflow_mode +
"_" + self.options.command
32 fill_function = getattr(self, function_name)
33 except AttributeError:
34 errmsg =
"Class `{}` does not implement `{}`"
35 raise NotImplementedError( errmsg.format(self.__class__.__name__,
37 log.debug(
"Preparing workflow with function %s" % function_name)
42 self.
pset_name =
'dtVDriftSegmentCalibration_cfg.py'
43 self.
pset_template =
'CalibMuon.DTCalibration.dtVDriftSegmentCalibration_cfg'
44 if self.options.datasettype ==
"Cosmics":
45 self.
pset_template =
'CalibMuon.DTCalibration.dtVDriftSegmentCalibration_cosmics_cfg'
48 self.process.GlobalTag.globaltag = self.options.globaltag
49 self.process.dtVDriftSegmentCalibration.rootFileName = self.
output_file
51 if self.options.inputCalibDB:
52 err =
"Option inputCalibDB not available for segment."
53 err +=
"Maybe you want to use option inputTtrigDB"
55 self.prepare_common_submit()
56 if self.options.inputTtrigDB:
58 if self.options.datasettype ==
"Cosmics":
60 connect = os.path.basename(self.options.inputTtrigDB)
61 self.addPoolDBESSource( process = self.
process,
62 moduleName =
'tTrigDB',
63 record =
'DTTtrigRcd',
65 connect =
str(
"sqlite_file:%s" % connect),
68 self.input_files.append( os.path.abspath(self.options.inputTtrigDB) )
69 self.write_pset_file()
72 self.load_options_command(
"submit")
75 self.
pset_name =
'dtVDriftSegmentWriter_cfg.py'
76 self.
pset_template =
'CalibMuon.DTCalibration.dtVDriftSegmentWriter_cfg'
77 tag = self.prepare_common_write()
78 merged_file = os.path.join(self.result_path, self.
output_file)
81 if self.options.inputVDriftDB:
82 self.add_local_vdrift_db(self)
83 vdrift_db =
"vDrift_segment"+ tag +
".db"
84 vdrift_db = os.path.join(self.result_path, vdrift_db)
85 self.process.dtVDriftSegmentWriter.vDriftAlgoConfig.rootFileName =
"file:///" + merged_file
86 self.process.PoolDBOutputService.connect =
'sqlite_file:%s' % vdrift_db
87 self.process.source.firstRun = cms.untracked.uint32(self.options.run)
88 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
89 self.write_pset_file()
92 self.
pset_name =
'dumpDBToFile_vdrift_cfg.py'
93 self.
pset_template =
'CalibMuon.DTCalibration.dumpDBToFile_vdrift_cfg'
94 if self.options.input_dumpDB:
96 test = self.result_path
97 self.load_options_command(
"write")
100 dbpath = os.path.abspath(self.options.input_dumpDB)
102 crabtask = self.crabFunctions.CrabTask(crab_config = self.crab_config_filepath,
104 tag = crabtask.crabConfig.Data.outputDatasetTag
105 dbpath = os.path.abspath( os.path.join(self.result_path,
106 "vDrift_segment"+ tag +
".db"))
107 self.prepare_common_dump(dbpath)
108 self.write_pset_file()
119 self.
pset_name =
'dtVDriftMeanTimerCalibration_cfg.py'
120 self.
pset_template =
'CalibMuon.DTCalibration.dtVDriftMeanTimerCalibration_cfg'
121 if self.options.datasettype ==
"Cosmics":
122 self.
pset_template =
'CalibMuon.DTCalibration.dtVDriftMeanTimerCalibration_cosmics_cfg'
125 self.process.GlobalTag.globaltag = self.options.globaltag
126 self.process.dtVDriftMeanTimerCalibration.rootFileName = self.
output_file
128 if self.options.inputCalibDB:
129 err =
"Option inputCalibDB not available for meantimer."
130 err +=
"Maybe you want to use option inputTtrigDB"
131 raise ValueError(err)
132 self.prepare_common_submit()
133 if self.options.inputTtrigDB:
135 if self.options.datasettype ==
"Cosmics":
137 connect = os.path.basename(self.options.inputTtrigDB)
138 self.addPoolDBESSource( process = self.
process,
139 moduleName =
'tTrigDB',
140 record =
'DTTtrigRcd',
142 connect =
str(
"sqlite_file:%s" % connect),
145 self.input_files.append( os.path.abspath(self.options.inputTtrigDB) )
146 self.write_pset_file()
149 self.load_options_command(
"submit")
152 self.
pset_name =
'dtVDriftMeanTimerWriter_cfg.py'
153 self.
pset_template =
'CalibMuon.DTCalibration.dtVDriftMeanTimerWriter_cfg'
154 tag = self.prepare_common_write()
155 merged_file = os.path.join(self.result_path, self.
output_file)
158 if self.options.inputVDriftDB:
159 self.add_local_vdrift_db(self)
160 vdrift_db =
"vDrift_meantimer" + tag +
".db"
161 vdrift_db = os.path.join(self.result_path, vdrift_db)
162 self.process.dtVDriftMeanTimerWriter.vDriftAlgoConfig.rootFileName =
"file:///" + merged_file
163 self.process.PoolDBOutputService.connect =
'sqlite_file:%s' % vdrift_db
164 self.process.source.firstRun = cms.untracked.uint32(self.options.run)
165 self.process.GlobalTag.globaltag = cms.string(
str(self.options.globaltag))
166 self.write_pset_file()
169 self.
pset_name =
'dumpDBToFile_vdrift_cfg.py'
170 self.
pset_template =
'CalibMuon.DTCalibration.dumpDBToFile_vdrift_cfg'
171 if self.options.input_dumpDB:
173 test = self.result_path
174 self.load_options_command(
"write")
177 dbpath = os.path.abspath(self.options.input_dumpDB)
179 crabtask = self.crabFunctions.CrabTask(crab_config = self.crab_config_filepath,
181 tag = crabtask.crabConfig.Data.outputDatasetTag
182 dbpath = os.path.abspath( os.path.join(self.result_path,
183 "vDrift_meantimer" + tag +
".db"))
184 self.prepare_common_dump(dbpath)
185 self.write_pset_file()
197 vdrift_parser = subparser_container.add_parser(
"vdrift",
204 vdrift_subparsers = vdrift_parser.add_subparsers( dest=
"workflow_mode",
205 help=
"Possible workflow modes",)
207 vdrift_segment_subparser = vdrift_subparsers.add_parser(
"segment",
210 vdrift_meantimer_subparser = vdrift_subparsers.add_parser(
"meantimer",
216 vdrift_segment_subparsers = vdrift_segment_subparser.add_subparsers( dest=
"command",
217 help=
"Possible commands for segments")
218 vdrift_segment_submit_parser = vdrift_segment_subparsers.add_parser(
220 parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(),
221 super(DTvdriftWorkflow,cls).get_submission_options_parser(),
222 super(DTvdriftWorkflow,cls).get_local_input_db_options_parser(),
223 super(DTvdriftWorkflow,cls).get_input_db_options_parser()],
224 help =
"Submit job to the GRID via crab3")
225 vdrift_segment_submit_parser.add_argument(
"--inputTtrigDB",
226 help=
"Local alternative calib ttrig db")
228 vdrift_segment_check_parser = vdrift_segment_subparsers.add_parser(
230 parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(),
231 super(DTvdriftWorkflow,cls).get_check_options_parser()],
232 help =
"Check status of submitted jobs")
234 vdrift_segment_write_parser = vdrift_segment_subparsers.add_parser(
236 parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(),
237 super(DTvdriftWorkflow,cls).get_write_options_parser()
239 help =
"Write result from root output to text file")
241 vdrift_segment_dump_parser = vdrift_segment_subparsers.add_parser(
243 parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(),
244 super(DTvdriftWorkflow,cls).get_dump_options_parser()],
245 help =
"Dump database to text file")
247 vdrift_segment_all_parser = vdrift_segment_subparsers.add_parser(
249 parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(),
250 super(DTvdriftWorkflow,cls).get_submission_options_parser(),
251 super(DTvdriftWorkflow,cls).get_check_options_parser(),
252 super(DTvdriftWorkflow,cls).get_input_db_options_parser(),
253 super(DTvdriftWorkflow,cls).get_local_input_db_options_parser(),
254 super(DTvdriftWorkflow,cls).get_write_options_parser(),
255 super(DTvdriftWorkflow,cls).get_dump_options_parser()
257 help =
"Perform all steps: submit, check, write, dump in this order")
258 vdrift_segment_all_parser.add_argument(
"--inputTtrigDB",
259 help=
"Local alternative calib ttrig db")
263 vdrift_meantimer_subparsers = vdrift_meantimer_subparser.add_subparsers( dest=
"command",
264 help=
"Possible commands for meantimers")
265 vdrift_meantimer_submit_parser = vdrift_meantimer_subparsers.add_parser(
267 parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(),
268 super(DTvdriftWorkflow,cls).get_submission_options_parser(),
269 super(DTvdriftWorkflow,cls).get_local_input_db_options_parser(),
270 super(DTvdriftWorkflow,cls).get_input_db_options_parser()],
271 help =
"Submit job to the GRID via crab3")
272 vdrift_meantimer_submit_parser.add_argument(
"--inputTtrigDB",
273 help=
"Local alternative calib ttrig db")
275 vdrift_meantimer_check_parser = vdrift_meantimer_subparsers.add_parser(
277 parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(),
278 super(DTvdriftWorkflow,cls).get_check_options_parser()],
279 help =
"Check status of submitted jobs")
281 vdrift_meantimer_write_parser = vdrift_meantimer_subparsers.add_parser(
283 parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(),
284 super(DTvdriftWorkflow,cls).get_write_options_parser()
286 help =
"Write result from root output to text file")
288 vdrift_meantimer_dump_parser = vdrift_meantimer_subparsers.add_parser(
290 parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(),
291 super(DTvdriftWorkflow,cls).get_dump_options_parser()],
292 help =
"Dump database to text file")
294 vdrift_meantimer_all_parser = vdrift_meantimer_subparsers.add_parser(
296 parents=[super(DTvdriftWorkflow,cls).get_common_options_parser(),
297 super(DTvdriftWorkflow,cls).get_submission_options_parser(),
298 super(DTvdriftWorkflow,cls).get_check_options_parser(),
299 super(DTvdriftWorkflow,cls).get_input_db_options_parser(),
300 super(DTvdriftWorkflow,cls).get_local_input_db_options_parser(),
301 super(DTvdriftWorkflow,cls).get_write_options_parser(),
302 super(DTvdriftWorkflow,cls).get_dump_options_parser()
304 help =
"Perform all steps: submit, check, write, dump in this order")
305 vdrift_meantimer_all_parser.add_argument(
"--inputTtrigDB",
306 help=
"Local alternative calib ttrig db")
def prepare_meantimer_submit
Mean Timer #.
def prepare_meantimer_write
def prepare_meantimer_all
def prepare_segment_write
def prepare_meantimer_check
def prepare_segment_submit
def prepare_segment_check
def add_parser_options
CLI creation #.
outpath_workflow_mode_dict
def prepare_meantimer_dump