@@ -2223,13 +2223,31 @@ struct MuonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc
22232223 c.posX (), c.posY (), c.posZ (),
22242224 c.covXX (), c.covYY (), c.covZZ ());
22252225
2226+ bool hasOppositeSignMuonPair = false ;
2227+ std::vector<MuonPair> muonPairs;
2228+ getMuonPairs (collisionInfo, muonPairs);
2229+ for (auto [mchIndex1, mchIndex2] : muonPairs) {
2230+
2231+ int sign1 = muonTracks.rawIteratorAt (mchIndex1).sign ();
2232+ int sign2 = muonTracks.rawIteratorAt (mchIndex2).sign ();
2233+
2234+ // only consider opposite-sign pairs
2235+ if ((sign1 * sign2) < 0 ) {
2236+ hasOppositeSignMuonPair = true ;
2237+ break ;
2238+ }
2239+ }
2240+
22262241 // loop over MCH tracks
22272242 for (const auto & mchIndex : collisionInfo.mchTracks ) {
22282243 auto const & mchTrack = muonTracks.rawIteratorAt (mchIndex);
22292244
2230- // only store good MCH tracks
2231- if (!IsGoodMuon (mchTrack, c, cfgTrackChi2MchUp, 0 .f , cfgPtMchLow, {cfgEtaMftLow, cfgEtaMftUp}, {cfgRabsLow, cfgRabsUp}, fSigmaPdcaUp )) {
2232- continue ;
2245+ // store all MCH tracks when the event contains a muon pair of opposite sign
2246+ if (!hasOppositeSignMuonPair) {
2247+ // only store good MCH tracks
2248+ if (!IsGoodMuon (mchTrack, c, cfgTrackChi2MchUp, 0 .f , cfgPtMchLow, {cfgEtaMftLow, cfgEtaMftUp}, {cfgRabsLow, cfgRabsUp}, fSigmaPdcaUp )) {
2249+ continue ;
2250+ }
22332251 }
22342252
22352253 fwdTable (collId,
@@ -2809,18 +2827,24 @@ struct MuonGlobalAlignment { // o2-linter: disable=name/workflow-file,name/struc
28092827 std::vector<MuonPair> muonPairs;
28102828 getMuonPairs (collisionInfo, muonPairs);
28112829
2812- for (const auto & [mchIndex1, mchIndex2] : muonPairs) {
2830+ for (auto [mchIndex1, mchIndex2] : muonPairs) { // o2-linter: disable=const-ref-in-for-loop (values are modified in loop)
28132831
2814- auto const & muonTrack1 = muonTracks.rawIteratorAt (mchIndex1);
2815- auto const & muonTrack2 = muonTracks.rawIteratorAt (mchIndex2);
2816- int sign1 = muonTrack1.sign ();
2817- int sign2 = muonTrack2.sign ();
2832+ int sign1 = muonTracks.rawIteratorAt (mchIndex1).sign ();
2833+ int sign2 = muonTracks.rawIteratorAt (mchIndex2).sign ();
28182834
28192835 // only consider opposite-sign pairs
28202836 if ((sign1 * sign2) >= 0 ) {
28212837 continue ;
28222838 }
28232839
2840+ // make sure that index #1 corresponds to the positive track
2841+ if (sign1 < 0 ) {
2842+ std::swap (mchIndex1, mchIndex2);
2843+ }
2844+
2845+ auto const & muonTrack1 = muonTracks.rawIteratorAt (mchIndex1);
2846+ auto const & muonTrack2 = muonTracks.rawIteratorAt (mchIndex2);
2847+
28242848 bool isGoodMuon1 = IsGoodMuon (muonTrack1, collision, cfgTrackChi2MchUp, 0 .f , cfgPtMchLow, {cfgEtaMchLow, cfgEtaMchUp}, {cfgRabsLow, cfgRabsUp}, fSigmaPdcaUp );
28252849 bool isGoodMuon2 = IsGoodMuon (muonTrack2, collision, cfgTrackChi2MchUp, 0 .f , cfgPtMchLow, {cfgEtaMchLow, cfgEtaMchUp}, {cfgRabsLow, cfgRabsUp}, fSigmaPdcaUp );
28262850 bool goodMuonTracks = (isGoodMuon1 && isGoodMuon2);
0 commit comments