CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/RecoTracker/TkSeedGenerator/src/SeedGeneratorFromRegionHits.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkSeedGenerator/interface/SeedGeneratorFromRegionHits.h"
00002 
00003 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGenerator.h"
00004 #include "RecoTracker/TkSeedingLayers/interface/SeedComparitor.h"
00005 #include "RecoTracker/TkSeedGenerator/interface/SeedCreator.h"
00006 
00007 
00008 
00009 
00010 SeedGeneratorFromRegionHits::SeedGeneratorFromRegionHits(
00011     OrderedHitsGenerator *ohg, SeedComparitor* asc, SeedCreator* asp)
00012   : theHitsGenerator(ohg), theComparitor(asc), theSeedCreator(asp)
00013 { }
00014 
00015 
00016 void SeedGeneratorFromRegionHits::run(TrajectorySeedCollection & seedCollection, 
00017     const TrackingRegion & region, const edm::Event& ev, const edm::EventSetup& es)
00018 {
00019   if (theComparitor) theComparitor->init(es);
00020   theSeedCreator->init(region, es, theComparitor.get());
00021   const OrderedSeedingHits & hitss = theHitsGenerator->run(region, ev, es);
00022 
00023   unsigned int nHitss =  hitss.size();
00024   if (seedCollection.empty()) seedCollection.reserve(nHitss); // don't do multiple reserves in the case of multiple regions: it would make things even worse
00025                                                               // as it will cause N re-allocations instead of the normal log(N)/log(2)
00026   for (unsigned int iHits = 0; iHits < nHitss; ++iHits) { 
00027     const SeedingHitSet & hits =  hitss[iHits];
00028     if (!theComparitor || theComparitor->compatible(hits, region) ) {
00029       theSeedCreator->makeSeed(seedCollection, hits);
00030     }
00031   }
00032   theHitsGenerator->clear();
00033 }