37 return StatusCode::SUCCESS;
49 return StatusCode::SUCCESS;
53 return StatusCode::SUCCESS;
55 if (!muonTruthSegments.isValid()) {
57 return StatusCode::FAILURE;
59 if (!segments.isValid()) {
61 return StatusCode::FAILURE;
66 return StatusCode::FAILURE;
68 if (truthTrackCol->
empty()) {
70 return StatusCode::SUCCESS;
74 auto ppos = truthSegmentContainerName.find(
'.');
75 truthSegmentContainerName.resize(
std::min(ppos,truthSegmentContainerName.size()));
77 ppos = segmentCollectionName.find(
'.');
78 segmentCollectionName.resize(
std::min(ppos,segmentCollectionName.size()));
80 std::vector<const Muon::MuonSegment*> muonSegments;
81 typedef std::map<const Muon::MuonSegment*, ElementLink<xAOD::MuonSegmentContainer> > MuonSegmentLinkMap;
82 MuonSegmentLinkMap muonSegmentLinkMap;
83 unsigned int segIndex = 0;
84 muonSegments.reserve(segments->size());
85 for (
const auto *
const seg : *segments) {
87 if (seg->muonSegment().isValid()) {
91 muonSegments.push_back(mseg);
99 std::vector<const MuonSimDataCollection*> muonSimData;
101 if (!simDataMap.isValid()) {
105 if (!simDataMap.isPresent())
continue;
106 muonSimData.push_back(simDataMap.cptr());
111 if (!cscSimDataMap.
isValid()) {
116 cscSimDataMap.
cptr());
121 ATH_MSG_DEBUG(
"Matching reconstructed segments " << muonSegments.size());
125 std::map<Muon::MuonStationIndex::ChIndex, std::vector<ElementLink<xAOD::MuonSegmentContainer> > > chamberTruthSegmentLinks;
127 for (
const auto *
const truthSegment : *muonTruthSegments) {
129 std::vector<ElementLink<xAOD::MuonSegmentContainer> >& linkVec = chamberTruthSegmentLinks[truthSegment->chamberIndex()];
130 linkVec.emplace_back(truthSegmentContainerName, segIndex);
132 <<
" nlinks " << linkVec.size() <<
" link " << *linkVec.back());
138 std::set<Muon::MuonStationIndex::ChIndex> chambers;
139 std::vector<std::pair<Muon::MuonStationIndex::ChIndex, const TrackRecord*> > chamberTruthVec;
140 for (
const auto&
result : segmentMatchResult) {
143 if (!
result.second.truthTrack)
continue;
148 if (!
result.second.mdts.matchedHits.empty())
id = *
result.second.mdts.matchedHits.begin();
149 if (!
result.second.cscs.matchedHits.empty())
id = *
result.second.cscs.matchedHits.begin();
150 if (!
result.second.stgcs.matchedHits.empty())
id = *
result.second.stgcs.matchedHits.begin();
151 if (!
result.second.mms.matchedHits.empty())
id = *
result.second.mms.matchedHits.begin();
152 if (!
id.is_valid())
continue;
155 auto pos = chambers.insert(chIndex);
160 for (
const auto&
index : chamberTruthVec) {
171 std::pair<Muon::MuonStationIndex::ChIndex, const TrackRecord*> chPair;
172 chPair.first = chIndex;
173 chPair.second =
result.second.truthTrack;
174 chamberTruthVec.push_back(chPair);
177 auto segPos = muonSegmentLinkMap.find(
result.first);
178 if (segPos == muonSegmentLinkMap.end()) {
190 auto truthPos = chamberTruthSegmentLinks.find(chIndex);
191 if (truthPos == chamberTruthSegmentLinks.end())
continue;
193 << truthPos->second.size());
195 for (
auto& truthSegLink : truthPos->second) {
197 truthSegLink.toPersistent();
205 truthParticleLinkAcc(
"truthParticleLink");
206 if (!truthParticleLinkAcc.
isAvailable(*truthSegment)) {
211 truthParticleLinkAcc(*truthSegment);
213 if (!truthParticle) {
223 muonTruthSegments(*truthSegment) = recoLink;
224 segments(*recoSegment) = truthSegLink;
230 return StatusCode::SUCCESS;