CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
customizeHLTforL1Emulator.py
Go to the documentation of this file.
2 import sys, string
3 
4 def switchToL1Emulator(process,
5  # default settings given are such that only the GT is re-emulated
6  newGmtSetting = False,
7  MergeMethodPtBrl = 'minPt',
8  MergeMethodPtFwd = 'minPt',
9  newCSCTFLUTs = False,
10  newGctSetting = False,
11  newECALLUTs = False,
12  newHCALLUTs = False):
13  """patch the process to run the RawToDigi and SimL1Emulator sequences instead of unpacking the hltGctDigis and hltGtDigis"""
14 
15  # redefine the HLTL1UnpackerSequence
16  HLTL1UnpackerSequence = cms.Sequence( process.RawToDigi + process.SimL1Emulator + process.hltL1GtObjectMap + process.hltL1extraParticles )
17 
18  for iterable in process.sequences.itervalues():
19  iterable.replace( process.HLTL1UnpackerSequence, HLTL1UnpackerSequence)
20 
21  for iterable in process.paths.itervalues():
22  iterable.replace( process.HLTL1UnpackerSequence, HLTL1UnpackerSequence)
23 
24  for iterable in process.endpaths.itervalues():
25  iterable.replace( process.HLTL1UnpackerSequence, HLTL1UnpackerSequence)
26 
27  process.HLTL1UnpackerSequence = HLTL1UnpackerSequence
28 
29  # redefine the single hltGtDigis module, for paths that do not use the HLTL1UnpackerSequence
30  process.HLTL1GtDigisSequence = cms.Sequence( process.RawToDigi + process.SimL1Emulator )
31 
32  for iterable in process.sequences.itervalues():
33  iterable.replace( process.hltGtDigis, process.HLTL1GtDigisSequence)
34 
35  for iterable in process.paths.itervalues():
36  iterable.replace( process.hltGtDigis, process.HLTL1GtDigisSequence)
37 
38  for iterable in process.endpaths.itervalues():
39  iterable.replace( process.hltGtDigis, process.HLTL1GtDigisSequence)
40 
41  # GMT re-emulation
42  if newGmtSetting:
43  process.load('L1TriggerConfig.GMTConfigProducers.L1MuGMTParameters_cfi')
44 
45  # configure muon rank algo for GMT re-emulation
46  process.L1MuGMTParameters.MergeMethodPtBrl = cms.string(MergeMethodPtBrl)
47  process.L1MuGMTParameters.MergeMethodPtFwd = cms.string(MergeMethodPtFwd)
48 
49  process.L1MuGMTParameters.VersionSortRankEtaQLUT = cms.uint32(275)
50 
51  import L1Trigger.CSCTrackFinder.csctfDigis_cfi as csctfDigisGMT
52 
53  process.csctfReEmulDigis = csctfDigisGMT.csctfDigis.clone()
54  process.csctfReEmulDigis.CSCTrackProducer = cms.untracked.InputTag("csctfReEmulTracks")
55 
56  import L1Trigger.CSCTrackFinder.csctfTrackDigis_cfi as csctfTrackDigis
57 
58  process.csctfReEmulTracks = csctfTrackDigis.csctfTrackDigis.clone()
59  process.csctfReEmulTracks.readDtDirect = True
60  process.csctfReEmulTracks.SectorReceiverInput = cms.untracked.InputTag("csctfDigis")
61  process.csctfReEmulTracks.DtDirectProd = cms.untracked.InputTag("csctfDigis", "DT")
62  process.csctfReEmulTracks.SectorProcessor.initializeFromPSet = True
63 
64  process.load("L1Trigger.RPCTrigger.rpcTriggerDigis_cfi")
65  process.rpcReEmulDigis = process.rpcTriggerDigis.clone()
66 
67  process.load("L1Trigger.GlobalMuonTrigger.gmtDigis_cfi")
68  process.gmtReEmulDigis = process.gmtDigis.clone()
69  process.gmtReEmulDigis.DTCandidates = cms.InputTag("gtDigis","DT")
70  process.gmtReEmulDigis.RPCbCandidates = cms.InputTag("gtDigis","RPCb")
71 
72  # switch GMT input to use new re-emulated CSCTF input
73  if newCSCTFLUTs:
74  process.gmtReEmulDigis.CSCCandidates = cms.InputTag("csctfReEmulDigis","CSC")
75  else:
76  process.gmtReEmulDigis.CSCCandidates = cms.InputTag("gtDigis","CSC")
77 
78  process.gmtReEmulDigis.RPCfCandidates = cms.InputTag("gtDigis","RPCf")
79  process.gmtReEmulDigis.MipIsoData = cms.InputTag("none")
80 
81  HLTL1MuonTriggerSequence = cms.Sequence( process.csctfReEmulTracks + process.csctfReEmulDigis + process.gmtReEmulDigis )
82 
83  # configure GT re-emulation to use new re-emulated GMT input
84  process.simGtDigis.GmtInputTag = 'gmtReEmulDigis'
85  process.HLTL1MuonTriggerSequence = HLTL1MuonTriggerSequence
86  process.HLTL1UnpackerSequence.replace( process.simGtDigis, process.HLTL1MuonTriggerSequence + process.simGtDigis)
87 
88  # GCT re-emulation
89  if newGctSetting:
90  process.load('SimCalorimetry.EcalTrigPrimProducers.ecalTriggerPrimitiveDigis_cff')
91  process.load('SimCalorimetry.HcalTrigPrimProducers.hcaltpdigi_cff')
92 
93  # settings for using new ECAL LUTs
94  if newECALLUTs:
95  process.ecalReEmulDigis = process.simEcalTriggerPrimitiveDigis.clone()
96  process.ecalReEmulDigis.Label = 'ecalDigis'
97  process.ecalReEmulDigis.InstanceEB = 'ebDigis'
98  process.ecalReEmulDigis.InstanceEE = 'eeDigis'
99  process.ecalReEmulDigis.BarrelOnly = False
100 
101  # settings for using new HCAL LUTs
102  if newHCALLUTs:
103  process.hcalReEmulDigis = process.simHcalTriggerPrimitiveDigis.clone()
104  process.hcalReEmulDigis.inputLabel = cms.VInputTag(cms.InputTag('hcalDigis'), cms.InputTag('hcalDigis'))
105  process.HcalTPGCoderULUT.LUTGenerationMode = cms.bool(False)
106 
107  # configure RCT re-emulation
109  process.rctReEmulDigis = L1Trigger.RegionalCaloTrigger.rctDigis_cfi.rctDigis.clone()
110 
111  if newECALLUTs:
112  process.rctReEmulDigis.ecalDigis = cms.VInputTag( cms.InputTag( 'ecalReEmulDigis' ) )
113  else:
114  process.rctReEmulDigis.ecalDigis = cms.VInputTag( cms.InputTag( 'ecalDigis:EcalTriggerPrimitives' ) )
115 
116  if newHCALLUTs:
117  process.rctReEmulDigis.hcalDigis = cms.VInputTag( cms.InputTag( 'hcalReEmulDigis' ) )
118  else:
119  process.rctReEmulDigis.hcalDigis = cms.VInputTag( cms.InputTag( 'hcalDigis' ) )
120 
121  # configure GCT re-emulation
123  process.gctReEmulDigis = L1Trigger.GlobalCaloTrigger.gctDigis_cfi.gctDigis.clone()
124  process.gctReEmulDigis.inputLabel = 'rctReEmulDigis'
125 
126  if newECALLUTs and newHCALLUTs:
127  HLTL1CaloTriggerSequence = cms.Sequence( process.ecalReEmulDigis + process.hcalReEmulDigis + process.rctReEmulDigis + process.gctReEmulDigis )
128  elif newECALLUTs:
129  HLTL1CaloTriggerSequence = cms.Sequence( process.ecalReEmulDigis + process.rctReEmulDigis + process.gctReEmulDigis )
130  elif newHCALLUTs:
131  HLTL1CaloTriggerSequence = cms.Sequence( process.hcalReEmulDigis + process.rctReEmulDigis + process.gctReEmulDigis )
132  else:
133  HLTL1CaloTriggerSequence = cms.Sequence( process.rctReEmulDigis + process.gctReEmulDigis )
134 
135  # configure GT re-emulation to use new re-emulated GCT input
136  process.simGtDigis.GctInputTag = 'gctReEmulDigis'
137  process.HLTL1CaloTriggerSequence = HLTL1CaloTriggerSequence
138  process.HLTL1UnpackerSequence.replace( process.simGtDigis, process.HLTL1CaloTriggerSequence + process.simGtDigis)
139 
140  return process
141 
142 
143 def switchToCustomL1Digis(process, customGmt, customGct, customGt):
144  """patch the process to use custom GMT, GCT and GT results"""
145 
146  # explicit replacements to use "simGtDigis", "simGmtDigis" and "simGctDigis" instead of "hltGtDigis" or "hltGctDigis"
147  if 'hltL1GtObjectMap' in process.__dict__:
148  process.hltL1GtObjectMap.GmtInputTag = cms.InputTag( customGmt )
149  process.hltL1GtObjectMap.GctInputTag = cms.InputTag( customGct )
150  if 'hltL1extraParticles' in process.__dict__:
151  process.hltL1extraParticles.muonSource = cms.InputTag( customGmt )
152  process.hltL1extraParticles.isolatedEmSource = cms.InputTag( customGct, 'isoEm' )
153  process.hltL1extraParticles.nonIsolatedEmSource = cms.InputTag( customGct, 'nonIsoEm' )
154  process.hltL1extraParticles.centralJetSource = cms.InputTag( customGct, 'cenJets' )
155  process.hltL1extraParticles.forwardJetSource = cms.InputTag( customGct, 'forJets' )
156  process.hltL1extraParticles.tauJetSource = cms.InputTag( customGct, 'tauJets' )
157  process.hltL1extraParticles.etTotalSource = cms.InputTag( customGct )
158  process.hltL1extraParticles.etHadSource = cms.InputTag( customGct )
159  process.hltL1extraParticles.etMissSource = cms.InputTag( customGct )
160  if 'hltL2MuonSeeds' in process.__dict__:
161  process.hltL2MuonSeeds.GMTReadoutCollection = cms.InputTag( customGmt )
162 
163  # automatic replacements to use "simGtDigis" and "simGctDigis" instead of "hltGtDigis" or "hltGctDigis"
164  for module in process.__dict__.itervalues():
165  if isinstance(module, cms._Module):
166  for parameter in module.__dict__.itervalues():
167  if isinstance(parameter, cms.InputTag):
168  if parameter.moduleLabel == 'hltGtDigis':
169  parameter.moduleLabel = customGt
170  elif parameter.moduleLabel == 'hltGctDigis':
171  parameter.moduleLabel = customGct
172 
173  # check if "hltGtDigis" and "hltGctDigis" are defined
174  hasGtDigis = 'hltGtDigis' in process.producers
175  hasGctDigis = 'hltGctDigis' in process.producers
176 
177  # remove "hltGtDigis" and "hltGctDigis" from all paths, endpaths and sequences
178  for iterable in process.sequences.itervalues():
179  if hasGtDigis: iterable.remove( process.hltGtDigis )
180  if hasGctDigis: iterable.remove( process.hltGctDigis )
181 
182  for iterable in process.paths.itervalues():
183  if hasGtDigis: iterable.remove( process.hltGtDigis )
184  if hasGctDigis: iterable.remove( process.hltGctDigis )
185 
186  for iterable in process.endpaths.itervalues():
187  if hasGtDigis: iterable.remove( process.hltGtDigis )
188  if hasGctDigis: iterable.remove( process.hltGctDigis )
189 
190  return process
191 
192 
193 def switchToSimGtDigis(process):
194  """patch the process to use newly emulated GT results"""
195  return switchToCustomL1Digis(process, 'gtDigis', 'gctDigis', 'simGtDigis')
196 
198  """patch the process to use newly emulated GMT, GCT and GT results"""
199  return switchToCustomL1Digis(process, 'simGmtDigis', 'simGctDigis', 'simGtDigis')
200 
202  """patch the process to use gtDigis for GMT results, and newly emulated GCT and GT results"""
203  return switchToCustomL1Digis(process, 'gtDigis', 'simGctDigis', 'simGtDigis')
204 
206  """patch the process to use gctDigis for GCT results, and newly emulated GMT and GT results"""
207  return switchToCustomL1Digis(process, 'simGmtDigis', 'gctDigis', 'simGtDigis')
208 
210  """patch the process to use newly emulated GMT, GCT and GT results starting from new Muon and Calo LUTs (eventually)"""
211  return switchToCustomL1Digis(process, 'gmtReEmulDigis', 'gctReEmulDigis', 'simGtDigis')
212 
214  """patch the process to use newly emulated GMT and GT results starting from new Muon LUTs (eventually)"""
215  return switchToCustomL1Digis(process, 'gmtReEmulDigis', 'gctDigis', 'simGtDigis')
216 
218  """patch the process to use newly emulated GCT and GT results starting from new Calo LUTs (eventually)"""
219  return switchToCustomL1Digis(process, 'gtDigis', 'gctReEmulDigis', 'simGtDigis')
220