Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Moved fastSim reconstruction to use era #20884

Merged
merged 3 commits into from Nov 9, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 23 additions & 1 deletion Configuration/StandardSequences/python/Reconstruction_cff.py
Expand Up @@ -10,6 +10,9 @@
from TrackingTools.Configuration.TrackingTools_cff import *
from RecoTracker.MeasurementDet.MeasurementTrackerEventProducer_cfi import *
from RecoPixelVertexing.PixelLowPtUtilities.siPixelClusterShapeCache_cfi import *

from Configuration.Eras.Modifier_fastSim_cff import fastSim

siPixelClusterShapeCachePreSplitting = siPixelClusterShapeCache.clone(
src = 'siPixelClustersPreSplitting'
)
Expand Down Expand Up @@ -73,6 +76,12 @@
_ctpps_2016_localreco_HcalNZS += recoCTPPS
ctpps_2016.toReplaceWith(localreco_HcalNZS, _ctpps_2016_localreco_HcalNZS)

###########################################
# no castor, zdc, Totem/CTPPS RP in FastSim
###########################################
_fastSim_localreco = localreco.copyAndExclude([castorreco,totemRPLocalReconstruction,ctppsDiamondLocalReconstruction,ctppsLocalTrackLiteProducer,ctppsPixelLocalReconstruction,trackerlocalreco])
fastSim.toReplaceWith(localreco, _fastSim_localreco)

#
# temporarily switching off recoGenJets; since this are MC and wil be moved to a proper sequence
#
Expand All @@ -91,6 +100,11 @@
_globalreco_tracking_LowPU.replace(trackingGlobalReco, recopixelvertexing+trackingGlobalReco)
from Configuration.Eras.Modifier_trackingLowPU_cff import trackingLowPU
trackingLowPU.toReplaceWith(globalreco_tracking, _globalreco_tracking_LowPU)
##########################################
# offlineBeamSpot is reconstructed before mixing in fastSim
##########################################
_fastSim_globalreco_tracking = globalreco_tracking.copyAndExclude([offlineBeamSpot,MeasurementTrackerEventPreSplitting,siPixelClusterShapeCachePreSplitting])
fastSim.toReplaceWith(globalreco_tracking,_fastSim_globalreco_tracking)

globalreco = cms.Sequence(globalreco_tracking*
particleFlowCluster*
Expand All @@ -106,6 +120,12 @@
_run3_globalreco = globalreco.copyAndExclude([CastorFullReco])
run3_common.toReplaceWith(globalreco, _run3_globalreco)

_fastSim_globalreco = globalreco.copyAndExclude([CastorFullReco,muoncosmicreco])
# insert the few tracking modules to be run after mixing back in the globalreco sequence
_fastSim_globalreco.insert(0,newCombinedSeeds+trackExtrapolator+caloTowerForTrk+firstStepPrimaryVerticesUnsorted+ak4CaloJetsForTrk+initialStepTrackRefsForJets+firstStepPrimaryVertices)
fastSim.toReplaceWith(globalreco,_fastSim_globalreco)


globalreco_plusPL= cms.Sequence(globalreco*ctfTracksPixelLess)

reducedRecHits = cms.Sequence ( reducedEcalRecHitsSequence * reducedHcalRecHitsSequence )
Expand All @@ -124,7 +144,9 @@
reducedRecHits*
cosmicDCTracksSeq
)

# not commisoned and not relevant in FastSim (?):
_fastSim_highlevelreco = highlevelreco.copyAndExclude([cosmicDCTracksSeq,muoncosmichighlevelreco])
fastSim.toReplaceWith(highlevelreco,_fastSim_highlevelreco)

from FWCore.Modules.logErrorHarvester_cfi import *

Expand Down
205 changes: 1 addition & 204 deletions FastSimulation/Configuration/python/Reconstruction_AftMix_cff.py
Expand Up @@ -6,209 +6,6 @@
# At present, only the generalTrack collection, produced with iterative tracking is mixed.
#############################

import FWCore.ParameterSet.Config as cms
from FWCore.ParameterSet.SequenceTypes import _SequenceCollection

# import standard reconstruction
# apply modifications before doing the actual import at the end
import Configuration.StandardSequences.Reconstruction_cff as _reco

# list of modules to be deleted
_mod2del = []

##########################################
# offlineBeamSpot is reconstructed before mixing
##########################################
_mod2del.append(_reco.offlineBeamSpot)
_reco.globalreco.remove(_reco.offlineBeamSpot) # temporary removing this by hand, cause the usual removal (see end of this file) doesn't seem work

###########################################
# no castor, zdc, Totem/CTPPS RP in FastSim
###########################################
_reco.localreco.remove(_reco.castorreco)
_reco.globalreco.remove(_reco.CastorFullReco)
_reco.hcalLocalRecoSequence.remove(_reco.zdcreco)
_reco.localreco.remove(_reco.totemRPLocalReconstruction)
_reco.localreco.remove(_reco.ctppsDiamondLocalReconstruction)
_reco.localreco.remove(_reco.ctppsLocalTrackLiteProducer)
_reco.localreco.remove(_reco.ctppsPixelLocalReconstruction)

##########################################
# Calo rechits
##########################################
# not commisoned and not relevant in FastSim (?):
_reco.reducedEcalRecHitsSequence.remove(_reco.seldigis)
_reco.ecalRecHitSequence.remove(_reco.ecalCompactTrigPrim)
_reco.ecalRecHitSequence.remove(_reco.ecalTPSkim)

# no flags for bad channels in FastSim
_reco.ecalRecHit.killDeadChannels = False
_reco.ecalRecHit.recoverEBFE = False
_reco.ecalRecHit.recoverEEFE = False
_reco.ecalUncalibRecHitSequence.remove(_reco.ecalDetIdToBeRecovered)

##########################################
# Changes to tracking sequences
##########################################
# modules to be removed
_mod2del = _reco.trackingGlobalReco.expandAndClone()._seq._collection
_mod2del.append(_reco.trackingGlobalReco)
_mod2del.extend(_reco.recopixelvertexing.expandAndClone()._seq._collection)
_mod2del.append(_reco.MeasurementTrackerEventPreSplitting)
# actually we want to keep a few modules that we need to run (again) after mixing)
for _entry in [_reco.firstStepPrimaryVerticesUnsorted,_reco.firstStepPrimaryVertices,_reco.ak4CaloJetsForTrk,_reco.caloTowerForTrk,_reco.initialStepTrackRefsForJets,_reco.trackExtrapolator]:
while _entry in _mod2del:
_mod2del.remove(_entry)

# remove tracking sequences from main reco sequences
_reco.localreco.remove(_reco.trackerlocalreco)
_reco.globalreco.remove(_reco.siPixelClusterShapeCachePreSplitting)
_reco.globalreco.remove(_reco.trackingGlobalReco)

# we need a replacment for the firstStepPrimaryVerticesUnsorted
# that includes tracker information of signal and pile up
# after mixing there is no such thing as initialStepTracks,
# so we replace the input collection for firstStepPrimaryVerticesUnsorted with generalTracks
_reco.firstStepPrimaryVerticesUnsorted.TrackLabel = "generalTracks"
_reco.initialStepTrackRefsForJets.src = "generalTracks"

# insert the few tracking modules to be run after mixing back in the globalreco sequence
#for _entry in reversed([trackExtrapolator,caloTowerForTrk,firstStepPrimaryVertices,ak4CaloJetsForTrk])
_reco.globalreco.insert(0,_reco.trackExtrapolator+_reco.caloTowerForTrk+_reco.firstStepPrimaryVerticesUnsorted+_reco.ak4CaloJetsForTrk+_reco.initialStepTrackRefsForJets+_reco.firstStepPrimaryVertices)

# FastSim doesn't use Runge Kute for propagation
# the following propagators are not used in FastSim, but just to be sure...
_reco.KFFitterForRefitOutsideIn.Propagator = 'SmartPropagatorAny'
_reco.KFSmootherForRefitOutsideIn.Propagator = 'SmartPropagator'

# replace the standard ecal-driven seeds with the FastSim emulated ones
import FastSimulation.Tracking.ElectronSeeds_cff
_reco.newCombinedSeeds = FastSimulation.Tracking.ElectronSeeds_cff.newCombinedSeeds
_reco.globalreco.insert(0,_reco.newCombinedSeeds)

##########################################
# FastSim changes to electron reconstruction
##########################################
# tracker driven electron seeds depend on the generalTracks trajectory collection
# However, in FastSim jobs, trajectories are only available for the 'before mixing' track collections
# Therefore we let the seeds depend on the 'before mixing' generalTracks collection
# TODO: investigate whether the dependence on trajectories can be avoided
import FastSimulation.Tracking.ElectronSeedTrackRefFix_cfi
_trackerDrivenElectronSeeds = FastSimulation.Tracking.ElectronSeedTrackRefFix_cfi.fixedTrackerDrivenElectronSeeds.clone()
_reco.electronSeeds.replace(_reco.trackerDrivenElectronSeeds,_reco.trackerDrivenElectronSeeds+_trackerDrivenElectronSeeds)
_reco.trackerDrivenElectronSeedsTmp = _reco.trackerDrivenElectronSeeds
_reco.trackerDrivenElectronSeedsTmp.TkColList = cms.VInputTag(cms.InputTag("generalTracksBeforeMixing"))
_reco.trackerDrivenElectronSeeds = _trackerDrivenElectronSeeds
_reco.trackerDrivenElectronSeeds.seedCollection.setModuleLabel("trackerDrivenElectronSeedsTmp")
_reco.trackerDrivenElectronSeeds.idCollection.setModuleLabel("trackerDrivenElectronSeedsTmp")

# replace the ECAL driven electron track candidates with the FastSim emulated ones
import FastSimulation.Tracking.electronCkfTrackCandidates_cff
_reco.fastElectronCkfTrackCandidates = FastSimulation.Tracking.electronCkfTrackCandidates_cff.electronCkfTrackCandidates.clone()
_reco.electronGsfTracking.replace(_reco.electronCkfTrackCandidates,_reco.fastElectronCkfTrackCandidates)
_reco.electronGsfTracks.src = "fastElectronCkfTrackCandidates"

# FastSim has no template fit on tracker hits
_reco.electronGsfTracks.TTRHBuilder = "WithoutRefit"

# the conversion producer depends on trajectories
# so we feed it with the 'before mixing' track colletion
_reco.generalConversionTrackProducer.TrackProducer = 'generalTracksBeforeMixing'

# then we need to fix the track references, so that they point to the final track collection, after mixing
import FastSimulation.Tracking.ConversionTrackRefFix_cfi
_conversionTrackRefFix = FastSimulation.Tracking.ConversionTrackRefFix_cfi.fixedConversionTracks.clone(
src = cms.InputTag("generalConversionTrackProducerTmp"))
_reco.conversionTrackSequenceNoEcalSeeded.replace(_reco.generalConversionTrackProducer,_reco.generalConversionTrackProducer+_conversionTrackRefFix)
_reco.generalConversionTrackProducerTmp = _reco.generalConversionTrackProducer
_reco.generalConversionTrackProducer = _conversionTrackRefFix

# this might be historical: not sure why we do this
_reco.egammaGlobalReco.replace(_reco.conversionTrackSequence,_reco.conversionTrackSequenceNoEcalSeeded)
_reco.allConversions.src = 'gsfGeneralConversionTrackMerger'
# TODO: revisit converions in FastSim

# not commisoned and not relevant in FastSim (?):
_reco.egammaHighLevelRecoPrePF.remove(_reco.uncleanedOnlyElectronSequence)

# not commisoned and not relevant in FastSim (?):
_reco.egammareco.remove(_reco.conversionSequence)
_reco.egammaHighLevelRecoPrePF.remove(_reco.conversionSequence)

##########################################
# FastSim changes to muon reconstruction
##########################################
# not commisoned and not relevant in FastSim (?):
_reco.globalreco.remove(_reco.muoncosmicreco)
_reco.highlevelreco.remove(_reco.cosmicDCTracksSeq)
_reco.highlevelreco.remove(_reco.muoncosmichighlevelreco)
_reco.muons.FillCosmicsIdMap = False

# not commisoned and not relevant in FastSim (?):
_reco.globalmuontracking.remove(_reco.displacedGlobalMuonTracking)
_reco.standalonemuontracking.remove(_reco.displacedMuonSeeds)
_reco.standalonemuontracking.remove(_reco.displacedStandAloneMuons)

# not commisoned and not relevant in FastSim (?):
_reco.muonGlobalReco.remove(_reco.muonreco_with_SET)

# not commisoned and not relevant in FastSim (?):
_reco.muonGlobalReco.remove(_reco.muonSelectionTypeSequence)
_reco.muons.FillSelectorMaps = False

# FastSim has no template fit on tracker hits
_reco.globalMuons.GLBTrajBuilderParameters.GlbRefitterParameters.TrackerRecHitBuilder = 'WithoutRefit'
_reco.globalMuons.GLBTrajBuilderParameters.TrackerRecHitBuilder = 'WithoutRefit'
_reco.globalMuons.GLBTrajBuilderParameters.TrackTransformer.TrackerRecHitBuilder = 'WithoutRefit'
_reco.tevMuons.RefitterParameters.TrackerRecHitBuilder = 'WithoutRefit'

# FastSim doesn't use Runge Kute for propagation
_reco.globalMuons.GLBTrajBuilderParameters.GlbRefitterParameters.Propagator = 'SmartPropagatorAny'
_reco.globalMuons.GLBTrajBuilderParameters.GlobalMuonTrackMatcher.Propagator = 'SmartPropagator'
_reco.globalMuons.GLBTrajBuilderParameters.TrackTransformer.Propagator = 'SmartPropagatorAny'
_reco.GlbMuKFFitter.Propagator = "SmartPropagatorAny"
_reco.GlobalMuonRefitter.Propagator = "SmartPropagatorAny"
_reco.KFSmootherForMuonTrackLoader.Propagator = "SmartPropagatorAny"
_reco.KFSmootherForRefitInsideOut.Propagator = "SmartPropagatorAny"
_reco.KFFitterForRefitInsideOut.Propagator = "SmartPropagatorAny"
_reco.tevMuons.RefitterParameters.Propagator = "SmartPropagatorAny"

##########################################
# FastSim changes to jet/met reconstruction
##########################################
# CSCHaloData depends on cosmic muons, not available in fastsim
_reco.BeamHaloId.remove(_reco.CSCHaloData)
# GlobalHaloData and BeamHaloSummary depend on CSCHaloData
_reco.BeamHaloId.remove(_reco.GlobalHaloData)
_reco.BeamHaloId.remove(_reco.BeamHaloSummary)

############################################
# deleting modules to avoid clashes with part of reconstruction run before mixing
############################################
for _entry in _mod2del:
for _key,_value in _reco.__dict__.items():
_index = -1
if isinstance(_value,cms.Sequence):
try:
_index = _value.index(_entry)
except:
pass
if _index >= 0:
_value.remove(_entry)
# removing the last item does not work, and changes the properties of the sequence
# so, we detect this changed behaviour and add the sequence to the list of items to be deleted
# this is buggy
if not isinstance(_value._seq,_SequenceCollection):
_mod2del.append(_value)

# and delete
for _entry in _mod2del:
for _key,_value in _reco.__dict__.items():
if _entry == _value:
delattr(_reco,_key)

############################################
# the actual import
############################################
#All work is now done with the fastSim era
from Configuration.StandardSequences.Reconstruction_cff import *
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here and in a few more places, is there a reverse equivalent, along the following lines:
FastSimulation/Configuration will contain only the fastsim modifiers and by itself can not be used.
Instead then the standard include should change to Configuration.StandardSequences.Reconstruction_cff

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was considering changing to just the standard includes as a seperate pull request. I wanted to minimize impact on other code (such as cmsDriver) as possible.


50 changes: 2 additions & 48 deletions FastSimulation/Tracking/python/DetachedTripletStep_cff.py
@@ -1,49 +1,3 @@
import FWCore.ParameterSet.Config as cms

# import the full tracking equivalent of this file
import RecoTracker.IterativeTracking.DetachedTripletStep_cff as _standard
from FastSimulation.Tracking.SeedingMigration import _hitSetProducerToFactoryPSet

# fast tracking mask producer
import FastSimulation.Tracking.FastTrackerRecHitMaskProducer_cfi
detachedTripletStepMasks = FastSimulation.Tracking.FastTrackerRecHitMaskProducer_cfi.maskProducerFromClusterRemover(_standard.detachedTripletStepClusters)

# tracking regions
detachedTripletStepTrackingRegions = _standard.detachedTripletStepTrackingRegions.clone()

# trajectory seeds
import FastSimulation.Tracking.TrajectorySeedProducer_cfi
detachedTripletStepSeeds = FastSimulation.Tracking.TrajectorySeedProducer_cfi.trajectorySeedProducer.clone(
layerList = _standard.detachedTripletStepSeedLayers.layerList.value(),
trackingRegions = "detachedTripletStepTrackingRegions",
hitMasks = cms.InputTag("detachedTripletStepMasks")
)
detachedTripletStepSeeds.seedFinderSelector.pixelTripletGeneratorFactory = _hitSetProducerToFactoryPSet(_standard.detachedTripletStepHitTriplets)

# track candidates
import FastSimulation.Tracking.TrackCandidateProducer_cfi
detachedTripletStepTrackCandidates = FastSimulation.Tracking.TrackCandidateProducer_cfi.trackCandidateProducer.clone(
src = cms.InputTag("detachedTripletStepSeeds"),
MinNumberOfCrossedLayers = 3,
hitMasks = cms.InputTag("detachedTripletStepMasks")
)

# tracks
detachedTripletStepTracks = _standard.detachedTripletStepTracks.clone(TTRHBuilder = 'WithoutRefit')

detachedTripletStepClassifier1 = _standard.detachedTripletStepClassifier1.clone()
detachedTripletStepClassifier1.vertices = "firstStepPrimaryVerticesBeforeMixing"
detachedTripletStepClassifier2 = _standard.detachedTripletStepClassifier2.clone()
detachedTripletStepClassifier2.vertices = "firstStepPrimaryVerticesBeforeMixing"

detachedTripletStep = _standard.detachedTripletStep.clone()

# Final sequence
DetachedTripletStep = cms.Sequence(detachedTripletStepMasks
+detachedTripletStepTrackingRegions
+detachedTripletStepSeeds
+detachedTripletStepTrackCandidates
+detachedTripletStepTracks
+detachedTripletStepClassifier1*detachedTripletStepClassifier2
+detachedTripletStep
)
# all work is now done using fastSim era
from RecoTracker.IterativeTracking.DetachedTripletStep_cff import *
2 changes: 1 addition & 1 deletion FastSimulation/Tracking/python/ElectronSeeds_cff.py
Expand Up @@ -2,7 +2,7 @@

# TODO: sync with RecoTracker/IterativeTracking/python/ElectronSeeds_cff.py

newCombinedSeeds = cms.EDProducer(
_newCombinedSeeds = cms.EDProducer(
"SeedCombiner",
seedCollections = cms.VInputTag(
cms.InputTag('initialStepSeeds'),
Expand Down
52 changes: 2 additions & 50 deletions FastSimulation/Tracking/python/InitialStep_cff.py
@@ -1,51 +1,3 @@
import FWCore.ParameterSet.Config as cms

# import the full tracking equivalent of this file
import RecoTracker.IterativeTracking.InitialStep_cff as _standard
from FastSimulation.Tracking.SeedingMigration import _hitSetProducerToFactoryPSet

# tracking regions
initialStepTrackingRegions = _standard.initialStepTrackingRegions.clone()

# trajectory seeds
import FastSimulation.Tracking.TrajectorySeedProducer_cfi
initialStepSeeds = FastSimulation.Tracking.TrajectorySeedProducer_cfi.trajectorySeedProducer.clone(
layerList = _standard.initialStepSeedLayers.layerList.value(),
trackingRegions = "initialStepTrackingRegions"
)
initialStepSeeds.seedFinderSelector.pixelTripletGeneratorFactory = _hitSetProducerToFactoryPSet(_standard.initialStepHitTriplets)
initialStepSeeds.seedFinderSelector.pixelTripletGeneratorFactory.SeedComparitorPSet.ComponentName = "none"

# track candidates
import FastSimulation.Tracking.TrackCandidateProducer_cfi
initialStepTrackCandidates = FastSimulation.Tracking.TrackCandidateProducer_cfi.trackCandidateProducer.clone(
src = cms.InputTag("initialStepSeeds"),
MinNumberOfCrossedLayers = 3
)

# tracks
initialStepTracks = _standard.initialStepTracks.clone(TTRHBuilder = 'WithoutRefit')

firstStepPrimaryVerticesBeforeMixing = _standard.firstStepPrimaryVerticesUnsorted.clone()

# final selection
initialStepClassifier1 = _standard.initialStepClassifier1.clone()
initialStepClassifier1.vertices = "firstStepPrimaryVerticesBeforeMixing"
initialStepClassifier2 = _standard.initialStepClassifier2.clone()
initialStepClassifier2.vertices = "firstStepPrimaryVerticesBeforeMixing"
initialStepClassifier3 = _standard.initialStepClassifier3.clone()
initialStepClassifier3.vertices = "firstStepPrimaryVerticesBeforeMixing"


initialStep = _standard.initialStep.clone()

# Final sequence
InitialStep = cms.Sequence(initialStepTrackingRegions
+initialStepSeeds
+initialStepTrackCandidates
+initialStepTracks
+firstStepPrimaryVerticesBeforeMixing
+initialStepClassifier1*initialStepClassifier2*initialStepClassifier3
+initialStep
)

# all work is now done via fastSim era
from RecoTracker.IterativeTracking.InitialStep_cff import *