#include #include #include "HitUtilities.hxx" namespace hits { bool Equal(const COMET::IHandle& a, const COMET::IHandle& b) { return a == b; } bool Equiv(const COMET::IHandle& a, const COMET::IHandle& b) { // short circuit equal hits. if (a==b) return true; // Unpack the hits into the most basic hits. COMET::IHitSelection aHits; UnpackHits(a,std::back_inserter(aHits)); COMET::IHitSelection bHits; UnpackHits(b,std::back_inserter(bHits)); // Check to see if any of the basic hits are equal. for (COMET::IHitSelection::const_iterator A = aHits.begin(); A != aHits.end(); ++A) { for (COMET::IHitSelection::const_iterator B = bHits.begin(); B != bHits.end(); ++B) { if (*A == *B) return true; } } return false; } void Subtract(COMET::IHitSelection& a, const COMET::IHitSelection& b) { COMET::IHitSelection::iterator r = copy_hits_if(a.begin(), a.end(), a.begin(), IOverlappedHitFilter(b)); if (r!=a.end()) a.erase(r,a.end()); } void Unique(COMET::IHitSelection& a) { std::sort(a.begin(), a.end(), hits::geomIdLessThan()); COMET::IHitSelection::iterator newEnd = std::unique(a.begin(), a.end(), hits::geomIdEquals()); a.erase(newEnd,a.end()); } };