CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
customizeHLTforALL.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 def customizeHLTforAll(process, menuType = "GRun", _customInfo = None):
4 
5  # rename "HLTSchedule" to "schedule":
6  # CMSSW policy is to have at most 1 schedule
7  # in the cms.Process, named "schedule"
8  if hasattr(process, 'HLTSchedule'):
9  if process.schedule_() != None:
10  raise Exception('process.schedule already exists')
11  process.setSchedule_(process.HLTSchedule)
12  del process.HLTSchedule
13 
14  if (_customInfo is not None):
15 
16  _maxEvents = _customInfo['maxEvents']
17  _globalTag = _customInfo['globalTag']
18  _inputFile = _customInfo['inputFile']
19  _realData = _customInfo['realData']
20 
21  import FWCore.ParameterSet.VarParsing as VarParsing
22  cmsRunOptions = VarParsing.VarParsing('python')
23 
24  cmsRunOptions.maxEvents = _maxEvents
25  cmsRunOptions.register('globalTag',_globalTag,cmsRunOptions.multiplicity.singleton,cmsRunOptions.varType.string,"GlobalTag")
26  cmsRunOptions.inputFiles = _inputFile
27  cmsRunOptions.register('realData',_realData,cmsRunOptions.multiplicity.singleton,cmsRunOptions.varType.bool,"Real Data?")
28 
29  cmsRunOptions.parseArguments()
30 
31 # report in log file
32 # print cmsRunOptions
33 
34  _maxEvents = cmsRunOptions.maxEvents
35  _globalTag = cmsRunOptions.globalTag
36  _inputFile = cmsRunOptions.inputFiles
37  _realData = cmsRunOptions.realData
38 
39 # maxEvents
40  if _maxEvents != -2:
41  _maxEvents = cms.untracked.int32( _maxEvents )
42  if hasattr(process,'maxEvents'):
43  process.maxEvents.input = _maxEvents
44  else:
45  process.maxEvents = cms.untracked.PSet( input = _maxEvents )
46 
47 # GlobalTag
48  if _globalTag == "@":
49  _globalTag = _customInfo['globalTags'][_realData]
50  if _globalTag != "":
51  if hasattr(process,'GlobalTag'):
52  from Configuration.AlCa.GlobalTag import GlobalTag
53  process.GlobalTag = GlobalTag(process.GlobalTag, _globalTag, '')
54 # process.GlobalTag.snapshotTime = cms.string("9999-12-31 23:59:59.000")
55 
56 # inputFile
57  if _inputFile[0] == "@":
58  _inputFile[0] = _customInfo['inputFiles'][_realData]
59  if _inputFile != "":
60  if hasattr(process,'source'):
61  process.source.fileNames = cms.untracked.vstring( _inputFile )
62 
63  if _realData:
64 # Real-Data customisation
65  if menuType == "HIon":
66 # fix "Unrunnable schedule" exception
67  from HLTrigger.Configuration.CustomConfigs import MassReplaceInputTag
68  process = MassReplaceInputTag(process,"rawDataRepacker","rawDataCollector") #,"rawDataRepacker::@skipCurrentProcess")
69  else:
70 # Monte-Carlo customisation
71  from HLTrigger.Configuration.customizeHLTforMC import customizeHLTforMC
72  process = customizeHLTforMC(process)
73  if menuType == "HIon":
74  from HLTrigger.Configuration.CustomConfigs import MassReplaceInputTag
75  process = MassReplaceInputTag(process,"rawDataRepacker","rawDataCollector")
76 
77  else:
78  pass
79 
80  return process