Skip to content

Commit 1789b38

Browse files
committed
[PWGDQ] fix linter errors
1 parent 5c29360 commit 1789b38

1 file changed

Lines changed: 76 additions & 66 deletions

File tree

PWGDQ/Tasks/mftMchMatcher.cxx

Lines changed: 76 additions & 66 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@
1111
//
1212
/// \file mftMchMatcher.cxx
1313
/// \brief MFT-MCH matching tool for data preparation
14+
/// \author Andrea Ferrero <andrea.ferrero@cern.ch>
15+
/// \author Marice Coquet <maurice.louis.coquet@cern.ch>
16+
/// \author Nivendra Ramasubramanian <niv.ram@cern.ch>
17+
/// \author Yoshini Bailung <yoshini.bailung@cern.ch>
1418

1519
#include "PWGDQ/Core/VarManager.h"
1620

@@ -218,43 +222,47 @@ DECLARE_SOA_TABLE(FwdMatchMLCandidates, "AOD", "FWDMLCAND",
218222
} // namespace o2::aod
219223

220224
struct mftMchMatcher {
225+
static constexpr int GlobalTrackTypeMax = 2;
226+
static constexpr int ThetaAbsBoundaryDeg = 3;
227+
static constexpr double SlopeResolutionZ = 535.;
228+
221229
Produces<o2::aod::FwdMatchMLCandidates> fwdMatchMLCandidates;
222230
//// Variables for selecting muon tracks
223-
Configurable<float> fPMchLow{"cfgPMchLow", 0.0f, ""};
224-
Configurable<float> fPtMchLow{"cfgPtMchLow", 0.7f, ""};
225-
Configurable<float> fEtaMchLow{"cfgEtaMchLow", -4.0f, ""};
226-
Configurable<float> fEtaMchUp{"cfgEtaMchUp", -2.5f, ""};
227-
Configurable<float> fRabsLow{"cfgRabsLow", 17.6f, ""};
228-
Configurable<float> fRabsUp{"cfgRabsUp", 89.5f, ""};
229-
Configurable<float> fSigmaPdcaUp{"cfgPdcaUp", 6.f, ""};
230-
Configurable<float> fTrackChi2MchUp{"cfgTrackChi2MchUp", 5.f, ""};
231-
Configurable<float> fMatchingChi2MchMidUp{"cfgMatchingChi2MchMidUp", 999.f, ""};
231+
Configurable<float> cfgPMchLow{"cfgPMchLow", 0.0f, ""};
232+
Configurable<float> cfgPtMchLow{"cfgPtMchLow", 0.7f, ""};
233+
//Configurable<float> cfgEtaMchLow{"cfgEtaMchLow", -4.0f, ""};
234+
//Configurable<float> cfgEtaMchUp{"cfgEtaMchUp", -2.5f, ""};
235+
Configurable<float> cfgRabsLow{"cfgRabsLow", 17.6f, ""};
236+
Configurable<float> cfgRabsUp{"cfgRabsUp", 89.5f, ""};
237+
Configurable<float> cfgPdcaUp{"cfgPdcaUp", 6.f, ""};
238+
Configurable<float> cfgTrackChi2MchUp{"cfgTrackChi2MchUp", 5.f, ""};
239+
//Configurable<float> cfgMatchingChi2MchMidUp{"cfgMatchingChi2MchMidUp", 999.f, ""};
232240

233241
//// Variables for selecting mft tracks
234-
Configurable<float> fEtaMFTLow{"cfgEtaMFTlow", -3.6f, ""};
235-
Configurable<float> fEtaMFTUp{"cfgEtaMFTup", -2.5f, ""};
236-
Configurable<float> fTrackChi2MFTUp{"cfgTrackChi2MFTUp", 10.f, ""};
237-
Configurable<float> fPtMFTLow{"cfgPtMFTLow", 0.1f, ""};
242+
Configurable<float> cfgEtaMFTlow{"cfgEtaMFTlow", -3.6f, ""};
243+
Configurable<float> cfgEtaMFTup{"cfgEtaMFTup", -2.5f, ""};
244+
//Configurable<float> cfgTrackChi2MFTUp{"cfgTrackChi2MFTUp", 10.f, ""};
245+
//Configurable<float> cfgPtMFTLow{"cfgPtMFTLow", 0.1f, ""};
238246

239247
//// Variables for matching configuration
240-
Configurable<int> fMaxCandidates{"cfgMaxCandidates", 0, ""};
241-
242-
Configurable<bool> fKeepBestMatch{"cfgKeepBestMatch", false, "Keep only the best match global muons in the skimming"};
243-
Configurable<float> fzMatching{"cfgzMatching", -77.5f, "Plane for MFT-MCH matching"};
244-
245-
Configurable<float> fSamplingFraction{"cfgSamplingFraction", 1.f, "Fraction of randomly selected events to be processed"};
246-
Configurable<float> fSamplingFractionTrueLeadingMatches{"cfgSamplingFractionTrueLeadingMatches", 1.f, "Fraction of randomly selected leading true matches to be processed"};
247-
Configurable<float> fSamplingFractionWrongLeadingMatches{"cfgSamplingFractionWrongLeadingMatches", 1.f, "Fraction of randomly selected leading wrong matches to be processed"};
248-
Configurable<float> fSamplingFractionDecayLeadingMatches{"cfgSamplingFractionDecayLeadingMatches", 1.f, "Fraction of randomly selected leading decay matches to be processed"};
249-
Configurable<float> fSamplingFractionFakeLeadingMatches{"cfgSamplingFractionFakeLeadingMatches", 1.f, "Fraction of randomly selected leading fake matches to be processed"};
250-
Configurable<float> fSamplingFractionTrueNonLeadingMatches{"cfgSamplingFractionTrueNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading true matches to be processed"};
251-
Configurable<float> fSamplingFractionWrongNonLeadingMatches{"cfgSamplingFractionWrongNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading wrong matches to be processed"};
252-
Configurable<float> fSamplingFractionDecayNonLeadingMatches{"cfgSamplingFractionDecayNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading decay matches to be processed"};
253-
Configurable<float> fSamplingFractionFakeNonLeadingMatches{"cfgSamplingFractionFakeNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading fake matches to be processed"};
254-
Configurable<int> fSamplingBcOddness{"cfgSamplingBcOddness", -1, "Select only events with even (0) or odd (1) global BCs"};
248+
//Configurable<int> cfgMaxCandidates{"cfgMaxCandidates", 0, ""};
249+
250+
Configurable<bool> cfgKeepBestMatch{"cfgKeepBestMatch", false, "Keep only the best match global muons in the skimming"};
251+
Configurable<float> cfgzMatching{"cfgzMatching", -77.5f, "Plane for MFT-MCH matching"};
252+
253+
Configurable<float> cfgSamplingFraction{"cfgSamplingFraction", 1.f, "Fraction of randomly selected events to be processed"};
254+
Configurable<float> cfgSamplingFractionTrueLeadingMatches{"cfgSamplingFractionTrueLeadingMatches", 1.f, "Fraction of randomly selected leading true matches to be processed"};
255+
Configurable<float> cfgSamplingFractionWrongLeadingMatches{"cfgSamplingFractionWrongLeadingMatches", 1.f, "Fraction of randomly selected leading wrong matches to be processed"};
256+
Configurable<float> cfgSamplingFractionDecayLeadingMatches{"cfgSamplingFractionDecayLeadingMatches", 1.f, "Fraction of randomly selected leading decay matches to be processed"};
257+
Configurable<float> cfgSamplingFractionFakeLeadingMatches{"cfgSamplingFractionFakeLeadingMatches", 1.f, "Fraction of randomly selected leading fake matches to be processed"};
258+
Configurable<float> cfgSamplingFractionTrueNonLeadingMatches{"cfgSamplingFractionTrueNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading true matches to be processed"};
259+
Configurable<float> cfgSamplingFractionWrongNonLeadingMatches{"cfgSamplingFractionWrongNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading wrong matches to be processed"};
260+
Configurable<float> cfgSamplingFractionDecayNonLeadingMatches{"cfgSamplingFractionDecayNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading decay matches to be processed"};
261+
Configurable<float> cfgSamplingFractionFakeNonLeadingMatches{"cfgSamplingFractionFakeNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading fake matches to be processed"};
262+
Configurable<int> cfgSamplingBcOddness{"cfgSamplingBcOddness", -1, "Select only events with even (0) or odd (1) global BCs"};
255263

256264
//// Variables for ccdb
257-
Configurable<std::string> ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
265+
Configurable<std::string> ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
258266
Configurable<std::string> grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"};
259267
Configurable<std::string> grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
260268
Configurable<std::string> geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
@@ -314,7 +322,9 @@ struct mftMchMatcher {
314322
static const double relPRes = 0.0004;
315323
static const double slopeRes = 0.0005;
316324

317-
double thetaAbs = TMath::ATan(mchTrack.rAtAbsorberEnd() / 505.) * TMath::RadToDeg();
325+
constexpr double AbsorberEndZ = 505.;
326+
constexpr double RadToDeg = 180. / o2::constants::math::PI;
327+
double thetaAbs = std::atan(mchTrack.rAtAbsorberEnd() / AbsorberEndZ) * RadToDeg;
318328

319329
// propagate muon track to vertex
320330
auto trackConv = VarManager::FwdToTrackPar(mchTrack, mchTrack);
@@ -329,17 +339,17 @@ struct mftMchMatcher {
329339
double p = mchTrackAtVertex.p();
330340

331341
double pDCA = mchTrack.pDca();
332-
double sigmaPDCA = (thetaAbs < 3) ? sigmaPDCA23 : sigmaPDCA310;
342+
double sigmaPDCA = (thetaAbs < ThetaAbsBoundaryDeg) ? sigmaPDCA23 : sigmaPDCA310;
333343
double nrp = nSigmaPDCA * relPRes * p;
334344
double pResEffect = sigmaPDCA / (1. - nrp / (1. + nrp));
335-
double slopeResEffect = 535. * slopeRes * p;
336-
double sigmaPDCAWithRes = TMath::Sqrt(pResEffect * pResEffect + slopeResEffect * slopeResEffect);
345+
double slopeResEffect = SlopeResolutionZ * slopeRes * p;
346+
double sigmaPDCAWithRes = std::sqrt(pResEffect * pResEffect + slopeResEffect * slopeResEffect);
337347

338348
return (pDCA <= nSigmaPDCA * sigmaPDCAWithRes);
339349
}
340350

341351
template <class T, class C>
342-
bool IsGoodMuon(const T& mchTrack, const C& collision,
352+
bool isGoodMuon(const T& mchTrack, const C& collision,
343353
double chi2Cut,
344354
double pCut,
345355
double pTCut,
@@ -383,7 +393,7 @@ struct mftMchMatcher {
383393
}
384394

385395
template <class T>
386-
bool IsGoodMFT(const T& mftTrack,
396+
bool isGoodMFT(const T& mftTrack,
387397
double chi2Cut,
388398
double pTCut,
389399
std::array<double, 2> etaCut)
@@ -427,18 +437,18 @@ struct mftMchMatcher {
427437
void init(o2::framework::InitContext&)
428438
{
429439
// Load geometry
430-
ccdbManager->setURL(ccdburl);
440+
ccdbManager->setURL(ccdbUrl);
431441
ccdbManager->setCaching(true);
432442
ccdbManager->setLocalObjectValidityChecking();
433-
fCCDBApi.init(ccdburl);
443+
fCCDBApi.init(ccdbUrl);
434444
mRunNumber = 0;
435445

436446
if (!o2::base::GeometryManager::isGeometryLoaded()) {
437447
LOGF(info, "Load geometry from CCDB");
438448
ccdbManager->get<TGeoManager>(geoPath);
439449
}
440450

441-
if (fSamplingFraction < 1.0) {
451+
if (cfgSamplingFraction < 1.0) {
442452
std::random_device rd;
443453
mGenerator = std::mt19937(rd());
444454
}
@@ -476,7 +486,7 @@ struct mftMchMatcher {
476486
fBestMatch.clear();
477487
std::unordered_map<int, std::pair<float, int>> mCandidates;
478488
for (const auto& muon : muons) {
479-
if (static_cast<int>(muon.trackType()) < 2) {
489+
if (static_cast<int>(muon.trackType()) < GlobalTrackTypeMax) {
480490
auto muonID = muon.matchMCHTrackId();
481491
auto chi2 = muon.chi2MatchMCHMFT();
482492
if (mCandidates.find(muonID) == mCandidates.end()) {
@@ -501,7 +511,7 @@ struct mftMchMatcher {
501511
// outer loop on muon tracks
502512
for (const auto& muonTrack : muonTracks) {
503513
// only consider MCH standalone or MCH-MID matches
504-
if (static_cast<int>(muonTrack.trackType()) <= 2) {
514+
if (static_cast<int>(muonTrack.trackType()) <= GlobalTrackTypeMax) {
505515
continue;
506516
}
507517

@@ -585,7 +595,7 @@ struct mftMchMatcher {
585595
{
586596
MuonMatchType result{kMatchTypeUndefined};
587597

588-
if (static_cast<int>(muonTrack.trackType()) > 2) {
598+
if (static_cast<int>(muonTrack.trackType()) > GlobalTrackTypeMax) {
589599
return result;
590600
}
591601

@@ -656,9 +666,9 @@ struct mftMchMatcher {
656666

657667
registry.get<TH1>(HIST("acceptedEvents"))->Fill(0);
658668
// reject a randomly selected fraction of events
659-
if (fSamplingFraction < 1.0) {
669+
if (cfgSamplingFraction < 1.0) {
660670
double rnd = mDistribution(mGenerator);
661-
if (rnd > fSamplingFraction) {
671+
if (rnd > cfgSamplingFraction) {
662672
return;
663673
}
664674
}
@@ -688,41 +698,41 @@ struct mftMchMatcher {
688698

689699
bool isBestMatch = fBestMatch.find(muon.globalIndex()) != fBestMatch.end();
690700

691-
if (fKeepBestMatch && !isBestMatch) {
701+
if (cfgKeepBestMatch && !isBestMatch) {
692702
continue;
693703
}
694704

695705
const auto& collision = collisions.rawIteratorAt(muon.collisionId());
696-
auto bc_coll = collision.template bc_as<TBCS>();
706+
auto bcColl = collision.template bc_as<TBCS>();
697707

698708
auto muontrack = muon.template matchMCHTrack_as<TMUONS>();
699709
auto mfttrack = muon.template matchMFTTrack_as<TMFTS>();
700710
auto const& mfttrackcov = mftCovs.rawIteratorAt(mftCovIndexes[mfttrack.globalIndex()]);
701711

702-
auto muonTime = muontrack.trackTime() + bc_coll.globalBC() * o2::constants::lhc::LHCBunchSpacingNS;
703-
auto mftTime = mfttrack.trackTime() + bc_coll.globalBC() * o2::constants::lhc::LHCBunchSpacingNS;
712+
auto muonTime = muontrack.trackTime() + bcColl.globalBC() * o2::constants::lhc::LHCBunchSpacingNS;
713+
auto mftTime = mfttrack.trackTime() + bcColl.globalBC() * o2::constants::lhc::LHCBunchSpacingNS;
704714

705715
o2::track::TrackParCovFwd mftprop = VarManager::FwdToTrackPar(mfttrack, mfttrackcov);
706716
o2::dataformats::GlobalFwdTrack muonprop = trackToGlobalFwd(muontrack, muontrack);
707-
if (fzMatching.value < 0.) {
708-
mftprop = VarManager::PropagateFwd(mfttrack, mfttrackcov, fzMatching.value);
717+
if (cfgzMatching.value < 0.) {
718+
mftprop = VarManager::PropagateFwd(mfttrack, mfttrackcov, cfgzMatching.value);
709719
muonprop = VarManager::PropagateMuon(muontrack, collision, VarManager::kToMatching);
710720
}
711721
auto muonpropCov = muonprop.getCovariances();
712722
auto mftpropCov = mftprop.getCovariances();
713723

714-
if (!IsGoodMuon(muontrack, collision, fTrackChi2MchUp, fPMchLow, fPtMchLow, {fEtaMFTLow, fEtaMFTUp}, {fRabsLow, fRabsUp}, fSigmaPdcaUp)) {
724+
if (!isGoodMuon(muontrack, collision, cfgTrackChi2MchUp, cfgPMchLow, cfgPtMchLow, {cfgEtaMFTlow, cfgEtaMFTup}, {cfgRabsLow, cfgRabsUp}, cfgPdcaUp)) {
715725
continue;
716726
}
717727

718728
// at this level we consider all the matching candidates, regardless of the MFT tracks quality
719729
// MFT track quality cuts should be applied only after having selected the best candidate
720-
// if (!IsGoodMFT(mfttrack, fTrackChi2MFTUp, fPtMFTLow, {fEtaMFTLow, fEtaMFTUp})){
730+
// if (!isGoodMFT(mfttrack, cfgTrackChi2MFTUp, cfgPtMFTLow, {cfgEtaMFTlow, cfgEtaMFTup})){
721731
// continue;
722732
//}
723733

724-
bool IsAmbig = (muon.compatibleCollIds().size() != 1);
725-
int MFTMult = collision.mftNtracks();
734+
bool isAmbig = (muon.compatibleCollIds().size() != 1);
735+
int mftMult = collision.mftNtracks();
726736
int matchAttempts = 0;
727737
auto matchAttemptsIt = matchAttemptsMap.find(muontrack.globalIndex());
728738
if (matchAttemptsIt == matchAttemptsMap.end()) {
@@ -750,35 +760,35 @@ struct mftMchMatcher {
750760
registry.get<TH1>(HIST("matchType"))->Fill(static_cast<int>(matchType));
751761

752762
// skipp odd/even BCs if requested
753-
if (fSamplingBcOddness.value >= 0 && (static_cast<int>((bc_coll.globalBC() % 2)) != fSamplingBcOddness.value)) {
763+
if (cfgSamplingBcOddness.value >= 0 && (static_cast<int>((bcColl.globalBC() % 2)) != cfgSamplingBcOddness.value)) {
754764
continue;
755765
}
756766

757767
float matchTypeSamplingFraction = 1.0;
758768
switch (matchType) {
759769
case kMatchTypeTrueLeading:
760-
matchTypeSamplingFraction = fSamplingFractionTrueLeadingMatches;
770+
matchTypeSamplingFraction = cfgSamplingFractionTrueLeadingMatches;
761771
break;
762772
case kMatchTypeTrueNonLeading:
763-
matchTypeSamplingFraction = fSamplingFractionTrueNonLeadingMatches;
773+
matchTypeSamplingFraction = cfgSamplingFractionTrueNonLeadingMatches;
764774
break;
765775
case kMatchTypeWrongLeading:
766-
matchTypeSamplingFraction = fSamplingFractionWrongLeadingMatches;
776+
matchTypeSamplingFraction = cfgSamplingFractionWrongLeadingMatches;
767777
break;
768778
case kMatchTypeWrongNonLeading:
769-
matchTypeSamplingFraction = fSamplingFractionWrongNonLeadingMatches;
779+
matchTypeSamplingFraction = cfgSamplingFractionWrongNonLeadingMatches;
770780
break;
771781
case kMatchTypeDecayLeading:
772-
matchTypeSamplingFraction = fSamplingFractionDecayLeadingMatches;
782+
matchTypeSamplingFraction = cfgSamplingFractionDecayLeadingMatches;
773783
break;
774784
case kMatchTypeDecayNonLeading:
775-
matchTypeSamplingFraction = fSamplingFractionDecayNonLeadingMatches;
785+
matchTypeSamplingFraction = cfgSamplingFractionDecayNonLeadingMatches;
776786
break;
777787
case kMatchTypeFakeLeading:
778-
matchTypeSamplingFraction = fSamplingFractionFakeLeadingMatches;
788+
matchTypeSamplingFraction = cfgSamplingFractionFakeLeadingMatches;
779789
break;
780790
case kMatchTypeFakeNonLeading:
781-
matchTypeSamplingFraction = fSamplingFractionFakeNonLeadingMatches;
791+
matchTypeSamplingFraction = cfgSamplingFractionFakeNonLeadingMatches;
782792
break;
783793
default:
784794
break;
@@ -848,8 +858,8 @@ struct mftMchMatcher {
848858
muon.chi2MatchMCHMFT(),
849859
muon.fwdDcaX(),
850860
muon.fwdDcaY(),
851-
IsAmbig,
852-
MFTMult,
861+
isAmbig,
862+
mftMult,
853863
matchAttempts,
854864
mcMaskMuon,
855865
mcMaskMft,
@@ -869,7 +879,7 @@ struct mftMchMatcher {
869879
if (bcs.size() > 0) {
870880
auto bc = bcs.begin();
871881
initCCDB(bc);
872-
VarManager::SetMatchingPlane(fzMatching.value);
882+
VarManager::SetMatchingPlane(cfgzMatching.value);
873883
}
874884

875885
fillTable<true>(collisions, bcs, muonTracks, mftTracks, mftCovs);
@@ -886,7 +896,7 @@ struct mftMchMatcher {
886896
if (bcs.size() > 0) {
887897
auto bc = bcs.begin();
888898
initCCDB(bc);
889-
VarManager::SetMatchingPlane(fzMatching.value);
899+
VarManager::SetMatchingPlane(cfgzMatching.value);
890900
}
891901

892902
fillTable<false>(collisions, bcs, muonTracks, mftTracks, mftCovs);

0 commit comments

Comments
 (0)