CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Reconstruction_AftMix_cff.py
Go to the documentation of this file.
1 #############################
2 # This cfg configures the part of reconstruction
3 # in FastSim to be done after event mixing
4 # FastSim mixes tracker information on reconstruction level,
5 # so tracks are recontructed before mixing.
6 # At present, only the generalTrack collection, produced with iterative tracking is mixed.
7 #############################
8 
9 import FWCore.ParameterSet.Config as cms
10 from FWCore.ParameterSet.SequenceTypes import _SequenceCollection
11 
12 # import standard reconstruction
13 # apply modifications before doing the actual import at the end
15 
16 # list of modules to be deleted
17 _mod2del = []
18 
19 ##########################################
20 # offlineBeamSpot is reconstructed before mixing
21 ##########################################
22 _mod2del.append(_reco.offlineBeamSpot)
23 _reco.globalreco.remove(_reco.offlineBeamSpot) # temporary removing this by hand, cause the usual removal (see end of this file) doesn't seem work
24 
25 ###########################################
26 # no castor / zdc in FastSim
27 ###########################################
28 _reco.localreco.remove(_reco.castorreco)
29 _reco.globalreco.remove(_reco.CastorFullReco)
30 _reco.hcalLocalRecoSequence.remove(_reco.zdcreco)
31 
32 ##########################################
33 # Calo rechits
34 ##########################################
35 # not commisoned and not relevant in FastSim (?):
36 _reco.reducedEcalRecHitsSequence.remove(_reco.seldigis)
37 _reco.ecalRecHitSequence.remove(_reco.ecalCompactTrigPrim)
38 _reco.ecalRecHitSequence.remove(_reco.ecalTPSkim)
39 
40 # no flags for bad channels in FastSim
41 _reco.ecalRecHit.killDeadChannels = False
42 _reco.ecalRecHit.recoverEBFE = False
43 _reco.ecalRecHit.recoverEEFE = False
44 _reco.ecalUncalibRecHitSequence.remove(_reco.ecalDetIdToBeRecovered)
45 
46 ##########################################
47 # Changes to tracking sequences
48 ##########################################
49 # modules to be removed
50 _mod2del = _reco.trackingGlobalReco.expandAndClone()._seq._collection
51 _mod2del.append(_reco.trackingGlobalReco)
52 _mod2del.extend(_reco.recopixelvertexing.expandAndClone()._seq._collection)
53 _mod2del.append(_reco.MeasurementTrackerEventPreSplitting)
54 # actually we want to keep a few modules that we need to run (again) after mixing)
55 for _entry in [_reco.firstStepPrimaryVertices,_reco.ak4CaloJetsForTrk,_reco.caloTowerForTrk,_reco.trackExtrapolator]:
56  while _entry in _mod2del:
57  _mod2del.remove(_entry)
58 
59 # remove tracking sequences from main reco sequences
60 _reco.localreco.remove(_reco.trackerlocalreco)
61 _reco.globalreco.remove(_reco.siPixelClusterShapeCachePreSplitting)
62 _reco.globalreco.remove(_reco.trackingGlobalReco)
63 
64 # we need a replacment for the firstStepPrimaryVertices
65 # that includes tracker information of signal and pile up
66 # after mixing there is no such thing as initialStepTracks,
67 # so we replace the input collection for firstStepPrimaryVertices with generalTracks
68 _reco.firstStepPrimaryVertices.TrackLabel = "generalTracks"
69 
70 # insert the few tracking modules to be run after mixing back in the globalreco sequence
71 #for _entry in reversed([trackExtrapolator,caloTowerForTrk,firstStepPrimaryVertices,ak4CaloJetsForTrk])
72 _reco.globalreco.insert(0,_reco.trackExtrapolator+_reco.caloTowerForTrk+_reco.firstStepPrimaryVertices+_reco.ak4CaloJetsForTrk)
73 
74 # FastSim doesn't use Runge Kute for propagation
75 # the following propagators are not used in FastSim, but just to be sure...
76 _reco.KFFitterForRefitOutsideIn.Propagator = 'SmartPropagatorAny'
77 _reco.KFSmootherForRefitOutsideIn.Propagator = 'SmartPropagator'
78 
79 # replace the standard ecal-driven seeds with the FastSim emulated ones
80 import FastSimulation.Tracking.globalCombinedSeeds_cfi
81 _reco.newCombinedSeeds = FastSimulation.Tracking.globalCombinedSeeds_cfi.newCombinedSeeds
82 _reco.globalreco.insert(0,_reco.newCombinedSeeds)
83 
84 ##########################################
85 # FastSim changes to electron reconstruction
86 ##########################################
87 # tracker driven electron seeds depend on the generalTracks trajectory collection
88 # However, in FastSim jobs, trajectories are only available for the 'before mixing' track collections
89 # Therefore we let the seeds depend on the 'before mixing' generalTracks collection
90 # TODO: investigate whether the dependence on trajectories can be avoided
91 import FastSimulation.Tracking.ElectronSeedTrackRefFix_cfi
92 _trackerDrivenElectronSeeds = FastSimulation.Tracking.ElectronSeedTrackRefFix_cfi.fixedTrackerDrivenElectronSeeds.clone()
93 _reco.electronSeeds.replace(_reco.trackerDrivenElectronSeeds,_reco.trackerDrivenElectronSeeds+_trackerDrivenElectronSeeds)
94 _reco.trackerDrivenElectronSeedsTmp = _reco.trackerDrivenElectronSeeds
95 _reco.trackerDrivenElectronSeedsTmp.TkColList = cms.VInputTag(cms.InputTag("generalTracksBeforeMixing"))
96 _reco.trackerDrivenElectronSeeds = _trackerDrivenElectronSeeds
97 _reco.trackerDrivenElectronSeeds.seedCollection.setModuleLabel("trackerDrivenElectronSeedsTmp")
98 _reco.trackerDrivenElectronSeeds.idCollection.setModuleLabel("trackerDrivenElectronSeedsTmp")
99 
100 # replace the ECAL driven electron track candidates with the FastSim emulated ones
102 _reco.electronGSGsfTrackCandidates = FastSimulation.EgammaElectronAlgos.electronGSGsfTrackCandidates_cff.electronGSGsfTrackCandidates
103 _reco.electronGsfTracking.replace(_reco.electronCkfTrackCandidates,_reco.electronGSGsfTrackCandidates)
104 _reco.electronGsfTracks.src = "electronGSGsfTrackCandidates"
105 
106 # FastSim has no template fit on tracker hits
107 _reco.electronGsfTracks.TTRHBuilder = "WithoutRefit"
108 
109 # the conversion producer depends on trajectories
110 # so we feed it with the 'before mixing' track colletion
111 _reco.generalConversionTrackProducer.TrackProducer = 'generalTracksBeforeMixing'
112 
113 # then we need to fix the track references, so that they point to the final track collection, after mixing
114 import FastSimulation.Tracking.ConversionTrackRefFix_cfi
115 _conversionTrackRefFix = FastSimulation.Tracking.ConversionTrackRefFix_cfi.fixedConversionTracks.clone(
116  src = cms.InputTag("generalConversionTrackProducerTmp"))
117 _reco.conversionTrackSequenceNoEcalSeeded.replace(_reco.generalConversionTrackProducer,_reco.generalConversionTrackProducer+_conversionTrackRefFix)
118 _reco.generalConversionTrackProducerTmp = _reco.generalConversionTrackProducer
119 _reco.generalConversionTrackProducer = _conversionTrackRefFix
120 
121 # this might be historical: not sure why we do this
122 _reco.egammaGlobalReco.replace(_reco.conversionTrackSequence,_reco.conversionTrackSequenceNoEcalSeeded)
123 _reco.allConversions.src = 'gsfGeneralConversionTrackMerger'
124 # TODO: revisit converions in FastSim
125 
126 # not commisoned and not relevant in FastSim (?):
127 _reco.egammaHighLevelRecoPrePF.remove(_reco.uncleanedOnlyElectronSequence)
128 
129 # not commisoned and not relevant in FastSim (?):
130 _reco.egammareco.remove(_reco.conversionSequence)
131 _reco.egammaHighLevelRecoPrePF.remove(_reco.conversionSequence)
132 
133 ##########################################
134 # FastSim changes to muon reconstruction
135 ##########################################
136 # not commisoned and not relevant in FastSim (?):
137 _reco.globalreco.remove(_reco.muoncosmicreco)
138 _reco.highlevelreco.remove(_reco.muoncosmichighlevelreco)
139 _reco.muons.FillCosmicsIdMap = False
140 
141 # not commisoned and not relevant in FastSim (?):
142 _reco.globalmuontracking.remove(_reco.displacedGlobalMuonTracking)
143 _reco.standalonemuontracking.remove(_reco.displacedMuonSeeds)
144 _reco.standalonemuontracking.remove(_reco.displacedStandAloneMuons)
145 
146 # not commisoned and not relevant in FastSim (?):
147 _reco.muonGlobalReco.remove(_reco.muonreco_with_SET)
148 
149 # not commisoned and not relevant in FastSim (?):
150 _reco.muonGlobalReco.remove(_reco.muonSelectionTypeSequence)
151 _reco.muons.FillSelectorMaps = False
152 
153 # FastSim has no template fit on tracker hits
154 _reco.globalMuons.GLBTrajBuilderParameters.GlbRefitterParameters.TrackerRecHitBuilder = 'WithoutRefit'
155 _reco.globalMuons.GLBTrajBuilderParameters.TrackerRecHitBuilder = 'WithoutRefit'
156 _reco.globalMuons.GLBTrajBuilderParameters.TrackTransformer.TrackerRecHitBuilder = 'WithoutRefit'
157 _reco.tevMuons.RefitterParameters.TrackerRecHitBuilder = 'WithoutRefit'
158 
159 # FastSim doesn't use Runge Kute for propagation
160 _reco.globalMuons.GLBTrajBuilderParameters.GlbRefitterParameters.Propagator = 'SmartPropagatorAny'
161 _reco.globalMuons.GLBTrajBuilderParameters.GlobalMuonTrackMatcher.Propagator = 'SmartPropagator'
162 _reco.globalMuons.GLBTrajBuilderParameters.TrackTransformer.Propagator = 'SmartPropagatorAny'
163 _reco.GlbMuKFFitter.Propagator = "SmartPropagatorAny"
164 _reco.GlobalMuonRefitter.Propagator = "SmartPropagatorAny"
165 _reco.KFSmootherForMuonTrackLoader.Propagator = "SmartPropagatorAny"
166 _reco.KFSmootherForRefitInsideOut.Propagator = "SmartPropagatorAny"
167 _reco.KFFitterForRefitInsideOut.Propagator = "SmartPropagatorAny"
168 _reco.tevMuons.RefitterParameters.Propagator = "SmartPropagatorAny"
169 
170 ##########################################
171 # FastSim changes to jet/met reconstruction
172 ##########################################
173 # not commisoned and not relevant in FastSim (?):
174 _reco.jetHighLevelReco.remove(_reco.recoJetAssociationsExplicit)
175 
176 # not commisoned and not relevant in FastSim (?):
177 _reco.metreco.remove(_reco.BeamHaloId)
178 
179 # not commisoned and not relevant in FastSim (?):
180 _reco.metrecoPlusHCALNoise.remove(_reco.hcalnoise)
181 
182 ############################################
183 # deleting modules to avoid clashes with part of reconstruction run before mixing
184 ############################################
185 for _entry in _mod2del:
186  for _key,_value in _reco.__dict__.items():
187  _index = -1
188  if isinstance(_value,cms.Sequence):
189  try:
190  _index = _value.index(_entry)
191  except:
192  pass
193  if _index >= 0:
194  _value.remove(_entry)
195  # removing the last item does not work, and changes the properties of the sequence
196  # so, we detect this changed behaviour and add the sequence to the list of items to be deleted
197  # this is buggy
198  if not isinstance(_value._seq,_SequenceCollection):
199  _mod2del.append(_value)
200 
201 # and delete
202 for _entry in _mod2del:
203  for _key,_value in _reco.__dict__.items():
204  if _entry == _value:
205  delattr(_reco,_key)
206 
207 ############################################
208 # the actual import
209 ############################################
211