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.
1 import FWCore.ParameterSet.Config as cms
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.isoTauJetSource = cms.InputTag( customGct, 'isoTauJets' )
158  process.hltL1extraParticles.etTotalSource = cms.InputTag( customGct )
159  process.hltL1extraParticles.etHadSource = cms.InputTag( customGct )
160  process.hltL1extraParticles.etMissSource = cms.InputTag( customGct )
161  process.hltL1extraParticles.htMissSource = cms.InputTag( customGct )
162  process.hltL1extraParticles.hfRingEtSumsSource = cms.InputTag( customGct )
163  process.hltL1extraParticles.hfRingBitCountsSource = cms.InputTag( customGct )
164  if 'hltL2MuonSeeds' in process.__dict__:
165  process.hltL2MuonSeeds.GMTReadoutCollection = cms.InputTag( customGmt )
166  if 'hltL2CosmicMuonSeeds' in process.__dict__:
167  process.hltL2CosmicMuonSeeds.GMTReadoutCollection = cms.InputTag( customGmt )
168 
169  # automatic replacements to use "simGtDigis" and "simGctDigis" instead of "hltGtDigis" or "hltGctDigis"
170  for module in process.__dict__.itervalues():
171  if isinstance(module, cms._Module):
172  for parameter in module.__dict__.itervalues():
173  if isinstance(parameter, cms.InputTag):
174  if parameter.moduleLabel == 'hltGtDigis':
175  parameter.moduleLabel = customGt
176  elif parameter.moduleLabel == 'hltGctDigis':
177  parameter.moduleLabel = customGct
178 
179  # check if "hltGtDigis" and "hltGctDigis" are defined
180  hasGtDigis = 'hltGtDigis' in process.producers
181  hasGctDigis = 'hltGctDigis' in process.producers
182 
183  # remove "hltGtDigis" and "hltGctDigis" from all paths, endpaths and sequences
184  for iterable in process.sequences.itervalues():
185  if hasGtDigis: iterable.remove( process.hltGtDigis )
186  if hasGctDigis: iterable.remove( process.hltGctDigis )
187 
188  for iterable in process.paths.itervalues():
189  if hasGtDigis: iterable.remove( process.hltGtDigis )
190  if hasGctDigis: iterable.remove( process.hltGctDigis )
191 
192  for iterable in process.endpaths.itervalues():
193  if hasGtDigis: iterable.remove( process.hltGtDigis )
194  if hasGctDigis: iterable.remove( process.hltGctDigis )
195 
196  return process
197 
198 
199 def switchToSimGtDigis(process):
200  """patch the process to use newly emulated GT results"""
201  return switchToCustomL1Digis(process, 'gtDigis', 'gctDigis', 'simGtDigis')
202 
204  """patch the process to use newly emulated GMT, GCT and GT results"""
205  return switchToCustomL1Digis(process, 'simGmtDigis', 'simGctDigis', 'simGtDigis')
206 
208  """patch the process to use newly emulated GMT, GCT and GT results"""
209  return switchToCustomL1Digis(process, 'gmtReEmulDigis', 'simCaloStage1LegacyFormatDigis', 'simGtDigis')
210 
212  """patch the process to use gtDigis for GMT results, and newly emulated GCT and GT results"""
213  return switchToCustomL1Digis(process, 'gtDigis', 'simGctDigis', 'simGtDigis')
214 
216  """patch the process to use gctDigis for GCT results, and newly emulated GMT and GT results"""
217  return switchToCustomL1Digis(process, 'simGmtDigis', 'gctDigis', 'simGtDigis')
218 
220  """patch the process to use newly emulated GMT, GCT and GT results starting from new Muon and Calo LUTs (eventually)"""
221  return switchToCustomL1Digis(process, 'gmtReEmulDigis', 'gctReEmulDigis', 'simGtDigis')
222 
224  """patch the process to use newly emulated GMT and GT results starting from new Muon LUTs (eventually)"""
225  return switchToCustomL1Digis(process, 'gmtReEmulDigis', 'gctDigis', 'simGtDigis')
226 
228  """patch the process to use newly emulated GCT and GT results starting from new Calo LUTs (eventually)"""
229  return switchToCustomL1Digis(process, 'gtDigis', 'gctReEmulDigis', 'simGtDigis')
230