99// granted to it by virtue of its status as an Intergovernmental Organization
1010// or submit itself to any jurisdiction.
1111//
12- // / \file globalMuonMatching.cxx
13- // / \brief Global muon matching
14- //
12+ // / \file global-muon-matcher.cxx
13+ // / \brief Task for analysis MFT-MCH muon matching
14+ // / \author Andrea Ferrero
15+ // /
1516#include " PWGDQ/Core/MuonMatchingMlResponse.h"
1617#include " PWGDQ/Core/VarManager.h"
1718
5253#include < Math/SMatrix.h>
5354#include < Math/SVector.h>
5455#include < TGeoGlobalMagField.h>
55- #include < TMath.h>
5656
5757#include < algorithm>
5858#include < array>
@@ -96,14 +96,14 @@ namespace globalmuonmatching
9696{
9797DECLARE_SOA_ARRAY_INDEX_COLUMN (GlobalMuonMatchCandidate, globalMuonMatchCandidate); // ! Array of GlobalMuonMatchCandidates indices
9898DECLARE_SOA_INDEX_COLUMN_FULL (FwdTrackRealign, fwdTrackRealign, int , FwdTracksReAlign, " " ); // ! Index of ambiguous FwdTracksReAlign entry
99- DECLARE_SOA_SLICE_INDEX_COLUMN (BC , bc); // ! BC index slice compatible with the track time window
99+ DECLARE_SOA_SLICE_INDEX_COLUMN (Bc , bc); // ! BC index slice compatible with the track time window
100100} // namespace globalmuonmatching
101101
102102DECLARE_SOA_TABLE (FwdTrkMatchCands, " AOD" , " FWDTRKMATCHCAND" , // ! Vectors of match-candidate indices stored per fwdtrack
103103 globalmuonmatching::GlobalMuonMatchCandidateIds, o2::soa::Marker<3 >);
104104
105105DECLARE_SOA_TABLE (AmbiguousFwdTracksReAlign, " AOD" , " AMBIGFWDREALIGN" , // ! FwdTracksReAlign entries without a unique collision association
106- o2::soa::Index<>, globalmuonmatching::FwdTrackRealignId, globalmuonmatching::BCIdSlice );
106+ o2::soa::Index<>, globalmuonmatching::FwdTrackRealignId, globalmuonmatching::BcIdSlice );
107107} // namespace o2::aod
108108
109109using MyEvents = soa::Join<aod::Collisions, aod::EvSels>;
@@ -115,8 +115,8 @@ using SMatrix55Sym = o2::track::SMatrix55Sym;
115115using SMatrix55Std = o2::track::SMatrix55Std;
116116using SMatrix5 = o2::track::SMatrix5;
117117
118- constexpr std::array<int , 10 > fgNDetElemCh = {4 , 4 , 4 , 4 , 18 , 18 , 26 , 26 , 26 , 26 };
119- constexpr std::array<int , 11 > fgSNDetElemCh = {0 , 4 , 8 , 12 , 16 , 34 , 52 , 78 , 104 , 130 , 156 };
118+ constexpr std::array<int , 10 > NDetElemCh = {4 , 4 , 4 , 4 , 18 , 18 , 26 , 26 , 26 , 26 };
119+ constexpr std::array<int , 11 > SNDetElemCh = {0 , 4 , 8 , 12 , 16 , 34 , 52 , 78 , 104 , 130 , 156 };
120120
121121struct GlobalMuonMatching {
122122
@@ -313,7 +313,7 @@ struct GlobalMuonMatching {
313313 Preslice<aod::FwdTrkCls> perMuon = aod::fwdtrkcl::fwdtrackId;
314314
315315 template <class T >
316- o2::mch::TrackParam FwdtoMCH (const T& fwdtrack)
316+ o2::mch::TrackParam fwdToMch (const T& fwdtrack)
317317 {
318318 // Convert Forward Track parameters and covariances matrix to the
319319 // MCH track format.
@@ -323,15 +323,15 @@ struct GlobalMuonMatching {
323323 const double x3 = fwdtrack.getTanl ();
324324 const double x4 = fwdtrack.getInvQPt ();
325325
326- const auto sinx2 = TMath::Sin (x2);
327- const auto cosx2 = TMath::Cos (x2);
326+ const auto sinX2 = std::sin (x2);
327+ const auto cosX2 = std::cos (x2);
328328
329- const double alpha1 = cosx2 / x3;
330- const double alpha3 = sinx2 / x3;
331- const double alpha4 = x4 / TMath::Sqrt (x3 * x3 + sinx2 * sinx2 );
329+ const double alpha1 = cosX2 / x3;
330+ const double alpha3 = sinX2 / x3;
331+ const double alpha4 = x4 / std::sqrt (x3 * x3 + sinX2 * sinX2 );
332332
333- auto K = TMath::Sqrt (x3 * x3 + sinx2 * sinx2 );
334- auto K3 = K * K * K ;
333+ const auto kNorm = std::sqrt (x3 * x3 + sinX2 * sinX2 );
334+ const auto kNorm3 = kNorm * kNorm * kNorm ;
335335
336336 // Covariances matrix conversion
337337 SMatrix55Std jacobian;
@@ -359,17 +359,17 @@ struct GlobalMuonMatching {
359359
360360 jacobian (0 , 0 ) = 1 ;
361361
362- jacobian (1 , 2 ) = -sinx2 / x3;
363- jacobian (1 , 3 ) = -cosx2 / (x3 * x3);
362+ jacobian (1 , 2 ) = -sinX2 / x3;
363+ jacobian (1 , 3 ) = -cosX2 / (x3 * x3);
364364
365365 jacobian (2 , 1 ) = 1 ;
366366
367- jacobian (3 , 2 ) = cosx2 / x3;
368- jacobian (3 , 3 ) = -sinx2 / (x3 * x3);
367+ jacobian (3 , 2 ) = cosX2 / x3;
368+ jacobian (3 , 3 ) = -sinX2 / (x3 * x3);
369369
370- jacobian (4 , 2 ) = -x4 * sinx2 * cosx2 / K3 ;
371- jacobian (4 , 3 ) = -x3 * x4 / K3 ;
372- jacobian (4 , 4 ) = 1 / K ;
370+ jacobian (4 , 2 ) = -x4 * sinX2 * cosX2 / kNorm3 ;
371+ jacobian (4 , 3 ) = -x3 * x4 / kNorm3 ;
372+ jacobian (4 , 4 ) = 1 / kNorm ;
373373 // jacobian*covariances*jacobian^T
374374 covariances = ROOT::Math::Similarity (jacobian, covariances);
375375
@@ -380,7 +380,7 @@ struct GlobalMuonMatching {
380380 return {convertedTrack};
381381 }
382382
383- o2::track::TrackParCovFwd MCHtoFwd (const o2::mch::TrackParam& mchParam)
383+ o2::track::TrackParCovFwd mchToFwd (const o2::mch::TrackParam& mchParam)
384384 {
385385 // Convert a MCH Track parameters and covariances matrix to the
386386 // Forward track format. Must be called after propagation though the absorber
@@ -392,13 +392,13 @@ struct GlobalMuonMatching {
392392 const double alpha3 = mchParam.getBendingSlope ();
393393 const double alpha4 = mchParam.getInverseBendingMomentum ();
394394
395- const double x2 = TMath::ATan2 (-alpha3, -alpha1);
396- const double x3 = -1 . / TMath::Sqrt (alpha3 * alpha3 + alpha1 * alpha1);
397- const double x4 = alpha4 * -x3 * TMath::Sqrt (1 + alpha3 * alpha3);
395+ const double x2 = std::atan2 (-alpha3, -alpha1);
396+ const double x3 = -1 . / std::sqrt (alpha3 * alpha3 + alpha1 * alpha1);
397+ const double x4 = alpha4 * -x3 * std::sqrt (1 + alpha3 * alpha3);
398398
399- auto K = alpha1 * alpha1 + alpha3 * alpha3;
400- auto K32 = K * TMath::Sqrt (K );
401- auto L = TMath::Sqrt (alpha3 * alpha3 + 1 );
399+ const auto kNorm = alpha1 * alpha1 + alpha3 * alpha3;
400+ const auto kNorm32 = kNorm * std::sqrt ( kNorm );
401+ const auto slopeLen = std::sqrt (alpha3 * alpha3 + 1 );
402402
403403 // Covariances matrix conversion
404404 SMatrix55Std jacobian;
@@ -428,15 +428,15 @@ struct GlobalMuonMatching {
428428
429429 jacobian (1 , 2 ) = 1 ;
430430
431- jacobian (2 , 1 ) = -alpha3 / K ;
432- jacobian (2 , 3 ) = alpha1 / K ;
431+ jacobian (2 , 1 ) = -alpha3 / kNorm ;
432+ jacobian (2 , 3 ) = alpha1 / kNorm ;
433433
434- jacobian (3 , 1 ) = alpha1 / K32 ;
435- jacobian (3 , 3 ) = alpha3 / K32 ;
434+ jacobian (3 , 1 ) = alpha1 / kNorm32 ;
435+ jacobian (3 , 3 ) = alpha3 / kNorm32 ;
436436
437- jacobian (4 , 1 ) = -alpha1 * alpha4 * L / K32 ;
438- jacobian (4 , 3 ) = alpha3 * alpha4 * (1 / (TMath::Sqrt (K ) * L ) - L / K32 );
439- jacobian (4 , 4 ) = L / TMath::Sqrt (K );
437+ jacobian (4 , 1 ) = -alpha1 * alpha4 * slopeLen / kNorm32 ;
438+ jacobian (4 , 3 ) = alpha3 * alpha4 * (1 / (std::sqrt ( kNorm ) * slopeLen ) - slopeLen / kNorm32 );
439+ jacobian (4 , 4 ) = slopeLen / std::sqrt ( kNorm );
440440
441441 // jacobian*covariances*jacobian^T
442442 covariances = ROOT::Math::Similarity (jacobian, covariances);
@@ -454,43 +454,43 @@ struct GlobalMuonMatching {
454454 return convertedTrack;
455455 }
456456
457- int GetDetElemId (int iDetElemNumber)
457+ int getDetElemId (int iDetElemNumber)
458458 {
459459 // make sure detector number is valid
460- if (iDetElemNumber < fgSNDetElemCh [0 ] ||
461- iDetElemNumber >= fgSNDetElemCh [NMchChambers]) {
460+ if (iDetElemNumber < SNDetElemCh [0 ] ||
461+ iDetElemNumber >= SNDetElemCh [NMchChambers]) {
462462 LOGF (fatal, " Invalid detector element number: %d" , iDetElemNumber);
463463 }
464464 // / get det element number from ID
465465 // get chamber and element number in chamber
466466 int iCh = 0 ;
467467 int iDet = 0 ;
468468 for (int i = 1 ; i <= NMchChambers; i++) {
469- if (iDetElemNumber < fgSNDetElemCh [i]) {
469+ if (iDetElemNumber < SNDetElemCh [i]) {
470470 iCh = i;
471- iDet = iDetElemNumber - fgSNDetElemCh [i - 1 ];
471+ iDet = iDetElemNumber - SNDetElemCh [i - 1 ];
472472 break ;
473473 }
474474 }
475475
476476 // make sure detector index is valid
477- if (iCh <= 0 || iCh > NMchChambers || iDet >= fgNDetElemCh [iCh - 1 ]) {
477+ if (iCh <= 0 || iCh > NMchChambers || iDet >= NDetElemCh [iCh - 1 ]) {
478478 LOGF (fatal, " Invalid detector element id: %d" , MchDetElemNumberingBase * iCh + iDet);
479479 }
480480
481481 // add number of detectors up to this chamber
482482 return MchDetElemNumberingBase * iCh + iDet;
483483 }
484484
485- bool RemoveTrack (mch::Track& track)
485+ bool removeTrack (mch::Track& track)
486486 {
487487 // Refit track with re-aligned clusters
488- bool removeTrack = false ;
488+ bool shouldRemoveTrack = false ;
489489 try {
490490 trackFitter.fit (track, false );
491491 } catch (std::exception const & e) {
492- removeTrack = true ;
493- return removeTrack ;
492+ shouldRemoveTrack = true ;
493+ return shouldRemoveTrack ;
494494 }
495495
496496 auto itStartingParam = std::prev (track.rend ());
@@ -500,7 +500,7 @@ struct GlobalMuonMatching {
500500 try {
501501 trackFitter.fit (track, true , false , (itStartingParam == track.rbegin ()) ? nullptr : &itStartingParam);
502502 } catch (std::exception const &) {
503- removeTrack = true ;
503+ shouldRemoveTrack = true ;
504504 break ;
505505 }
506506
@@ -522,7 +522,7 @@ struct GlobalMuonMatching {
522522 }
523523
524524 if (!itWorstParam->isRemovable ()) {
525- removeTrack = true ;
525+ shouldRemoveTrack = true ;
526526 track.removable ();
527527 break ;
528528 }
@@ -532,7 +532,7 @@ struct GlobalMuonMatching {
532532 itStartingParam = track.rbegin ();
533533
534534 if (track.getNClusters () < MinRemovableTrackClusters) {
535- removeTrack = true ;
535+ shouldRemoveTrack = true ;
536536 break ;
537537 }
538538 while (itNextToNextParam != track.end ()) {
@@ -544,14 +544,14 @@ struct GlobalMuonMatching {
544544 }
545545 }
546546
547- if (!removeTrack ) {
547+ if (!shouldRemoveTrack ) {
548548 for (auto & param : track) { // o2-linter: disable=const-ref-in-for-loop (object is modified in loop)
549549 param.setParameters (param.getSmoothParameters ());
550550 param.setCovariances (param.getSmoothCovariances ());
551551 }
552552 }
553553
554- return removeTrack ;
554+ return shouldRemoveTrack ;
555555 }
556556
557557 template <typename BC >
@@ -586,7 +586,7 @@ struct GlobalMuonMatching {
586586 LOGF (fatal, " Reference aligned geometry object is not available in CCDB at timestamp=%llu" , bc.timestamp ());
587587 }
588588 for (int i = 0 ; i < NMchDetElems; i++) {
589- int iDEN = GetDetElemId (i);
589+ int iDEN = getDetElemId (i);
590590 transformRef[iDEN] = transformation (iDEN);
591591 }
592592
@@ -600,7 +600,7 @@ struct GlobalMuonMatching {
600600 LOGF (fatal, " New aligned geometry object is not available in CCDB at timestamp=%llu" , bc.timestamp ());
601601 }
602602 for (int i = 0 ; i < NMchDetElems; i++) {
603- int iDEN = GetDetElemId (i);
603+ int iDEN = getDetElemId (i);
604604 transformNew[iDEN] = transformation (iDEN);
605605 }
606606
@@ -936,17 +936,17 @@ struct GlobalMuonMatching {
936936 using o2::aod::fwdtrack::ForwardTrackTypeEnum;
937937 using o2::aod::fwdtrackutils::propagationPoint;
938938
939- constexpr uint8_t candidateTrackType = static_cast <uint8_t >(ForwardTrackTypeEnum::GlobalForwardTrack);
939+ constexpr uint8_t CandidateTrackType = static_cast <uint8_t >(ForwardTrackTypeEnum::GlobalForwardTrack);
940940
941- auto propmuonAtMft = FwdtoMCH (mchPar);
941+ auto propmuonAtMft = fwdToMch (mchPar);
942942 o2::mch::TrackExtrap::extrapToVertex (propmuonAtMft,
943943 mftPar.getX (),
944944 mftPar.getY (),
945945 mftPar.getZ (),
946946 mftPar.getSigma2X (),
947947 mftPar.getSigma2Y ());
948948
949- const auto globalMuonRefit = o2::aod::fwdtrackutils::refitGlobalMuonCov (MCHtoFwd (propmuonAtMft), mftPar);
949+ const auto globalMuonRefit = o2::aod::fwdtrackutils::refitGlobalMuonCov (mchToFwd (propmuonAtMft), mftPar);
950950
951951 const auto nClusters = static_cast <int8_t >(std::min (127 , mchPar.getNClusters () + mftPar.getNClusters ()));
952952
@@ -971,7 +971,7 @@ struct GlobalMuonMatching {
971971
972972 gmCandidateFwdTracks (
973973 collisionId,
974- candidateTrackType ,
974+ CandidateTrackType ,
975975 globalMuonRefit.getX (),
976976 globalMuonRefit.getY (),
977977 globalMuonRefit.getZ (),
@@ -1003,7 +1003,7 @@ struct GlobalMuonMatching {
10031003
10041004 o2::track::TrackParCovFwd propagateToZMch (const o2::track::TrackParCovFwd& muon, const double z)
10051005 {
1006- auto mchTrack = FwdtoMCH (muon);
1006+ auto mchTrack = fwdToMch (muon);
10071007
10081008 float absFront = -90 .f ;
10091009 float absBack = -505 .f ;
@@ -1016,7 +1016,7 @@ struct GlobalMuonMatching {
10161016 o2::mch::TrackExtrap::extrapToZCov (mchTrack, z);
10171017 }
10181018
1019- return MCHtoFwd (mchTrack);
1019+ return mchToFwd (mchTrack);
10201020 }
10211021
10221022 o2::track::TrackParCovFwd propagateToZMft (const o2::track::TrackParCovFwd& mftTrack, const double z)
@@ -1030,14 +1030,14 @@ struct GlobalMuonMatching {
10301030 o2::track::TrackParCovFwd propagateToVertexMch (const TMCH & muon,
10311031 const C& collision)
10321032 {
1033- auto mchTrack = FwdtoMCH (fwdtrackutils::getTrackParCovFwd (muon, muon));
1033+ auto mchTrack = fwdToMch (fwdtrackutils::getTrackParCovFwd (muon, muon));
10341034 o2::mch::TrackExtrap::extrapToVertex (mchTrack,
10351035 collision.posX (),
10361036 collision.posY (),
10371037 collision.posZ (),
10381038 collision.covXX (),
10391039 collision.covYY ());
1040- return MCHtoFwd (mchTrack);
1040+ return mchToFwd (mchTrack);
10411041 }
10421042
10431043 // tag muons based on the track quality and the track position at the front and back MFT planes
@@ -1206,9 +1206,9 @@ struct GlobalMuonMatching {
12061206 }
12071207
12081208 template <typename TMFT , typename TMFTCOV >
1209- o2::track::TrackParCovFwd TransformMFT (TMFT & mftTrack, TMFTCOV const & mftTrackCov)
1209+ o2::track::TrackParCovFwd transformMft (TMFT & mftTrack, TMFTCOV const & mftTrackCov)
12101210 {
1211- auto track = FwdtoMCH (fwdtrackutils::getTrackParCovFwd (mftTrack, mftTrackCov));
1211+ auto track = fwdToMch (fwdtrackutils::getTrackParCovFwd (mftTrack, mftTrackCov));
12121212
12131213 double z = track.getZ ();
12141214 // double dZ = zMCH - z;
@@ -1232,7 +1232,7 @@ struct GlobalMuonMatching {
12321232 track.setBendingCoor (y + yCorrection);
12331233 track.setBendingSlope (ySlope + ySlopeCorrection);
12341234
1235- return MCHtoFwd (track);
1235+ return mchToFwd (track);
12361236 }
12371237
12381238 template <typename TMFTs, typename TMFTCOVs>
@@ -1245,7 +1245,7 @@ struct GlobalMuonMatching {
12451245 }
12461246
12471247 auto const & mftTrackCov = mftCovs.rawIteratorAt (mftTrackCovs[mftTrackIndex]);
1248- mMftTrackPars [mftTrackIndex] = TransformMFT (mftTrack, mftTrackCov);
1248+ mMftTrackPars [mftTrackIndex] = transformMft (mftTrack, mftTrackCov);
12491249 }
12501250 }
12511251
@@ -1289,8 +1289,8 @@ struct GlobalMuonMatching {
12891289 clusterMCH->y = master.y ();
12901290 clusterMCH->z = master.z ();
12911291
1292- uint32_t ClUId = mch::Cluster::buildUniqueId (static_cast <int >(cluster.deId () / 100 ) - 1 , cluster.deId (), clIndex);
1293- clusterMCH->uid = ClUId ;
1292+ const uint32_t clUid = mch::Cluster::buildUniqueId (static_cast <int >(cluster.deId () / 100 ) - 1 , cluster.deId (), clIndex);
1293+ clusterMCH->uid = clUid ;
12941294 clusterMCH->ex = cluster.isGoodX () ? 0.2 : 10.0 ;
12951295 clusterMCH->ey = cluster.isGoodY () ? 0.2 : 10.0 ;
12961296
@@ -1303,7 +1303,7 @@ struct GlobalMuonMatching {
13031303 // Refit the re-aligned track
13041304 int removable = 0 ;
13051305 if (convertedTrack.getNClusters () != 0 ) {
1306- removable = RemoveTrack (convertedTrack);
1306+ removable = removeTrack (convertedTrack);
13071307 } else {
13081308 LOGF (fatal, " Muon track %d has no associated clusters." , muon.globalIndex ());
13091309 }
@@ -1312,7 +1312,7 @@ struct GlobalMuonMatching {
13121312 mch::TrackParam trackParam = mch::TrackParam (convertedTrack.first ());
13131313
13141314 // Convert MCH track to FWD track and store new parameters after realignment
1315- mchTrackParIt->second = MCHtoFwd (mch::TrackParam (convertedTrack.first ()));
1315+ mchTrackParIt->second = mchToFwd (mch::TrackParam (convertedTrack.first ()));
13161316 mchTrackParIt->second .setTrackChi2 (trackParam.getTrackChi2 () / convertedTrack.getNDF ());
13171317 mchTrackParIt->second .setNClusters (convertedTrack.getNClusters ());
13181318 if (removable) {
0 commit comments