From 96ee0905d537af738cc5e46a5292deb2bd37109e Mon Sep 17 00:00:00 2001 From: lgray Date: Thu, 21 Sep 2017 09:27:06 -0500 Subject: [PATCH] do not reorder elements when assigning time --- .../plugins/importers/TrackTimingImporter.cc | 58 ++++++++----------- 1 file changed, 23 insertions(+), 35 deletions(-) diff --git a/RecoParticleFlow/PFProducer/plugins/importers/TrackTimingImporter.cc b/RecoParticleFlow/PFProducer/plugins/importers/TrackTimingImporter.cc index 9f087306ee80a..c08f8d2d87d4e 100644 --- a/RecoParticleFlow/PFProducer/plugins/importers/TrackTimingImporter.cc +++ b/RecoParticleFlow/PFProducer/plugins/importers/TrackTimingImporter.cc @@ -51,39 +51,27 @@ importToBlock( const edm::Event& e, e.getByToken(srcTimeGsf_, timeGsfH); e.getByToken(srcTimeErrorGsf_, timeErrGsfH); - auto TKs_end = std::partition(elems.begin(),elems.end(), - [](const ElementType& a){ - return a->type() == reco::PFBlockElement::TRACK; - }); - auto btk_elems = elems.begin(); - for( auto track = btk_elems; track != TKs_end; ++track) { - const auto& ref = (*track)->trackRef(); - if (timeH->contains(ref.id())) { - (*track)->setTime( (*timeH)[ref], (*timeErrH)[ref] ); - } - if( debug_ ) { - edm::LogInfo("TrackTimingImporter") - << "Track with pT / eta " << ref->pt() << " / " << ref->eta() - << " has time: " << (*track)->time() << " +/- " << (*track)->timeError() << std::endl; - } - - } - - auto gsfTKs_end = std::partition(elems.begin(),elems.end(), - [](const ElementType& a){ - return a->type() == reco::PFBlockElement::GSF; - }); - auto gsfbtk_elems = elems.begin(); - for( auto track = gsfbtk_elems; track != gsfTKs_end; ++track) { - const auto& ref = static_cast((*track).get())->GsftrackRef(); - if (timeGsfH->contains(ref.id())) { - (*track)->setTime( (*timeGsfH)[ref], (*timeErrGsfH)[ref] ); - } - if( debug_ ) { - edm::LogInfo("TrackTimingImporter") - << "Track with pT / eta " << ref->pt() << " / " << ref->eta() - << " has time: " << (*track)->time() << " +/- " << (*track)->timeError() << std::endl; - } - - } + for( auto& elem : elems ) { + if( reco::PFBlockElement::TRACK == elem->type() ) { + const auto& ref = elem->trackRef(); + if (timeH->contains(ref.id())) { + elem->setTime( (*timeH)[ref], (*timeErrH)[ref] ); + } + if( debug_ ) { + edm::LogInfo("TrackTimingImporter") + << "Track with pT / eta " << ref->pt() << " / " << ref->eta() + << " has time: " << elem->time() << " +/- " << elem->timeError() << std::endl; + } + } else if ( reco::PFBlockElement::GSF == elem->type() ) { + const auto& ref = static_cast(elem.get())->GsftrackRef(); + if (timeGsfH->contains(ref.id())) { + elem->setTime( (*timeGsfH)[ref], (*timeErrGsfH)[ref] ); + } + if( debug_ ) { + edm::LogInfo("TrackTimingImporter") + << "Track with pT / eta " << ref->pt() << " / " << ref->eta() + << " has time: " << elem->time() << " +/- " << elem->timeError() << std::endl; + } + } + } }