CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoTracker/TkHitPairs/src/RecHitsSortedInPhi.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkHitPairs/interface/RecHitsSortedInPhi.h"
00002 #include <algorithm>
00003 
00004 using namespace std;
00005 
00006 RecHitsSortedInPhi::RecHitsSortedInPhi( const std::vector<Hit>& hits)
00007 {
00008   for (std::vector<Hit>::const_iterator i=hits.begin(); i!=hits.end(); i++) {
00009     theHits.push_back(HitWithPhi(*i));
00010   }
00011   sort( theHits.begin(), theHits.end(), HitLessPhi());
00012 }
00013 
00014 void RecHitsSortedInPhi::hits( float phiMin, float phiMax, vector<Hit>& result) const
00015 {
00016   if ( phiMin < phiMax) {
00017     if ( phiMin < -Geom::fpi()) {
00018       copyResult( unsafeRange( phiMin + Geom::ftwoPi(), Geom::fpi()), result);
00019       copyResult( unsafeRange( -Geom::fpi(), phiMax), result);
00020     }
00021     else if (phiMax > Geom::pi()) {
00022       copyResult( unsafeRange( phiMin, Geom::fpi()), result);
00023       copyResult( unsafeRange( -Geom::fpi(), phiMax-Geom::ftwoPi()), result);
00024     }
00025     else {
00026       copyResult( unsafeRange( phiMin, phiMax), result);
00027     }
00028   }
00029   else {
00030     copyResult( unsafeRange( phiMin, Geom::fpi()), result);
00031     copyResult( unsafeRange( -Geom::fpi(), phiMax), result);
00032   }
00033 }
00034 
00035 vector<RecHitsSortedInPhi::Hit> RecHitsSortedInPhi::hits( float phiMin, float phiMax) const
00036 {
00037   vector<Hit> result;
00038   hits( phiMin, phiMax, result);
00039   return result;
00040 }
00041 
00042 RecHitsSortedInPhi::Range 
00043 RecHitsSortedInPhi::unsafeRange( float phiMin, float phiMax) const
00044 {
00045   return Range( 
00046       lower_bound( theHits.begin(), theHits.end(), HitWithPhi(phiMin), HitLessPhi()),
00047         upper_bound( theHits.begin(), theHits.end(), HitWithPhi(phiMax), HitLessPhi()));
00048 }