00001 #include "TrackPropagation/NavGeometry/interface/LinearSearchNavSurfaceImpl.h" 00002 #include "DataFormats/GeometrySurface/interface/Bounds.h" 00003 00004 const NavVolume* LinearSearchNavSurfaceImpl::nextVolume( const NavSurface::LocalPoint& point, 00005 SurfaceOrientation::Side side) const 00006 { 00007 if (side == SurfaceOrientation::positiveSide) { 00008 return findVolume( point, thePosVolumes); 00009 } 00010 else if (side == SurfaceOrientation::negativeSide) { 00011 return findVolume( point, theNegVolumes); 00012 } 00013 else return 0; // should not be called with SurfaceOrientation::onSurface 00014 } 00015 00016 const NavVolume* LinearSearchNavSurfaceImpl::findVolume( const NavSurface::LocalPoint& point, 00017 const VolumeContainer& vols) const 00018 { 00019 // simple linear search for volume who's bounds contain the point 00020 00021 //MM:return 0 if no volume was defined on this side! 00022 if (vols.size()==0) return 0; 00023 00024 for (VolumeContainer::const_iterator i=vols.begin(); i!=vols.end(); i++) { 00025 if (i->second->inside(point)) return i->first; 00026 } 00027 return 0; // if point outside of all bounds on this side 00028 } 00029 00030 const Bounds* LinearSearchNavSurfaceImpl::bounds( const NavVolume* vol) 00031 { 00032 for (VolumeContainer::const_iterator i=thePosVolumes.begin(); i!=thePosVolumes.end(); i++) { 00033 if (i->first == vol) return i->second; 00034 } 00035 for (VolumeContainer::const_iterator i=theNegVolumes.begin(); i!=theNegVolumes.end(); i++) { 00036 if (i->first == vol) return i->second; 00037 } 00038 return 0; // if volume not found 00039 } 00040 00041 void LinearSearchNavSurfaceImpl::addVolume( const NavVolume* vol, const Bounds* bounds, 00042 SurfaceOrientation::Side side) 00043 { 00044 if (side == SurfaceOrientation::positiveSide) { 00045 thePosVolumes.push_back( VolumeAndBounds( vol, bounds->clone())); 00046 } 00047 else { 00048 theNegVolumes.push_back( VolumeAndBounds( vol, bounds->clone())); 00049 } 00050 }