From ec3458f473eff118532945bba2128312ba55a367 Mon Sep 17 00:00:00 2001 From: ngrenz Date: Mon, 22 Jun 2015 21:55:02 +0200 Subject: [PATCH] change last if position + less variable creation and destruction --- .../src/TrackerHitAssociator.cc | 103 ++++++++++++------ 1 file changed, 68 insertions(+), 35 deletions(-) diff --git a/SimTracker/TrackerHitAssociation/src/TrackerHitAssociator.cc b/SimTracker/TrackerHitAssociation/src/TrackerHitAssociator.cc index 36e7e99f63477..1ce380c48af43 100644 --- a/SimTracker/TrackerHitAssociation/src/TrackerHitAssociator.cc +++ b/SimTracker/TrackerHitAssociation/src/TrackerHitAssociator.cc @@ -102,51 +102,84 @@ void TrackerHitAssociator::makeMaps(const edm::Event& theEvent, const TrackerHit const char* const highTag = "HighTof"; unsigned int tofBin; edm::EDConsumerBase::Labels labels; - for(auto const& cfToken : config.cfTokens_) { - edm::Handle > cf_simhit; - int Nhits = 0; - if (theEvent.getByToken(cfToken, cf_simhit)) { - std::unique_ptr > thisContainerHits(new MixCollection(cf_simhit.product())); - theEvent.labelsForToken(cfToken, labels); - if(std::strstr(labels.productInstance, highTag) != NULL) { - tofBin = StripDigiSimLink::HighTof; - } else { - tofBin = StripDigiSimLink::LowTof; - } - for (auto const& isim : *thisContainerHits) { - DetId theDet(isim.detUnitId()); - if (assocHitbySimTrack_) { - SimHitMap[theDet].push_back(isim); + if (assocHitbySimTrack_) { + for(auto const& cfToken : config.cfTokens_) { + edm::Handle > cf_simhit; + //int Nhits = 0; + if (theEvent.getByToken(cfToken, cf_simhit)) { + std::unique_ptr > thisContainerHits(new MixCollection(cf_simhit.product())); + theEvent.labelsForToken(cfToken, labels); + if(std::strstr(labels.productInstance, highTag) != NULL) { + tofBin = StripDigiSimLink::HighTof; } else { - simHitCollectionID theSimHitCollID = std::make_pair(theDet.subdetId(), tofBin); - SimHitCollMap[theSimHitCollID].push_back(isim); + tofBin = StripDigiSimLink::LowTof; + } + for (auto const& isim : *thisContainerHits) { + DetId theDet(isim.detUnitId()); + SimHitMap[theDet].push_back(isim); + // ++Nhits; } - ++Nhits; - } // std::cout << "simHits from crossing frames; map size = " << SimHitCollMap.size() << ", Hit count = " << Nhits << std::endl; - } - } - for(auto const& simHitToken : config.simHitTokens_) { - edm::Handle > simHits; - int Nhits = 0; - if(theEvent.getByToken(simHitToken, simHits)) { - theEvent.labelsForToken(simHitToken, labels); - if(std::strstr(labels.productInstance, highTag) != NULL) { - tofBin = StripDigiSimLink::HighTof; - } else { - tofBin = StripDigiSimLink::LowTof; } - for (auto const& isim : *simHits) { - DetId theDet(isim.detUnitId()); - if (assocHitbySimTrack_) { + } + for(auto const& simHitToken : config.simHitTokens_) { + edm::Handle > simHits; + //int Nhits = 0; + if(theEvent.getByToken(simHitToken, simHits)) { + theEvent.labelsForToken(simHitToken, labels); + if(std::strstr(labels.productInstance, highTag) != NULL) { + tofBin = StripDigiSimLink::HighTof; + } else { + tofBin = StripDigiSimLink::LowTof; + } + for (auto const& isim : *simHits) { + DetId theDet(isim.detUnitId()); SimHitMap[theDet].push_back(isim); + //++Nhits; + } + // std::cout << "simHits from prompt collections; map size = " << SimHitCollMap.size() << ", Hit count = " << Nhits << std::endl; + } + } + } else { + simHitCollectionID theSimHitCollID; + for(auto const& cfToken : config.cfTokens_) { + edm::Handle > cf_simhit; + //int Nhits = 0; + if (theEvent.getByToken(cfToken, cf_simhit)) { + std::unique_ptr > thisContainerHits(new MixCollection(cf_simhit.product())); + theEvent.labelsForToken(cfToken, labels); + if(std::strstr(labels.productInstance, highTag) != NULL) { + tofBin = StripDigiSimLink::HighTof; } else { - simHitCollectionID theSimHitCollID = std::make_pair(theDet.subdetId(), tofBin); + tofBin = StripDigiSimLink::LowTof; + } + for (auto const& isim : *thisContainerHits) { + DetId theDet(isim.detUnitId()); + theSimHitCollID = std::make_pair(theDet.subdetId(), tofBin); SimHitCollMap[theSimHitCollID].push_back(isim); + //++Nhits; } - ++Nhits; + // std::cout << "simHits from crossing frames; map size = " << SimHitCollMap.size() << ", Hit count = " << Nhits << std::endl; } + } + for(auto const& simHitToken : config.simHitTokens_) { + edm::Handle > simHits; + //int Nhits = 0; + if(theEvent.getByToken(simHitToken, simHits)) { + theEvent.labelsForToken(simHitToken, labels); + if(std::strstr(labels.productInstance, highTag) != NULL) { + tofBin = StripDigiSimLink::HighTof; + } else { + tofBin = StripDigiSimLink::LowTof; + } + for (auto const& isim : *simHits) { + DetId theDet(isim.detUnitId()); + theSimHitCollID = std::make_pair(theDet.subdetId(), tofBin); + SimHitCollMap[theSimHitCollID].push_back(isim); + //++Nhits; + } // std::cout << "simHits from prompt collections; map size = " << SimHitCollMap.size() << ", Hit count = " << Nhits << std::endl; + } } } }