CMS 3D CMS Logo

optionsL1T.py
Go to the documentation of this file.
1 from __future__ import print_function
2 #
3 # L1T Command Line Options:
4 #
5 # Append this snippet to you cmsDriver.py config file like this:
6 #
7 # cat L1Trigger/L1TCommon/scripts/optionsL1T.py
8 #
9 # to provide support for command-line options such as:
10 #
11 # maxEvents=<n>
12 # skip=<n>
13 # ntuple=<file>
14 # inputFiles="file1.root,file2.root"
15 #
16 # menu (not yet implemented)
17 #
18 import FWCore.ParameterSet.Config as cms
19 import FWCore.ParameterSet.VarParsing as VarParsing
20 import os
21 import sys
22 import commands
23 options = VarParsing.VarParsing ('analysis')
24 options = VarParsing.VarParsing ('analysis')
25 options.register ('ntuple', "", VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "The output ntuple file name")
26 options.register ('menu', "", VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.string, "Override the L1 menu with specified XML file")
27 options.register ('skip', "", VarParsing.VarParsing.multiplicity.singleton, VarParsing.VarParsing.varType.int, "The number of events to skip initially")
28 options.ntuple = ''
29 options.menu = ''
30 options.skip = 0
31 print(options)
32 
33 options.parseArguments()
34 
35 if (not options.menu == ""):
36  print("L1T INFO: menu override in command line not yet implemented...")
37 
38 if (not options.ntuple == ""):
39  print("L1T INFO: using command line option ntuple: ", options.ntuple)
40  if (hasattr(process,"TFileService")):
41  process.TFileService.fileName = cms.string(options.ntuple)
42  #print process.TFileService
43 
44 if (hasattr(process,"maxEvents")):
45  print("L1T INFO: using command line option maxEvents: ", options.maxEvents)
46  process.maxEvents.input = options.maxEvents
47  #print process.maxEvents
48 
49 if (hasattr(process,"source")):
50  if options.skip > 0:
51  print("L1T INFO: using command line option skip: ", options.skip)
52  process.source.skipEvents = cms.untracked.uint32(options.skip)
53  if (not options.inputFiles == []):
54  print("L1T INFO: using command line option inputFiles: ", options.inputFiles)
55  process.source.fileNames = cms.untracked.vstring(options.inputFiles)
edm::print
S & print(S &os, JobReport::InputFile const &f)
Definition: JobReport.cc:66
VarParsing.VarParsing
Definition: VarParsing.py:10