diff --git a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx index 2f96571ae61..7466a973bcb 100644 --- a/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx +++ b/PWGLF/TableProducer/Nuspex/decay3bodybuilder.cxx @@ -75,7 +75,7 @@ using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; -o2::common::core::MetadataHelper metadataInfo; +o2::common::core::MetadataHelper metadataInfo{}; static constexpr int nParameters = 1; static const std::vector tableNames{ @@ -220,31 +220,31 @@ struct decay3bodyBuilder { // Helper struct to contain MC information prior to filling struct mc3Bodyinfo { - int label; - std::array genDecVtx{0.f}; - std::array genMomentum{0.f}; - float genCt; - float genPhi; - float genEta; - float genRapidity; - std::array genMomProton{0.f}; - std::array genMomPion{0.f}; - std::array genMomDeuteron{0.f}; - bool isReco; - int motherLabel; - int motherPdgCode; - int daughterPrPdgCode; - int daughterPiPdgCode; - int daughterDePdgCode; - bool isDeuteronPrimary; - bool survivedEventSel; + int label = -1; + std::array genDecVtx{-1.f, -1.f, -1.f}; + std::array genMomentum{-1.f, -1.f, -1.f}; + float genCt = -1.f; + float genPhi = -1.f; + float genEta = -1.f; + float genRapidity = -1.f; + std::array genMomProton{-1.f, -1.f, -1.f}; + std::array genMomPion{-1.f, -1.f, -1.f}; + std::array genMomDeuteron{-1.f, -1.f, -1.f}; + bool isReco = false; + int motherLabel = -1; + int motherPdgCode = -1; + int daughterPrPdgCode = -1; + int daughterPiPdgCode = -1; + int daughterDePdgCode = -1; + bool isDeuteronPrimary = false; + bool survivedEventSel = false; }; mc3Bodyinfo this3BodyMCInfo; // CCDB and magnetic field - int mRunNumber; - float d_bz; - Service ccdb; + int mRunNumber = 0; + float d_bz = 0.f; + Service ccdb{}; o2::base::Propagator::MatCorrType matCorr = o2::base::Propagator::MatCorrType::USEMatCorrNONE; std::unordered_map ccdbCache; // Maps runNumber -> d_bz o2::base::MatLayerCylSet* lut = nullptr; @@ -379,7 +379,7 @@ struct decay3bodyBuilder { // list enabled tables for (int i = 0; i < nTables; i++) { - if (mEnabledTables[i]) { + if (mEnabledTables[i] != 0) { LOGF(info, " -~> Table enabled: %s", tableNames[i]); } } @@ -433,26 +433,26 @@ struct decay3bodyBuilder { } } - if (mEnabledTables[kVtx3BodyDatas] && mEnabledTables[kMcVtx3BodyDatas]) { + if (mEnabledTables[kVtx3BodyDatas] != 0 && mEnabledTables[kMcVtx3BodyDatas] != 0) { LOG(fatal) << "Tables Vtx3BodyDatas and McVtx3BodyDatas cannot both be enabled at the same time. Choose one!"; } // Add histograms separately for different process functions - if (doprocessRealData == true || doprocessMonteCarlo == true) { + if (doprocessRealData || doprocessMonteCarlo) { auto hEventCounter = registry.add("Counters/hEventCounter", "hEventCounter", HistType::kTH1D, {{2, 0.0f, 2.0f}}); hEventCounter->GetXaxis()->SetBinLabel(1, "all"); hEventCounter->GetXaxis()->SetBinLabel(2, "selected"); hEventCounter->LabelsOption("v"); } - if (doprocessMonteCarlo == true) { + if (doprocessMonteCarlo) { auto hMcEventCounter = registry.add("Counters/hMcEventCounter", "hMcEventCounter", HistType::kTH1D, {{2, 0.0f, 2.0f}}); hMcEventCounter->GetXaxis()->SetBinLabel(1, "all"); hMcEventCounter->GetXaxis()->SetBinLabel(2, "reconstructed"); hMcEventCounter->LabelsOption("v"); } - if (doprocessRealData == true || doprocessRealDataReduced == true || doprocessMonteCarlo == true) { + if (doprocessRealData || doprocessRealDataReduced || doprocessMonteCarlo) { if (doTrackQA) { // histograms for all daughter tracks of (selected) 3body candidates registry.add("QA/Tracks/hTrackProtonTPCNcls", "hTrackProtonTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}); registry.add("QA/Tracks/hTrackPionTPCNcls", "hTrackPionTPCNcls", HistType::kTH1F, {{152, 0, 152, "# TPC clusters"}}); @@ -482,7 +482,7 @@ struct decay3bodyBuilder { } } - if (doprocessRealDataReduced3bodyMixing == true) { + if (doprocessRealDataReduced3bodyMixing) { auto h3bodyCombinationCounter = registry.add("Mixing/h3bodyCombinationCounter", "h3bodyCombinationCounter", HistType::kTH1D, {{4, 0.0f, 4.0f}}); h3bodyCombinationCounter->GetXaxis()->SetBinLabel(1, "total"); h3bodyCombinationCounter->GetXaxis()->SetBinLabel(2, "not same collision"); @@ -513,7 +513,7 @@ struct decay3bodyBuilder { } auto timestamp = bc.timestamp(); - o2::parameters::GRPMagField* grpmag = 0x0; + o2::parameters::GRPMagField* grpmag = nullptr; ccdb->clearCache(ccdbConfigurations.grpmagPath); grpmag = ccdb->getSpecific(ccdbConfigurations.grpmagPath, timestamp); if (!grpmag) { @@ -521,7 +521,7 @@ struct decay3bodyBuilder { } o2::base::Propagator::initFieldFromGRP(grpmag); // Fetch magnetic field from ccdb for current collision - auto d_bz = o2::base::Propagator::Instance()->getNominalBz(); + d_bz = o2::base::Propagator::Instance()->getNominalBz(); LOG(info) << "Retrieved GRP for timestamp " << timestamp << " with magnetic field of " << d_bz << " kG"; // set magnetic field value for DCA fitter @@ -550,9 +550,9 @@ struct decay3bodyBuilder { float getMagFieldFromRunNumber(int runNumber) { - float magField; + float magField{}; // Check if the CCDB data for this run is already cached - if (ccdbCache.find(runNumber) != ccdbCache.end()) { + if (ccdbCache.contains(runNumber)) { LOG(debug) << "CCDB data already cached for run " << runNumber; magField = ccdbCache[runNumber]; // if not, retrieve it from CCDB @@ -729,10 +729,10 @@ struct decay3bodyBuilder { auto trackPion = protonSign > 0 ? trackNeg : trackPos; // get deuteron TOF PID - float tofNSigmaDeuteron; + float tofNSigmaDeuteron{}; if constexpr (!soa::is_table) { // running over derived data tofNSigmaDeuteron = trackDeuteron.tofNSigmaDe(); - } else if constexpr (soa::is_table) { // running over AO2Ds + } else { // running over AO2Ds if constexpr (soa::is_table) { // running over MC (track table with labels) tofNSigmaDeuteron = getTOFnSigma(mRespParamsV3, collision, trackDeuteron); } else { // running over real data @@ -803,11 +803,10 @@ struct decay3bodyBuilder { if (!trackProton.has_mcParticle() || !trackPion.has_mcParticle() || !trackDeuteron.has_mcParticle()) { if (!doStoreMcBkg) { continue; // if not storing MC background, skip candidates where at least one daughter is not matched to MC particle - } else { - this3BodyMCInfo.motherLabel = -5; // at least one of the daughters not matched to MC particle - // fill analysis table (only McVtx3BodyDatas is filled here) - fillAnalysisTables(); } + this3BodyMCInfo.motherLabel = -5; // at least one of the daughters not matched to MC particle + // fill analysis table (only McVtx3BodyDatas is filled here) + fillAnalysisTables(); } else { // all daughters are matched to MC particles, get their MC info // get MC daughter particles auto mcTrackProton = trackProton.template mcParticle_as(); @@ -880,18 +879,24 @@ struct decay3bodyBuilder { bool haveProton = false, havePion = false, haveDeuteron = false; bool haveAntiProton = false, haveAntiPion = false, haveAntiDeuteron = false; for (const auto& mcparticleDaughter : mcparticle.template daughters_as()) { - if (mcparticleDaughter.pdgCode() == PDG_t::kProton) + if (mcparticleDaughter.pdgCode() == PDG_t::kProton) { haveProton = true; - if (mcparticleDaughter.pdgCode() == PDG_t::kProtonBar) + } + if (mcparticleDaughter.pdgCode() == PDG_t::kProtonBar) { haveAntiProton = true; - if (mcparticleDaughter.pdgCode() == PDG_t::kPiPlus) + } + if (mcparticleDaughter.pdgCode() == PDG_t::kPiPlus) { havePion = true; - if (mcparticleDaughter.pdgCode() == PDG_t::kPiMinus) + } + if (mcparticleDaughter.pdgCode() == PDG_t::kPiMinus) { haveAntiPion = true; - if (mcparticleDaughter.pdgCode() == o2::constants::physics::Pdg::kDeuteron) + } + if (mcparticleDaughter.pdgCode() == o2::constants::physics::Pdg::kDeuteron) { haveDeuteron = true; - if (mcparticleDaughter.pdgCode() == -o2::constants::physics::Pdg::kDeuteron) + } + if (mcparticleDaughter.pdgCode() == -o2::constants::physics::Pdg::kDeuteron) { haveAntiDeuteron = true; + } } // check if hypertriton decayed via 3-body decay and is particle or anti-particle @@ -1077,13 +1082,13 @@ struct decay3bodyBuilder { void fillAnalysisTables() { // generate analysis tables - if (mEnabledTables[kDecay3BodyIndices]) { + if (mEnabledTables[kDecay3BodyIndices] != 0) { products.decay3bodyindices(helper.decay3body.decay3bodyID, helper.decay3body.protonID, helper.decay3body.pionID, helper.decay3body.deuteronID, helper.decay3body.collisionID); registry.fill(HIST("Counters/hTableBuildingStatistics"), kDecay3BodyIndices); } - if (mEnabledTables[kVtx3BodyDatas]) { + if (mEnabledTables[kVtx3BodyDatas] != 0) { products.vtx3bodydatas(helper.decay3body.sign, helper.decay3body.mass, helper.decay3body.massV0, helper.decay3body.position[0], helper.decay3body.position[1], helper.decay3body.position[2], @@ -1109,14 +1114,14 @@ struct decay3bodyBuilder { helper.decay3body.pidForTrackingDeuteron); registry.fill(HIST("Counters/hTableBuildingStatistics"), kVtx3BodyDatas); } - if (mEnabledTables[kVtx3BodyCovs]) { + if (mEnabledTables[kVtx3BodyCovs] != 0) { products.vtx3bodycovs(helper.decay3body.covProton.data(), helper.decay3body.covPion.data(), helper.decay3body.covDeuteron.data(), helper.decay3body.covariance.data()); registry.fill(HIST("Counters/hTableBuildingStatistics"), kVtx3BodyCovs); } - if (mEnabledTables[kMcVtx3BodyDatas]) { + if (mEnabledTables[kMcVtx3BodyDatas] != 0) { products.mcvtx3bodydatas(helper.decay3body.sign, helper.decay3body.mass, helper.decay3body.massV0, helper.decay3body.position[0], helper.decay3body.position[1], helper.decay3body.position[2], @@ -1182,9 +1187,8 @@ struct decay3bodyBuilder { // fill analysis tables with built candidate fillAnalysisTables(); return; - } else { - return; } + return; } // ______________________________________________________________ @@ -1259,9 +1263,8 @@ struct decay3bodyBuilder { // check if the common mother is a hypertriton if (std::abs(momPdgCode) == o2::constants::physics::Pdg::kHyperTriton) { return momID; - } else { - return -1; // common mother found but not a hypertriton } + return -1; // common mother found but not a hypertriton } // ______________________________________________________________ @@ -1339,7 +1342,7 @@ struct decay3bodyBuilder { auto yAxis = registry.get(HIST("Mixing/hDecay3BodyRadiusPhi"))->GetYaxis(); for (const auto& decay3body : decay3bodys) { - int bin_Radius, bin_Phi; + int bin_Radius{}, bin_Phi{}; if (decay3bodyBuilderOpts.useKFParticle) { bin_Radius = xAxis->FindBin(decay3body.radiusKF()); bin_Phi = yAxis->FindBin(decay3body.phiKF()); diff --git a/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx b/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx index a9931b9d051..d63be90ba45 100644 --- a/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx +++ b/PWGLF/TableProducer/Nuspex/trackedHypertritonRecoTask.cxx @@ -228,7 +228,7 @@ struct TrackedHypertritonRecoTask { bool isSignal = false; bool isRecoMCCollision = false; bool survivedEventSelection = false; - uint8_t fakeHeITSLayerMap = 0; + uint8_t fakeHeITSLayerMap{}; int motherLabel = -1; int statusCode = 0; }; @@ -779,7 +779,7 @@ struct TrackedHypertritonRecoTask { } template - std::array getItsTrackDCAToSV(TTracked3body tracked3Body) + std::array getItsTrackDCAToSV(TTracked3body const& tracked3Body) { const auto itsTrack = tracked3Body.template itsTrack_as(); auto itsTrackParCov = getTrackParCov(itsTrack);