diff --git a/PWGDQ/Tasks/muonGlobalAlignment.cxx b/PWGDQ/Tasks/muonGlobalAlignment.cxx index e8a85c3555c..cdc3fe7cd79 100644 --- a/PWGDQ/Tasks/muonGlobalAlignment.cxx +++ b/PWGDQ/Tasks/muonGlobalAlignment.cxx @@ -2334,14 +2334,6 @@ struct MuonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc continue; } - collTable(collisionInfo.runNumber, - collisionInfo.globalBC, - collisionInfo.timestamp, - c.posX(), c.posY(), c.posZ(), - c.covXX(), c.covYY(), c.covZZ(), - c.collisionTime(), c.collisionTimeRes()); - collisionIdRemapping[collisionIndex] = remappedCollisionIndex; - bool hasGoodOppositeSignMuonPair = false; std::vector muonPairs; getMuonPairs(collisionInfo, muonPairs); @@ -2391,14 +2383,10 @@ struct MuonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc } // loop over MCH tracks + int nMchTracksStored = 0; for (const auto& mchIndex : collisionInfo.mchTracks) { auto const& mchTrack = muonTracks.rawIteratorAt(mchIndex); - // skip tracks that have already been stored from another compatible collision - if (muonTrackIdRemapping.contains(mchIndex)) { - continue; - } - // skip tracks without associated collision (this should never be true here) if (!mchTrack.has_collision()) { continue; @@ -2414,6 +2402,13 @@ struct MuonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc } } + nMchTracksStored += 1; + + // skip tracks that have already been stored from another compatible collision + if (muonTrackIdRemapping.contains(mchIndex)) { + continue; + } + fwdTable(remappedCollisionIndex, mchTrack.trackType(), mchTrack.x(), mchTrack.y(), mchTrack.z(), @@ -2494,6 +2489,17 @@ struct MuonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc } } + if (nMchTracksStored < 1) { + continue; + } + + collTable(collisionInfo.runNumber, + collisionInfo.globalBC, + collisionInfo.timestamp, + c.posX(), c.posY(), c.posZ(), + c.covXX(), c.covYY(), c.covZZ(), + c.collisionTime(), c.collisionTimeRes()); + collisionIdRemapping[collisionIndex] = remappedCollisionIndex; remappedCollisionIndex += 1; }