Go to the documentation of this file.00001 #ifndef RecHitsSortedInPhi_H
00002 #define RecHitsSortedInPhi_H
00003
00004 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
00005
00006 #include <vector>
00007
00013 class RecHitsSortedInPhi {
00014 public:
00015
00016 typedef TransientTrackingRecHit::ConstRecHitPointer Hit;
00017
00018
00019 class HitWithPhi {
00020 public:
00021 HitWithPhi( const Hit & hit) : theHit(hit), thePhi(hit->globalPosition().phi()) {}
00022 HitWithPhi( float phi) : theHit(0), thePhi(phi) {}
00023 float phi() const {return thePhi;}
00024 const Hit hit() const { return theHit;}
00025 private:
00026 Hit theHit;
00027 float thePhi;
00028 };
00029
00030 struct HitLessPhi {
00031 bool operator()( const HitWithPhi& a, const HitWithPhi& b) { return a.phi() < b.phi(); }
00032 };
00033 typedef std::vector<HitWithPhi>::const_iterator HitIter;
00034 typedef std::pair<HitIter,HitIter> Range;
00035
00036 RecHitsSortedInPhi( const std::vector<Hit>& hits);
00037
00038 bool empty() const { return theHits.empty(); }
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 std::vector<Hit> hits( float phiMin, float phiMax) const;
00050
00051
00052
00053
00054
00055
00056
00057 void hits( float phiMin, float phiMax, std::vector<Hit>& result) const;
00058
00059
00060
00061
00062
00063 Range unsafeRange( float phiMin, float phiMax) const;
00064
00065 std::vector<Hit> hits() const {
00066 std::vector<Hit> result; result.reserve(theHits.size());
00067 for (HitIter i=theHits.begin(); i!=theHits.end(); i++) result.push_back(i->hit());
00068 return result;
00069 }
00070
00071
00072 Range all() const {
00073 return Range(theHits.begin(), theHits.end());
00074 }
00075
00076 private:
00077
00078 std::vector<HitWithPhi> theHits;
00079
00080 static void copyResult( const Range& range, std::vector<Hit>& result) {
00081 result.reserve(result.size()+(range.second-range.first));
00082 for (HitIter i = range.first; i != range.second; i++) result.push_back( i->hit());
00083 }
00084
00085 };
00086
00087 #endif