Skip to content

Commit

Permalink
split TrackTimeValueMap producer into seperate instances for generalT…
Browse files Browse the repository at this point in the history
…racks and gsf tracks in order to avoid circular dependencies in vertex reco and electron reco
  • Loading branch information
bendavid committed Sep 18, 2017
1 parent 89a315f commit 4a37aac
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 41 deletions.
4 changes: 2 additions & 2 deletions RecoParticleFlow/PFProducer/python/particleFlowBlock_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions RecoParticleFlow/PFProducer/python/simPFProducer_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
)
43 changes: 7 additions & 36 deletions SimTracker/TrackAssociation/plugins/TrackTimeValueMapProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ class TrackTimeValueMapProducer : public edm::global::EDProducer<> {
private:
// inputs
const edm::EDGetTokenT<edm::View<reco::Track> > tracks_;
const edm::EDGetTokenT<edm::View<reco::Track> > gsfTracks_;
const std::string tracksName_;
const edm::EDGetTokenT<TrackingParticleCollection> trackingParticles_;
const edm::EDGetTokenT<TrackingVertexCollection> trackingVertices_;
const edm::EDGetTokenT<edm::HepMCProduct> hepMCProduct_;
Expand All @@ -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<typename ParticleType, typename T>
Expand All @@ -86,7 +84,7 @@ namespace {

TrackTimeValueMapProducer::TrackTimeValueMapProducer(const edm::ParameterSet& conf) :
tracks_(consumes<edm::View<reco::Track> >( conf.getParameter<edm::InputTag>("trackSrc") ) ),
gsfTracks_(consumes<edm::View<reco::Track> >( conf.getParameter<edm::InputTag>("gsfTrackSrc") ) ),
tracksName_(conf.getParameter<edm::InputTag>("trackSrc").label()),
trackingParticles_(consumes<TrackingParticleCollection>( conf.getParameter<edm::InputTag>("trackingParticleSrc") ) ),
trackingVertices_(consumes<TrackingVertexCollection>( conf.getParameter<edm::InputTag>("trackingVertexSrc") ) ),
associators_( edm::vector_transform( conf.getParameter<std::vector<edm::InputTag> >("associators"), [this](const edm::InputTag& tag){ return this->consumes<reco::TrackToTrackingParticleAssociator>(tag); } ) )
Expand All @@ -99,12 +97,8 @@ TrackTimeValueMapProducer::TrackTimeValueMapProducer(const edm::ParameterSet& co
resolutions_.emplace_back( resomod );

// times and time resolutions for general tracks
produces<edm::ValueMap<float> >(generalTracksName+name);
produces<edm::ValueMap<float> >(generalTracksName+name+resolution);

//for gsf tracks
produces<edm::ValueMap<float> >(gsfTracksName+name);
produces<edm::ValueMap<float> >(gsfTracksName+name+resolution);
produces<edm::ValueMap<float> >(tracksName_+name);
produces<edm::ValueMap<float> >(tracksName_+name+resolution);
}
// get RNG engine
edm::Service<edm::RandomNumberGenerator> rng;
Expand Down Expand Up @@ -136,35 +130,26 @@ void TrackTimeValueMapProducer::produce(edm::StreamID sid, edm::Event& evt, cons
evt.getByToken(tracks_, TrackCollectionH);
const edm::View<reco::Track>& TrackCollection = *TrackCollectionH;

edm::Handle<edm::View<reco::Track> > GsfTrackCollectionH;
evt.getByToken(gsfTracks_, GsfTrackCollectionH);
const edm::View<reco::Track>& GsfTrackCollection = *GsfTrackCollectionH;

//get tracking particle collections
edm::Handle<TrackingParticleCollection> TPCollectionH;
evt.getByToken(trackingParticles_, TPCollectionH);
//const TrackingParticleCollection& TPCollection = *TPCollectionH;

// associate the reco tracks / gsf Tracks
std::vector<reco::RecoToSimCollection> associatedTracks, associatedTracksGsf;
std::vector<reco::RecoToSimCollection> 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<float> times, resos;
std::vector<float> 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];
Expand All @@ -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 );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')),
Expand Down
8 changes: 8 additions & 0 deletions TrackingTools/GsfTracking/python/GsfElectronTracking_cff.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

0 comments on commit 4a37aac

Please sign in to comment.