49 uint16_t detid =
id.det();
51 std::vector<const TrackingRecHit*>
hits;
56 uint16_t subdet =
id.subdetId();
58 if (
hit.dimension() == 1) {
60 }
else if (
hit.dimension() > 1) {
63 std::vector<const TrackingRecHit*> seg2D =
hit.recHits();
65 for (std::vector<const TrackingRecHit*>::const_iterator it = seg2D.begin(); it != seg2D.end(); ++it) {
66 std::vector<const TrackingRecHit*> hits1D = (*it)->recHits();
67 copy(hits1D.begin(), hits1D.end(), back_inserter(
hits));
71 if (
hit.dimension() == 2) {
73 }
else if (
hit.dimension() == 4) {
80 if (
hit.dimension() == 2) {
82 }
else if (
hit.dimension() == 4) {
131 bool reallyDoSmoothing) {
132 std::vector<bool> dummyVecBool;
138 std::vector<bool>& tkBoolVec,
141 bool reallyDoSmoothing) {
144 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
152 auto updatedAtVtxTrackCollection = std::make_unique<reco::TrackCollection>();
159 auto trackToTrackmap = std::make_unique<reco::TrackToTrackMap>(trackCollectionRefProd, trackUpdatedCollectionRefProd);
162 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
167 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
172 auto trajectoryCollection = std::make_unique<vector<Trajectory>>();
182 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
204 std::map<unsigned int, unsigned int> tjTkMap;
212 theTrackerRecHitBuilder.
product();
213 hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder.
product())->cloner();
217 unsigned int tjCnt = 0;
219 ++itRawTrajectory, ++tjCnt) {
220 auto rawTrajectory =
std::move(*itRawTrajectory);
224 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(*rawTrajectory);
226 if (!trajectoriesSM.empty()) {
228 trajectory = trajectoriesSM.front();
232 LogInfo(
metname) <<
"The trajectory has not been smoothed!" << endl;
236 trajectoryCollection->
push_back(trajectory);
245 if (!resultOfTrackExtrapAtPCA.first) {
259 track.setExtra(trackExtraRef);
262 pair<bool, reco::Track> updateResult(
false,
reco::Track());
268 if (!updateResult.first)
272 updateResult.second.setExtra(trackExtraRef);
275 trackToTrackmap->insert(
reco::TrackRef(trackCollectionRefProd, trackIndex++),
276 reco::TrackRef(trackUpdatedCollectionRefProd, trackUpdatedIndex++));
284 auto ih = recHitCollection->size();
285 t2t(trajectory, *recHitCollection, trajParams, chi2s);
286 auto ie = recHitCollection->size();
288 trackExtra.
setHits(recHitCollectionRefProd, ih, ie - ih);
293 for (; ih < ie; ++ih) {
294 auto const&
hit = (*recHitCollection)[ih];
296 for (
auto hh :
hits) {
302 for (
auto hh :
hits) {
304 UNLIKELY(!updateResult.second.appendHitPattern(*hh, ttopo))
break;
310 trackExtraCollection->push_back(trackExtra);
318 updatedAtVtxTrackCollection->push_back(updateResult.second);
320 if (tkBoolVec.size() > tjCnt)
321 tkBoolVec[tjCnt] =
true;
323 tjTkMap[iTjRef - 1] = iTkRef - 1;
336 returnTrackHandle =
event.put(
std::move(updatedAtVtxTrackCollection),
instance +
"UpdatedAtVtx");
339 nonUpdatedHandle = returnTrackHandle;
346 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(rTrajs, nonUpdatedHandle);
349 for (std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
i != tjTkMap.end();
i++) {
350 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory>>(rTrajs, (*i).first),
356 return returnTrackHandle;
362 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
365 auto trackLinksCollection = std::make_unique<reco::MuonTrackLinksCollection>();
368 if (muonCands.empty()) {
369 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
370 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
374 event.put(
std::move(trackExtraCollection));
384 return event.put(
std::move(trackLinksCollection));
390 for (CandidateContainer::iterator it = muonCands.begin(); it != muonCands.end(); ++it) {
391 LogDebug(
metname) <<
"Loader glbSeedRef " << (*it)->trajectory()->seedRef().isNonnull();
392 if ((*it)->trackerTrajectory())
394 <<
"tkSeedRef " << (*it)->trackerTrajectory()->seedRef().isNonnull();
396 combinedTrajs.push_back((*it)->releaseTrajectory());
398 auto tt = (*it)->releaseTrackerTrajectory();
414 std::vector<bool> combTksVec(combinedTrajs.size(),
false);
418 std::vector<bool> trackerTksVec(trackerTrajs.size(),
false);
424 trackerTrajs.clear();
426 LogTrace(
metname) <<
"Set the final links in the MuonTrackLinks collection";
428 unsigned int candposition(0),
position(0), tkposition(0);
432 for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); ++it, ++candposition) {
438 if (combTksVec[candposition]) {
444 links.setStandAloneTrack((*it)->muonTrack());
445 links.setTrackerTrack((*it)->trackerTrack());
446 links.setGlobalTrack(combinedTR);
450 links.setTrackerTrack(trackerTR);
453 trackLinksCollection->push_back(
links);
469 return event.put(
std::move(trackLinksCollection));
475 const std::vector<std::pair<Trajectory*, reco::TrackRef>>& miniMap,
479 bool reallyDoSmoothing) {
482 const string metname =
"Muon|RecoMuon|MuonTrackLoader|TevMuonTrackLoader";
492 auto trackToTrackmap = std::make_unique<reco::TrackToTrackMap>(trackHandle, trackCollectionRefProd);
495 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
500 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
505 auto trajectoryCollection = std::make_unique<std::vector<Trajectory>>();
515 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
533 std::map<unsigned int, unsigned int> tjTkMap;
541 hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder.
product())->cloner();
547 auto rawTrajectory =
std::move(*itRawTrajectory);
549 std::vector<std::pair<Trajectory*, reco::TrackRef>>::const_iterator mmit;
550 for (mmit = miniMap.begin(); mmit != miniMap.end(); ++mmit) {
551 if (mmit->first == rawTrajectory.get())
552 glbRef = mmit->second;
558 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(*rawTrajectory);
560 if (!trajectoriesSM.empty()) {
562 trajectory = trajectoriesSM.front();
565 LogInfo(
metname) <<
"The trajectory has not been smoothed!" << endl;
569 trajectoryCollection->
push_back(trajectory);
578 if (!resultOfTrackExtrapAtPCA.first) {
592 track.setExtra(trackExtraRef);
595 trackToTrackmap->insert(glbRef,
reco::TrackRef(trackCollectionRefProd, trackIndex++));
598 pair<bool, reco::Track> updateResult(
false,
reco::Track());
604 auto ih = recHitCollection->size();
605 t2t(trajectory, *recHitCollection, trajParams, chi2s);
606 auto ie = recHitCollection->size();
608 trackExtra.
setHits(recHitCollectionRefProd, ih, ie - ih);
613 for (; ih < ie; ++ih) {
614 auto const&
hit = (*recHitCollection)[ih];
616 for (
auto hh :
hits) {
622 for (
auto hh :
hits) {
624 UNLIKELY(!updateResult.second.appendHitPattern(*hh, ttopo))
break;
630 trackExtraCollection->push_back(trackExtra);
638 tjTkMap[iTjRef - 1] = iTkRef - 1;
652 nonUpdatedHandle = returnTrackHandle;
659 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(rTrajs, nonUpdatedHandle);
662 for (std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
i != tjTkMap.end();
i++) {
663 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory>>(rTrajs, (*i).first),
669 return returnTrackHandle;
674 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
686 if (extrapolationResult.first)
687 ftsAtVtx = extrapolationResult.second;
690 LogInfo(
metname) <<
"Track in the Tracker: taking the innermost state instead of the state at PCA";
694 LogInfo(
metname) <<
"Propagation to PCA failed, taking the innermost state instead of the state at PCA";
697 LogInfo(
metname) <<
"Stand Alone track: this track will be rejected";
698 return pair<bool, reco::Track>(
false,
reco::Track());
719 return pair<bool, reco::Track>(
true,
track);
724 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
733 if (!updateResult.first) {
734 return pair<bool, reco::Track>(
false,
reco::Track());
750 return pair<bool, reco::Track>(
true, updatedTrack);
754 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
764 unsigned int innerId = 0, outerId = 0;
795 LogTrace(
metname) <<
"The Global Muon outerMostMeasurementState is not compatible with the recHit detector! "
796 "Setting outerMost postition to recHit position if recHit isValid: "
797 << outerRecHit->isValid();