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 # reusable functions
4 def producers_by_type(process, *types):
5  return (module for module in process._Process__producers.values() if module._TypedParameterizable__type in types)
6 
7 def esproducers_by_type(process, *types):
8  return (module for module in process._Process__esproducers.values() if module._TypedParameterizable__type in types)
9 
10 
11 # Update to replace old jet corrector mechanism
12 from HLTrigger.Configuration.customizeHLTforNewJetCorrectors import customizeHLTforNewJetCorrectors
13 
14 # Possibility to put different ring dependent cut on ADC (PR #9232)
15 def customiseFor9232(process):
16  if hasattr(process,'hltEcalPhiSymFilter'):
17  if hasattr(process.hltEcalPhiSymFilter,'ampCut_barrel'):
18  delattr(process.hltEcalPhiSymFilter,'ampCut_barrel')
19  if hasattr(process.hltEcalPhiSymFilter,'ampCut_endcap'):
20  delattr(process.hltEcalPhiSymFilter,'ampCut_endcap')
21  return process
22 
23 # upgrade RecoTrackSelector to allow BTV-like cuts (PR #8679)
24 def customiseFor8679(process):
25  if hasattr(process,'hltBSoftMuonMu5L3') :
26  delattr(process.hltBSoftMuonMu5L3,'min3DHit')
27  setattr(process.hltBSoftMuonMu5L3,'minLayer', cms.int32(0))
28  setattr(process.hltBSoftMuonMu5L3,'min3DLayer', cms.int32(0))
29  setattr(process.hltBSoftMuonMu5L3,'minPixelHit', cms.int32(0))
30  setattr(process.hltBSoftMuonMu5L3,'usePV', cms.bool(False))
31  setattr(process.hltBSoftMuonMu5L3,'vertexTag', cms.InputTag(''))
32  return process
33 
34 
35 # Updating the config (PR #8356)
36 def customiseFor8356(process):
37  MTRBPSet = cms.PSet(
38  Rescale_eta = cms.double( 3.0 ),
39  Rescale_phi = cms.double( 3.0 ),
40  Rescale_Dz = cms.double( 3.0 ),
41  EtaR_UpperLimit_Par1 = cms.double( 0.25 ),
42  EtaR_UpperLimit_Par2 = cms.double( 0.15 ),
43  PhiR_UpperLimit_Par1 = cms.double( 0.6 ),
44  PhiR_UpperLimit_Par2 = cms.double( 0.2 ),
45  UseVertex = cms.bool( False ),
46  Pt_fixed = cms.bool( False ),
47  Z_fixed = cms.bool( True ),
48  Phi_fixed = cms.bool( False ),
49  Eta_fixed = cms.bool( False ),
50  Pt_min = cms.double( 1.5 ),
51  Phi_min = cms.double( 0.1 ),
52  Eta_min = cms.double( 0.1 ),
53  DeltaZ = cms.double( 15.9 ),
54  DeltaR = cms.double( 0.2 ),
55  DeltaEta = cms.double( 0.2 ),
56  DeltaPhi = cms.double( 0.2 ),
57  maxRegions = cms.int32( 2 ),
58  precise = cms.bool( True ),
59  OnDemand = cms.int32( -1 ),
60  MeasurementTrackerName = cms.InputTag( "hltESPMeasurementTracker" ),
61  beamSpot = cms.InputTag( "hltOnlineBeamSpot" ),
62  vertexCollection = cms.InputTag( "pixelVertices" ),
63  input = cms.InputTag( 'hltL2Muons','UpdatedAtVtx' )
64  )
65 
66  for l3MPModule in producers_by_type(process, 'L3MuonProducer'):
67  if hasattr(l3MPModule, 'GlbRefitterParameters'):
68  l3MPModule.GlbRefitterParameters.RefitFlag = cms.bool(True)
69  if hasattr(l3MPModule, 'L3TrajBuilderParameters'):
70  if hasattr(l3MPModule.L3TrajBuilderParameters, 'MuonTrackingRegionBuilder'):
71  l3MPModule.L3TrajBuilderParameters.MuonTrackingRegionBuilder = MTRBPSet
72 
73  listL3seedingModule = ['hltL3TrajSeedIOHit','hltL3NoFiltersNoVtxTrajSeedIOHit','hltHIL3TrajSeedIOHit']
74  for l3IOTrajModule in listL3seedingModule:
75  if hasattr(process, l3IOTrajModule):
76  if hasattr(getattr(process, l3IOTrajModule), 'MuonTrackingRegionBuilder'):
77  setattr(getattr(process, l3IOTrajModule), 'MuonTrackingRegionBuilder', MTRBPSet)
78 
79  return process
80 
81 
82 # Simplified TrackerTopologyEP config (PR #7966)
83 def customiseFor7966(process):
84  if hasattr(process, 'trackerTopology'):
85  params = process.trackerTopology.parameterNames_()
86  for param in params:
87  delattr(process.trackerTopology, param)
88  setattr(process.trackerTopology, 'appendToDataLabel', cms.string(""))
89  if hasattr(process,'TrackerDigiGeometryESModule'):
90  if hasattr(process.TrackerDigiGeometryESModule,'trackerGeometryConstants'):
91  delattr(process.TrackerDigiGeometryESModule,'trackerGeometryConstants')
92  return process
93 
94 # Removal of 'upgradeGeometry' from TrackerDigiGeometryESModule (PR #7794)
95 def customiseFor7794(process):
96  if hasattr(process, 'TrackerDigiGeometryESModule'):
97  if hasattr(process.TrackerDigiGeometryESModule, 'trackerGeometryConstants'):
98  if hasattr(process.TrackerDigiGeometryESModule.trackerGeometryConstants, 'upgradeGeometry'):
99  delattr(process.TrackerDigiGeometryESModule.trackerGeometryConstants, 'upgradeGeometry')
100  return process
101 
102 
103 # Removal of L1 Stage 1 unpacker configuration from config (PR #10087)
104 def customiseFor10087(process):
105  if hasattr(process, 'hltCaloStage1Digis'):
106  if hasattr(process.hltCaloStage1Digis, 'FWId'):
107  delattr(process.hltCaloStage1Digis, 'FWId')
108  if hasattr(process.hltCaloStage1Digis, 'FedId'):
109  delattr(process.hltCaloStage1Digis, 'FedId')
110  return process
111 
112 def customiseFor10234(process):
113  if hasattr(process, 'hltCaloStage1Digis'):
114  if hasattr(process.hltCaloStage1Digis, 'FWId'):
115  delattr(process.hltCaloStage1Digis, 'FWId')
116  if hasattr(process.hltCaloStage1Digis, 'FedId'):
117  delattr(process.hltCaloStage1Digis, 'FedId')
118  return process
119 
120 def customiseFor10353(process):
121  # Take care of geometry changes in HCAL
122  if not hasattr(process,'hcalDDDSimConstants'):
123  process.hcalDDDSimConstants = cms.ESProducer( 'HcalDDDSimConstantsESModule' )
124  if not hasattr(process,'hcalDDDRecConstants'):
125  process.hcalDDDRecConstants = cms.ESProducer( 'HcalDDDRecConstantsESModule' )
126  return process
127 
128 # upgrade RecoTrackSelector to allow selection on originalAlgo (PR #10418)
129 def customiseFor10418(process):
130  if hasattr(process,'hltBSoftMuonMu5L3') :
131  setattr(process.hltBSoftMuonMu5L3,'originalAlgorithm', cms.vstring())
132  setattr(process.hltBSoftMuonMu5L3,'algorithmMaskContains', cms.vstring())
133  return process
134 
135 # migrate RPCPointProducer to a global::EDProducer (PR #10927)
136 def customiseFor10927(process):
137  if any(module.type_() is 'RPCPointProducer' for module in process.producers.itervalues()):
138  if not hasattr(process, 'CSCObjectMapESProducer'):
139  process.CSCObjectMapESProducer = cms.ESProducer( 'CSCObjectMapESProducer' )
140  if not hasattr(process, 'DTObjectMapESProducer'):
141  process.DTObjectMapESProducer = cms.ESProducer( 'DTObjectMapESProducer' )
142  return process
143 
144 # change RecoTrackRefSelector to stream::EDProducer (PR #10911)
145 def customiseFor10911(process):
146  if hasattr(process,'hltBSoftMuonMu5L3'):
147  # Switch module type from EDFilter to EDProducer
148  process.hltBSoftMuonMu5L3 = cms.EDProducer("RecoTrackRefSelector", **process.hltBSoftMuonMu5L3.parameters_())
149  return process
150 
151 # Fix MeasurementTrackerEvent configuration in several TrackingRegionProducers (PR 11183)
152 def customiseFor11183(process):
153  def useMTEName(componentName):
154  if componentName in ["CandidateSeededTrackingRegionsProducer", "TrackingRegionsFromBeamSpotAndL2Tau"]:
155  return "whereToUseMeasurementTracker"
156  return "howToUseMeasurementTracker"
157 
158  def replaceInPSet(pset, moduleLabel):
159  for paramName in pset.parameterNames_():
160  param = getattr(pset, paramName)
161  if isinstance(param, cms.PSet):
162  if hasattr(param, "ComponentName") and param.ComponentName.value() in ["CandidateSeededTrackingRegionsProducer", "TauRegionalPixelSeedGenerator"]:
163  useMTE = useMTEName(param.ComponentName.value())
164 
165  if hasattr(param.RegionPSet, "measurementTrackerName"):
166  param.RegionPSet.measurementTrackerName = cms.InputTag(param.RegionPSet.measurementTrackerName.value())
167  if hasattr(param.RegionPSet, useMTE):
168  raise Exception("Assumption of CandidateSeededTrackingRegionsProducer not having '%s' parameter failed" % useMTE)
169  setattr(param.RegionPSet, useMTE, cms.string("ForSiStrips"))
170  else:
171  setattr(param.RegionPSet, useMTE, cms.string("Never"))
172  else:
173  replaceInPSet(param, moduleLabel)
174  elif isinstance(param, cms.VPSet):
175  for element in param:
176  replaceInPSet(element, moduleLabel)
177 
178  for label, module in process.producers_().iteritems():
179  replaceInPSet(module, label)
180 
181  return process
182 
183 
184 def customiseFor11497(process):
185  # Take care of CaloTowerTopology
186  if not hasattr(process,'CaloTowerTopologyEP'):
187  process.CaloTowerTopologyEP = cms.ESProducer( 'CaloTowerTopologyEP' )
188  return process
189 
190 
191 def customiseFor12044(process):
192  # add a label to indentify the PFProducer calibrations
193  for module in producers_by_type(process, 'PFProducer'):
194  if not 'calibrationsLabel' in module.__dict__:
195  module.calibrationsLabel = cms.string('HLT')
196  return process
197 
198 
199 def customiseFor12062(process):
200  # add a label to indentify the b-tagging calibrations
201  for module in esproducers_by_type(process, 'CombinedSecondaryVertexESProducer'):
202  if not 'recordLabel' in module.__dict__:
203  module.recordLabel = cms.string('HLT')
204  return process
205 
206 
207 # CMSSW version specific customizations
208 def customiseHLTforCMSSW(process, menuType="GRun", fastSim=False):
209  import os
210  cmsswVersion = os.environ['CMSSW_VERSION']
211 
212  if cmsswVersion >= "CMSSW_7_6":
213  process = customiseFor10418(process)
214  process = customiseFor10353(process)
215  process = customiseFor10911(process)
216  process = customiseFor11183(process)
217  process = customiseFor11497(process)
218  process = customiseFor12044(process)
219  process = customiseFor12062(process)
220  if cmsswVersion >= "CMSSW_7_5":
221  process = customiseFor10927(process)
222  process = customiseFor9232(process)
223  process = customiseFor8679(process)
224  process = customiseFor8356(process)
225  process = customiseFor7966(process)
226  process = customiseFor7794(process)
227  process = customiseFor10087(process)
228  process = customizeHLTforNewJetCorrectors(process)
229  if cmsswVersion >= "CMSSW_7_4":
230  process = customiseFor10234(process)
231 
232  return process
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:34