From 4a37aac412c0a31f72b262bcfd23cd545621152c Mon Sep 17 00:00:00 2001 From: Josh Bendavid Date: Tue, 24 Jan 2017 22:21:07 +0100 Subject: [PATCH] split TrackTimeValueMap producer into seperate instances for generalTracks and gsf tracks in order to avoid circular dependencies in vertex reco and electron reco --- .../python/particleFlowBlock_cfi.py | 4 +- .../PFProducer/python/simPFProducer_cfi.py | 4 +- .../plugins/TrackTimeValueMapProducer.cc | 43 +++---------------- .../python/trackTimeValueMapProducer_cfi.py | 1 - .../python/GsfElectronTracking_cff.py | 8 ++++ 5 files changed, 19 insertions(+), 41 deletions(-) diff --git a/RecoParticleFlow/PFProducer/python/particleFlowBlock_cfi.py b/RecoParticleFlow/PFProducer/python/particleFlowBlock_cfi.py index 50c3cd05a0b92..1f381b5374925 100644 --- a/RecoParticleFlow/PFProducer/python/particleFlowBlock_cfi.py +++ b/RecoParticleFlow/PFProducer/python/particleFlowBlock_cfi.py @@ -183,8 +183,8 @@ def _findIndicesByModule(name): ) for idx in _findIndicesByModule('GSFTrackImporter'): _addTiming[idx] = dict( - timeValueMap = cms.InputTag("trackTimeValueMapProducer:gsfTracksConfigurableFlatResolutionModel"), - timeErrorMap = cms.InputTag("trackTimeValueMapProducer:gsfTracksConfigurableFlatResolutionModelResolution") + timeValueMap = cms.InputTag("gsfTrackTimeValueMapProducer:electronGsfTracksConfigurableFlatResolutionModel"), + timeErrorMap = cms.InputTag("gsfTrackTimeValueMapProducer:electronGsfTracksConfigurableFlatResolutionModelResolution") ) phase2_timing.toModify( particleFlowBlock, diff --git a/RecoParticleFlow/PFProducer/python/simPFProducer_cfi.py b/RecoParticleFlow/PFProducer/python/simPFProducer_cfi.py index f8d4b908ded4b..2bf8b6f5e1057 100644 --- a/RecoParticleFlow/PFProducer/python/simPFProducer_cfi.py +++ b/RecoParticleFlow/PFProducer/python/simPFProducer_cfi.py @@ -21,6 +21,6 @@ simPFProducer, trackTimeValueMap = cms.InputTag("trackTimeValueMapProducer:generalTracksConfigurableFlatResolutionModel"), trackTimeErrorMap = cms.InputTag("trackTimeValueMapProducer:generalTracksConfigurableFlatResolutionModelResolution"), - gsfTrackTimeValueMap = cms.InputTag("trackTimeValueMapProducer:gsfTracksConfigurableFlatResolutionModel"), - gsfTrackTimeErrorMap = cms.InputTag("trackTimeValueMapProducer:gsfTracksConfigurableFlatResolutionModelResolution"), + gsfTrackTimeValueMap = cms.InputTag("gsfTrackTimeValueMapProducer:electronGsfTracksConfigurableFlatResolutionModel"), + gsfTrackTimeErrorMap = cms.InputTag("gsfTrackTimeValueMapProducer:electronGsfTracksConfigurableFlatResolutionModelResolution"), ) diff --git a/SimTracker/TrackAssociation/plugins/TrackTimeValueMapProducer.cc b/SimTracker/TrackAssociation/plugins/TrackTimeValueMapProducer.cc index 2b4aa16599aec..f255eb07622f2 100644 --- a/SimTracker/TrackAssociation/plugins/TrackTimeValueMapProducer.cc +++ b/SimTracker/TrackAssociation/plugins/TrackTimeValueMapProducer.cc @@ -48,7 +48,7 @@ class TrackTimeValueMapProducer : public edm::global::EDProducer<> { private: // inputs const edm::EDGetTokenT > tracks_; - const edm::EDGetTokenT > gsfTracks_; + const std::string tracksName_; const edm::EDGetTokenT trackingParticles_; const edm::EDGetTokenT trackingVertices_; const edm::EDGetTokenT hepMCProduct_; @@ -67,8 +67,6 @@ DEFINE_FWK_MODULE(TrackTimeValueMapProducer); namespace { constexpr float fakeBeamSpotTimeWidth = 0.300f; // ns - const std::string generalTracksName("generalTracks"); - const std::string gsfTracksName("gsfTracks"); const std::string resolution("Resolution"); template @@ -86,7 +84,7 @@ namespace { TrackTimeValueMapProducer::TrackTimeValueMapProducer(const edm::ParameterSet& conf) : tracks_(consumes >( conf.getParameter("trackSrc") ) ), - gsfTracks_(consumes >( conf.getParameter("gsfTrackSrc") ) ), + tracksName_(conf.getParameter("trackSrc").label()), trackingParticles_(consumes( conf.getParameter("trackingParticleSrc") ) ), trackingVertices_(consumes( conf.getParameter("trackingVertexSrc") ) ), associators_( edm::vector_transform( conf.getParameter >("associators"), [this](const edm::InputTag& tag){ return this->consumes(tag); } ) ) @@ -99,12 +97,8 @@ TrackTimeValueMapProducer::TrackTimeValueMapProducer(const edm::ParameterSet& co resolutions_.emplace_back( resomod ); // times and time resolutions for general tracks - produces >(generalTracksName+name); - produces >(generalTracksName+name+resolution); - - //for gsf tracks - produces >(gsfTracksName+name); - produces >(gsfTracksName+name+resolution); + produces >(tracksName_+name); + produces >(tracksName_+name+resolution); } // get RNG engine edm::Service rng; @@ -136,35 +130,26 @@ void TrackTimeValueMapProducer::produce(edm::StreamID sid, edm::Event& evt, cons evt.getByToken(tracks_, TrackCollectionH); const edm::View& TrackCollection = *TrackCollectionH; - edm::Handle > GsfTrackCollectionH; - evt.getByToken(gsfTracks_, GsfTrackCollectionH); - const edm::View& GsfTrackCollection = *GsfTrackCollectionH; - //get tracking particle collections edm::Handle TPCollectionH; evt.getByToken(trackingParticles_, TPCollectionH); //const TrackingParticleCollection& TPCollection = *TPCollectionH; // associate the reco tracks / gsf Tracks - std::vector associatedTracks, associatedTracksGsf; + std::vector associatedTracks; for( auto associator : associators ) { associatedTracks.emplace_back(associator->associateRecoToSim(TrackCollectionH, TPCollectionH)); - associatedTracksGsf.emplace_back(associator->associateRecoToSim(GsfTrackCollectionH, TPCollectionH)); } calculateTrackTimes(TrackCollection, associatedTracks, generalTrackTimes); - calculateTrackTimes(GsfTrackCollection, associatedTracksGsf, gsfTrackTimes); for( const auto& reso : resolutions_ ) { const std::string& name = reso->name(); std::vector times, resos; - std::vector gsf_times, gsf_resos; times.reserve(TrackCollection.size()); resos.reserve(TrackCollection.size()); - gsf_times.reserve(GsfTrackCollection.size()); - gsf_resos.reserve(GsfTrackCollection.size()); for( unsigned i = 0; i < TrackCollection.size(); ++i ) { const reco::Track& tk = TrackCollection[i]; @@ -178,22 +163,8 @@ void TrackTimeValueMapProducer::produce(edm::StreamID sid, edm::Event& evt, cons } } - for( unsigned i = 0; i < GsfTrackCollection.size(); ++i ) { - const reco::Track& tk = GsfTrackCollection[i]; - if( edm::isFinite( gsfTrackTimes[i] ) && gsfTrackTimes[i] != 0.f ) { - const float resolution = reso->getTimeResolution(tk); - gsf_times.push_back( CLHEP::RandGauss::shoot(rng_engine, gsfTrackTimes[i], resolution) ); - gsf_resos.push_back( resolution ); - } else { - gsf_times.push_back( 0.0f ); - gsf_resos.push_back( fakeBeamSpotTimeWidth ); - } - } - - writeValueMap( evt, TrackCollectionH, times, generalTracksName+name ); - writeValueMap( evt, TrackCollectionH, resos, generalTracksName+name+resolution ); - writeValueMap( evt, GsfTrackCollectionH, gsf_times, gsfTracksName+name ); - writeValueMap( evt, GsfTrackCollectionH, gsf_resos, gsfTracksName+name+resolution ); + writeValueMap( evt, TrackCollectionH, times, tracksName_+name ); + writeValueMap( evt, TrackCollectionH, resos, tracksName_+name+resolution ); } } diff --git a/SimTracker/TrackAssociation/python/trackTimeValueMapProducer_cfi.py b/SimTracker/TrackAssociation/python/trackTimeValueMapProducer_cfi.py index 8547a1b37e7a9..6e57cb3e245ea 100644 --- a/SimTracker/TrackAssociation/python/trackTimeValueMapProducer_cfi.py +++ b/SimTracker/TrackAssociation/python/trackTimeValueMapProducer_cfi.py @@ -3,7 +3,6 @@ trackTimeValueMapProducer = cms.EDProducer( 'TrackTimeValueMapProducer', trackSrc = cms.InputTag('generalTracks'), - gsfTrackSrc = cms.InputTag('electronGsfTracks'), trackingParticleSrc = cms.InputTag('mix:MergedTrackTruth'), trackingVertexSrc = cms.InputTag('mix:MergedTrackTruth'), associators = cms.VInputTag(cms.InputTag('quickTrackAssociatorByHits')), diff --git a/TrackingTools/GsfTracking/python/GsfElectronTracking_cff.py b/TrackingTools/GsfTracking/python/GsfElectronTracking_cff.py index 23fc1e93316a4..bd9458e4f74aa 100644 --- a/TrackingTools/GsfTracking/python/GsfElectronTracking_cff.py +++ b/TrackingTools/GsfTracking/python/GsfElectronTracking_cff.py @@ -24,3 +24,11 @@ phase2_hgcal.toReplaceWith( electronGsfTracking, _electronGsfTracking ) + +from SimTracker.TrackAssociation.trackTimeValueMapProducer_cfi import trackTimeValueMapProducer +gsfTrackTimeValueMapProducer = trackTimeValueMapProducer.clone(trackSrc = cms.InputTag('electronGsfTracks')) + +electronGsfTrackingWithTiming = cms.Sequence(electronGsfTracking.copy()*gsfTrackTimeValueMapProducer) + +from Configuration.Eras.Modifier_phase2_timing_cff import phase2_timing +phase2_timing.toReplaceWith(electronGsfTracking, electronGsfTrackingWithTiming)