Go to the documentation of this file.00001 #ifndef RecoTracker_TkSeedingLayers_HitExtractor_H
00002 #define RecoTracker_TkSeedingLayers_HitExtractor_H
00003
00004 #include <vector>
00005 #include <iterator>
00006 #include "RecoTracker/TransientTrackingRecHit/interface/TkTransientTrackingRecHitBuilder.h"
00007 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
00008
00009 namespace edm { class Event; class EventSetup; }
00010 namespace ctfseeding { class SeedingLayer; }
00011
00012 namespace ctfseeding {
00013
00014 class HitExtractor {
00015 public:
00016 typedef std::vector<TransientTrackingRecHit::ConstRecHitPointer> Hits;
00017 virtual ~HitExtractor(){}
00018 virtual Hits hits(const SeedingLayer & sl, const edm::Event& , const edm::EventSetup& ) const =0;
00019 };
00020
00021 class HitConv {
00022 public:
00023 HitConv(const SeedingLayer &sl, const edm::EventSetup &es) : sl_(sl), es_(es) {}
00024 template<typename H>
00025 TransientTrackingRecHit::ConstRecHitPointer operator()(const H &hit) {
00026 const TrackingRecHit* trh = &hit;
00027 return sl_.hitBuilder()->build(trh); }
00028 private:
00029 const SeedingLayer &sl_;
00030 const edm::EventSetup &es_;
00031 };
00032
00033 template <typename DSTV, typename A, typename B>
00034 inline void range2SeedingHits(DSTV const & dstv,
00035 HitExtractor::Hits & v,
00036 std::pair<A,B> const & sel,
00037 const SeedingLayer &sl, const edm::EventSetup &es) {
00038 typename DSTV::Range range = dstv.equal_range(sel.first,sel.second);
00039 size_t ts = v.size();
00040 for(typename DSTV::const_iterator id=range.first; id!=range.second; id++)
00041 ts += std::distance((*id).begin(), (*id).end());
00042 v.reserve(ts);
00043 for(typename DSTV::const_iterator id=range.first; id!=range.second; id++){
00044 std::transform((*id).begin(), (*id).end(), std::back_inserter(v), HitConv(sl,es));
00045 }
00046 }
00047
00048 }
00049
00050 #endif