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.);
438 tp->setTrackParameterCovarianceMatrix(0, dummy_cov);
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;
454 tp->setPatternRecognitionInfo(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()) {
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()) {
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;
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()) {
650 ATH_MSG_DEBUG(
"Adding MuGirl: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
651 muon.setTrackParticleLink(xAOD::Muon::CombinedTrackParticle, link);
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;
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();
763 if (trackCollection) {
803 if (!muon.nMuonSegments()) {
804 std::vector< ElementLink<xAOD::MuonSegmentContainer>> segments;
808 segments.push_back(link);
809 ATH_MSG_DEBUG(
"Adding MuGirl: xaod::MuonSegment px " << (*link)->px() <<
" py " << (*link)->py() <<
" pz "
815 muon.setMuonSegmentLinks(segments);
818 if (muon.muonSpectrometerTrackParticleLink().isValid()) {
return; }
822 if (muon.author() != xAOD::Muon::MuGirl)
831 ATH_MSG_DEBUG(
"There is no extrapolated track associated to the MuonCandidate.");
832 if (muon.author() == xAOD::Muon::MuidCo) {
838 ATH_MSG_DEBUG(
"Adding standalone fit (refitted): pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi "
840 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
841 float fieldInt =
m_trackQuery->fieldIntegral(**meLink, ctx).betweenSpectrometerMeasurements();
842 muon.setParameter(fieldInt, xAOD::Muon::spectrometerFieldIntegral);
844 acc_nUnspoiledCscHits(muon) = nunspoiled;
848 if (!extrapolatedTrack)
ATH_MSG_WARNING(
"Track doesn't have extrapolated track. Skipping");
851 "Track doesn't have perigee parameters on extrapolated "
858 if (muon.muonType() != xAOD::Muon::MuonStandAlone) {
869 ATH_MSG_DEBUG(
"Adding MS-only extrapolated track: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi "
872 muon.setTrackParticleLink(xAOD::Muon::MSOnlyExtrapolatedMuonSpectrometerTrackParticle, link);
874 ATH_MSG_WARNING(
"failed to create MS-only extrapolated track particle");
880 ATH_MSG_DEBUG(
"Adding standalone fit (refitted): pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi "
882 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
883 float fieldInt =
m_trackQuery->fieldIntegral(**meLink, ctx).betweenSpectrometerMeasurements();
884 muon.setParameter(fieldInt, xAOD::Muon::spectrometerFieldIntegral);
886 acc_nUnspoiledCscHits(muon) = nunspoiled;
890 if (muon.author() == xAOD::Muon::MuGirl && muon.extrapolatedMuonSpectrometerTrackParticleLink().isValid()) {
899 ATH_MSG_DEBUG(
"Adding MS-only extrapolated track to MuGirl muon: pt "
900 << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
902 muon.setTrackParticleLink(xAOD::Muon::MSOnlyExtrapolatedMuonSpectrometerTrackParticle, link);
905 muon.setParameter(fieldInt, xAOD::Muon::spectrometerFieldIntegral);
913 ATH_MSG_DEBUG(
"Adding standalone fit (un-refitted): pt " << (*link)->pt() <<
" eta " << (*link)->eta()
914 <<
" phi " << (*link)->phi());
916 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
919 muon.setParameter(fieldInt, xAOD::Muon::spectrometerFieldIntegral);
930 ATH_MSG_DEBUG(
"Adding standalone fit: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
932 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
935 muon.setParameter(fieldInt, xAOD::Muon::spectrometerFieldIntegral);
937 acc_nUnspoiledCscHits(muon) = nunspoiled;
946 const std::vector<const InDetCandidateToTagMap*>& tagMaps)
const {
947 resolvedInDetCandidates.clear();
949 if (!tag_map)
continue;
950 for (
const auto& combined_tag : *tag_map) {
951 const TagBase* tag = combined_tag.second.get();
953 if (muGirlLowBetaTag) { resolvedInDetCandidates.emplace_back(combined_tag.first, std::vector<const TagBase*>{tag}); }
959 ATH_MSG_DEBUG(
"ID candidates: " << tagMaps.size() <<
" after stau selection " << resolvedInDetCandidates.size());
961 msg(MSG::DEBUG) <<
"ID candidate staus: " << candidate.first->toString() <<
endmsg;
967 std::stable_sort(resolvedInDetCandidates.begin(), resolvedInDetCandidates.end(),
969 return a.first->indetTrackParticle().pt() > b.first->indetTrackParticle().pt();
974 const std::vector<const InDetCandidateToTagMap*>& tagMaps,
976 std::vector<const MuonCombined::MuonCandidate*>& resolvedMuonCandidates,
977 bool select_commissioning)
const {
978 resolvedMuonCandidates.clear();
979 resolvedInDetCandidates.clear();
981 std::unique_ptr<const TrackCollection> resolvedTracks;
982 std::vector<std::unique_ptr<Trk::Track>> garbage_collection;
989 if (!tag_map)
continue;
990 for (
const auto& comb_tag : *tag_map) {
991 const TagBase* tag = comb_tag.second.get();
995 if (tag->isCommissioning() != select_commissioning)
break;
996 InDetCandidateTagsMap::iterator itr =
997 std::find_if(inDetCandidateMap.begin(), inDetCandidateMap.end(),
998 [&comb_tag](
const InDetCandidateTags& to_test) { return (*to_test.first) == (*comb_tag.first); });
999 if (itr != inDetCandidateMap.end())
1000 itr->second.emplace_back(tag);
1002 inDetCandidateMap.emplace_back(std::make_pair(comb_tag.first, std::vector<const TagBase*>{tag}));
1009 if (!inDetCandidateMap.empty()) {
1015 resolvedInDetCandidates.reserve(inDetCandidateMap.size());
1016 caloMuons.reserve(inDetCandidateMap.size());
1019 if (comb_tag.second.size() == 1 && comb_tag.second.front()->type() == xAOD::Muon::CaloTagged) {
1020 caloMuons.emplace_back(std::move(comb_tag));
1022 resolvedInDetCandidates.emplace_back(std::move(comb_tag));
1024 inDetCandidateMap.clear();
1027 if (
msgLvl(MSG::DEBUG)) {
1028 ATH_MSG_DEBUG(
"Found " << resolvedInDetCandidates.size() <<
" inner detector tags in event "
1029 << ctx.eventID().event_number());
1031 std::stringstream
tags;
1032 for (
const TagBase* tag : candidate.second)
tags <<
" " << tag->toString();
1033 ATH_MSG_DEBUG(
"ID candidate: " << candidate.first->toString() <<
" " <<
tags.str());
1039 to_resolve.reserve(resolvedInDetCandidates.size());
1040 garbage_collection.reserve(resolvedInDetCandidates.size());
1044 std::map<const Trk::Track*, InDetCandidateTags> trackInDetCandLinks;
1048 const TagBase* primaryTag = candidate.second[0];
1055 trackInDetCandLinks[to_resolve.
back()] = std::move(candidate);
1061 if (!segments.empty()) {
1063 garbage_collection.emplace_back(
1066 to_resolve.
push_back(garbage_collection.back().get());
1068 trackInDetCandLinks[garbage_collection.back().get()] = std::move(candidate);
1072 resolvedInDetCandidates.clear();
1078 for (
const Trk::Track* track : *resolvedTracks) {
1079 std::map<const Trk::Track*, InDetCandidateTags>::iterator trackCandLink = trackInDetCandLinks.find(track);
1080 if (trackCandLink == trackInDetCandLinks.end()) {
1081 ATH_MSG_WARNING(
"Unable to find internal link between MS track and ID candidate!");
1084 resolvedInDetCandidates.push_back(std::move(trackCandLink->second));
1088 if (
msgLvl(MSG::VERBOSE)) {
1090 << resolvedInDetCandidates.size() <<
" trackCandLinks: " << trackInDetCandLinks.size()
1091 <<
" to_resolve: " << to_resolve.size() <<
" resolvedTracks: " << resolvedTracks->size());
1093 ATH_MSG_DEBUG(
"ID candidate: " << candidate.first->toString() <<
" " << candidate.second[0]->toString());
1097 ATH_MSG_DEBUG(
"ID candidate: " << candidate.first->toString() <<
" " << candidate.second[0]->toString());
1101 resolvedInDetCandidates.insert(resolvedInDetCandidates.end(), caloMuons.begin(), caloMuons.end());
1104 std::stable_sort(resolvedInDetCandidates.begin(), resolvedInDetCandidates.end(),
1106 return a.first->indetTrackParticle().pt() > b.first->indetTrackParticle().pt();
1112 if (!muonCandidates) {
return; }
1114 if (
msgLvl(MSG::DEBUG)) {
1120 if (resolvedTracks) { resolvedTracks2.
assign(resolvedTracks->begin(), resolvedTracks->end()); }
1122 std::set<const MuonCandidate*> used_candidates;
1124 for (
const TagBase* tag : indet_cand.second) {
1126 if (tag->author() == xAOD::Muon::MuidCo) {
1129 }
else if (tag->author() == xAOD::Muon::STACO && indet_cand.second[0] == tag) {
1138 std::map<const Trk::Track*, const MuonCandidate*> trackMuonCandLinks;
1140 if (candidate->isCommissioning() != select_commissioning)
continue;
1141 const Trk::Track* track = candidate->primaryTrack();
1142 if (used_candidates.count(candidate)) {
1146 used_candidates.insert(candidate);
1148 trackMuonCandLinks[track] = candidate;
1155 for (
const Trk::Track* track : *resolvedTracks) {
1156 auto trackCandLink = trackMuonCandLinks.find(track);
1157 if (trackCandLink != trackMuonCandLinks.end()) resolvedMuonCandidates.push_back(trackCandLink->second);
1161 if (
msgLvl(MSG::DEBUG)) {
1162 ATH_MSG_DEBUG(
"Muon candidates: " << muonCandidates->
size() <<
" after ambiguity solving " << resolvedMuonCandidates.size());
1163 for (
const MuonCandidate* candidate : resolvedMuonCandidates) {
1164 msg(MSG::DEBUG) <<
"Muon candidate: " << candidate->toString() <<
endmsg;
1170 const std::vector<const Muon::MuonSegment*>& segments,
1174 auto trackStateOnSurfaces = std::make_unique<Trk::TrackStates>();
1178 double momentum{1e8},
charge{0.};
1179 std::unique_ptr<const Trk::TrackParameters> pars{
m_edmHelperSvc->createTrackParameters(*seg, momentum,
charge)};
1181 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0);
1184 std::unique_ptr<Trk::TrackParameters> exPars{
m_propagator->propagateParameters(
1186 if (!exPars) {
ATH_MSG_VERBOSE(
"Could not propagate Track to segment surface"); }
1189 trackStateOnSurfaces->push_back(trackState);
1195 info.setPatternRecognitionInfo(author);
1196 std::unique_ptr<Trk::Track> newtrack =
1197 std::make_unique<Trk::Track>(info, std::move(trackStateOnSurfaces), (indetTrack.
fitQuality())->uniqueClone());
1206 if (!muon.primaryTrackParticleLink().isValid()) {
1207 ATH_MSG_DEBUG(
"No primary track particle set, deleting muon");
1212 setP4(muon, *primary);
1213 const float qOverP = primary->qOverP();
1214 if (qOverP != 0.0) {
1215 muon.setCharge(qOverP > 0 ? 1. : -1.);
1217 ATH_MSG_WARNING(
"MuonCreatorTool::dressMuon - trying to set qOverP, but value from muon.primaryTrackParticle ["
1218 << muon.primaryTrackParticleLink().dataID()
1219 <<
"] is zero. Setting charge=0.0. The eta/phi of the muon is: " << muon.eta() <<
" / " << muon.phi());
1220 muon.setCharge(0.0);
1230 muon.setParameter(curvatureSignificance, xAOD::Muon::scatteringCurvatureSignificance);
1232 muon.setParameter(neighbourSignificance, xAOD::Muon::scatteringNeighbourSignificance);
1233 ATH_MSG_VERBOSE(
"Got curvatureSignificance " << curvatureSignificance <<
" and neighbourSignificance "
1234 << neighbourSignificance);
1239 muon.setParameter(momentumBalanceSignificance, xAOD::Muon::momentumBalanceSignificance);
1240 ATH_MSG_VERBOSE(
"Got momentumBalanceSignificance " << momentumBalanceSignificance);
1245 muon.setParameter(meanDeltaADC, xAOD::Muon::meanDeltaADCCountsMDT);
1250 acc_MuonSpectrometerPt(muon) = muon.pt();
1251 acc_InnerDetectorPt(muon) = muon.pt();
1262 if (muon.trackParticle(xAOD::Muon::CombinedTrackParticle)) {
1263 trk = muon.trackParticle(xAOD::Muon::CombinedTrackParticle)->track();
1265 if (!trk && muon.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle)) {
1266 trk = muon.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle)->track();
1272 ATH_MSG_VERBOSE(
"Couldn't find matching track which might have energy loss.");
1278 if (!muon.inDetTrackParticleLink().isValid()) {
1279 ATH_MSG_WARNING(
"Missing ID track particle link in addEnergyLossToMuon!");
1284 const Trk::Track* trk = (*(muon.inDetTrackParticleLink()))->track();
1294 for (; it != itEnd; ++it) {
1295 if ((*it)->trackParameters()) {
1301 ATH_MSG_WARNING(
"Missing ID TSOS with track parameters in addEnergyLossToMuon!");
1306 std::vector<const Trk::TrackStateOnSurface*>* caloTSOS =
m_caloMaterialProvider->getCaloTSOS(*((*it)->trackParameters()), *trk);
1317 std::vector<const Trk::TrackStateOnSurface*>::const_iterator it2 = caloTSOS->begin();
1318 std::vector<const Trk::TrackStateOnSurface*>::const_iterator itEnd2 = caloTSOS->end();
1319 for (; it2 != itEnd2; ++it2)
delete *it2;
1326 muon.setParameter(0.f, xAOD::Muon::EnergyLoss);
1327 muon.setParameter(0.f, xAOD::Muon::ParamEnergyLoss);
1328 muon.setParameter(0.f, xAOD::Muon::MeasEnergyLoss);
1329 muon.setParameter(0.f, xAOD::Muon::EnergyLossSigma);
1330 muon.setParameter(0.f, xAOD::Muon::MeasEnergyLossSigma);
1331 muon.setParameter(0.f, xAOD::Muon::ParamEnergyLossSigmaPlus);
1332 muon.setParameter(0.f, xAOD::Muon::ParamEnergyLossSigmaMinus);
1334 muon.setEnergyLossType(xAOD::Muon::Parametrized);
1335 muon.setParameter(0.f, xAOD::Muon::FSR_CandidateEnergy);
1341 unsigned int numEnergyLossPerTrack = 0;
1342 bool problem =
false;
1343 for (
const auto* tsos : *tsosVector) {
1345 if (!meot)
continue;
1348 if (!caloEnergy)
continue;
1349 ++numEnergyLossPerTrack;
1351 muon.setParameter(
static_cast<float>(caloEnergy->
deltaE()), xAOD::Muon::EnergyLoss);
1352 muon.setParameter(
static_cast<float>(caloEnergy->
deltaEParam()), xAOD::Muon::ParamEnergyLoss);
1353 muon.setParameter(
static_cast<float>(caloEnergy->
deltaEMeas()), xAOD::Muon::MeasEnergyLoss);
1354 muon.setParameter(
static_cast<float>(caloEnergy->
sigmaDeltaE()), xAOD::Muon::EnergyLossSigma);
1355 muon.setParameter(
static_cast<float>(caloEnergy->
sigmaDeltaEMeas()), xAOD::Muon::MeasEnergyLossSigma);
1356 muon.setParameter(
static_cast<float>(caloEnergy->
sigmaPlusDeltaEParam()), xAOD::Muon::ParamEnergyLossSigmaPlus);
1357 muon.setParameter(
static_cast<float>(caloEnergy->
sigmaMinusDeltaEParam()), xAOD::Muon::ParamEnergyLossSigmaMinus);
1359 muon.setEnergyLossType(
static_cast<xAOD::Muon::EnergyLossType
>(caloEnergy->
energyLossType()));
1360 muon.setParameter(
static_cast<float>(caloEnergy->
fsrCandidateEnergy()), xAOD::Muon::FSR_CandidateEnergy);
1362 if (numEnergyLossPerTrack > 1) {
1373 if (!tp || !clusterContainer) {
1379 ATH_MSG_DEBUG(
" Selected track: pt " << tp->pt() <<
" eta " << tp->eta() <<
" phi " << tp->phi());
1387 if (!inputCaloExt) {
1390 std::unique_ptr<Trk::CaloExtension> caloExtension =
m_caloExtTool->caloExtension(ctx, *tp);
1391 if (!caloExtension) {
1395 if (caloExtension->caloLayerIntersections().empty())
1396 ATH_MSG_DEBUG(
"Received a caloExtension object without track extrapolation");
1403 ATH_MSG_DEBUG(
"Failed to create cluster from ParticleCellAssociation");
1406 ATH_MSG_DEBUG(
" New cluster: eta " << cluster->
eta() <<
" phi " << cluster->
phi() <<
" cells " << cluster->
size());
1411 muon.setClusterLink(clusterLink);
1415 caloNoise = noiseH.
cptr();
1418 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
Test to see if the link can be dereferenced.
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.
size_t index() const
Return the index of this element within its container.
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.
const Trk::Track * track() const
Returns a pointer (which can be NULL) to the Trk::Track which was used to make this TrackParticle.
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.