Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:26:46

0001 #ifndef RecoPixelVertexing_PixelTrackFitting_PixelTrackCleanerWrapper_H
0002 #define RecoPixelVertexing_PixelTrackFitting_PixelTrackCleanerWrapper_H
0003 
0004 #include "RecoPixelVertexing/PixelTrackFitting/interface/PixelTrackCleaner.h"
0005 #include "RecoPixelVertexing/PixelTrackFitting/interface/TracksWithHits.h"
0006 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0007 
0008 #include <map>
0009 #include <cassert>
0010 
0011 class PixelTrackCleanerWrapper {
0012 public:
0013   PixelTrackCleanerWrapper(const PixelTrackCleaner *tc) : theCleaner(tc) {}
0014   pixeltrackfitting::TracksWithTTRHs clean(const pixeltrackfitting::TracksWithTTRHs &initialT_TTRHs) const {
0015     pixeltrackfitting::TracksWithRecHits initialT_TRHs;
0016     std::map<const TrackingRecHit *, SeedingHitSet::ConstRecHitPointer> hitMap;
0017 
0018     for (pixeltrackfitting::TracksWithTTRHs::const_iterator it = initialT_TTRHs.begin(), iend = initialT_TTRHs.end();
0019          it < iend;
0020          ++it) {
0021       SeedingHitSet ttrhs = it->second;
0022       std::vector<const TrackingRecHit *> trhs;
0023       for (unsigned int i = 0, n = ttrhs.size(); i < n; ++i) {
0024         const TrackingRecHit *trh = ttrhs[i]->hit();
0025         trhs.push_back(trh);
0026         hitMap[trh] = ttrhs[i];
0027       }
0028       initialT_TRHs.push_back(pixeltrackfitting::TrackWithRecHits(it->first, trhs));
0029     }
0030 
0031     pixeltrackfitting::TracksWithRecHits finalT_TRHs = theCleaner->cleanTracks(initialT_TRHs);
0032     pixeltrackfitting::TracksWithTTRHs finalT_TTRHs;
0033 
0034     for (pixeltrackfitting::TracksWithRecHits::const_iterator it = finalT_TRHs.begin(), iend = finalT_TRHs.end();
0035          it < iend;
0036          ++it) {
0037       const std::vector<const TrackingRecHit *> &trhs = it->second;
0038       assert(!(trhs.size() < 2));
0039       if (trhs.size() < 2)
0040         continue;
0041       SeedingHitSet ttrhs(hitMap[trhs[0]],
0042                           hitMap[trhs[1]],
0043                           trhs.size() > 2 ? hitMap[trhs[2]] : SeedingHitSet::nullPtr(),
0044                           trhs.size() > 3 ? hitMap[trhs[3]] : SeedingHitSet::nullPtr());
0045 
0046       finalT_TTRHs.push_back(pixeltrackfitting::TrackWithTTRHs(it->first, ttrhs));
0047     }
0048     return finalT_TTRHs;
0049   }
0050 
0051 private:
0052   const PixelTrackCleaner *theCleaner;
0053 };
0054 #endif