CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10_patch1/src/TrackingTools/TrajectoryCleaning/src/TrajectoryCleanerBySharedSeeds.cc

Go to the documentation of this file.
00001 #include "TrackingTools/TrajectoryCleaning/interface/TrajectoryCleanerBySharedSeeds.h"
00002 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
00003 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00004 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHit.h"
00005 
00006 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00007 
00008 #include <map>
00009 #include <vector>
00010 
00011 using namespace std;
00012 
00013 /*****************************************************************************/
00014 bool TrajectoryCleanerBySharedSeeds::sameSeed(const TrajectorySeed & s1,const TrajectorySeed & s2) const
00015 {
00016   if(s1.nHits()==0 && s2.nHits()==0) return false;
00017   if(s1.nHits() != s2.nHits()) return false;
00018 
00019   TrajectorySeed::range r1 = s1.recHits();
00020   TrajectorySeed::range r2 = s2.recHits();
00021 
00022   TrajectorySeed::const_iterator h1 = r1.first;
00023   TrajectorySeed::const_iterator h2 = r2.first;
00024 
00025   do
00026   {
00027     if(!(h1->sharesInput(&(*h2),TrackingRecHit::all)))
00028       return false;
00029 
00030     h1++; h2++;
00031   }
00032   while(h1 != s1.recHits().second && 
00033         h2 != s2.recHits().second);
00034 
00035   return true;
00036 }
00037 
00038 /*****************************************************************************/
00039 void TrajectoryCleanerBySharedSeeds::clean(TrajectoryPointerContainer&) const
00040 {
00041 }
00042 
00043 /*****************************************************************************/
00044 void TrajectoryCleanerBySharedSeeds::clean
00045   (std::vector<Trajectory> & trajs) const
00046 {
00047   if(trajs.size() == 0) return;
00048 
00049   // Best track
00050   unsigned int best = 0;
00051 
00052   // Track are assumed to come in seed blocks
00053   for(unsigned int actual = 1; actual < trajs.size(); actual++)
00054   {
00055     if(sameSeed(trajs[best].seed(), trajs[actual].seed()))
00056     {
00057       // Track to remove 
00058       unsigned int remove;
00059 
00060       // remove track with lower number of found hits, higher chi2
00061       if(trajs[best].foundHits() != trajs[actual].foundHits())
00062       {
00063         if(trajs[best].foundHits()  > trajs[actual].foundHits())
00064           remove = actual;
00065         else { remove = best; best = actual; }
00066       }
00067       else
00068       {
00069         if(trajs[best].chiSquared() < trajs[actual].chiSquared())
00070           remove = actual;
00071         else { remove = best; best = actual; }
00072       }
00073 
00074       trajs[remove].invalidate();
00075     }    
00076   }
00077 
00078   LogTrace("TrajectoryCleanerBySharedSeeds") << "  [TrajecCleaner] cleaned trajs : 1/" << trajs.size()
00079                                              << " (with " << trajs[best].measurements().size() << " hits)" << std::endl;
00080 }
00081