Go to the documentation of this file.00001 #include "RecoTracker/CkfPattern/interface/IntermediateTrajectoryCleaner.h"
00002 #include <boost/bind.hpp>
00003 #include <algorithm>
00004 #include <functional>
00005
00006
00007 #ifdef GIO_WAIT
00008 void
00009 IntermediateTrajectoryCleaner::clean(TempTrajectoryContainer &theTrajectories) {
00010 }
00011 #else
00012
00013 void
00014 IntermediateTrajectoryCleaner::clean(IntermediateTrajectoryCleaner::TempTrajectoryContainer &theTrajectories) {
00015
00016 if (theTrajectories.empty()) return;
00017 if (theTrajectories[0].measurements().size()<4) return;
00018
00019 for (TempTrajectoryContainer::iterator firstTraj=theTrajectories.begin(), firstEnd=theTrajectories.end() - 1;
00020 firstTraj != firstEnd; ++firstTraj) {
00021
00022 if ( (!firstTraj->isValid()) ||
00023 (!firstTraj->lastMeasurement().recHit()->isValid()) ) continue;
00024
00025 TempTrajectory::DataContainer::const_iterator itFirst = firstTraj->measurements().rbegin();
00026 ConstRecHitPointer first_hit1 = itFirst->recHit(); --itFirst;
00027 ConstRecHitPointer first_hit2 = itFirst->recHit(); --itFirst;
00028 ConstRecHitPointer first_hit3 = itFirst->recHit();
00029
00030 bool fh2Valid = first_hit2->isValid();
00031
00032 for (TempTrajectoryContainer::iterator secondTraj = (firstTraj+1), secondEnd = theTrajectories.end();
00033 secondTraj != secondEnd; ++secondTraj) {
00034
00035 if ( (!secondTraj->isValid()) ||
00036 (!secondTraj->lastMeasurement().recHit()->isValid()) ) continue;
00037
00038 TempTrajectory::DataContainer::const_iterator itSecond = secondTraj->measurements().rbegin();
00039 ConstRecHitPointer second_hit1 = itSecond->recHit(); --itSecond;
00040 ConstRecHitPointer second_hit2 = itSecond->recHit(); --itSecond;
00041 ConstRecHitPointer second_hit3 = itSecond->recHit();
00042
00043 if ( &(*first_hit3) == &(*second_hit3) ) {
00044 if (fh2Valid ^ second_hit2->isValid()) {
00045 if ( first_hit1->hit()->sharesInput( second_hit1->hit(), TrackingRecHit::all ) ){
00046
00047 if (!fh2Valid) {
00048 firstTraj->invalidate();
00049 break;
00050 }
00051
00052 secondTraj->invalidate();
00053 }
00054 }
00055 }
00056 }
00057 }
00058 theTrajectories.erase(std::remove_if( theTrajectories.begin(),theTrajectories.end(),
00059 std::not1(std::mem_fun_ref(&TempTrajectory::isValid))),
00060
00061 theTrajectories.end());
00062 }
00063 #endif