#include <TrajectoryCleanerBySharedHits.h>
Public Types | |
typedef std::vector< Trajectory * > | TrajectoryPointerContainer |
Public Member Functions | |
virtual void | clean (TrajectoryPointerContainer &) const |
TrajectoryCleanerBySharedHits (const edm::ParameterSet &iConfig) | |
TrajectoryCleanerBySharedHits () | |
virtual | ~TrajectoryCleanerBySharedHits () |
Private Attributes | |
bool | allowSharedFirstHit |
double | theFraction |
A concrete TrajectoryCleaner that considers two trajectories to be mutually exclusive if they share more than some fraction of their hits. The "best" trajectory of each set of mutually exclusive ones is kept, the others are eliminated. The goodness of a track is defined in terms of Chi^2, number of reconstructed hits, and number of lost hits.
Definition at line 16 of file TrajectoryCleanerBySharedHits.h.
typedef std::vector<Trajectory*> TrajectoryCleanerBySharedHits::TrajectoryPointerContainer |
Reimplemented from TrajectoryCleaner.
Definition at line 20 of file TrajectoryCleanerBySharedHits.h.
TrajectoryCleanerBySharedHits::TrajectoryCleanerBySharedHits | ( | ) | [inline] |
Definition at line 22 of file TrajectoryCleanerBySharedHits.h.
: theFraction(0.19), allowSharedFirstHit(true){}
TrajectoryCleanerBySharedHits::TrajectoryCleanerBySharedHits | ( | const edm::ParameterSet & | iConfig | ) | [inline] |
Definition at line 25 of file TrajectoryCleanerBySharedHits.h.
: theFraction(iConfig.getParameter<double>("fractionShared")), allowSharedFirstHit(iConfig.getParameter<bool>("allowSharedFirstHit")){}
virtual TrajectoryCleanerBySharedHits::~TrajectoryCleanerBySharedHits | ( | ) | [inline, virtual] |
Definition at line 29 of file TrajectoryCleanerBySharedHits.h.
{};
void TrajectoryCleanerBySharedHits::clean | ( | TrajectoryPointerContainer & | tc | ) | const [virtual] |
Implements TrajectoryCleaner.
Definition at line 30 of file TrajectoryCleanerBySharedHits.cc.
References alongMomentum, gather_cfg::cout, DEBUG_PRINT, TrackingRecHit::geographicalId(), TransientTrackingRecHit::hit(), Trajectory::invalidate(), TrackingRecHit::isValid(), min, TrackingRecHit::sharesInput(), and TrackingRecHit::some.
Referenced by RoadSearchTrackCandidateMakerAlgorithm::PrepareTrackCandidates(), RoadSearchTrackCandidateMakerAlgorithm::run(), InOutConversionTrackFinder::tracks(), and OutInConversionTrackFinder::tracks().
{ if (tc.size() <= 1) return; // nothing to clean //typedef boost::unordered_map<const TransientTrackingRecHit*, TIs, HashByDetId, EqualsBySharesInput> RecHitMap; typedef cmsutil::SimpleAllocHashMultiMap<const TransientTrackingRecHit*, Trajectory *, HashByDetId, EqualsBySharesInput> RecHitMap; //typedef boost::unordered_map<Trajectory*, int> TrajMap; // for each Trajectory it stores the number of shared hits typedef cmsutil::UnsortedDumbVectorMap<Trajectory*, int> TrajMap; static RecHitMap theRecHitMap(128,256,1024);// allocate 128 buckets, one row for 256 keys and one row for 512 values theRecHitMap.clear(10*tc.size()); // set 10*tc.size() active buckets // numbers are not optimized DEBUG_PRINT(std::cout << "Filling RecHit map" << std::endl); for (TrajectoryPointerContainer::iterator it = tc.begin(); it != tc.end(); ++it) { DEBUG_PRINT(std::cout << " Processing trajectory " << *it << " (" << (*it)->foundHits() << " valid hits)" << std::endl); const Trajectory::DataContainer & pd = (*it)->measurements(); for (Trajectory::DataContainer::const_iterator im = pd.begin(); im != pd.end(); im++) { const TransientTrackingRecHit* theRecHit = &(*(*im).recHit()); if (theRecHit->isValid()) { DEBUG_PRINT(std::cout << " Added hit " << theRecHit << " for trajectory " << *it << std::endl); theRecHitMap.insert(theRecHit, *it); } } } DEBUG_PRINT(theRecHitMap.dump()); DEBUG_PRINT(std::cout << "Using RecHit map" << std::endl); // for each trajectory fill theTrajMap static TrajMap theTrajMap; for (TrajectoryCleaner::TrajectoryPointerIterator itt = tc.begin(); itt != tc.end(); ++itt) { if((*itt)->isValid()){ DEBUG_PRINT(std::cout << " Processing trajectory " << *itt << " (" << (*itt)->foundHits() << " valid hits)" << std::endl); theTrajMap.clear(); const Trajectory::DataContainer & pd = (*itt)->measurements(); for (Trajectory::DataContainer::const_iterator im = pd.begin(); im != pd.end(); ++im) { //RC const TransientTrackingRecHit* theRecHit = ((*im).recHit()); const TransientTrackingRecHit* theRecHit = &(*(*im).recHit()); if (theRecHit->isValid()) { DEBUG_PRINT(std::cout << " Searching for overlaps on hit " << theRecHit << " for trajectory " << *itt << std::endl); for (RecHitMap::value_iterator ivec = theRecHitMap.values(theRecHit); ivec.good(); ++ivec) { if (*ivec != *itt){ if ((*ivec)->isValid()){ theTrajMap[*ivec]++; } } } } } //end filling theTrajMap // check for duplicated tracks if(!theTrajMap.empty() > 0){ for(TrajMap::iterator imapp = theTrajMap.begin(); imapp != theTrajMap.end(); ++imapp){ if((*imapp).second > 0 ){ int innerHit = 0; if ( allowSharedFirstHit ) { const TrajectoryMeasurement & innerMeasure1 = ( (*itt)->direction() == alongMomentum ) ? (*itt)->firstMeasurement() : (*itt)->lastMeasurement(); const TransientTrackingRecHit* h1 = &(*(innerMeasure1).recHit()); const TrajectoryMeasurement & innerMeasure2 = ( (*imapp).first->direction() == alongMomentum ) ? (*imapp).first->firstMeasurement() : (*imapp).first->lastMeasurement(); const TransientTrackingRecHit* h2 = &(*(innerMeasure2).recHit()); if ( (h1 == h2) || ((h1->geographicalId() == h2->geographicalId()) && (h1->hit()->sharesInput(h2->hit(), TrackingRecHit::some))) ) { innerHit = 1; } } int nhit1 = (*itt)->foundHits(); int nhit2 = (*imapp).first->foundHits(); if( ((*imapp).second - innerHit) >= ( (min(nhit1, nhit2)-innerHit) * theFraction) ){ Trajectory* badtraj; if (nhit1 != nhit2) // remove the shortest trajectory badtraj = (nhit1 > nhit2) ? (*imapp).first : *itt; else // remove the trajectory with largest chi squared badtraj = ((*imapp).first->chiSquared() > (*itt)->chiSquared()) ? (*imapp).first : *itt; badtraj->invalidate(); // invalidate this trajectory } } } } } } }
bool TrajectoryCleanerBySharedHits::allowSharedFirstHit [private] |
Definition at line 36 of file TrajectoryCleanerBySharedHits.h.
double TrajectoryCleanerBySharedHits::theFraction [private] |
Definition at line 35 of file TrajectoryCleanerBySharedHits.h.