58 declareInterface<IMuonCreatorTool>(
this);
114 return StatusCode::SUCCESS;
117 const std::vector<const InDetCandidateToTagMap*>& tagMaps,
OutputData& outputData)
const {
118 create(ctx, muonCandidates, tagMaps, outputData,
false);
119 create(ctx, muonCandidates, tagMaps, outputData,
true);
122 const std::vector<const InDetCandidateToTagMap*>& tagMaps,
OutputData& outputData,
123 bool select_commissioning)
const {
127 std::vector<const MuonCombined::MuonCandidate*> resolvedMuonCandidates;
131 resolveOverlaps(ctx, muonCandidates, tagMaps, resolvedInDetCandidates, resolvedMuonCandidates, select_commissioning);
132 else if (!select_commissioning)
135 unsigned int numIdCan = resolvedInDetCandidates.size();
136 unsigned int numMuCan = muonCandidates ? muonCandidates->
size() : 0;
137 ATH_MSG_DEBUG(
"Creating xAOD::Muons from: " << numIdCan <<
" indet candidates and " << numMuCan <<
" muon candidates ");
140 ATH_MSG_DEBUG(
"MuonCandidates : overlap removal " << muonCandidates->
size() <<
" in, " << resolvedMuonCandidates.size()
151 if (select_commissioning) { muon->addAllAuthor(xAOD::Muon::Author::Commissioning); }
153 if (!muon->primaryTrackParticleLink().isValid()) {
154 ATH_MSG_ERROR(
"This muon has no valid primaryTrackParticleLink! Author=" << muon->author());
163 if (muon && select_commissioning) { muon->addAllAuthor(xAOD::Muon::Author::Commissioning); }
181 ATH_MSG_DEBUG(
"MuonCreatorTool::create(...) No extrapolated track - aborting. Will not create Muon.");
190 muon->setAuthor(xAOD::Muon::MuidSA);
191 muon->setMuonType(xAOD::Muon::MuonStandAlone);
192 muon->addAllAuthor(xAOD::Muon::MuidSA);
197 using TrackParticleType = xAOD::Muon::TrackParticleType;
198 if (
m_requireMSOEforSA && !muon->trackParticle(TrackParticleType::ExtrapolatedMuonSpectrometerTrackParticle)) {
199 ATH_MSG_DEBUG(
"Creation of track particle for SA muon failed, removing it");
210 const xAOD::TrackParticle* track = muon->trackParticle(TrackParticleType::ExtrapolatedMuonSpectrometerTrackParticle);
211 if (!track) track = muon->primaryTrackParticle();
212 std::unique_ptr<Trk::CaloExtension> caloExtension =
m_caloExtTool->caloExtension(ctx, *track);
214 ATH_MSG_DEBUG(
"failed to get a calo extension for this SA muon, discard it");
219 ATH_MSG_DEBUG(
"failed to retrieve any calo layers for this SA muon, discard it");
235 addMuGirl(ctx, muon,
nullptr, outputData);
239 acc_nUnspoiledCscHits(muon) = 0;
240 acc_MuonSpectrometerPt(muon) = -1;
241 acc_InnerDetectorPt(muon) = -1;
243 acc_ET_Core(muon) = 0;
244 acc_ET_EMCore(muon) = 0;
245 acc_ET_TileCore(muon) = 0;
246 acc_ET_HECCore(muon) = 0;
252 if (candidate.second.empty()) {
253 ATH_MSG_DEBUG(
"MuonCreatorTool::create(...) - InDetCandidate with empty combinedDataTags. Aborting. Will not create Muon.");
256 const std::vector<const TagBase*>&
tags = candidate.second;
259 if (muGirlLowBetaTag) {
260 ATH_MSG_DEBUG(
"Track has only a MuGirlLowBetaTag but Staus are not being built, so will not create muon");
273 muon->setTrackParticleLink(xAOD::Muon::InnerDetectorTrackParticle, candidate.first->indetTrackParticleLink());
274 ATH_MSG_DEBUG(
"Adding InDet Track: pt " << candidate.first->indetTrackParticle().pt() <<
" eta "
275 << candidate.first->indetTrackParticle().eta() <<
" phi "
276 << candidate.first->indetTrackParticle().phi());
290 if (muGirlLowBetaTag) {
293 muon->setAuthor(tag->author());
294 muon->setMuonType(tag->type());
296 if (tag->type() == xAOD::Muon::Combined) {
309 if (slowMuon && muonLink.
isValid()) {
319 if (muGirlLowBetaTag)
continue;
323 ATH_MSG_DEBUG(
"MuonCreatorTool first muon tag: author=" << tag->author() <<
" type=" << tag->type());
324 muon->setAuthor(tag->author());
325 muon->setMuonType(tag->type());
327 if (candidate.first->isSiliconAssociated()) { muon->setMuonType(xAOD::Muon::SiliconAssociatedForwardMuon); }
331 muon->addAllAuthor(tag->author());
334 xAOD::Muon::MuonType
type = tag->type();
335 if (
type == xAOD::Muon::Combined) {
342 addMuGirl(ctx, *muon, muGirlTag, outputData);
344 if (!(cbFitTag || stacoTag || muGirlTag)) {
ATH_MSG_WARNING(
"Unknown combined tag "); }
346 }
else if (
type == xAOD::Muon::SegmentTagged) {
351 addMuGirl(ctx, *muon, muGirlTag, outputData);
353 if (!(segTag || muGirlTag)) {
ATH_MSG_WARNING(
"Unknown segment-tagged tag "); }
354 }
else if (
type == xAOD::Muon::CaloTagged) {
374 bool haveEloss = muon->parameter(eLoss, xAOD::Muon::EnergyLoss);
375 if (!haveEloss || eLoss == 0) {
384 ATH_MSG_DEBUG(
"Done creating muon with " << acc_nUnspoiledCscHits(*muon) <<
" unspoiled csc hits");
402 acc_phi0(muon) = -999;
403 acc_theta(muon) = -999;
404 acc_qOverP(muon) = -999;
405 acc_qOverPerr(muon) = -999.;
409 ATH_MSG_DEBUG(
"Adding Staco Muon " << tag->author() <<
" type " << tag->type());
411 if (!muon.combinedTrackParticleLink().isValid()) {
415 const Trk::Track* msTrack = tag->muonCandidate().extrapolatedTrack() ? tag->muonCandidate().extrapolatedTrack()
416 : &tag->muonCandidate().muonSpectrometerTrack();
422 if (idSummary) summary += *idSummary;
423 if (msSummary) summary += *msSummary;
437 std::vector<float> dummy_cov(15, 0.);
442 if (link.isValid()) {
444 ATH_MSG_DEBUG(
"Adding statistical combination: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi "
446 muon.setTrackParticleLink(xAOD::Muon::CombinedTrackParticle, link);
452 std::bitset<xAOD::NumberOfTrackRecoInfo> pattern;
458 (*accessor)( *tp ) = (*accessor)( id_track_particle );
461 (*accessor)( *tp ) = (*accessor)( id_track_particle );
472 muon.setParameter(5, xAOD::Muon::msInnerMatchDOF);
473 muon.setParameter(
static_cast<float>(tag->matchChi2()), xAOD::Muon::msInnerMatchChi2);
476 acc_d0(muon) = tag->combinedParameters().parameters()[
Trk::d0];
477 acc_z0(muon) = tag->combinedParameters().parameters()[
Trk::z0];
478 acc_phi0(muon) = tag->combinedParameters().parameters()[
Trk::phi0];
479 acc_theta(muon) = tag->combinedParameters().parameters()[
Trk::theta];
480 acc_qOverP(muon) = tag->combinedParameters().parameters()[
Trk::qOverP];
483 ATH_MSG_DEBUG(
"Done adding Staco Muon " << tag->author() <<
" type " << tag->type());
493 ATH_MSG_DEBUG(
"Adding Combined fit Muon " << tag->author() <<
" type " << tag->type());
494 if (!muon.combinedTrackParticleLink().isValid()) {
501 if (link.isValid()) {
503 ATH_MSG_DEBUG(
"Adding combined fit: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
504 muon.setTrackParticleLink(xAOD::Muon::CombinedTrackParticle, link);
510 addMuonCandidate(ctx, tag->muonCandidate(), muon, outputData, tag->updatedExtrapolatedTrackLink());
513 const float inner_chi2 = tag->matchChi2();
514 muon.setParameter(tag->matchDoF(), xAOD::Muon::msInnerMatchDOF);
515 muon.setParameter(inner_chi2, xAOD::Muon::msInnerMatchChi2);
517 ATH_MSG_DEBUG(
"Done adding Combined Fit Muon " << tag->author() <<
" type " << tag->type());
530 ATH_MSG_DEBUG(
"Adding MuGirlLowBeta Muon " << tag->author() <<
" type " << tag->type());
534 if (slowMuon && stauExtras) {
557 std::vector<uint8_t>& eTechVec = eTechAcc(*slowMuon);
558 std::vector<unsigned int>& idVec = idAcc(*slowMuon);
559 std::vector<float>& mToFVec = mToFAcc(*slowMuon);
560 std::vector<float>& xVec = xAcc(*slowMuon);
561 std::vector<float>& yVec = yAcc(*slowMuon);
562 std::vector<float>& zVec = zAcc(*slowMuon);
563 std::vector<float>& eVec = eAcc(*slowMuon);
564 std::vector<float>& errorVec = errorAcc(*slowMuon);
565 std::vector<float>& shiftVec = shiftAcc(*slowMuon);
566 std::vector<float>& propagationTimeVec = propTimeAcc(*slowMuon);
567 std::vector<uint8_t>& passesMDTBetaCutVec = hitPassesMDTBetaCutAcc(*slowMuon);
569 for (
const auto& hit : stauExtras->
hits) {
570 eTechVec.push_back(hit.eTech);
571 idVec.push_back(hit.id.get_identifier32().get_compact());
572 mToFVec.push_back(hit.mToF);
573 xVec.push_back(hit.x);
574 yVec.push_back(hit.y);
575 zVec.push_back(hit.z);
576 eVec.push_back(hit.e);
577 errorVec.push_back(hit.error);
578 shiftVec.push_back(hit.shift);
579 propagationTimeVec.push_back(hit.propagationTime);
580 passesMDTBetaCutVec.push_back(hit.passesMDTBetaCut ? uint8_t{1} : uint8_t{0});
588 std::vector<int>& adcVec = adcAcc(*slowMuon);
589 std::vector<float>& rdriftVec = rdriftAcc(*slowMuon);
593 adcVec.push_back(extraMDTinfo.adc);
594 rdriftVec.push_back(extraMDTinfo.rdrift);
602 if (!muon.combinedTrackParticleLink().isValid() && tag->combinedTrack()) {
609 if (link.isValid()) {
610 ATH_MSG_DEBUG(
"Adding MuGirlLowBeta: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
611 muon.setTrackParticleLink(xAOD::Muon::CombinedTrackParticle, link);
613 ATH_MSG_WARNING(
"Creating of MuGirlLowBeta TrackParticle Link failed");
619 std::vector<ElementLink<xAOD::MuonSegmentContainer>> segments;
622 if (link.isValid()) {
623 segments.push_back(link);
624 ATH_MSG_DEBUG(
"Adding MuGirlLowBeta: xaod::MuonSegment px " << (*link)->px() <<
" py " << (*link)->py() <<
" pz "
629 muon.setMuonSegmentLinks(segments);
639 ATH_MSG_DEBUG(
"Adding MuGirl Muon " << tag->author() <<
" type " << tag->type());
641 if (!muon.combinedTrackParticleLink().isValid() && tag->combinedTrack()) {
648 if (link.isValid()) {
650 ATH_MSG_DEBUG(
"Adding MuGirl: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
651 muon.setTrackParticleLink(xAOD::Muon::CombinedTrackParticle, link);
662 if (link.isValid()) {
663 ATH_MSG_DEBUG(
"Adding MuGirl: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
664 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
672 std::vector<ElementLink<xAOD::MuonSegmentContainer>> segments;
675 if (link.isValid()) {
676 segments.push_back(link);
677 ATH_MSG_DEBUG(
"Adding MuGirl: xaod::MuonSegment px " << (*link)->px() <<
" py " << (*link)->py() <<
" pz "
682 muon.setMuonSegmentLinks(segments);
685 ATH_MSG_DEBUG(
"Done Adding MuGirl Muon " << tag->author() <<
" type " << tag->type());
691 muon.setParameter(-1.f, xAOD::Muon::segmentDeltaEta);
692 muon.setParameter(-1.f, xAOD::Muon::segmentDeltaPhi);
693 muon.setParameter(-1.f, xAOD::Muon::segmentChi2OverDoF);
697 ATH_MSG_DEBUG(
"Adding Segment Tag Muon " << tag->author() <<
" type " << tag->type());
699 std::vector<ElementLink<xAOD::MuonSegmentContainer>> segments;
700 bool foundseg =
false;
701 for (
const auto& info : tag->segmentsInfo()) {
706 if (muon.author() == xAOD::Muon::MuTagIMO) {
708 if (seglink.
isValid()) segments.push_back(seglink);
712 muon.setParameter(
static_cast<float>(info.dtheta), xAOD::Muon::segmentDeltaEta);
713 muon.setParameter(
static_cast<float>(info.dphi), xAOD::Muon::segmentDeltaPhi);
714 muon.setParameter(
static_cast<float>(info.segment->fitQuality()->chiSquared() / info.segment->fitQuality()->numberDoF()),
715 xAOD::Muon::segmentChi2OverDoF);
717 }
else if (muon.author() != xAOD::Muon::MuTagIMO)
721 if (muon.author() == xAOD::Muon::MuTagIMO) muon.setMuonSegmentLinks(segments);
731 mu.setParameter(0.f, xAOD::Muon::CaloMuonScore);
732 mu.setParameter(
static_cast<int>(0xFF), xAOD::Muon::CaloMuonIDTag);
736 acc_ET_Core(mu) = 0.0;
737 acc_ElType(mu) = -999.0;
738 acc_ElFSREnergy(mu) = -999.0;
743 ATH_MSG_DEBUG(
"Adding Calo Muon with author " << tag->author() <<
", type " << tag->type() <<
", CaloMuonScore "
744 << tag->caloMuonScore());
745 mu.setParameter(
static_cast<float>(tag->caloMuonScore()), xAOD::Muon::CaloMuonScore);
746 mu.setParameter(
static_cast<int>(tag->caloMuonIdTag()), xAOD::Muon::CaloMuonIDTag);
751 acc_ET_Core(mu) = tag->etCore();
752 acc_ElType(mu) = tag->energyLossType();
753 acc_ElFSREnergy(mu) = tag->fsrCandidateEnergy();
759 const EventContext& ctx,
764 if (trackCollection) {
804 if (!muon.nMuonSegments()) {
805 std::vector< ElementLink<xAOD::MuonSegmentContainer>> segments;
808 if (link.isValid()) {
809 segments.push_back(link);
810 ATH_MSG_DEBUG(
"Adding MuGirl: xaod::MuonSegment px " << (*link)->px() <<
" py " << (*link)->py() <<
" pz "
816 muon.setMuonSegmentLinks(segments);
819 if (muon.muonSpectrometerTrackParticleLink().isValid()) {
return; }
823 if (muon.author() != xAOD::Muon::MuGirl)
832 ATH_MSG_DEBUG(
"There is no extrapolated track associated to the MuonCandidate.");
833 if (muon.author() == xAOD::Muon::MuidCo) {
838 if (link.isValid()) {
839 ATH_MSG_DEBUG(
"Adding standalone fit (refitted): pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi "
841 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
842 float fieldInt =
m_trackQuery->fieldIntegral(**meLink, ctx).betweenSpectrometerMeasurements();
843 muon.setParameter(fieldInt, xAOD::Muon::spectrometerFieldIntegral);
845 acc_nUnspoiledCscHits(muon) = nunspoiled;
849 if (!extrapolatedTrack)
ATH_MSG_WARNING(
"Track doesn't have extrapolated track. Skipping");
852 "Track doesn't have perigee parameters on extrapolated "
859 if (muon.muonType() != xAOD::Muon::MuonStandAlone) {
869 if (link.isValid()) {
870 ATH_MSG_DEBUG(
"Adding MS-only extrapolated track: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi "
873 muon.setTrackParticleLink(xAOD::Muon::MSOnlyExtrapolatedMuonSpectrometerTrackParticle, link);
875 ATH_MSG_WARNING(
"failed to create MS-only extrapolated track particle");
880 if (link.isValid()) {
881 ATH_MSG_DEBUG(
"Adding standalone fit (refitted): pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi "
883 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
884 float fieldInt =
m_trackQuery->fieldIntegral(**meLink, ctx).betweenSpectrometerMeasurements();
885 muon.setParameter(fieldInt, xAOD::Muon::spectrometerFieldIntegral);
887 acc_nUnspoiledCscHits(muon) = nunspoiled;
891 if (muon.author() == xAOD::Muon::MuGirl && muon.extrapolatedMuonSpectrometerTrackParticleLink().isValid()) {
899 if (link.isValid()) {
900 ATH_MSG_DEBUG(
"Adding MS-only extrapolated track to MuGirl muon: pt "
901 << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
903 muon.setTrackParticleLink(xAOD::Muon::MSOnlyExtrapolatedMuonSpectrometerTrackParticle, link);
906 muon.setParameter(fieldInt, xAOD::Muon::spectrometerFieldIntegral);
913 if (link.isValid()) {
914 ATH_MSG_DEBUG(
"Adding standalone fit (un-refitted): pt " << (*link)->pt() <<
" eta " << (*link)->eta()
915 <<
" phi " << (*link)->phi());
917 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
920 muon.setParameter(fieldInt, xAOD::Muon::spectrometerFieldIntegral);
930 if (link.isValid()) {
931 ATH_MSG_DEBUG(
"Adding standalone fit: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
933 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
936 muon.setParameter(fieldInt, xAOD::Muon::spectrometerFieldIntegral);
938 acc_nUnspoiledCscHits(muon) = nunspoiled;
947 const std::vector<const InDetCandidateToTagMap*>& tagMaps)
const {
948 resolvedInDetCandidates.clear();
950 if (!tag_map)
continue;
951 for (
const auto& combined_tag : *tag_map) {
952 const TagBase* tag = combined_tag.second.get();
954 if (muGirlLowBetaTag) { resolvedInDetCandidates.emplace_back(combined_tag.first, std::vector<const TagBase*>{tag}); }
960 ATH_MSG_DEBUG(
"ID candidates: " << tagMaps.size() <<
" after stau selection " << resolvedInDetCandidates.size());
962 msg(MSG::DEBUG) <<
"ID candidate staus: " << candidate.first->toString() <<
endmsg;
968 std::stable_sort(resolvedInDetCandidates.begin(), resolvedInDetCandidates.end(),
970 return a.first->indetTrackParticle().pt() > b.first->indetTrackParticle().pt();
975 const std::vector<const InDetCandidateToTagMap*>& tagMaps,
977 std::vector<const MuonCombined::MuonCandidate*>& resolvedMuonCandidates,
978 bool select_commissioning)
const {
979 resolvedMuonCandidates.clear();
980 resolvedInDetCandidates.clear();
982 std::unique_ptr<const TrackCollection> resolvedTracks;
983 std::vector<std::unique_ptr<Trk::Track>> garbage_collection;
990 if (!tag_map)
continue;
991 for (
const auto& comb_tag : *tag_map) {
992 const TagBase* tag = comb_tag.second.get();
996 if (tag->isCommissioning() != select_commissioning)
break;
997 InDetCandidateTagsMap::iterator itr =
998 std::find_if(inDetCandidateMap.begin(), inDetCandidateMap.end(),
999 [&comb_tag](
const InDetCandidateTags& to_test) { return (*to_test.first) == (*comb_tag.first); });
1000 if (itr != inDetCandidateMap.end())
1001 itr->second.emplace_back(tag);
1003 inDetCandidateMap.emplace_back(std::make_pair(comb_tag.first, std::vector<const TagBase*>{tag}));
1010 if (!inDetCandidateMap.empty()) {
1016 resolvedInDetCandidates.reserve(inDetCandidateMap.size());
1017 caloMuons.reserve(inDetCandidateMap.size());
1020 if (comb_tag.second.size() == 1 && comb_tag.second.front()->type() == xAOD::Muon::CaloTagged) {
1021 caloMuons.emplace_back(std::move(comb_tag));
1023 resolvedInDetCandidates.emplace_back(std::move(comb_tag));
1025 inDetCandidateMap.clear();
1028 if (
msgLvl(MSG::DEBUG)) {
1029 ATH_MSG_DEBUG(
"Found " << resolvedInDetCandidates.size() <<
" inner detector tags in event "
1030 << ctx.eventID().event_number());
1032 std::stringstream
tags;
1033 for (
const TagBase* tag : candidate.second)
tags <<
" " << tag->toString();
1034 ATH_MSG_DEBUG(
"ID candidate: " << candidate.first->toString() <<
" " <<
tags.str());
1040 to_resolve.reserve(resolvedInDetCandidates.size());
1041 garbage_collection.reserve(resolvedInDetCandidates.size());
1045 std::map<const Trk::Track*, InDetCandidateTags> trackInDetCandLinks;
1049 const TagBase* primaryTag = candidate.second[0];
1056 trackInDetCandLinks[to_resolve.
back()] = std::move(candidate);
1062 if (!segments.empty()) {
1064 garbage_collection.emplace_back(
1067 to_resolve.
push_back(garbage_collection.back().get());
1069 trackInDetCandLinks[garbage_collection.back().get()] = std::move(candidate);
1073 resolvedInDetCandidates.clear();
1079 for (
const Trk::Track* track : *resolvedTracks) {
1080 std::map<const Trk::Track*, InDetCandidateTags>::iterator trackCandLink = trackInDetCandLinks.find(track);
1081 if (trackCandLink == trackInDetCandLinks.end()) {
1082 ATH_MSG_WARNING(
"Unable to find internal link between MS track and ID candidate!");
1085 resolvedInDetCandidates.push_back(std::move(trackCandLink->second));
1089 if (
msgLvl(MSG::VERBOSE)) {
1091 << resolvedInDetCandidates.size() <<
" trackCandLinks: " << trackInDetCandLinks.size()
1092 <<
" to_resolve: " << to_resolve.size() <<
" resolvedTracks: " << resolvedTracks->size());
1094 ATH_MSG_DEBUG(
"ID candidate: " << candidate.first->toString() <<
" " << candidate.second[0]->toString());
1098 ATH_MSG_DEBUG(
"ID candidate: " << candidate.first->toString() <<
" " << candidate.second[0]->toString());
1102 resolvedInDetCandidates.insert(resolvedInDetCandidates.end(), caloMuons.begin(), caloMuons.end());
1105 std::stable_sort(resolvedInDetCandidates.begin(), resolvedInDetCandidates.end(),
1107 return a.first->indetTrackParticle().pt() > b.first->indetTrackParticle().pt();
1113 if (!muonCandidates) {
return; }
1115 if (
msgLvl(MSG::DEBUG)) {
1121 if (resolvedTracks) { resolvedTracks2.
assign(resolvedTracks->begin(), resolvedTracks->end()); }
1123 std::set<const MuonCandidate*> used_candidates;
1125 for (
const TagBase* tag : indet_cand.second) {
1127 if (tag->author() == xAOD::Muon::MuidCo) {
1130 }
else if (tag->author() == xAOD::Muon::STACO && indet_cand.second[0] == tag) {
1139 std::map<const Trk::Track*, const MuonCandidate*> trackMuonCandLinks;
1141 if (candidate->isCommissioning() != select_commissioning)
continue;
1142 const Trk::Track* track = candidate->primaryTrack();
1143 if (used_candidates.count(candidate)) {
1147 used_candidates.insert(candidate);
1149 trackMuonCandLinks[track] = candidate;
1156 for (
const Trk::Track* track : *resolvedTracks) {
1157 auto trackCandLink = trackMuonCandLinks.find(track);
1158 if (trackCandLink != trackMuonCandLinks.end()) resolvedMuonCandidates.push_back(trackCandLink->second);
1162 if (
msgLvl(MSG::DEBUG)) {
1163 ATH_MSG_DEBUG(
"Muon candidates: " << muonCandidates->
size() <<
" after ambiguity solving " << resolvedMuonCandidates.size());
1164 for (
const MuonCandidate* candidate : resolvedMuonCandidates) {
1165 msg(MSG::DEBUG) <<
"Muon candidate: " << candidate->toString() <<
endmsg;
1171 const std::vector<const Muon::MuonSegment*>& segments,
1175 auto trackStateOnSurfaces = std::make_unique<Trk::TrackStates>();
1179 double momentum{1e8},
charge{0.};
1180 std::unique_ptr<const Trk::TrackParameters> pars{
m_edmHelperSvc->createTrackParameters(*seg, momentum,
charge)};
1182 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0);
1185 std::unique_ptr<Trk::TrackParameters> exPars{
m_propagator->propagateParameters(
1187 if (!exPars) {
ATH_MSG_VERBOSE(
"Could not propagate Track to segment surface"); }
1190 trackStateOnSurfaces->push_back(trackState);
1196 info.setPatternRecognitionInfo(author);
1197 std::unique_ptr<Trk::Track> newtrack =
1198 std::make_unique<Trk::Track>(info, std::move(trackStateOnSurfaces), (indetTrack.
fitQuality())->uniqueClone());
1207 if (!muon.primaryTrackParticleLink().isValid()) {
1208 ATH_MSG_DEBUG(
"No primary track particle set, deleting muon");
1213 setP4(muon, *primary);
1214 const float qOverP = primary->qOverP();
1215 if (qOverP != 0.0) {
1216 muon.setCharge(qOverP > 0 ? 1. : -1.);
1218 ATH_MSG_WARNING(
"MuonCreatorTool::dressMuon - trying to set qOverP, but value from muon.primaryTrackParticle ["
1219 << muon.primaryTrackParticleLink().dataID()
1220 <<
"] is zero. Setting charge=0.0. The eta/phi of the muon is: " << muon.eta() <<
" / " << muon.phi());
1221 muon.setCharge(0.0);
1231 muon.setParameter(curvatureSignificance, xAOD::Muon::scatteringCurvatureSignificance);
1233 muon.setParameter(neighbourSignificance, xAOD::Muon::scatteringNeighbourSignificance);
1234 ATH_MSG_VERBOSE(
"Got curvatureSignificance " << curvatureSignificance <<
" and neighbourSignificance "
1235 << neighbourSignificance);
1240 muon.setParameter(momentumBalanceSignificance, xAOD::Muon::momentumBalanceSignificance);
1241 ATH_MSG_VERBOSE(
"Got momentumBalanceSignificance " << momentumBalanceSignificance);
1246 muon.setParameter(meanDeltaADC, xAOD::Muon::meanDeltaADCCountsMDT);
1251 acc_MuonSpectrometerPt(muon) = muon.pt();
1252 acc_InnerDetectorPt(muon) = muon.pt();
1263 if (muon.trackParticle(xAOD::Muon::CombinedTrackParticle)) {
1264 trk = muon.trackParticle(xAOD::Muon::CombinedTrackParticle)->track();
1266 if (!trk && muon.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle)) {
1267 trk = muon.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle)->track();
1273 ATH_MSG_VERBOSE(
"Couldn't find matching track which might have energy loss.");
1279 if (!muon.inDetTrackParticleLink().isValid()) {
1280 ATH_MSG_WARNING(
"Missing ID track particle link in addEnergyLossToMuon!");
1285 const Trk::Track* trk = (*(muon.inDetTrackParticleLink()))->track();
1295 for (; it != itEnd; ++it) {
1296 if ((*it)->trackParameters()) {
1302 ATH_MSG_WARNING(
"Missing ID TSOS with track parameters in addEnergyLossToMuon!");
1307 std::vector<const Trk::TrackStateOnSurface*>* caloTSOS =
m_caloMaterialProvider->getCaloTSOS(*((*it)->trackParameters()), *trk);
1318 std::vector<const Trk::TrackStateOnSurface*>::const_iterator it2 = caloTSOS->begin();
1319 std::vector<const Trk::TrackStateOnSurface*>::const_iterator itEnd2 = caloTSOS->end();
1320 for (; it2 != itEnd2; ++it2)
delete *it2;
1327 muon.setParameter(0.f, xAOD::Muon::EnergyLoss);
1328 muon.setParameter(0.f, xAOD::Muon::ParamEnergyLoss);
1329 muon.setParameter(0.f, xAOD::Muon::MeasEnergyLoss);
1330 muon.setParameter(0.f, xAOD::Muon::EnergyLossSigma);
1331 muon.setParameter(0.f, xAOD::Muon::MeasEnergyLossSigma);
1332 muon.setParameter(0.f, xAOD::Muon::ParamEnergyLossSigmaPlus);
1333 muon.setParameter(0.f, xAOD::Muon::ParamEnergyLossSigmaMinus);
1335 muon.setEnergyLossType(xAOD::Muon::Parametrized);
1336 muon.setParameter(0.f, xAOD::Muon::FSR_CandidateEnergy);
1342 unsigned int numEnergyLossPerTrack = 0;
1343 bool problem =
false;
1344 for (
const auto* tsos : *tsosVector) {
1346 if (!meot)
continue;
1349 if (!caloEnergy)
continue;
1350 ++numEnergyLossPerTrack;
1352 muon.setParameter(
static_cast<float>(caloEnergy->
deltaE()), xAOD::Muon::EnergyLoss);
1353 muon.setParameter(
static_cast<float>(caloEnergy->
deltaEParam()), xAOD::Muon::ParamEnergyLoss);
1354 muon.setParameter(
static_cast<float>(caloEnergy->
deltaEMeas()), xAOD::Muon::MeasEnergyLoss);
1355 muon.setParameter(
static_cast<float>(caloEnergy->
sigmaDeltaE()), xAOD::Muon::EnergyLossSigma);
1356 muon.setParameter(
static_cast<float>(caloEnergy->
sigmaDeltaEMeas()), xAOD::Muon::MeasEnergyLossSigma);
1357 muon.setParameter(
static_cast<float>(caloEnergy->
sigmaPlusDeltaEParam()), xAOD::Muon::ParamEnergyLossSigmaPlus);
1358 muon.setParameter(
static_cast<float>(caloEnergy->
sigmaMinusDeltaEParam()), xAOD::Muon::ParamEnergyLossSigmaMinus);
1360 muon.setEnergyLossType(
static_cast<xAOD::Muon::EnergyLossType
>(caloEnergy->
energyLossType()));
1361 muon.setParameter(
static_cast<float>(caloEnergy->
fsrCandidateEnergy()), xAOD::Muon::FSR_CandidateEnergy);
1363 if (numEnergyLossPerTrack > 1) {
1374 if (!tp || !clusterContainer) {
1388 if (!inputCaloExt) {
1391 std::unique_ptr<Trk::CaloExtension> caloExtension =
m_caloExtTool->caloExtension(ctx, *tp);
1392 if (!caloExtension) {
1396 if (caloExtension->caloLayerIntersections().empty())
1397 ATH_MSG_DEBUG(
"Received a caloExtension object without track extrapolation");
1399 cluster =
m_cellCollector.collectCells(*caloExtension, caloDDMgr, *container, *clusterContainer);
1401 cluster =
m_cellCollector.collectCells(*inputCaloExt, caloDDMgr, *container, *clusterContainer);
1404 ATH_MSG_DEBUG(
"Failed to create cluster from ParticleCellAssociation");
1407 ATH_MSG_DEBUG(
" New cluster: eta " << cluster->
eta() <<
" phi " << cluster->
phi() <<
" cells " << cluster->
size());
1412 muon.setClusterLink(clusterLink);
1416 caloNoise = noiseH.
cptr();
1419 std::vector<float> etcore(4, 0);
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
double charge(const T &p)
Helper class to provide constant type-safe access to aux data.
DataVector adapter that acts like it holds const pointers.
Helper class to provide type-safe access to aux data.
DataVector< MuonCombined::MuonCandidate > MuonCandidateCollection
This typedef represents a collection of MuonCandidate objects.
DataVector< Trk::Track > TrackCollection
This typedef represents a collection of Trk::Track objects.
bool msgLvl(const MSG::Level lvl) const
This class provides the client interface for accessing the detector description information common to...
class extending the basic Trk::EnergyLoss to describe the measured or parameterised muon energy loss ...
CaloEnergy::EnergyLossType energyLossType(void) const
Accessor methods.
double sigmaMinusDeltaEParam() const
get parametrised energy loss minus error
double deltaEMeas() const
get measured energy loss
double sigmaDeltaEMeas() const
get measured energy loss error
double deltaEParam() const
get parametrised energy loss
double sigmaPlusDeltaEParam() const
get parametrised energy loss plus error
float fsrCandidateEnergy() const
FSR Candidate Energy.
DataVector adapter that acts like it holds const pointers.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
ElementProxy back()
Access the last element in the collection as an lvalue.
const DV * asDataVector() const
Return a pointer to this object, as a const DataVector.
void assign(InputIterator first, InputIterator last)
Assign from iterators.
const_reverse_iterator rend() const noexcept
Return a const_reverse_iterator pointing at the beginning of the collection.
void pop_back()
Remove the last element from the collection.
value_type push_back(value_type pElem)
Add an element to the end of the collection.
const PtrVector & stdcont() const
Return the underlying std::vector of the container.
const_reverse_iterator rbegin() const noexcept
Return a const_reverse_iterator pointing past the end of the collection.
std::reverse_iterator< const_iterator > const_reverse_iterator
size_type size() const noexcept
Returns the number of elements in the collection.
ElementLink implementation for ROOT usage.
bool isValid() const
Check if the element can be found.
TagBase implementation for a calo tag.
TagBase implementation for a combined fit.
const MuonCandidate & muonCandidate() const
access to MuonCandidate
const xAOD::TrackParticle & indetTrackParticle() const
access TrackParticle
TagBase implementation for a combined fit.
TagBase implementation for a combined fit.
std::string toString() const
print candidate to string
const ElementLink< TrackCollection > & extrapolatedTrackLink() const
access extrapolated track element link
const std::vector< const Muon::MuonSegment * > & getSegments() const
returns the vector of associated muon segments
const ElementLink< xAOD::TrackParticleContainer > & muonSpectrometerTrackLink() const
access spectrometer track, always there
const Trk::Track * extrapolatedTrack() const
access extrapolated track, can be zero if back extrapolation failed
unsigned int linkIndex(const Trk::Segment *storegate) const
Returns the index of the persistent in the output container In case, that the segment has not been pe...
TagBase implementation for a segment tagger.
TagBase implementation for a combined fit.
const MuonCandidate & muonCandidate() const
access to MuonCandidate
base-class for combined reconstruction output Provides access to MuonType and Author
virtual const Trk::Track * primaryTrack() const
access to primary muon system track, zero if non available
virtual std::vector< const Muon::MuonSegment * > associatedSegments() const
access to associated segments, empty vector if non available
This is the common class for 3D segments used in the muon spectrometer.
lightweight return data-object for (mainly indet) scattering angle analysis by track query
double curvatureSignificance(void) const
ScatteringAngleSignificance inline accessor: significance of maximum curvature discontinuity.
double neighbourSignificance(void) const
ScatteringAngleSignificance inline accessor: maximum significance of neighbouring scatterers.
Helper class to provide type-safe access to aux data.
const_pointer_type cptr()
Tracking class to hold the extrapolation through calorimeter Layers Both the caloEntryLayerIntersecti...
This class describes energy loss material effects in the ATLAS tracking EDM.
double sigmaDeltaE() const
returns the symmatric error
double deltaE() const
returns the
Class to represent and store fit qualities from track reconstruction in terms of and number of degre...
magnetic field properties to steer the behavior of the extrapolation
represents the full description of deflection and e-loss of a track in material.
const EnergyLoss * energyLoss() const
returns the energy loss object.
This class is the pure abstract base class for all fittable tracking measurements.
Contains information about the 'fitter' of this track.
@ Unknown
Track fitter not defined.
@ MuTag
Tracks produced by MuTag.
represents the track state (measurement, material, fit parameters and quality) at a surface.
@ Measurement
This is a measurement, and will at least contain a Trk::MeasurementBase.
A summary of the information contained by a track.
int get(const SummaryType &type) const
returns the summary information for the passed SummaryType.
const Trk::TrackStates * trackStateOnSurfaces() const
return a pointer to a const DataVector of const TrackStateOnSurfaces.
const TrackInfo & info() const
Returns a const ref to info of a const tracks.
const Perigee * perigeeParameters() const
return Perigee.
const Trk::TrackSummary * trackSummary() const
Returns a pointer to the const Trk::TrackSummary owned by this const track (could be nullptr).
const FitQuality * fitQuality() const
return a pointer to the fit quality const-overload
virtual double eta() const
The pseudorapidity ( ) of the particle.
size_t size() const
size method (forwarded from CaloClusterCellLink obj)
virtual double phi() const
The azimuthal angle ( ) of the particle.
void setMuonLink(const ElementLink< MuonContainer > &muonLink)
Sets.
void setNRpcHits(int nRpcHits)
Sets.
void setNTileCells(int nTileCells)
Sets.
void setAnn(float ann)
Sets.
void setMdtInfo(float mdtBetaAvg, float mdtBetaRms, float mdtBetaChi2, int mdtBetaDof)
Sets.
void setBeta(float beta)
Sets.
void setBetaT(float betaT)
Sets.
void setRpcInfo(float rpcBetaAvg, float rpcBetaRms, float rpcBetaChi2, int rpcBetaDof)
Sets.
void setCaloInfo(float caloBetaAvg, float caloBetaRms, float caloBetaChi2, int caloBetaDof)
Sets.
void setTrackParameterCovarianceMatrix(unsigned int index, std::vector< float > &cov)
Set the cov matrix of the parameter at 'index', using a vector of floats.
void setTrackLink(const ElementLink< TrackCollection > &track)
Set the link to the original track.
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
virtual double phi() const override final
The azimuthal angle ( ) of the particle (has range to .).
virtual double pt() const override final
The transverse momentum ( ) of the particle.
virtual double eta() const override final
The pseudorapidity ( ) of the particle.
void setPatternRecognitionInfo(const std::bitset< xAOD::NumberOfTrackRecoInfo > &patternReco)
Method setting the pattern recognition algorithm, using a bitset.
std::vector< std::string > tags
double error(const Amg::MatrixX &mat, int index)
return diagonal error of the matrix caller should ensure the matrix is symmetric and the index is in ...
The MuonTagToSegMap is an auxillary construct that links the MuonSegments associated with a combined ...
@ VIEW_ELEMENTS
this data object is a view, it does not own its elmts
@ NoField
Field is set to 0., 0., 0.,.
@ numberOfCscUnspoiltEtaHits
number of unspoilt CSC eta measurements (all CSC phi measurements are by definition spoilt).
void stable_sort(DataModel_detail::iterator< DVL > beg, DataModel_detail::iterator< DVL > end)
Specialization of stable_sort for DataVector/List.
CaloCluster_v1 CaloCluster
Define the latest version of the calorimeter cluster class.
TrackParticle_v1 TrackParticle
Reference the current persistent version:
SlowMuon_v1 SlowMuon
Reference the current persistent version:
TrackParticleContainer_v1 TrackParticleContainer
Definition of the current "TrackParticle container version".
Muon_v1 Muon
Reference the current persistent version:
CaloClusterContainer_v1 CaloClusterContainer
Define the latest version of the calorimeter cluster container.
@ STACO
Tracks produced by STACO.