Skip to content

Commit d412958

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

1 file changed

Lines changed: 75 additions & 73 deletions

File tree

PWGDQ/Tasks/mftMchMatcher.cxx

Lines changed: 75 additions & 73 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

@@ -78,7 +82,7 @@ using namespace std;
7882

7983
using SMatrix55 = ROOT::Math::SMatrix<double, 5, 5, ROOT::Math::MatRepSym<double, 5>>;
8084
using SMatrix55Std = ROOT::Math::SMatrix<double, 5>;
81-
using SMatrix5 = ROOT::Math::SVector<Double_t, 5>;
85+
using SMatrix5 = ROOT::Math::SVector<Double_t, 5>; // o2-linter: disable=root/entity (ROOT object is needed)
8286

8387
namespace o2::aod
8488
{
@@ -143,10 +147,10 @@ DECLARE_SOA_COLUMN(C1PtTglMFT, c1PtTglMFT, float);
143147
DECLARE_SOA_COLUMN(Chi2Glob, chi2Glob, float);
144148
DECLARE_SOA_COLUMN(Chi2Match, chi2Match, float);
145149
DECLARE_SOA_COLUMN(IsAmbig, isAmbig, bool);
146-
DECLARE_SOA_COLUMN(MFTMult, mftMult, int);
150+
DECLARE_SOA_COLUMN(MFTMult, mftMult, int); // o2-linter: disable=name/o2-column (keep temporarily)
147151
DECLARE_SOA_COLUMN(MatchAttempts, matchAttempts, int);
148-
DECLARE_SOA_COLUMN(DCAX, dcaX, float);
149-
DECLARE_SOA_COLUMN(DCAY, dcaY, float);
152+
DECLARE_SOA_COLUMN(DCAX, dcaX, float); // o2-linter: disable=name/o2-column (keep temporarily)
153+
DECLARE_SOA_COLUMN(DCAY, dcaY, float); // o2-linter: disable=name/o2-column (keep temporarily)
150154
DECLARE_SOA_COLUMN(McMaskGlob, mcMaskGlob, int);
151155
DECLARE_SOA_COLUMN(MatchLabel, matchLabel, int);
152156
DECLARE_SOA_COLUMN(IsSignal, isSignal, bool);
@@ -217,44 +221,40 @@ DECLARE_SOA_TABLE(FwdMatchMLCandidates, "AOD", "FWDMLCAND",
217221
fwdmatchcandidates::IsSignal);
218222
} // namespace o2::aod
219223

220-
struct mftMchMatcher {
224+
struct mftMchMatcher { // o2-linter: disable=name/struct (keep temporarily)
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> cfgRabsLow{"cfgRabsLow", 17.6f, ""};
234+
Configurable<float> cfgRabsUp{"cfgRabsUp", 89.5f, ""};
235+
Configurable<float> cfgPdcaUp{"cfgPdcaUp", 6.f, ""};
236+
Configurable<float> cfgTrackChi2MchUp{"cfgTrackChi2MchUp", 5.f, ""};
232237

233238
//// 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, ""};
238-
239-
//// 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"};
239+
Configurable<float> cfgEtaMFTlow{"cfgEtaMFTlow", -3.6f, ""};
240+
Configurable<float> cfgEtaMFTup{"cfgEtaMFTup", -2.5f, ""};
241+
242+
Configurable<bool> cfgKeepBestMatch{"cfgKeepBestMatch", false, "Keep only the best match global muons in the skimming"};
243+
Configurable<float> cfgzMatching{"cfgzMatching", -77.5f, "Plane for MFT-MCH matching"};
244+
245+
Configurable<float> cfgSamplingFraction{"cfgSamplingFraction", 1.f, "Fraction of randomly selected events to be processed"};
246+
Configurable<float> cfgSamplingFractionTrueLeadingMatches{"cfgSamplingFractionTrueLeadingMatches", 1.f, "Fraction of randomly selected leading true matches to be processed"};
247+
Configurable<float> cfgSamplingFractionWrongLeadingMatches{"cfgSamplingFractionWrongLeadingMatches", 1.f, "Fraction of randomly selected leading wrong matches to be processed"};
248+
Configurable<float> cfgSamplingFractionDecayLeadingMatches{"cfgSamplingFractionDecayLeadingMatches", 1.f, "Fraction of randomly selected leading decay matches to be processed"};
249+
Configurable<float> cfgSamplingFractionFakeLeadingMatches{"cfgSamplingFractionFakeLeadingMatches", 1.f, "Fraction of randomly selected leading fake matches to be processed"};
250+
Configurable<float> cfgSamplingFractionTrueNonLeadingMatches{"cfgSamplingFractionTrueNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading true matches to be processed"};
251+
Configurable<float> cfgSamplingFractionWrongNonLeadingMatches{"cfgSamplingFractionWrongNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading wrong matches to be processed"};
252+
Configurable<float> cfgSamplingFractionDecayNonLeadingMatches{"cfgSamplingFractionDecayNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading decay matches to be processed"};
253+
Configurable<float> cfgSamplingFractionFakeNonLeadingMatches{"cfgSamplingFractionFakeNonLeadingMatches", 1.f, "Fraction of randomly selected non-leading fake matches to be processed"};
254+
Configurable<int> cfgSamplingBcOddness{"cfgSamplingBcOddness", -1, "Select only events with even (0) or odd (1) global BCs"};
255255

256256
//// Variables for ccdb
257-
Configurable<std::string> ccdburl{"ccdb-url", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
257+
Configurable<std::string> ccdbUrl{"ccdbUrl", "http://alice-ccdb.cern.ch", "url of the ccdb repository"};
258258
Configurable<std::string> grpPath{"grpPath", "GLO/GRP/GRP", "Path of the grp file"};
259259
Configurable<std::string> grpmagPath{"grpmagPath", "GLO/Config/GRPMagField", "CCDB path of the GRPMagField object"};
260260
Configurable<std::string> geoPath{"geoPath", "GLO/Config/GeometryAligned", "Path of the geometry file"};
@@ -314,7 +314,9 @@ struct mftMchMatcher {
314314
static const double relPRes = 0.0004;
315315
static const double slopeRes = 0.0005;
316316

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

319321
// propagate muon track to vertex
320322
auto trackConv = VarManager::FwdToTrackPar(mchTrack, mchTrack);
@@ -329,17 +331,17 @@ struct mftMchMatcher {
329331
double p = mchTrackAtVertex.p();
330332

331333
double pDCA = mchTrack.pDca();
332-
double sigmaPDCA = (thetaAbs < 3) ? sigmaPDCA23 : sigmaPDCA310;
334+
double sigmaPDCA = (thetaAbs < ThetaAbsBoundaryDeg) ? sigmaPDCA23 : sigmaPDCA310;
333335
double nrp = nSigmaPDCA * relPRes * p;
334336
double pResEffect = sigmaPDCA / (1. - nrp / (1. + nrp));
335-
double slopeResEffect = 535. * slopeRes * p;
336-
double sigmaPDCAWithRes = TMath::Sqrt(pResEffect * pResEffect + slopeResEffect * slopeResEffect);
337+
double slopeResEffect = SlopeResolutionZ * slopeRes * p;
338+
double sigmaPDCAWithRes = std::sqrt(pResEffect * pResEffect + slopeResEffect * slopeResEffect);
337339

338340
return (pDCA <= nSigmaPDCA * sigmaPDCAWithRes);
339341
}
340342

341343
template <class T, class C>
342-
bool IsGoodMuon(const T& mchTrack, const C& collision,
344+
bool isGoodMuon(const T& mchTrack, const C& collision,
343345
double chi2Cut,
344346
double pCut,
345347
double pTCut,
@@ -383,7 +385,7 @@ struct mftMchMatcher {
383385
}
384386

385387
template <class T>
386-
bool IsGoodMFT(const T& mftTrack,
388+
bool isGoodMFT(const T& mftTrack,
387389
double chi2Cut,
388390
double pTCut,
389391
std::array<double, 2> etaCut)
@@ -427,18 +429,18 @@ struct mftMchMatcher {
427429
void init(o2::framework::InitContext&)
428430
{
429431
// Load geometry
430-
ccdbManager->setURL(ccdburl);
432+
ccdbManager->setURL(ccdbUrl);
431433
ccdbManager->setCaching(true);
432434
ccdbManager->setLocalObjectValidityChecking();
433-
fCCDBApi.init(ccdburl);
435+
fCCDBApi.init(ccdbUrl);
434436
mRunNumber = 0;
435437

436438
if (!o2::base::GeometryManager::isGeometryLoaded()) {
437439
LOGF(info, "Load geometry from CCDB");
438440
ccdbManager->get<TGeoManager>(geoPath);
439441
}
440442

441-
if (fSamplingFraction < 1.0) {
443+
if (cfgSamplingFraction < 1.0) {
442444
std::random_device rd;
443445
mGenerator = std::mt19937(rd());
444446
}
@@ -476,7 +478,7 @@ struct mftMchMatcher {
476478
fBestMatch.clear();
477479
std::unordered_map<int, std::pair<float, int>> mCandidates;
478480
for (const auto& muon : muons) {
479-
if (static_cast<int>(muon.trackType()) < 2) {
481+
if (static_cast<int>(muon.trackType()) < GlobalTrackTypeMax) {
480482
auto muonID = muon.matchMCHTrackId();
481483
auto chi2 = muon.chi2MatchMCHMFT();
482484
if (mCandidates.find(muonID) == mCandidates.end()) {
@@ -501,7 +503,7 @@ struct mftMchMatcher {
501503
// outer loop on muon tracks
502504
for (const auto& muonTrack : muonTracks) {
503505
// only consider MCH standalone or MCH-MID matches
504-
if (static_cast<int>(muonTrack.trackType()) <= 2) {
506+
if (static_cast<int>(muonTrack.trackType()) <= GlobalTrackTypeMax) {
505507
continue;
506508
}
507509

@@ -585,7 +587,7 @@ struct mftMchMatcher {
585587
{
586588
MuonMatchType result{kMatchTypeUndefined};
587589

588-
if (static_cast<int>(muonTrack.trackType()) > 2) {
590+
if (static_cast<int>(muonTrack.trackType()) > GlobalTrackTypeMax) {
589591
return result;
590592
}
591593

@@ -656,9 +658,9 @@ struct mftMchMatcher {
656658

657659
registry.get<TH1>(HIST("acceptedEvents"))->Fill(0);
658660
// reject a randomly selected fraction of events
659-
if (fSamplingFraction < 1.0) {
661+
if (cfgSamplingFraction < 1.0) {
660662
double rnd = mDistribution(mGenerator);
661-
if (rnd > fSamplingFraction) {
663+
if (rnd > cfgSamplingFraction) {
662664
return;
663665
}
664666
}
@@ -688,41 +690,41 @@ struct mftMchMatcher {
688690

689691
bool isBestMatch = fBestMatch.find(muon.globalIndex()) != fBestMatch.end();
690692

691-
if (fKeepBestMatch && !isBestMatch) {
693+
if (cfgKeepBestMatch && !isBestMatch) {
692694
continue;
693695
}
694696

695697
const auto& collision = collisions.rawIteratorAt(muon.collisionId());
696-
auto bc_coll = collision.template bc_as<TBCS>();
698+
auto bcColl = collision.template bc_as<TBCS>();
697699

698700
auto muontrack = muon.template matchMCHTrack_as<TMUONS>();
699701
auto mfttrack = muon.template matchMFTTrack_as<TMFTS>();
700702
auto const& mfttrackcov = mftCovs.rawIteratorAt(mftCovIndexes[mfttrack.globalIndex()]);
701703

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

705707
o2::track::TrackParCovFwd mftprop = VarManager::FwdToTrackPar(mfttrack, mfttrackcov);
706708
o2::dataformats::GlobalFwdTrack muonprop = trackToGlobalFwd(muontrack, muontrack);
707-
if (fzMatching.value < 0.) {
708-
mftprop = VarManager::PropagateFwd(mfttrack, mfttrackcov, fzMatching.value);
709+
if (cfgzMatching.value < 0.) {
710+
mftprop = VarManager::PropagateFwd(mfttrack, mfttrackcov, cfgzMatching.value);
709711
muonprop = VarManager::PropagateMuon(muontrack, collision, VarManager::kToMatching);
710712
}
711713
auto muonpropCov = muonprop.getCovariances();
712714
auto mftpropCov = mftprop.getCovariances();
713715

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

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

724-
bool IsAmbig = (muon.compatibleCollIds().size() != 1);
725-
int MFTMult = collision.mftNtracks();
726+
bool isAmbig = (muon.compatibleCollIds().size() != 1);
727+
int mftMult = collision.mftNtracks();
726728
int matchAttempts = 0;
727729
auto matchAttemptsIt = matchAttemptsMap.find(muontrack.globalIndex());
728730
if (matchAttemptsIt == matchAttemptsMap.end()) {
@@ -750,35 +752,35 @@ struct mftMchMatcher {
750752
registry.get<TH1>(HIST("matchType"))->Fill(static_cast<int>(matchType));
751753

752754
// skipp odd/even BCs if requested
753-
if (fSamplingBcOddness.value >= 0 && (static_cast<int>((bc_coll.globalBC() % 2)) != fSamplingBcOddness.value)) {
755+
if (cfgSamplingBcOddness.value >= 0 && (static_cast<int>((bcColl.globalBC() % 2)) != cfgSamplingBcOddness.value)) {
754756
continue;
755757
}
756758

757759
float matchTypeSamplingFraction = 1.0;
758760
switch (matchType) {
759761
case kMatchTypeTrueLeading:
760-
matchTypeSamplingFraction = fSamplingFractionTrueLeadingMatches;
762+
matchTypeSamplingFraction = cfgSamplingFractionTrueLeadingMatches;
761763
break;
762764
case kMatchTypeTrueNonLeading:
763-
matchTypeSamplingFraction = fSamplingFractionTrueNonLeadingMatches;
765+
matchTypeSamplingFraction = cfgSamplingFractionTrueNonLeadingMatches;
764766
break;
765767
case kMatchTypeWrongLeading:
766-
matchTypeSamplingFraction = fSamplingFractionWrongLeadingMatches;
768+
matchTypeSamplingFraction = cfgSamplingFractionWrongLeadingMatches;
767769
break;
768770
case kMatchTypeWrongNonLeading:
769-
matchTypeSamplingFraction = fSamplingFractionWrongNonLeadingMatches;
771+
matchTypeSamplingFraction = cfgSamplingFractionWrongNonLeadingMatches;
770772
break;
771773
case kMatchTypeDecayLeading:
772-
matchTypeSamplingFraction = fSamplingFractionDecayLeadingMatches;
774+
matchTypeSamplingFraction = cfgSamplingFractionDecayLeadingMatches;
773775
break;
774776
case kMatchTypeDecayNonLeading:
775-
matchTypeSamplingFraction = fSamplingFractionDecayNonLeadingMatches;
777+
matchTypeSamplingFraction = cfgSamplingFractionDecayNonLeadingMatches;
776778
break;
777779
case kMatchTypeFakeLeading:
778-
matchTypeSamplingFraction = fSamplingFractionFakeLeadingMatches;
780+
matchTypeSamplingFraction = cfgSamplingFractionFakeLeadingMatches;
779781
break;
780782
case kMatchTypeFakeNonLeading:
781-
matchTypeSamplingFraction = fSamplingFractionFakeNonLeadingMatches;
783+
matchTypeSamplingFraction = cfgSamplingFractionFakeNonLeadingMatches;
782784
break;
783785
default:
784786
break;
@@ -848,8 +850,8 @@ struct mftMchMatcher {
848850
muon.chi2MatchMCHMFT(),
849851
muon.fwdDcaX(),
850852
muon.fwdDcaY(),
851-
IsAmbig,
852-
MFTMult,
853+
isAmbig,
854+
mftMult,
853855
matchAttempts,
854856
mcMaskMuon,
855857
mcMaskMft,
@@ -869,7 +871,7 @@ struct mftMchMatcher {
869871
if (bcs.size() > 0) {
870872
auto bc = bcs.begin();
871873
initCCDB(bc);
872-
VarManager::SetMatchingPlane(fzMatching.value);
874+
VarManager::SetMatchingPlane(cfgzMatching.value);
873875
}
874876

875877
fillTable<true>(collisions, bcs, muonTracks, mftTracks, mftCovs);
@@ -886,7 +888,7 @@ struct mftMchMatcher {
886888
if (bcs.size() > 0) {
887889
auto bc = bcs.begin();
888890
initCCDB(bc);
889-
VarManager::SetMatchingPlane(fzMatching.value);
891+
VarManager::SetMatchingPlane(cfgzMatching.value);
890892
}
891893

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

0 commit comments

Comments
 (0)