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.");
191 muon->setMuonType(xAOD::Muon::MuonStandAlone);
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");
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");
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());
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();
344 if (!(cbFitTag || stacoTag || muGirlTag)) {
ATH_MSG_WARNING(
"Unknown combined tag "); }
346 }
else if (
type == xAOD::Muon::SegmentTagged) {
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.;
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;
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);
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);
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());
534 if (slowMuon && stauExtras) {
554 std::vector<uint8_t>& eTechVec = eTechAcc(*slowMuon);
555 std::vector<unsigned int>& idVec = idAcc(*slowMuon);
556 std::vector<float>& mToFVec = mToFAcc(*slowMuon);
557 std::vector<float>& xVec = xAcc(*slowMuon);
558 std::vector<float>& yVec = yAcc(*slowMuon);
559 std::vector<float>& zVec = zAcc(*slowMuon);
560 std::vector<float>& eVec = eAcc(*slowMuon);
562 std::vector<float>& errorVec = errorAcc(*slowMuon);
563 std::vector<float>& shiftVec = shiftAcc(*slowMuon);
564 std::vector<float>& propagationTimeVec = propTimeAcc(*slowMuon);
566 for (
const auto& hit : stauExtras->
hits) {
567 eTechVec.push_back(hit.eTech);
568 idVec.push_back(hit.id.get_identifier32().get_compact());
569 mToFVec.push_back(hit.mToF);
570 xVec.push_back(hit.x);
571 yVec.push_back(hit.y);
572 zVec.push_back(hit.z);
573 eVec.push_back(hit.e);
574 errorVec.push_back(hit.error);
575 shiftVec.push_back(hit.shift);
576 propagationTimeVec.push_back(hit.propagationTime);
580 if (!
muon.combinedTrackParticleLink().isValid() &&
tag->combinedTrack()) {
588 ATH_MSG_DEBUG(
"Adding MuGirlLowBeta: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
589 muon.setTrackParticleLink(xAOD::Muon::CombinedTrackParticle, link);
591 ATH_MSG_WARNING(
"Creating of MuGirlLowBeta TrackParticle Link failed");
597 std::vector<ElementLink<xAOD::MuonSegmentContainer>> segments;
600 if (link.isValid()) {
601 segments.push_back(link);
602 ATH_MSG_DEBUG(
"Adding MuGirlLowBeta: xaod::MuonSegment px " << (*link)->px() <<
" py " << (*link)->py() <<
" pz "
607 muon.setMuonSegmentLinks(segments);
619 if (!
muon.combinedTrackParticleLink().isValid() &&
tag->combinedTrack()) {
628 ATH_MSG_DEBUG(
"Adding MuGirl: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
629 muon.setTrackParticleLink(xAOD::Muon::CombinedTrackParticle, link);
641 ATH_MSG_DEBUG(
"Adding MuGirl: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
642 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
650 std::vector<ElementLink<xAOD::MuonSegmentContainer>> segments;
654 segments.push_back(link);
655 ATH_MSG_DEBUG(
"Adding MuGirl: xaod::MuonSegment px " << (*link)->px() <<
" py " << (*link)->py() <<
" pz "
660 muon.setMuonSegmentLinks(segments);
677 std::vector<ElementLink<xAOD::MuonSegmentContainer>> segments;
678 bool foundseg =
false;
679 for (
const auto&
info :
tag->segmentsInfo()) {
686 if (seglink.
isValid()) segments.push_back(seglink);
692 muon.setParameter(
static_cast<float>(
info.segment->fitQuality()->chiSquared() /
info.segment->fitQuality()->numberDoF()),
709 mu.setParameter(0.
f, xAOD::Muon::CaloMuonScore);
710 mu.setParameter(
static_cast<int>(0xFF), xAOD::Muon::CaloMuonIDTag);
714 acc_ET_Core(
mu) = 0.0;
715 acc_ElType(
mu) = -999.0;
716 acc_ElFSREnergy(
mu) = -999.0;
721 ATH_MSG_DEBUG(
"Adding Calo Muon with author " <<
tag->author() <<
", type " <<
tag->type() <<
", CaloMuonScore "
722 <<
tag->caloMuonScore());
723 mu.setParameter(
static_cast<float>(
tag->caloMuonScore()), xAOD::Muon::CaloMuonScore);
724 mu.setParameter(
static_cast<int>(
tag->caloMuonIdTag()), xAOD::Muon::CaloMuonIDTag);
729 acc_ET_Core(
mu) =
tag->etCore();
730 acc_ElType(
mu) =
tag->energyLossType();
731 acc_ElFSREnergy(
mu) =
tag->fsrCandidateEnergy();
741 if (trackCollection) {
781 if (!
muon.nMuonSegments()) {
782 std::vector< ElementLink<xAOD::MuonSegmentContainer>> segments;
786 segments.push_back(link);
787 ATH_MSG_DEBUG(
"Adding MuGirl: xaod::MuonSegment px " << (*link)->px() <<
" py " << (*link)->py() <<
" pz "
793 muon.setMuonSegmentLinks(segments);
796 if (
muon.muonSpectrometerTrackParticleLink().isValid()) {
return; }
809 ATH_MSG_DEBUG(
"There is no extrapolated track associated to the MuonCandidate.");
816 ATH_MSG_DEBUG(
"Adding standalone fit (refitted): pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi "
818 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
819 float fieldInt =
m_trackQuery->fieldIntegral(**meLink, ctx).betweenSpectrometerMeasurements();
822 acc_nUnspoiledCscHits(
muon) = nunspoiled;
826 if (!extrapolatedTrack)
ATH_MSG_WARNING(
"Track doesn't have extrapolated track. Skipping");
829 "Track doesn't have perigee parameters on extrapolated "
836 if (
muon.muonType() != xAOD::Muon::MuonStandAlone) {
847 ATH_MSG_DEBUG(
"Adding MS-only extrapolated track: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi "
850 muon.setTrackParticleLink(xAOD::Muon::MSOnlyExtrapolatedMuonSpectrometerTrackParticle, link);
852 ATH_MSG_WARNING(
"failed to create MS-only extrapolated track particle");
858 ATH_MSG_DEBUG(
"Adding standalone fit (refitted): pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi "
860 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
861 float fieldInt =
m_trackQuery->fieldIntegral(**meLink, ctx).betweenSpectrometerMeasurements();
864 acc_nUnspoiledCscHits(
muon) = nunspoiled;
877 ATH_MSG_DEBUG(
"Adding MS-only extrapolated track to MuGirl muon: pt "
878 << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
880 muon.setTrackParticleLink(xAOD::Muon::MSOnlyExtrapolatedMuonSpectrometerTrackParticle, link);
891 ATH_MSG_DEBUG(
"Adding standalone fit (un-refitted): pt " << (*link)->pt() <<
" eta " << (*link)->eta()
892 <<
" phi " << (*link)->phi());
894 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
908 ATH_MSG_DEBUG(
"Adding standalone fit: pt " << (*link)->pt() <<
" eta " << (*link)->eta() <<
" phi " << (*link)->phi());
910 muon.setTrackParticleLink(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle, link);
915 acc_nUnspoiledCscHits(
muon) = nunspoiled;
924 const std::vector<const InDetCandidateToTagMap*>& tagMaps)
const {
925 resolvedInDetCandidates.clear();
927 if (!tag_map)
continue;
928 for (
const auto& combined_tag : *tag_map) {
929 const TagBase*
tag = combined_tag.second.get();
931 if (muGirlLowBetaTag) { resolvedInDetCandidates.emplace_back(combined_tag.first, std::vector<const TagBase*>{
tag}); }
937 ATH_MSG_DEBUG(
"ID candidates: " << tagMaps.size() <<
" after stau selection " << resolvedInDetCandidates.size());
938 for (
const InDetCandidateTags& candidate : resolvedInDetCandidates) {
945 std::stable_sort(resolvedInDetCandidates.begin(), resolvedInDetCandidates.end(),
946 [](
const InDetCandidateTags&
a,
const InDetCandidateTags&
b) {
947 return a.first->indetTrackParticle().pt() > b.first->indetTrackParticle().pt();
952 const std::vector<const InDetCandidateToTagMap*>& tagMaps,
954 std::vector<const MuonCombined::MuonCandidate*>& resolvedMuonCandidates,
955 bool select_commissioning)
const {
956 resolvedMuonCandidates.clear();
957 resolvedInDetCandidates.clear();
959 std::unique_ptr<const TrackCollection> resolvedTracks;
960 std::vector<std::unique_ptr<Trk::Track>> garbage_collection;
967 if (!tag_map)
continue;
968 for (
const auto& comb_tag : *tag_map) {
973 if (
tag->isCommissioning() != select_commissioning)
break;
975 std::find_if(inDetCandidateMap.begin(), inDetCandidateMap.end(),
976 [&comb_tag](
const InDetCandidateTags& to_test) { return (*to_test.first) == (*comb_tag.first); });
977 if (itr != inDetCandidateMap.end())
978 itr->second.emplace_back(
tag);
980 inDetCandidateMap.emplace_back(std::make_pair(comb_tag.first, std::vector<const TagBase*>{tag}));
987 if (!inDetCandidateMap.empty()) {
993 resolvedInDetCandidates.reserve(inDetCandidateMap.size());
994 caloMuons.reserve(inDetCandidateMap.size());
996 std::stable_sort(comb_tag.second.begin(), comb_tag.second.end(),
SortTagBasePtr());
997 if (comb_tag.second.size() == 1 && comb_tag.second.front()->type() == xAOD::Muon::CaloTagged) {
998 caloMuons.emplace_back(std::move(comb_tag));
1000 resolvedInDetCandidates.emplace_back(std::move(comb_tag));
1002 inDetCandidateMap.clear();
1004 std::stable_sort(resolvedInDetCandidates.begin(), resolvedInDetCandidates.end(),
SortInDetCandidates());
1006 ATH_MSG_DEBUG(
"Found " << resolvedInDetCandidates.size() <<
" inner detector tags in event "
1007 << ctx.eventID().event_number());
1009 std::stringstream
tags;
1011 ATH_MSG_DEBUG(
"ID candidate: " << candidate.first->toString() <<
" " <<
tags.str());
1017 to_resolve.reserve(resolvedInDetCandidates.size());
1018 garbage_collection.reserve(resolvedInDetCandidates.size());
1022 std::map<const Trk::Track*, InDetCandidateTags> trackInDetCandLinks;
1026 const TagBase* primaryTag = candidate.second[0];
1033 trackInDetCandLinks[to_resolve.back()] = std::move(candidate);
1039 if (!segments.empty()) {
1041 garbage_collection.emplace_back(
1042 createDummyTrack(ctx, primaryTag->
associatedSegments(), *(candidate.first->indetTrackParticle().track())));
1044 to_resolve.push_back(garbage_collection.back().get());
1046 trackInDetCandLinks[garbage_collection.back().get()] = std::move(candidate);
1050 resolvedInDetCandidates.clear();
1053 resolvedTracks.reset(m_ambiguityProcessor->process(to_resolve.asDataVector()));
1058 if (trackCandLink == trackInDetCandLinks.end()) {
1059 ATH_MSG_WARNING(
"Unable to find internal link between MS track and ID candidate!");
1062 resolvedInDetCandidates.push_back(std::move(trackCandLink->second));
1068 << resolvedInDetCandidates.size() <<
" trackCandLinks: " << trackInDetCandLinks.size()
1069 <<
" to_resolve: " << to_resolve.size() <<
" resolvedTracks: " << resolvedTracks->size());
1071 ATH_MSG_DEBUG(
"ID candidate: " << candidate.first->toString() <<
" " << candidate.second[0]->toString());
1075 ATH_MSG_DEBUG(
"ID candidate: " << candidate.first->toString() <<
" " << candidate.second[0]->toString());
1079 resolvedInDetCandidates.insert(resolvedInDetCandidates.end(), caloMuons.begin(), caloMuons.end());
1082 std::stable_sort(resolvedInDetCandidates.begin(), resolvedInDetCandidates.end(),
1084 return a.first->indetTrackParticle().pt() > b.first->indetTrackParticle().pt();
1090 if (!muonCandidates) {
return; }
1098 if (resolvedTracks) { resolvedTracks2.assign(resolvedTracks->
begin(), resolvedTracks->
end()); }
1100 std::set<const MuonCandidate*> used_candidates;
1102 for (
const TagBase*
tag : indet_cand.second) {
1116 std::map<const Trk::Track*, const MuonCandidate*> trackMuonCandLinks;
1118 if (candidate->isCommissioning() != select_commissioning)
continue;
1120 if (used_candidates.count(candidate)) {
1124 used_candidates.insert(candidate);
1125 resolvedTracks2.push_back(
track);
1126 trackMuonCandLinks[
track] = candidate;
1130 resolvedTracks.reset(m_ambiguityProcessor->process(resolvedTracks2.asDataVector()));
1134 auto trackCandLink = trackMuonCandLinks.find(
track);
1135 if (trackCandLink != trackMuonCandLinks.end()) resolvedMuonCandidates.push_back(trackCandLink->second);
1140 ATH_MSG_DEBUG(
"Muon candidates: " << muonCandidates->size() <<
" after ambiguity solving " << resolvedMuonCandidates.size());
1141 for (
const MuonCandidate* candidate : resolvedMuonCandidates) {
1147 std::unique_ptr<Trk::Track> MuonCreatorTool::createDummyTrack(
const EventContext& ctx,
1148 const std::vector<const Muon::MuonSegment*>& segments,
1152 auto trackStateOnSurfaces = std::make_unique<Trk::TrackStates>();
1157 std::unique_ptr<const Trk::TrackParameters>
pars{m_edmHelperSvc->createTrackParameters(*seg,
momentum,
charge)};
1159 std::bitset<Trk::TrackStateOnSurface::NumberOfTrackStateOnSurfaceTypes> typePattern(0);
1162 std::unique_ptr<Trk::TrackParameters> exPars{m_propagator->propagateParameters(
1164 if (!exPars) {
ATH_MSG_VERBOSE(
"Could not propagate Track to segment surface"); }
1167 trackStateOnSurfaces->push_back(trackState);
1174 std::unique_ptr<Trk::Track> newtrack =
1175 std::make_unique<Trk::Track>(
info, std::move(trackStateOnSurfaces), (indetTrack.
fitQuality())->uniqueClone());
1178 if (m_trackSummaryTool.isEnabled()) { m_trackSummaryTool->computeAndReplaceTrackSummary(*newtrack,
false); }
1184 if (!
muon.primaryTrackParticleLink().isValid()) {
1185 ATH_MSG_DEBUG(
"No primary track particle set, deleting muon");
1195 ATH_MSG_WARNING(
"MuonCreatorTool::dressMuon - trying to set qOverP, but value from muon.primaryTrackParticle ["
1196 <<
muon.primaryTrackParticleLink().dataID()
1197 <<
"] is zero. Setting charge=0.0. The eta/phi of the muon is: " <<
muon.eta() <<
" / " <<
muon.phi());
1198 muon.setCharge(0.0);
1202 m_muonDressingTool->addMuonHitSummary(
muon);
1205 if (!m_scatteringAngleTool.empty()) {
1211 ATH_MSG_VERBOSE(
"Got curvatureSignificance " << curvatureSignificance <<
" and neighbourSignificance "
1212 << neighbourSignificance);
1215 if (!m_momentumBalanceTool.empty()) {
1221 if (!m_meanMDTdADCTool.empty()) {
1222 float meanDeltaADC =
float(m_meanMDTdADCTool->meanMDTdADCFiller(
muon));
1223 muon.setParameter(meanDeltaADC, xAOD::Muon::meanDeltaADCCountsMDT);
1227 if (!m_selectorTool.empty()) {
1228 acc_MuonSpectrometerPt(
muon) =
muon.pt();
1229 acc_InnerDetectorPt(
muon) =
muon.pt();
1231 m_selectorTool->setPassesIDCuts(
muon);
1234 m_selectorTool->setQuality(
muon);
1238 if (m_fillEnergyLossFromTrack) {
1240 if (
muon.trackParticle(xAOD::Muon::CombinedTrackParticle)) {
1241 trk =
muon.trackParticle(xAOD::Muon::CombinedTrackParticle)->track();
1243 if (!trk &&
muon.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle)) {
1244 trk =
muon.trackParticle(xAOD::Muon::ExtrapolatedMuonSpectrometerTrackParticle)->track();
1249 fillEnergyLossFromTrack(
muon,
nullptr);
1250 ATH_MSG_VERBOSE(
"Couldn't find matching track which might have energy loss.");
1256 if (!
muon.inDetTrackParticleLink().isValid()) {
1257 ATH_MSG_WARNING(
"Missing ID track particle link in addEnergyLossToMuon!");
1262 const Trk::Track* trk = (*(
muon.inDetTrackParticleLink()))->track();
1272 for (;
it != itEnd; ++
it) {
1273 if ((*it)->trackParameters()) {
1279 ATH_MSG_WARNING(
"Missing ID TSOS with track parameters in addEnergyLossToMuon!");
1284 std::vector<const Trk::TrackStateOnSurface*>* caloTSOS = m_caloMaterialProvider->getCaloTSOS(*((*it)->trackParameters()), *trk);
1292 fillEnergyLossFromTrack(
muon, caloTSOS);
1295 std::vector<const Trk::TrackStateOnSurface*>::const_iterator it2 = caloTSOS->begin();
1296 std::vector<const Trk::TrackStateOnSurface*>::const_iterator itEnd2 = caloTSOS->end();
1297 for (; it2 != itEnd2; ++it2)
delete *it2;
1301 void MuonCreatorTool::fillEnergyLossFromTrack(
xAOD::Muon&
muon,
const std::vector<const Trk::TrackStateOnSurface*>* tsosVector)
const {
1304 muon.setParameter(0.
f, xAOD::Muon::EnergyLoss);
1305 muon.setParameter(0.
f, xAOD::Muon::ParamEnergyLoss);
1306 muon.setParameter(0.
f, xAOD::Muon::MeasEnergyLoss);
1307 muon.setParameter(0.
f, xAOD::Muon::EnergyLossSigma);
1308 muon.setParameter(0.
f, xAOD::Muon::MeasEnergyLossSigma);
1309 muon.setParameter(0.
f, xAOD::Muon::ParamEnergyLossSigmaPlus);
1310 muon.setParameter(0.
f, xAOD::Muon::ParamEnergyLossSigmaMinus);
1312 muon.setEnergyLossType(xAOD::Muon::Parametrized);
1313 muon.setParameter(0.
f, xAOD::Muon::FSR_CandidateEnergy);
1314 if (m_fillExtraELossInfo) acc_numEnergyLossPerTrack(
muon) = 0;
1319 unsigned int numEnergyLossPerTrack = 0;
1320 bool problem =
false;
1321 for (
const auto* tsos : *tsosVector) {
1323 if (!meot)
continue;
1326 if (!caloEnergy)
continue;
1327 ++numEnergyLossPerTrack;
1329 muon.setParameter(
static_cast<float>(caloEnergy->
deltaE()), xAOD::Muon::EnergyLoss);
1330 muon.setParameter(
static_cast<float>(caloEnergy->
deltaEParam()), xAOD::Muon::ParamEnergyLoss);
1331 muon.setParameter(
static_cast<float>(caloEnergy->
deltaEMeas()), xAOD::Muon::MeasEnergyLoss);
1332 muon.setParameter(
static_cast<float>(caloEnergy->
sigmaDeltaE()), xAOD::Muon::EnergyLossSigma);
1333 muon.setParameter(
static_cast<float>(caloEnergy->
sigmaDeltaEMeas()), xAOD::Muon::MeasEnergyLossSigma);
1337 muon.setEnergyLossType(
static_cast<xAOD::Muon::EnergyLossType
>(caloEnergy->
energyLossType()));
1338 muon.setParameter(
static_cast<float>(caloEnergy->
fsrCandidateEnergy()), xAOD::Muon::FSR_CandidateEnergy);
1340 if (numEnergyLossPerTrack > 1) {
1344 if (m_fillExtraELossInfo) acc_numEnergyLossPerTrack(
muon) = numEnergyLossPerTrack;
1351 if (!
tp || !clusterContainer) {
1357 ATH_MSG_DEBUG(
" Selected track: pt " <<
tp->pt() <<
" eta " <<
tp->eta() <<
" phi " <<
tp->phi());
1365 if (!inputCaloExt) {
1368 std::unique_ptr<Trk::CaloExtension> caloExtension = m_caloExtTool->caloExtension(ctx, *
tp);
1369 if (!caloExtension) {
1374 ATH_MSG_DEBUG(
"Received a caloExtension object without track extrapolation");
1376 cluster = m_cellCollector.collectCells(*caloExtension, caloDDMgr, *container, *clusterContainer);
1378 cluster = m_cellCollector.collectCells(*inputCaloExt, caloDDMgr, *container, *clusterContainer);
1381 ATH_MSG_DEBUG(
"Failed to create cluster from ParticleCellAssociation");
1384 ATH_MSG_DEBUG(
" New cluster: eta " << cluster->
eta() <<
" phi " << cluster->
phi() <<
" cells " << cluster->
size());
1389 muon.setClusterLink(clusterLink);
1391 if (!m_caloNoiseKey.empty()) {
1393 caloNoise = noiseH.
cptr();
1396 std::vector<float> etcore(4, 0);
1397 m_cellCollector.collectEtCore(*cluster, etcore, caloNoise, m_sigmaCaloNoiseCut);
1403 if (m_caloNoiseKey.empty())
1404 ATH_MSG_DEBUG(
"NO Tool for calo noise,sigma: " << m_sigmaCaloNoiseCut);