CMS 3D CMS Logo

PixelTrackReconstruction.cc
Go to the documentation of this file.
1 #include <vector>
2 
19 
20 using namespace pixeltrackfitting;
21 using edm::ParameterSet;
22 
24  : theHitSetsToken(iC.consumes<RegionsSeedingHitSets>(cfg.getParameter<edm::InputTag>("SeedingHitSets"))),
25  theFitterToken(iC.consumes<PixelFitter>(cfg.getParameter<edm::InputTag>("Fitter"))),
26  theCleanerName(cfg.getParameter<std::string>("Cleaner")) {
27  edm::InputTag filterTag = cfg.getParameter<edm::InputTag>("Filter");
28  if (not filterTag.label().empty()) {
29  theFilterToken = iC.consumes<PixelTrackFilter>(filterTag);
30  }
31 }
32 
34 
36  desc.add<edm::InputTag>("SeedingHitSets", edm::InputTag("pixelTracksHitTriplets"));
37  desc.add<edm::InputTag>("Fitter", edm::InputTag("pixelFitterByHelixProjections"));
38  desc.add<edm::InputTag>("Filter", edm::InputTag("pixelTrackFilterByKinematics"));
39  desc.add<std::string>("Cleaner", "pixelTrackCleanerBySharedHits");
40 }
41 
44  ev.getByToken(theHitSetsToken, hhitSets);
45  const auto& hitSets = *hhitSets;
46 
48  ev.getByToken(theFitterToken, hfitter);
49  const auto& fitter = *hfitter;
50 
51  const PixelTrackFilter* filter = nullptr;
54  ev.getByToken(theFilterToken, hfilter);
55  filter = hfilter.product();
56  }
57 
58  std::vector<const TrackingRecHit*> hits;
59  hits.reserve(4);
60  for (const auto& regionHitSets : hitSets) {
61  const TrackingRegion& region = regionHitSets.region();
62 
63  for (const SeedingHitSet& tuplet : regionHitSets) {
65  auto nHits = tuplet.size();
66  hits.resize(nHits);
67  for (unsigned int iHit = 0; iHit < nHits; ++iHit)
68  hits[iHit] = tuplet[iHit];
69 
70  // fitting
71  std::unique_ptr<reco::Track> track = fitter.run(hits, region, es);
72  if (!track)
73  continue;
74 
75  if (filter) {
76  if (!(*filter)(track.get(), hits)) {
77  continue;
78  }
79  }
80 
81  // add tracks
82  tracks.emplace_back(track.release(), tuplet);
83  }
84  }
85 
86  // skip ovelrapped tracks
87  if (!theCleanerName.empty()) {
89  es.get<PixelTrackCleaner::Record>().get(theCleanerName, hcleaner);
90  const auto& cleaner = *hcleaner;
91  if (cleaner.fast())
92  cleaner.cleanTracks(tracks);
93  else
94  tracks = PixelTrackCleanerWrapper(&cleaner).clean(tracks);
95  }
96 }
T getParameter(std::string const &) const
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
pixeltrackfitting::TracksWithTTRHs clean(const pixeltrackfitting::TracksWithTTRHs &initialT_TTRHs) const
edm::EDGetTokenT< PixelTrackFilter > theFilterToken
bool ev
std::vector< TrackWithTTRHs > TracksWithTTRHs
PixelTrackReconstruction(const edm::ParameterSet &conf, edm::ConsumesCollector &&iC)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
void run(pixeltrackfitting::TracksWithTTRHs &tah, edm::Event &ev, const edm::EventSetup &es)
T const * product() const
Definition: Handle.h:69
std::string const & label() const
Definition: InputTag.h:36
HLT enums.
T get() const
Definition: EventSetup.h:73
bool isUninitialized() const
Definition: EDGetToken.h:70
static void fillDescriptions(edm::ParameterSetDescription &desc)
edm::EDGetTokenT< RegionsSeedingHitSets > theHitSetsToken
edm::EDGetTokenT< PixelFitter > theFitterToken