test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
customizeHLTforCMSSW.py
Go to the documentation of this file.
1 import FWCore.ParameterSet.Config as cms
2 
3 #
4 # reusable functions
5 def producers_by_type(process, *types):
6  return (module for module in process._Process__producers.values() if module._TypedParameterizable__type in types)
7 def filters_by_type(process, *types):
8  return (filter for filter in process._Process__filters.values() if filter._TypedParameterizable__type in types)
9 def analyzers_by_type(process, *types):
10  return (analyzer for analyzer in process._Process__analyzers.values() if analyzer._TypedParameterizable__type in types)
11 
12 def esproducers_by_type(process, *types):
13  return (module for module in process._Process__esproducers.values() if module._TypedParameterizable__type in types)
14 
15 #
16 # one action function per PR - put the PR number into the name of the function
17 
18 # example:
19 # def customiseFor12718(process):
20 # for pset in process._Process__psets.values():
21 # if hasattr(pset,'ComponentType'):
22 # if (pset.ComponentType == 'CkfBaseTrajectoryFilter'):
23 # if not hasattr(pset,'minGoodStripCharge'):
24 # pset.minGoodStripCharge = cms.PSet(refToPSet_ = cms.string('HLTSiStripClusterChargeCutNone'))
25 # return process
26 
27 # Add quadruplet-specific pixel track duplicate cleaning mode (PR #13753)
28 def customiseFor13753(process):
29  for producer in producers_by_type(process, "PixelTrackProducer"):
30  if producer.CleanerPSet.ComponentName.value() == "PixelTrackCleanerBySharedHits" and not hasattr(producer.CleanerPSet, "useQuadrupletAlgo"):
31  producer.CleanerPSet.useQuadrupletAlgo = cms.bool(False)
32  return process
33 
34 # Add pixel seed extension (PR #14356)
35 def customiseFor14356(process):
36  for name, pset in process.psets_().iteritems():
37  if hasattr(pset, "ComponentType") and pset.ComponentType.value() == "CkfBaseTrajectoryFilter" and not hasattr(pset, "pixelSeedExtension"):
38  pset.pixelSeedExtension = cms.bool(False)
39  return process
40 
41 #
42 # CMSSW version specific customizations
43 def customizeHLTforCMSSW(process, menuType="GRun"):
44 
45  import os
46  cmsswVersion = os.environ['CMSSW_VERSION']
47 
48  if cmsswVersion >= "CMSSW_8_1":
49  process = customiseFor14356(process)
50  process = customiseFor13753(process)
51 # process = customiseFor12718(process)
52  pass
53 
54 # stage-2 changes only if needed
55  if ("Fake" in menuType):
56  return process
57 
58 # if ( menuType in ("FULL","GRun","PIon")):
59 # from HLTrigger.Configuration.CustomConfigs import L1XML
60 # process = L1XML(process,"L1Menu_Collisions2016_dev_v3.xml")
61 # from HLTrigger.Configuration.CustomConfigs import L1REPACK
62 # process = L1REPACK(process)
63 #
64 # _debug = False
65 #
66 # special case
67 # for module in filters_by_type(process,"HLTL1TSeed"):
68 # label = module._Labelable__label
69 # if hasattr(getattr(process,label),'SaveTags'):
70 # delattr(getattr(process,label),'SaveTags')
71 #
72 # replace converted l1extra=>l1t plugins which are not yet in ConfDB
73 # replaceList = {
74 # 'EDAnalyzer' : { },
75 # 'EDFilter' : {
76 # 'HLTMuonL1Filter' : 'HLTMuonL1TFilter',
77 # 'HLTMuonL1RegionalFilter' : 'HLTMuonL1TRegionalFilter',
78 # 'HLTMuonTrkFilter' : 'HLTMuonTrkL1TFilter',
79 # 'HLTMuonL1toL3TkPreFilter' : 'HLTMuonL1TtoL3TkPreFilter',
80 # 'HLTMuonDimuonL2Filter' : 'HLTMuonDimuonL2FromL1TFilter',
81 # 'HLTEgammaL1MatchFilterRegional' : 'HLTEgammaL1TMatchFilterRegional',
82 # 'HLTMuonL2PreFilter' : 'HLTMuonL2FromL1TPreFilter',
83 # 'HLTPixelIsolTrackFilter' : 'HLTPixelIsolTrackL1TFilter',
84 # },
85 # 'EDProducer' : {
86 # 'CaloTowerCreatorForTauHLT' : 'CaloTowerFromL1TCreatorForTauHLT',
87 # 'L1HLTTauMatching' : 'L1THLTTauMatching',
88 # 'HLTCaloJetL1MatchProducer' : 'HLTCaloJetL1TMatchProducer',
89 # 'HLTPFJetL1MatchProducer' : 'HLTPFJetL1TMatchProducer',
90 # 'HLTL1MuonSelector' : 'HLTL1TMuonSelector',
91 # 'L2MuonSeedGenerator' : 'L2MuonSeedGeneratorFromL1T',
92 # 'IsolatedPixelTrackCandidateProducer' : 'IsolatedPixelTrackCandidateL1TProducer',
93 # }
94 # }
95 # for type,list in replaceList.iteritems():
96 # if (type=="EDAnalyzer"):
97 # if _debug:
98 # print "# Replacing EDAnalyzers:"
99 # for old,new in list.iteritems():
100 # if _debug:
101 # print '## EDAnalyzer plugin type: ',old,' -> ',new
102 # for module in analyzers_by_type(process,old):
103 # label = module._Labelable__label
104 # if _debug:
105 # print '### Instance: ',label
106 # setattr(process,label,cms.EDAnalyzer(new,**module.parameters_()))
107 # elif (type=="EDFilter"):
108 # if _debug:
109 # print "# Replacing EDFilters :"
110 # for old,new in list.iteritems():
111 # if _debug:
112 # print '## EDFilter plugin type : ',old,' -> ',new
113 # for module in filters_by_type(process,old):
114 # label = module._Labelable__label
115 # if _debug:
116 # print '### Instance: ',label
117 # setattr(process,label,cms.EDFilter(new,**module.parameters_()))
118 # elif (type=="EDProducer"):
119 # if _debug:
120 # print "# Replacing EDProducers:"
121 # for old,new in list.iteritems():
122 # if _debug:
123 # print '## EDProducer plugin type: ',old,' -> ',new
124 # for module in producers_by_type(process,old):
125 # label = module._Labelable__label
126 # if _debug:
127 # print '### Instance: ',label
128 # setattr(process,label,cms.EDProducer(new,**module.parameters_()))
129 # if (new == 'CaloTowerFromL1TCreatorForTauHLT'):
130 # setattr(getattr(process,label),'TauTrigger',cms.InputTag('hltCaloStage2Digis:Tau'))
131 # if ((new == 'HLTCaloJetL1TMatchProducer') or (new == 'HLTPFJetL1TMatchProducer')):
132 # setattr(getattr(process,label),'L1Jets',cms.InputTag('hltCaloStage2Digis:Jet'))
133 # if hasattr(getattr(process,label),'L1CenJets'):
134 # delattr(getattr(process,label),'L1CenJets')
135 # if hasattr(getattr(process,label),'L1ForJets'):
136 # delattr(getattr(process,label),'L1ForJets')
137 # if hasattr(getattr(process,label),'L1TauJets'):
138 # delattr(getattr(process,label),'L1TauJets')
139 # if (new == 'HLTL1TMuonSelector'):
140 # setattr(getattr(process,label),'InputObjects',cms.InputTag('hltGmtStage2Digis:Muon'))
141 # if (new == 'L2MuonSeedGeneratorFromL1T'):
142 # setattr(getattr(process,label),'GMTReadoutCollection',cms.InputTag(''))
143 # setattr(getattr(process,label),'InputObjects',cms.InputTag('hltGmtStage2Digis:Muon'))
144 # if (new == 'IsolatedPixelTrackCandidateL1TProducer'):
145 # setattr(getattr(process,label),'L1eTauJetsSource',cms.InputTag('hltCaloStage2Digis:Tau'))
146 #
147 # else:
148 # if _debug:
149 # print "# Error - Type ',type,' not recognised!"
150 #
151 # Both of the HLTEcalRecHitInAllL1RegionsProducer instances need InputTag fixes
152 # for module in producers_by_type(process,'HLTEcalRecHitInAllL1RegionsProducer'):
153 # label = module._Labelable__label
154 # setattr(getattr(process,label).l1InputRegions[0],'inputColl',cms.InputTag('hltCaloStage2Digis:EGamma'))
155 # setattr(getattr(process,label).l1InputRegions[0],'type',cms.string("EGamma"))
156 # setattr(getattr(process,label).l1InputRegions[1],'inputColl',cms.InputTag('hltCaloStage2Digis:EGamma'))
157 # setattr(getattr(process,label).l1InputRegions[1],'type',cms.string("EGamma"))
158 # setattr(getattr(process,label).l1InputRegions[2],'inputColl',cms.InputTag('hltCaloStage2Digis:Jet'))
159 # setattr(getattr(process,label).l1InputRegions[2],'type',cms.string("Jet"))
160 #
161 # One of the EgammaHLTCaloTowerProducer instances need InputTag fixes
162 # if hasattr(process,'hltRegionalTowerForEgamma'):
163 # setattr(getattr(process,'hltRegionalTowerForEgamma'),'L1NonIsoCand',cms.InputTag('hltCaloStage2Digis:EGamma'))
164 # setattr(getattr(process,'hltRegionalTowerForEgamma'),'L1IsoCand' ,cms.InputTag('hltCaloStage2Digis:EGamma'))
165 #
166 # replace remaining l1extra modules with filter returning 'false'
167 # badTypes = (
168 # 'HLTLevel1Activity',
169 # )
170 # if _debug:
171 # print "# Unconverted module types: ",badTypes
172 # badModules = [ ]
173 # for badType in badTypes:
174 # if _debug:
175 # print '## Unconverted module type: ',badType
176 # for module in analyzers_by_type(process,badType):
177 # label = module._Labelable__label
178 # badModules += [label]
179 # if _debug:
180 # print '### analyzer label: ',label
181 # for module in filters_by_type(process,badType):
182 # label = module._Labelable__label
183 # badModules += [label]
184 # if _debug:
185 # print '### filter label: ',label
186 # for module in producers_by_type(process,badType):
187 # label = module._Labelable__label
188 # badModules += [label]
189 # if _debug:
190 # print '### producer label: ',label
191 # for label in badModules:
192 # setattr(process,label,cms.EDFilter("HLTBool",result=cms.bool(False)))
193 
194  return process