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