51 uint16_t detid =
id.det();
53 std::vector<const TrackingRecHit*>
hits;
58 uint16_t subdet =
id.subdetId();
60 if (
hit.dimension() == 1) {
62 }
else if (
hit.dimension() > 1) {
65 std::vector<const TrackingRecHit*> seg2D =
hit.recHits();
67 for (std::vector<const TrackingRecHit*>::const_iterator it = seg2D.begin(); it != seg2D.end(); ++it) {
68 std::vector<const TrackingRecHit*> hits1D = (*it)->recHits();
69 copy(hits1D.begin(), hits1D.end(), back_inserter(
hits));
73 if (
hit.dimension() == 2) {
75 }
else if (
hit.dimension() == 4) {
82 if (
hit.dimension() == 2) {
84 }
else if (
hit.dimension() == 4) {
133 bool reallyDoSmoothing) {
134 std::vector<bool> dummyVecBool;
140 std::vector<bool>& tkBoolVec,
143 bool reallyDoSmoothing) {
146 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
154 auto updatedAtVtxTrackCollection = std::make_unique<reco::TrackCollection>();
161 auto trackToTrackmap = std::make_unique<reco::TrackToTrackMap>(trackCollectionRefProd, trackUpdatedCollectionRefProd);
164 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
169 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
174 auto trajectoryCollection = std::make_unique<vector<Trajectory>>();
184 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
206 std::map<unsigned int, unsigned int> tjTkMap;
214 theTrackerRecHitBuilder.
product();
215 hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder.
product())->cloner();
219 unsigned int tjCnt = 0;
221 ++itRawTrajectory, ++tjCnt) {
222 auto rawTrajectory =
std::move(*itRawTrajectory);
226 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(*rawTrajectory);
228 if (!trajectoriesSM.empty()) {
230 trajectory = trajectoriesSM.front();
234 LogInfo(
metname) <<
"The trajectory has not been smoothed!" << endl;
238 trajectoryCollection->
push_back(trajectory);
247 if (!resultOfTrackExtrapAtPCA.first) {
261 track.setExtra(trackExtraRef);
264 pair<bool, reco::Track> updateResult(
false,
reco::Track());
270 if (!updateResult.first)
274 updateResult.second.setExtra(trackExtraRef);
277 trackToTrackmap->insert(
reco::TrackRef(trackCollectionRefProd, trackIndex++),
278 reco::TrackRef(trackUpdatedCollectionRefProd, trackUpdatedIndex++));
286 auto ih = recHitCollection->size();
287 t2t(trajectory, *recHitCollection, trajParams, chi2s);
288 auto ie = recHitCollection->size();
290 trackExtra.
setHits(recHitCollectionRefProd, ih, ie - ih);
295 for (; ih < ie; ++ih) {
296 auto const&
hit = (*recHitCollection)[ih];
298 for (
auto hh :
hits) {
304 for (
auto hh :
hits) {
305 if UNLIKELY (!updateResult.second.appendHitPattern(*hh, ttopo))
312 trackExtraCollection->push_back(trackExtra);
320 updatedAtVtxTrackCollection->push_back(updateResult.second);
322 if (tkBoolVec.size() > tjCnt)
323 tkBoolVec[tjCnt] =
true;
325 tjTkMap[iTjRef - 1] = iTkRef - 1;
338 returnTrackHandle =
event.put(
std::move(updatedAtVtxTrackCollection),
instance +
"UpdatedAtVtx");
341 nonUpdatedHandle = returnTrackHandle;
348 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(rTrajs, nonUpdatedHandle);
351 for (std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
i != tjTkMap.end();
i++) {
352 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory>>(rTrajs, (*i).first),
358 return returnTrackHandle;
364 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
367 auto trackLinksCollection = std::make_unique<reco::MuonTrackLinksCollection>();
370 if (muonCands.empty()) {
371 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
372 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
376 event.put(
std::move(trackExtraCollection));
386 return event.put(
std::move(trackLinksCollection));
392 for (CandidateContainer::iterator it = muonCands.begin(); it != muonCands.end(); ++it) {
393 LogDebug(
metname) <<
"Loader glbSeedRef " << (*it)->trajectory()->seedRef().isNonnull();
394 if ((*it)->trackerTrajectory())
396 <<
"tkSeedRef " << (*it)->trackerTrajectory()->seedRef().isNonnull();
398 combinedTrajs.push_back((*it)->releaseTrajectory());
400 auto tt = (*it)->releaseTrackerTrajectory();
416 std::vector<bool> combTksVec(combinedTrajs.size(),
false);
420 std::vector<bool> trackerTksVec(trackerTrajs.size(),
false);
426 trackerTrajs.clear();
428 LogTrace(
metname) <<
"Set the final links in the MuonTrackLinks collection";
430 unsigned int candposition(0),
position(0), tkposition(0);
434 for (CandidateContainer::const_iterator it = muonCands.begin(); it != muonCands.end(); ++it, ++candposition) {
440 if (combTksVec[candposition]) {
446 links.setStandAloneTrack((*it)->muonTrack());
447 links.setTrackerTrack((*it)->trackerTrack());
448 links.setGlobalTrack(combinedTR);
452 links.setTrackerTrack(trackerTR);
455 trackLinksCollection->push_back(
links);
471 return event.put(
std::move(trackLinksCollection));
477 const std::vector<std::pair<Trajectory*, reco::TrackRef>>& miniMap,
481 bool reallyDoSmoothing) {
484 const string metname =
"Muon|RecoMuon|MuonTrackLoader|TevMuonTrackLoader";
494 auto trackToTrackmap = std::make_unique<reco::TrackToTrackMap>(trackHandle, trackCollectionRefProd);
497 auto trackExtraCollection = std::make_unique<reco::TrackExtraCollection>();
502 auto recHitCollection = std::make_unique<TrackingRecHitCollection>();
507 auto trajectoryCollection = std::make_unique<std::vector<Trajectory>>();
517 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>();
535 std::map<unsigned int, unsigned int> tjTkMap;
543 hitCloner = static_cast<TkTransientTrackingRecHitBuilder const*>(theTrackerRecHitBuilder.
product())->cloner();
549 auto rawTrajectory =
std::move(*itRawTrajectory);
551 std::vector<std::pair<Trajectory*, reco::TrackRef>>::const_iterator mmit;
552 for (mmit = miniMap.begin(); mmit != miniMap.end(); ++mmit) {
553 if (mmit->first == rawTrajectory.get())
554 glbRef = mmit->second;
560 vector<Trajectory> trajectoriesSM =
theSmoother->trajectories(*rawTrajectory);
562 if (!trajectoriesSM.empty()) {
564 trajectory = trajectoriesSM.front();
567 LogInfo(
metname) <<
"The trajectory has not been smoothed!" << endl;
571 trajectoryCollection->
push_back(trajectory);
580 if (!resultOfTrackExtrapAtPCA.first) {
594 track.setExtra(trackExtraRef);
597 trackToTrackmap->insert(glbRef,
reco::TrackRef(trackCollectionRefProd, trackIndex++));
600 pair<bool, reco::Track> updateResult(
false,
reco::Track());
606 auto ih = recHitCollection->size();
607 t2t(trajectory, *recHitCollection, trajParams, chi2s);
608 auto ie = recHitCollection->size();
610 trackExtra.
setHits(recHitCollectionRefProd, ih, ie - ih);
615 for (; ih < ie; ++ih) {
616 auto const&
hit = (*recHitCollection)[ih];
618 for (
auto hh :
hits) {
624 for (
auto hh :
hits) {
625 if UNLIKELY (!updateResult.second.appendHitPattern(*hh, ttopo))
632 trackExtraCollection->push_back(trackExtra);
640 tjTkMap[iTjRef - 1] = iTkRef - 1;
654 nonUpdatedHandle = returnTrackHandle;
661 auto trajTrackMap = std::make_unique<TrajTrackAssociationCollection>(rTrajs, nonUpdatedHandle);
664 for (std::map<unsigned int, unsigned int>::iterator
i = tjTkMap.begin();
i != tjTkMap.end();
i++) {
665 trajTrackMap->insert(
edm::Ref<std::vector<Trajectory>>(rTrajs, (*i).first),
671 return returnTrackHandle;
676 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
688 if (extrapolationResult.first)
689 ftsAtVtx = extrapolationResult.second;
692 LogInfo(
metname) <<
"Track in the Tracker: taking the innermost state instead of the state at PCA";
696 LogInfo(
metname) <<
"Propagation to PCA failed, taking the innermost state instead of the state at PCA";
699 LogInfo(
metname) <<
"Stand Alone track: this track will be rejected";
700 return pair<bool, reco::Track>(
false,
reco::Track());
721 return pair<bool, reco::Track>(
true,
track);
726 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
735 if (!updateResult.first) {
736 return pair<bool, reco::Track>(
false,
reco::Track());
752 return pair<bool, reco::Track>(
true, updatedTrack);
756 const string metname =
"Muon|RecoMuon|MuonTrackLoader";
766 unsigned int innerId = 0, outerId = 0;
797 LogTrace(
metname) <<
"The Global Muon outerMostMeasurementState is not compatible with the recHit detector! "
798 "Setting outerMost postition to recHit position if recHit isValid: "
799 << outerRecHit->isValid();