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 # Module restructuring for PR #15439
28 def customiseFor15439(process):
29  for producer in producers_by_type(process, "EgammaHLTBcHcalIsolationProducersRegional", "EgammaHLTEcalPFClusterIsolationProducer", "EgammaHLTHcalPFClusterIsolationProducer", "MuonHLTEcalPFClusterIsolationProducer", "MuonHLTHcalPFClusterIsolationProducer"):
30  if hasattr(producer, "effectiveAreaBarrel") and hasattr(producer, "effectiveAreaEndcap"):
31  if not hasattr(producer, "effectiveAreas") and not hasattr(producer, "absEtaLowEdges"):
32  producer.absEtaLowEdges = cms.vdouble( 0.0, 1.479 )
33  producer.effectiveAreas = cms.vdouble( producer.effectiveAreaBarrel.value(), producer.effectiveAreaEndcap.value() )
34  del producer.effectiveAreaBarrel
35  del producer.effectiveAreaEndcap
36  return process
37 
38 # Add quadruplet-specific pixel track duplicate cleaning mode (PR #13753)
39 def customiseFor13753(process):
40  for producer in producers_by_type(process, "PixelTrackProducer"):
41  if producer.CleanerPSet.ComponentName.value() == "PixelTrackCleanerBySharedHits" and not hasattr(producer.CleanerPSet, "useQuadrupletAlgo"):
42  producer.CleanerPSet.useQuadrupletAlgo = cms.bool(False)
43  return process
44 
45 # Add pixel seed extension (PR #14356)
46 def customiseFor14356(process):
47  for name, pset in process.psets_().iteritems():
48  if hasattr(pset, "ComponentType") and pset.ComponentType.value() == "CkfBaseTrajectoryFilter" and not hasattr(pset, "pixelSeedExtension"):
49  pset.pixelSeedExtension = cms.bool(False)
50  return process
51 
52 #
53 # CMSSW version specific customizations
54 def customizeHLTforCMSSW(process, menuType="GRun"):
55 
56  import os
57  cmsswVersion = os.environ['CMSSW_VERSION']
58 
59  if cmsswVersion >= "CMSSW_8_0":
60  process = customiseFor15439(process)
61 
62  if cmsswVersion >= "CMSSW_8_1":
63  process = customiseFor14356(process)
64  process = customiseFor13753(process)
65 # process = customiseFor12718(process)
66  pass
67 
68 # stage-2 changes only if needed
69  if ("Fake" in menuType):
70  return process
71 
72 # if ( menuType in ("FULL","GRun","PIon")):
73 # from HLTrigger.Configuration.CustomConfigs import L1XML
74 # process = L1XML(process,"L1Menu_Collisions2016_dev_v3.xml")
75 # from HLTrigger.Configuration.CustomConfigs import L1REPACK
76 # process = L1REPACK(process)
77 #
78 # _debug = False
79 #
80 # special case
81 # for module in filters_by_type(process,"HLTL1TSeed"):
82 # label = module._Labelable__label
83 # if hasattr(getattr(process,label),'SaveTags'):
84 # delattr(getattr(process,label),'SaveTags')
85 #
86 # replace converted l1extra=>l1t plugins which are not yet in ConfDB
87 # replaceList = {
88 # 'EDAnalyzer' : { },
89 # 'EDFilter' : {
90 # 'HLTMuonL1Filter' : 'HLTMuonL1TFilter',
91 # 'HLTMuonL1RegionalFilter' : 'HLTMuonL1TRegionalFilter',
92 # 'HLTMuonTrkFilter' : 'HLTMuonTrkL1TFilter',
93 # 'HLTMuonL1toL3TkPreFilter' : 'HLTMuonL1TtoL3TkPreFilter',
94 # 'HLTMuonDimuonL2Filter' : 'HLTMuonDimuonL2FromL1TFilter',
95 # 'HLTEgammaL1MatchFilterRegional' : 'HLTEgammaL1TMatchFilterRegional',
96 # 'HLTMuonL2PreFilter' : 'HLTMuonL2FromL1TPreFilter',
97 # 'HLTPixelIsolTrackFilter' : 'HLTPixelIsolTrackL1TFilter',
98 # },
99 # 'EDProducer' : {
100 # 'CaloTowerCreatorForTauHLT' : 'CaloTowerFromL1TCreatorForTauHLT',
101 # 'L1HLTTauMatching' : 'L1THLTTauMatching',
102 # 'HLTCaloJetL1MatchProducer' : 'HLTCaloJetL1TMatchProducer',
103 # 'HLTPFJetL1MatchProducer' : 'HLTPFJetL1TMatchProducer',
104 # 'HLTL1MuonSelector' : 'HLTL1TMuonSelector',
105 # 'L2MuonSeedGenerator' : 'L2MuonSeedGeneratorFromL1T',
106 # 'IsolatedPixelTrackCandidateProducer' : 'IsolatedPixelTrackCandidateL1TProducer',
107 # }
108 # }
109 # for type,list in replaceList.iteritems():
110 # if (type=="EDAnalyzer"):
111 # if _debug:
112 # print "# Replacing EDAnalyzers:"
113 # for old,new in list.iteritems():
114 # if _debug:
115 # print '## EDAnalyzer plugin type: ',old,' -> ',new
116 # for module in analyzers_by_type(process,old):
117 # label = module._Labelable__label
118 # if _debug:
119 # print '### Instance: ',label
120 # setattr(process,label,cms.EDAnalyzer(new,**module.parameters_()))
121 # elif (type=="EDFilter"):
122 # if _debug:
123 # print "# Replacing EDFilters :"
124 # for old,new in list.iteritems():
125 # if _debug:
126 # print '## EDFilter plugin type : ',old,' -> ',new
127 # for module in filters_by_type(process,old):
128 # label = module._Labelable__label
129 # if _debug:
130 # print '### Instance: ',label
131 # setattr(process,label,cms.EDFilter(new,**module.parameters_()))
132 # elif (type=="EDProducer"):
133 # if _debug:
134 # print "# Replacing EDProducers:"
135 # for old,new in list.iteritems():
136 # if _debug:
137 # print '## EDProducer plugin type: ',old,' -> ',new
138 # for module in producers_by_type(process,old):
139 # label = module._Labelable__label
140 # if _debug:
141 # print '### Instance: ',label
142 # setattr(process,label,cms.EDProducer(new,**module.parameters_()))
143 # if (new == 'CaloTowerFromL1TCreatorForTauHLT'):
144 # setattr(getattr(process,label),'TauTrigger',cms.InputTag('hltCaloStage2Digis:Tau'))
145 # if ((new == 'HLTCaloJetL1TMatchProducer') or (new == 'HLTPFJetL1TMatchProducer')):
146 # setattr(getattr(process,label),'L1Jets',cms.InputTag('hltCaloStage2Digis:Jet'))
147 # if hasattr(getattr(process,label),'L1CenJets'):
148 # delattr(getattr(process,label),'L1CenJets')
149 # if hasattr(getattr(process,label),'L1ForJets'):
150 # delattr(getattr(process,label),'L1ForJets')
151 # if hasattr(getattr(process,label),'L1TauJets'):
152 # delattr(getattr(process,label),'L1TauJets')
153 # if (new == 'HLTL1TMuonSelector'):
154 # setattr(getattr(process,label),'InputObjects',cms.InputTag('hltGmtStage2Digis:Muon'))
155 # if (new == 'L2MuonSeedGeneratorFromL1T'):
156 # setattr(getattr(process,label),'GMTReadoutCollection',cms.InputTag(''))
157 # setattr(getattr(process,label),'InputObjects',cms.InputTag('hltGmtStage2Digis:Muon'))
158 # if (new == 'IsolatedPixelTrackCandidateL1TProducer'):
159 # setattr(getattr(process,label),'L1eTauJetsSource',cms.InputTag('hltCaloStage2Digis:Tau'))
160 #
161 # else:
162 # if _debug:
163 # print "# Error - Type ',type,' not recognised!"
164 #
165 # Both of the HLTEcalRecHitInAllL1RegionsProducer instances need InputTag fixes
166 # for module in producers_by_type(process,'HLTEcalRecHitInAllL1RegionsProducer'):
167 # label = module._Labelable__label
168 # setattr(getattr(process,label).l1InputRegions[0],'inputColl',cms.InputTag('hltCaloStage2Digis:EGamma'))
169 # setattr(getattr(process,label).l1InputRegions[0],'type',cms.string("EGamma"))
170 # setattr(getattr(process,label).l1InputRegions[1],'inputColl',cms.InputTag('hltCaloStage2Digis:EGamma'))
171 # setattr(getattr(process,label).l1InputRegions[1],'type',cms.string("EGamma"))
172 # setattr(getattr(process,label).l1InputRegions[2],'inputColl',cms.InputTag('hltCaloStage2Digis:Jet'))
173 # setattr(getattr(process,label).l1InputRegions[2],'type',cms.string("Jet"))
174 #
175 # One of the EgammaHLTCaloTowerProducer instances need InputTag fixes
176 # if hasattr(process,'hltRegionalTowerForEgamma'):
177 # setattr(getattr(process,'hltRegionalTowerForEgamma'),'L1NonIsoCand',cms.InputTag('hltCaloStage2Digis:EGamma'))
178 # setattr(getattr(process,'hltRegionalTowerForEgamma'),'L1IsoCand' ,cms.InputTag('hltCaloStage2Digis:EGamma'))
179 #
180 # replace remaining l1extra modules with filter returning 'false'
181 # badTypes = (
182 # 'HLTLevel1Activity',
183 # )
184 # if _debug:
185 # print "# Unconverted module types: ",badTypes
186 # badModules = [ ]
187 # for badType in badTypes:
188 # if _debug:
189 # print '## Unconverted module type: ',badType
190 # for module in analyzers_by_type(process,badType):
191 # label = module._Labelable__label
192 # badModules += [label]
193 # if _debug:
194 # print '### analyzer label: ',label
195 # for module in filters_by_type(process,badType):
196 # label = module._Labelable__label
197 # badModules += [label]
198 # if _debug:
199 # print '### filter label: ',label
200 # for module in producers_by_type(process,badType):
201 # label = module._Labelable__label
202 # badModules += [label]
203 # if _debug:
204 # print '### producer label: ',label
205 # for label in badModules:
206 # setattr(process,label,cms.EDFilter("HLTBool",result=cms.bool(False)))
207 
208  return process