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 HitExtractor(){
00019 skipClusters=false;}
00020 virtual Hits hits(const SeedingLayer & sl, const edm::Event& , const edm::EventSetup& ) const =0;
00021
00022
00023 void useSkipClusters( const edm::InputTag & m) {
00024 skipClusters=true;
00025 theSkipClusters=m;
00026 }
00027 bool skipClusters;
00028 edm::InputTag theSkipClusters;
00029 };
00030
00031 class HitConv {
00032 public:
00033 HitConv(const SeedingLayer &sl, const edm::EventSetup &es) : sl_(sl), es_(es) {}
00034 template<typename H>
00035 TransientTrackingRecHit::ConstRecHitPointer operator()(const H &hit) {
00036 const TrackingRecHit* trh = &hit;
00037 return sl_.hitBuilder()->build(trh); }
00038 private:
00039 const SeedingLayer &sl_;
00040 const edm::EventSetup &es_;
00041
00042 };
00043
00044 template <typename DSTV, typename A, typename B>
00045 inline void range2SeedingHits(DSTV const & dstv,
00046 HitExtractor::Hits & v,
00047 std::pair<A,B> const & sel,
00048 const SeedingLayer &sl, const edm::EventSetup &es) {
00049 typename DSTV::Range range = dstv.equal_range(sel.first,sel.second);
00050 size_t ts = v.size();
00051 for(typename DSTV::const_iterator id=range.first; id!=range.second; id++)
00052 ts += std::distance((*id).begin(), (*id).end());
00053 v.reserve(ts);
00054 for(typename DSTV::const_iterator id=range.first; id!=range.second; id++){
00055 std::transform((*id).begin(), (*id).end(), std::back_inserter(v), HitConv(sl,es));
00056 }
00057 }
00058
00059 }
00060
00061 #endif