From d671cf8f387f6e63627610c9eed857b797452c21 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 14:03:06 +0200 Subject: [PATCH 01/14] Try-catch for 3-prong secondary-vertexing + monitoring tools. --- .../TableProducer/candidateCreator3Prong.cxx | 20 +++++++- PWGHF/Utils/utilsTrkCandHf.h | 46 +++++++++++++++++++ 2 files changed, 64 insertions(+), 2 deletions(-) create mode 100644 PWGHF/Utils/utilsTrkCandHf.h diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index 84ff29f1876..a6afd518a21 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -30,10 +30,12 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::analysis; using namespace o2::hf_evsel; +using namespace o2::hf_trkcandsel; using namespace o2::aod::hf_cand_3prong; using namespace o2::aod::hf_collision_centrality; using namespace o2::constants::physics; @@ -90,7 +92,7 @@ struct HfCandidateCreator3Prong { // filter candidates Filter filterSelected3Prongs = (createDplus && (o2::aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_3prong::DecayType::DplusToPiKPi))) != static_cast(0)) || (createDs && (o2::aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_3prong::DecayType::DsToKKPi))) != static_cast(0)) || (createLc && (o2::aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_3prong::DecayType::LcToPKPi))) != static_cast(0)) || (createXic && (o2::aod::hf_track_index::hfflag & static_cast(BIT(aod::hf_cand_3prong::DecayType::XicToPKPi))) != static_cast(0)); - std::shared_ptr hCollisions, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel; + std::shared_ptr hCollisions, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel, hCandidates; HistogramRegistry registry{"registry"}; void init(InitContext const&) @@ -142,6 +144,7 @@ struct HfCandidateCreator3Prong { hPosXAfterEvSel = registry.add("hPosXAfterEvSel", "selected events;#it{x}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{200, -0.5, 0.5}}}); hPosYAfterEvSel = registry.add("hPosYAfterEvSel", "selected events;#it{y}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{200, -0.5, 0.5}}}); hNumPvContributorsAfterSel = registry.add("hNumPvContributorsAfterSel", "selected events;#it{y}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{500, -0.5, 499.5}}}); + hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); massPi = MassPiPlus; massK = MassKPlus; @@ -164,6 +167,9 @@ struct HfCandidateCreator3Prong { /// collision monitoring setLabelHistoEvSel(hCollisions); + + /// candidate monitoring + setLabelHistoCands(hCandidates); } template @@ -206,9 +212,19 @@ struct HfCandidateCreator3Prong { df.setBz(bz); // reconstruct the 3-prong secondary vertex - if (df.process(trackParVar0, trackParVar1, trackParVar2) == 0) { + hCandidates->Fill(SVFitting::BeforeFit); + try { + if (df.process(trackParVar0, trackParVar1, trackParVar2) == 0) { + continue; + } + } + catch(const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidates->Fill(SVFitting::Fail); continue; } + hCandidates->Fill(SVFitting::FitOk); + const auto& secondaryVertex = df.getPCACandidate(); auto chi2PCA = df.getChi2AtPCACandidate(); auto covMatrixPCA = df.calcPCACovMatrixFlat(); diff --git a/PWGHF/Utils/utilsTrkCandHf.h b/PWGHF/Utils/utilsTrkCandHf.h new file mode 100644 index 00000000000..90f63ec56a0 --- /dev/null +++ b/PWGHF/Utils/utilsTrkCandHf.h @@ -0,0 +1,46 @@ +// Copyright 2019-2020 CERN and copyright holders of ALICE O2. +// See https://alice-o2.web.cern.ch/copyright for details of the copyright holders. +// All rights not expressly granted are reserved. +// +// This software is distributed under the terms of the GNU General Public +// License v3 (GPL Version 3), copied verbatim in the file "COPYING". +// +// In applying this license CERN does not waive the privileges and immunities +// granted to it by virtue of its status as an Intergovernmental Organization +// or submit itself to any jurisdiction. + +/// \file utilsTrkCandHf.h +/// \brief Utility for track and candidate selections for HF analyses +/// \author Mattia Faggin , CERN + +#ifndef PWGHF_UTILS_UTILSTRKCANDHF_H_ +#define PWGHF_UTILS_UTILSTRKCANDHF_H_ + +#include "Framework/HistogramSpec.h" + +namespace o2::hf_trkcandsel +{ +// secondary vertex fitting monitoring +enum SVFitting { + BeforeFit = 0, + FitOk, + Fail, + NCases +}; + +o2::framework::AxisSpec axisCands = {SVFitting::NCases, -0.5f, static_cast(SVFitting::NCases) - 0.5f, ""}; + +/// @brief Function to put labels on candidate monitoring histogram +/// \param hCandidates is the histogram +template +void setLabelHistoCands(Histo& hCandidates) +{ + hCandidates->SetTitle("HF candidate counter;;candidates"); + hCandidates->GetXaxis()->SetBinLabel(SVFitting::BeforeFit + 1, "Before secondary vertexing"); + hCandidates->GetXaxis()->SetBinLabel(SVFitting::FitOk + 1, "With secondary vertex"); + hCandidates->GetXaxis()->SetBinLabel(SVFitting::Fail + 1, "Run-time error in secondary vertexing"); +} + +} // namespace o2::hf_trkcandsel + +#endif // PWGHF_UTILS_UTILSTRKCANDHF_H_ \ No newline at end of file From 008de26e4fa8509ca5a6803775becd75f371ecb0 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 14:16:36 +0200 Subject: [PATCH 02/14] Try-catch for 2-prong secondary-vertexing + Clang format. --- .../TableProducer/candidateCreator2Prong.cxx | 19 +++++++++++++++++-- .../TableProducer/candidateCreator3Prong.cxx | 3 +-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreator2Prong.cxx b/PWGHF/TableProducer/candidateCreator2Prong.cxx index 1fe4937b2a5..e80fbf366d4 100644 --- a/PWGHF/TableProducer/candidateCreator2Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator2Prong.cxx @@ -41,10 +41,12 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::analysis; using namespace o2::hf_evsel; +using namespace o2::hf_trkcandsel; using namespace o2::aod::hf_cand_2prong; using namespace o2::aod::hf_collision_centrality; using namespace o2::constants::physics; @@ -92,7 +94,7 @@ struct HfCandidateCreator2Prong { double massKPi{0.}; double bz{0.}; - std::shared_ptr hCollisions, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel; + std::shared_ptr hCollisions, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel, hCandidates; HistogramRegistry registry{"registry"}; void init(InitContext const&) @@ -143,6 +145,7 @@ struct HfCandidateCreator2Prong { hPosXAfterEvSel = registry.add("hPosXAfterEvSel", "selected events;#it{x}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{200, -0.5, 0.5}}}); hPosYAfterEvSel = registry.add("hPosYAfterEvSel", "selected events;#it{y}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{200, -0.5, 0.5}}}); hNumPvContributorsAfterSel = registry.add("hNumPvContributorsAfterSel", "selected events;#it{y}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{500, -0.5, 499.5}}}); + hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); massPi = MassPiPlus; massK = MassKPlus; @@ -171,6 +174,9 @@ struct HfCandidateCreator2Prong { /// collision monitoring setLabelHistoEvSel(hCollisions); + + /// candidate monitoring + setLabelHistoCands(hCandidates); } template @@ -211,9 +217,18 @@ struct HfCandidateCreator2Prong { df.setBz(bz); // reconstruct the 2-prong secondary vertex - if (df.process(trackParVarPos1, trackParVarNeg1) == 0) { + hCandidates->Fill(SVFitting::BeforeFit); + try { + if (df.process(trackParVarPos1, trackParVarNeg1) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidates->Fill(SVFitting::Fail); continue; } + hCandidates->Fill(SVFitting::FitOk); + const auto& secondaryVertex = df.getPCACandidate(); auto chi2PCA = df.getChi2AtPCACandidate(); auto covMatrixPCA = df.calcPCACovMatrixFlat(); diff --git a/PWGHF/TableProducer/candidateCreator3Prong.cxx b/PWGHF/TableProducer/candidateCreator3Prong.cxx index a6afd518a21..d14b3a8f46f 100644 --- a/PWGHF/TableProducer/candidateCreator3Prong.cxx +++ b/PWGHF/TableProducer/candidateCreator3Prong.cxx @@ -217,8 +217,7 @@ struct HfCandidateCreator3Prong { if (df.process(trackParVar0, trackParVar1, trackParVar2) == 0) { continue; } - } - catch(const std::runtime_error& error) { + } catch (const std::runtime_error& error) { LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; hCandidates->Fill(SVFitting::Fail); continue; From 072ef8dfca5e562ef9af399f9c72c7341f0550df Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 14:34:56 +0200 Subject: [PATCH 03/14] Try-catch for secondary-vertexing in candCreatorCascade. --- .../TableProducer/candidateCreatorCascade.cxx | 22 +++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreatorCascade.cxx b/PWGHF/TableProducer/candidateCreatorCascade.cxx index 52a9b53858e..f3bb5526750 100644 --- a/PWGHF/TableProducer/candidateCreatorCascade.cxx +++ b/PWGHF/TableProducer/candidateCreatorCascade.cxx @@ -30,10 +30,12 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::analysis; using namespace o2::hf_evsel; +using namespace o2::hf_trkcandsel; using namespace o2::aod::hf_collision_centrality; using namespace o2::constants::physics; using namespace o2::framework; @@ -80,7 +82,7 @@ struct HfCandidateCreatorCascade { double mass2K0sP{0.}; double bz = 0.; - std::shared_ptr hCollisions, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel; + std::shared_ptr hCollisions, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel, hCandidates; HistogramRegistry registry{"registry"}; void init(InitContext const&) @@ -117,6 +119,7 @@ struct HfCandidateCreatorCascade { hPosXAfterEvSel = registry.add("hPosXAfterEvSel", "selected events;#it{x}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{200, -0.5, 0.5}}}); hPosYAfterEvSel = registry.add("hPosYAfterEvSel", "selected events;#it{y}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{200, -0.5, 0.5}}}); hNumPvContributorsAfterSel = registry.add("hNumPvContributorsAfterSel", "selected events;#it{y}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{500, -0.5, 499.5}}}); + hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); massP = MassProton; massK0s = MassK0Short; @@ -140,6 +143,9 @@ struct HfCandidateCreatorCascade { /// collision monitoring setLabelHistoEvSel(hCollisions); + + /// candidate monitoring + setLabelHistoCands(hCandidates); } template @@ -258,11 +264,19 @@ struct HfCandidateCreatorCascade { auto trackV0 = o2::dataformats::V0(vertexV0, momentumV0, {0, 0, 0, 0, 0, 0}, trackParCovV0DaughPos, trackParCovV0DaughNeg); // build the V0 track (indices for v0 daughters set to 0 for now) // reconstruct the cascade secondary vertex - if (df.process(trackV0, trackParCovBach) == 0) { + hCandidates->Fill(SVFitting::BeforeFit); + try { + if (df.process(trackV0, trackParCovBach) == 0) { + continue; + } else { + // LOG(info) << "Vertexing succeeded for Lc candidate"; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidates->Fill(SVFitting::Fail); continue; - } else { - // LOG(info) << "Vertexing succeeded for Lc candidate"; } + hCandidates->Fill(SVFitting::FitOk); const auto& secondaryVertex = df.getPCACandidate(); auto chi2PCA = df.getChi2AtPCACandidate(); From fb3073d42ffb6504421852c1d5c1dd33fa916941 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 14:52:37 +0200 Subject: [PATCH 04/14] Try-catch for 2-prong secondary-vertexing for Dstar. --- PWGHF/TableProducer/candidateCreatorDstar.cxx | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreatorDstar.cxx b/PWGHF/TableProducer/candidateCreatorDstar.cxx index 871b3371582..524d7982884 100644 --- a/PWGHF/TableProducer/candidateCreatorDstar.cxx +++ b/PWGHF/TableProducer/candidateCreatorDstar.cxx @@ -30,9 +30,11 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/Utils/utilsEvSelHf.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::hf_evsel; +using namespace o2::hf_trkcandsel; using namespace o2::aod::hf_collision_centrality; using namespace o2::constants::physics; using namespace o2::framework; @@ -86,7 +88,7 @@ struct HfCandidateCreatorDstar { AxisSpec ptAxis = {100, 0., 2.0, "#it{p}_{T} (GeV/#it{c}"}; AxisSpec dcaAxis = {200, -500., 500., "#it{d}_{xy,z} (#mum)"}; - std::shared_ptr hCollisions, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel; + std::shared_ptr hCollisions, hPosZBeforeEvSel, hPosZAfterEvSel, hPosXAfterEvSel, hPosYAfterEvSel, hNumPvContributorsAfterSel, hCandidates; HistogramRegistry registry{ "registry", {{"Refit/hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 1.e-4}}}}, @@ -143,6 +145,7 @@ struct HfCandidateCreatorDstar { hPosXAfterEvSel = registry.add("EvSel/hPosXAfterEvSel", "selected events;#it{x}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{200, -0.5, 0.5}}}); hPosYAfterEvSel = registry.add("EvSel/hPosYAfterEvSel", "selected events;#it{y}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{200, -0.5, 0.5}}}); hNumPvContributorsAfterSel = registry.add("EvSel/hNumPvContributorsAfterSel", "selected events;#it{y}_{prim. vtx.} (cm);entries", {HistType::kTH1D, {{500, -0.5, 499.5}}}); + hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); // LOG(info) << "Init Function Invoked"; massPi = MassPiPlus; @@ -166,6 +169,9 @@ struct HfCandidateCreatorDstar { /// collision monitoring setLabelHistoEvSel(hCollisions); + + /// candidate monitoring + setLabelHistoCands(hCandidates); } /// @brief function for secondary vertex reconstruction and candidate creator @@ -233,9 +239,18 @@ struct HfCandidateCreatorDstar { df.setBz(bz); // reconstruct the 2-prong secondary vertex - if (df.process(trackD0Prong0ParVarPos1, trackD0Prong1ParVarNeg1) == 0) { + hCandidates->Fill(SVFitting::BeforeFit); + try { + if (df.process(trackD0Prong0ParVarPos1, trackD0Prong1ParVarNeg1) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidates->Fill(SVFitting::Fail); continue; } + hCandidates->Fill(SVFitting::FitOk); + const auto& secondaryVertex = df.getPCACandidate(); auto chi2PCA = df.getChi2AtPCACandidate(); auto covMatrixPCA = df.calcPCACovMatrixFlat(); From 7d88756f38d0b3c2b9f4aacb6b7ac6f2f7b38f37 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 15:23:19 +0200 Subject: [PATCH 05/14] Try-catch for B+ secondary-vertexing. --- PWGHF/TableProducer/candidateCreatorBplus.cxx | 41 +++++++++++++++---- 1 file changed, 34 insertions(+), 7 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreatorBplus.cxx b/PWGHF/TableProducer/candidateCreatorBplus.cxx index 40440dbf27a..c780cf972e2 100644 --- a/PWGHF/TableProducer/candidateCreatorBplus.cxx +++ b/PWGHF/TableProducer/candidateCreatorBplus.cxx @@ -32,9 +32,11 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::analysis; +using namespace o2::hf_trkcandsel; using namespace o2::aod; using namespace o2::constants::physics; using namespace o2::framework; @@ -102,6 +104,9 @@ struct HfCandidateCreatorBplus { OutputObj hEtaPi{TH1F("hEtaPi", "Pion track;#it{#eta};entries", 400, -2., 2.)}; OutputObj hMassBplusToD0Pi{TH1F("hMassBplusToD0Pi", "2-prong candidates;inv. mass (B^{+} #rightarrow #bar{D^{0}}#pi^{+}) (GeV/#it{c}^{2});entries", 500, 3., 8.)}; + std::shared_ptr hCandidatesD, hCandidatesB; + HistogramRegistry registry{"registry"}; + void init(InitContext const&) { // invariant-mass window cut @@ -133,6 +138,12 @@ struct HfCandidateCreatorBplus { ccdb->setLocalObjectValidityChecking(); lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut)); runNumber = 0; + + /// candidate monitoring + hCandidatesD = registry.add("hCandidatesD", "D candidate counter", {HistType::kTH1D, {axisCands}}); + hCandidatesB = registry.add("hCandidatesB", "B candidate counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidatesD); + setLabelHistoCands(hCandidatesB); } /// Single-track cuts for pions on dcaXY @@ -219,9 +230,17 @@ struct HfCandidateCreatorBplus { } // reconstruct D0 secondary vertex - if (df.process(trackParCovProng0, trackParCovProng1) == 0) { + hCandidatesD->Fill(SVFitting::BeforeFit); + try { + if (df.process(trackParCovProng0, trackParCovProng1) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for D cannot work, skipping the candidate."; + hCandidatesD->Fill(SVFitting::Fail); continue; } + hCandidatesD->Fill(SVFitting::FitOk); const auto& vertexD0 = df.getPCACandidatePos(); trackParCovProng0.propagateTo(vertexD0[0], bz); @@ -278,9 +297,17 @@ struct HfCandidateCreatorBplus { std::array pVecBCand = {0., 0., 0.}; // find the DCA between the D0 and the bachelor track, for B+ - if (dfB.process(trackD0, trackParCovPi) == 0) { + hCandidatesB->Fill(SVFitting::BeforeFit); + try { + if (dfB.process(trackD0, trackParCovPi) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for B cannot work, skipping the candidate."; + hCandidatesB->Fill(SVFitting::Fail); continue; } + hCandidatesB->Fill(SVFitting::FitOk); dfB.propagateTracksToVertex(); // propagate the bachelor and D0 to the B+ vertex trackD0.getPxPyPzGlo(pVecD0); // momentum of D0 at the B+ vertex @@ -330,11 +357,11 @@ struct HfCandidateCreatorBplus { hfFlag); rowCandidateProngs(candD0.globalIndex(), trackPion.globalIndex()); // index D0 and bachelor - } // track loop - } // D0 cand loop - } // collision - } // process -}; // struct + } // track loop + } // D0 cand loop + } // collision + } // process +}; // struct /// Extends the base table with expression columns and performs MC matching struct HfCandidateCreatorBplusExpressions { From d216b16665356d69bc5096181f05e52d1a2d755e Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 15:37:59 +0200 Subject: [PATCH 06/14] Try-catch for B0 secondary-vertexing. --- PWGHF/TableProducer/candidateCreatorB0.cxx | 33 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 3 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreatorB0.cxx b/PWGHF/TableProducer/candidateCreatorB0.cxx index 2a6ce856352..185a57c99c8 100644 --- a/PWGHF/TableProducer/candidateCreatorB0.cxx +++ b/PWGHF/TableProducer/candidateCreatorB0.cxx @@ -29,6 +29,7 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::analysis; @@ -36,10 +37,11 @@ using namespace o2::aod; using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; /// Reconstruction of B0 candidates struct HfCandidateCreatorB0 { - Produces rowCandidateBase; // table defined in CandidateReconstructionTables.h + Produces rowCandidateBase; // table defined in CandidateReconstructionTables.h Produces rowCandidateProngs; // table defined in CandidateReconstructionTables.h // vertexing @@ -99,6 +101,9 @@ struct HfCandidateCreatorB0 { OutputObj hCovPVXX{TH1F("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", 100, 0., 1.e-4)}; OutputObj hCovSVXX{TH1F("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", 100, 0., 0.2)}; + std::shared_ptr hCandidatesD, hCandidatesB; + HistogramRegistry registry{"registry"}; + void init(InitContext const&) { // invariant-mass window cut @@ -132,6 +137,12 @@ struct HfCandidateCreatorB0 { ccdb->setLocalObjectValidityChecking(); lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut)); runNumber = 0; + + /// candidate monitoring + hCandidatesD = registry.add("hCandidatesD", "D candidate counter", {HistType::kTH1D, {axisCands}}); + hCandidatesB = registry.add("hCandidatesB", "B candidate counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidatesD); + setLabelHistoCands(hCandidatesB); } /// Single-track cuts for pions on dcaXY @@ -224,9 +235,17 @@ struct HfCandidateCreatorB0 { // --------------------------------- // reconstruct 3-prong secondary vertex (D±) - if (df3.process(trackParCov0, trackParCov1, trackParCov2) == 0) { + hCandidatesD->Fill(SVFitting::BeforeFit); + try { + if (df3.process(trackParCov0, trackParCov1, trackParCov2) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidatesD->Fill(SVFitting::Fail); continue; } + hCandidatesD->Fill(SVFitting::FitOk); const auto& secondaryVertexD = df3.getPCACandidate(); // propagate the 3 prongs to the secondary vertex @@ -278,9 +297,17 @@ struct HfCandidateCreatorB0 { // --------------------------------- // reconstruct the 2-prong B0 vertex - if (df2.process(trackParCovD, trackParCovPi) == 0) { + hCandidatesB->Fill(SVFitting::BeforeFit); + try { + if (df2.process(trackParCovD, trackParCovPi) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidatesB->Fill(SVFitting::Fail); continue; } + hCandidatesB->Fill(SVFitting::FitOk); // calculate relevant properties const auto& secondaryVertexB0 = df2.getPCACandidate(); From dbe12df54491fb67f7af1bf0cc7674f293d9a73c Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 15:49:13 +0200 Subject: [PATCH 07/14] Try-catch for Bs secondary-vertexing. --- PWGHF/TableProducer/candidateCreatorB0.cxx | 4 +-- PWGHF/TableProducer/candidateCreatorBs.cxx | 31 ++++++++++++++++++++-- 2 files changed, 31 insertions(+), 4 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreatorB0.cxx b/PWGHF/TableProducer/candidateCreatorB0.cxx index 185a57c99c8..409b1051faf 100644 --- a/PWGHF/TableProducer/candidateCreatorB0.cxx +++ b/PWGHF/TableProducer/candidateCreatorB0.cxx @@ -241,7 +241,7 @@ struct HfCandidateCreatorB0 { continue; } } catch (const std::runtime_error& error) { - LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for D cannot work, skipping the candidate."; hCandidatesD->Fill(SVFitting::Fail); continue; } @@ -303,7 +303,7 @@ struct HfCandidateCreatorB0 { continue; } } catch (const std::runtime_error& error) { - LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for B cannot work, skipping the candidate."; hCandidatesB->Fill(SVFitting::Fail); continue; } diff --git a/PWGHF/TableProducer/candidateCreatorBs.cxx b/PWGHF/TableProducer/candidateCreatorBs.cxx index 107f46e1b06..3047135b9be 100644 --- a/PWGHF/TableProducer/candidateCreatorBs.cxx +++ b/PWGHF/TableProducer/candidateCreatorBs.cxx @@ -29,6 +29,7 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::analysis; @@ -36,6 +37,7 @@ using namespace o2::aod; using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; /// Reconstruction of Bs candidates struct HfCandidateCreatorBs { @@ -94,6 +96,9 @@ struct HfCandidateCreatorBs { OutputObj hCovPVXX{TH1F("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", 100, 0., 1.e-4)}; OutputObj hCovSVXX{TH1F("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", 100, 0., 0.2)}; + std::shared_ptr hCandidatesD, hCandidatesB; + HistogramRegistry registry{"registry"}; + void init(InitContext const&) { massPi = MassPiPlus; @@ -123,6 +128,12 @@ struct HfCandidateCreatorBs { ccdb->setLocalObjectValidityChecking(); lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get(ccdbPathLut)); runNumber = 0; + + /// candidate monitoring + hCandidatesD = registry.add("hCandidatesD", "D candidate counter", {HistType::kTH1D, {axisCands}}); + hCandidatesB = registry.add("hCandidatesB", "B candidate counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidatesD); + setLabelHistoCands(hCandidatesB); } /// Single-track cuts for pions on dcaXY @@ -204,9 +215,17 @@ struct HfCandidateCreatorBs { // --------------------------------- // reconstruct 3-prong secondary vertex (Ds±) - if (df3.process(trackParCov0, trackParCov1, trackParCov2) == 0) { + hCandidatesD->Fill(SVFitting::BeforeFit); + try { + if (df3.process(trackParCov0, trackParCov1, trackParCov2) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for D cannot work, skipping the candidate."; + hCandidatesD->Fill(SVFitting::Fail); continue; } + hCandidatesD->Fill(SVFitting::FitOk); const auto& secondaryVertexDs = df3.getPCACandidate(); // propagate the 3 prongs to the secondary vertex @@ -259,9 +278,17 @@ struct HfCandidateCreatorBs { // --------------------------------- // reconstruct the 2-prong Bs vertex - if (df2.process(trackParCovDs, trackParCovPi) == 0) { + hCandidatesB->Fill(SVFitting::BeforeFit); + try { + if (df2.process(trackParCovDs, trackParCovPi) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for B cannot work, skipping the candidate."; + hCandidatesB->Fill(SVFitting::Fail); continue; } + hCandidatesB->Fill(SVFitting::FitOk); // calculate relevant properties const auto& secondaryVertexBs = df2.getPCACandidate(); From 0d90b023bfe49cdcd8c8144cbe1ae38d05356721 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 15:58:56 +0200 Subject: [PATCH 08/14] Try-catch for Lb secondary-vertexing. --- PWGHF/TableProducer/candidateCreatorLb.cxx | 32 ++++++++++++++++++++-- 1 file changed, 30 insertions(+), 2 deletions(-) diff --git a/PWGHF/TableProducer/candidateCreatorLb.cxx b/PWGHF/TableProducer/candidateCreatorLb.cxx index 85d1add7792..9f630e1fcc5 100644 --- a/PWGHF/TableProducer/candidateCreatorLb.cxx +++ b/PWGHF/TableProducer/candidateCreatorLb.cxx @@ -26,6 +26,7 @@ #include "PWGHF/Core/HfHelper.h" #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::analysis; @@ -33,6 +34,7 @@ using namespace o2::aod; using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; void customize(std::vector& workflowOptions) { @@ -78,6 +80,9 @@ struct HfCandidateCreatorLb { OutputObj hCovPVXX{TH1F("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", 100, 0., 1.e-4)}; OutputObj hCovSVXX{TH1F("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", 100, 0., 0.2)}; + std::shared_ptr hCandidatesLc, hCandidatesLb; + HistogramRegistry registry{"registry"}; + void init(InitContext const&) { massPi = MassPiMinus; @@ -100,6 +105,12 @@ struct HfCandidateCreatorLb { df3.setMinRelChi2Change(minRelChi2Change); df3.setUseAbsDCA(useAbsDCA); df3.setWeightedFinalPCA(useWeightedFinalPCA); + + /// candidate monitoring + hCandidatesLc = registry.add("hCandidatesLc", "Lc candidate counter", {HistType::kTH1D, {axisCands}}); + hCandidatesLb = registry.add("hCandidatesLb", "B candidate counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidatesLc); + setLabelHistoCands(hCandidatesLb); } void process(aod::Collision const&, @@ -131,9 +142,18 @@ struct HfCandidateCreatorLb { auto collision = track0.collision(); // reconstruct the 3-prong secondary vertex - if (df3.process(trackParVar0, trackParVar1, trackParVar2) == 0) { + hCandidatesLc->Fill(SVFitting::BeforeFit); + try { + if (df3.process(trackParVar0, trackParVar1, trackParVar2) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidatesLc->Fill(SVFitting::Fail); continue; } + hCandidatesLc->Fill(SVFitting::FitOk); + const auto& secondaryVertex = df3.getPCACandidate(); trackParVar0.propagateTo(secondaryVertex[0], bz); trackParVar1.propagateTo(secondaryVertex[0], bz); @@ -164,9 +184,17 @@ struct HfCandidateCreatorLb { auto trackParVarPi = getTrackParCov(trackPion); // reconstruct the 3-prong Lc vertex - if (df2.process(trackLc, trackParVarPi) == 0) { + hCandidatesLb->Fill(SVFitting::BeforeFit); + try { + if (df2.process(trackLc, trackParVarPi) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidatesLb->Fill(SVFitting::Fail); continue; } + hCandidatesLb->Fill(SVFitting::FitOk); // calculate relevant properties const auto& secondaryVertexLb = df2.getPCACandidate(); From 968ada895cda642440152e8631a6e2cd8d626fcf Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 16:17:18 +0200 Subject: [PATCH 09/14] Try-catch for secondary-vertexing in reduced candidate creators. --- .../candidateCreatorB0Reduced.cxx | 18 +++++++++- .../candidateCreatorBplusReduced.cxx | 18 +++++++++- .../dataCreatorCharmHadPiReduced.cxx | 33 +++++++++++++++++-- 3 files changed, 65 insertions(+), 4 deletions(-) diff --git a/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx index ce08d3bdf8b..0747f767544 100644 --- a/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateCreatorB0Reduced.cxx @@ -27,11 +27,13 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; /// Reconstruction of B0 candidates struct HfCandidateCreatorB0Reduced { @@ -64,6 +66,7 @@ struct HfCandidateCreatorB0Reduced { Preslice> candsDWithMlPerCollision = hf_track_index_reduced::hfRedCollisionId; Preslice> tracksPionPerCollision = hf_track_index_reduced::hfRedCollisionId; + std::shared_ptr hCandidates; HistogramRegistry registry{"registry"}; void init(InitContext const&) @@ -92,6 +95,10 @@ struct HfCandidateCreatorB0Reduced { registry.add("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 1.e-4}}}); registry.add("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 0.2}}}); registry.add("hEvents", "Events;;entries", HistType::kTH1F, {{1, 0.5, 1.5}}); + + /// candidate monitoring + hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidates); } /// Main function to perform B0 candidate creation @@ -135,9 +142,18 @@ struct HfCandidateCreatorB0Reduced { } // --------------------------------- // reconstruct the 2-prong B0 vertex - if (df2.process(trackParCovD, trackParCovPi) == 0) { + hCandidates->Fill(SVFitting::BeforeFit); + try { + if (df2.process(trackParCovD, trackParCovPi) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidates->Fill(SVFitting::Fail); continue; } + hCandidates->Fill(SVFitting::FitOk); + // DPi passed B0 reconstruction // calculate relevant properties diff --git a/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx b/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx index a959e738b8a..0d4c8f8418e 100644 --- a/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx +++ b/PWGHF/D2H/TableProducer/candidateCreatorBplusReduced.cxx @@ -27,11 +27,13 @@ #include "PWGHF/DataModel/CandidateReconstructionTables.h" #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::aod; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; /// Reconstruction of B+ candidates struct HfCandidateCreatorBplusReduced { @@ -61,6 +63,7 @@ struct HfCandidateCreatorBplusReduced { Preslice> candsDPerCollision = hf_track_index_reduced::hfRedCollisionId; Preslice> tracksPionPerCollision = hf_track_index_reduced::hfRedCollisionId; + std::shared_ptr hCandidates; HistogramRegistry registry{"registry"}; void init(InitContext const&) @@ -84,6 +87,10 @@ struct HfCandidateCreatorBplusReduced { registry.add("hCovPVXX", "2-prong candidates;XX element of cov. matrix of prim. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 1.e-4}}}); registry.add("hCovSVXX", "2-prong candidates;XX element of cov. matrix of sec. vtx. position (cm^{2});entries", {HistType::kTH1F, {{100, 0., 0.2}}}); registry.add("hEvents", "Events;;entries", HistType::kTH1F, {{1, 0.5, 1.5}}); + + /// candidate monitoring + hCandidates = registry.add("hCandidates", "candidates counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidates); } void process(HfRedCollisionsWithExtras const& collisions, @@ -138,9 +145,18 @@ struct HfCandidateCreatorBplusReduced { } // --------------------------------- // reconstruct the 2-prong B+ vertex - if (df2.process(trackParCovD, trackParCovPi) == 0) { + hCandidates->Fill(SVFitting::BeforeFit); + try { + if (df2.process(trackParCovD, trackParCovPi) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidates->Fill(SVFitting::Fail); continue; } + hCandidates->Fill(SVFitting::FitOk); + // D0Pi passed B+ reconstruction // calculate relevant properties diff --git a/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx index b13e7b7e03d..062f887683c 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx @@ -33,6 +33,7 @@ #include "PWGHF/DataModel/CandidateSelectionTables.h" #include "PWGHF/Utils/utilsBfieldCCDB.h" #include "PWGHF/D2H/DataModel/ReducedDataModel.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::analysis; @@ -40,6 +41,7 @@ using namespace o2::aod; using namespace o2::constants::physics; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; enum Event : uint8_t { Processed = 0, @@ -148,6 +150,7 @@ struct HfDataCreatorCharmHadPiReduced { Preslice candsD0PerCollisionWithMl = aod::track_association::collisionId; Preslice trackIndicesPerCollision = aod::track_association::collisionId; + std::shared_ptr hCandidatesD0, hCandidatesDPlus; HistogramRegistry registry{"registry"}; void init(InitContext const&) @@ -232,6 +235,12 @@ struct HfDataCreatorCharmHadPiReduced { registry.add(Form("hPt%s", histMassTitle0.data()), Form("%s candidates candidates;%s candidate #it{p}_{T} (GeV/#it{c});entries", charmHadTitle0.data(), charmHadTitle0.data()), {HistType::kTH1F, {{100, 0., 10.}}}); registry.add("hPtPion", "#pi^{#plus} candidates;#pi^{#plus} candidate #it{p}_{T} (GeV/#it{c});entries", {HistType::kTH1F, {{100, 0., 10.}}}); registry.add(Form("hCpa%s", histMassTitle0.data()), Form("%s candidates;%s cosine of pointing angle;entries", charmHadTitle0.data(), charmHadTitle0.data()), {HistType::kTH1F, {{110, -1.1, 1.1}}}); + + /// candidate monitoring + hCandidatesD00 = registry.add("hCandidatesD00", "D candidate counter", {HistType::kTH1D, {axisCands}}); + hCandidatesDPlus = registry.add("hCandidatesDPlus", "B candidate counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidatesD00); + setLabelHistoCands(hCandidatesDPlus); } /// Pion selection (D Pi <-- B0) @@ -518,9 +527,19 @@ struct HfDataCreatorCharmHadPiReduced { o2::track::TrackParCov trackParCovCharmHad{}; std::array pVecCharm{}; if constexpr (decChannel == DecayChannel::B0ToDminusPi) { // D∓ → π∓ K± π∓ - if (df3.process(trackParCov0, trackParCov1, trackParCov2) == 0) { + + hCandidatesDPlus->Fill(SVFitting::BeforeFit); + try { + if (df3.process(trackParCov0, trackParCov1, trackParCov2) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidatesDPlus->Fill(SVFitting::Fail); continue; } + hCandidatesDPlus->Fill(SVFitting::FitOk); + auto secondaryVertexCharm = df3.getPCACandidate(); trackParCov0.propagateTo(secondaryVertexCharm[0], bz); trackParCov1.propagateTo(secondaryVertexCharm[0], bz); @@ -532,9 +551,19 @@ struct HfDataCreatorCharmHadPiReduced { trackParCovCharmHad = df3.createParentTrackParCov(); trackParCovCharmHad.setAbsCharge(charmHadDauTracks[1].sign()); // to be sure } else if constexpr (decChannel == DecayChannel::BplusToD0barPi) { // D0(bar) → K± π∓ - if (df2.process(trackParCov0, trackParCov1) == 0) { + + hCandidatesD0->Fill(SVFitting::BeforeFit); + try { + if (df2.process(trackParCov0, trackParCov1) == 0) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN cannot work, skipping the candidate."; + hCandidatesD0->Fill(SVFitting::Fail); continue; } + hCandidatesD0->Fill(SVFitting::FitOk); + auto secondaryVertexCharm = df2.getPCACandidate(); trackParCov0.propagateTo(secondaryVertexCharm[0], bz); trackParCov1.propagateTo(secondaryVertexCharm[0], bz); From d9473c43245f6a517bb0a5c857ffe422dfa07bcd Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 17:43:27 +0200 Subject: [PATCH 10/14] Try-catch for secondary-vertexing in OmegaC tree creator with str. tracking. --- PWGHF/TableProducer/treeCreatorOmegacSt.cxx | 215 ++++++++++++-------- 1 file changed, 130 insertions(+), 85 deletions(-) diff --git a/PWGHF/TableProducer/treeCreatorOmegacSt.cxx b/PWGHF/TableProducer/treeCreatorOmegacSt.cxx index ab0033e72e4..fd503131096 100644 --- a/PWGHF/TableProducer/treeCreatorOmegacSt.cxx +++ b/PWGHF/TableProducer/treeCreatorOmegacSt.cxx @@ -39,10 +39,12 @@ #include "Common/DataModel/CollisionAssociationTables.h" #include "PWGLF/DataModel/LFStrangenessTables.h" #include "PWGHF/Core/SelectorCuts.h" +#include "PWGHF/Utils/utilsTrkCandHf.h" using namespace o2; using namespace o2::framework; using namespace o2::framework::expressions; +using namespace o2::hf_trkcandsel; namespace o2::aod { @@ -228,6 +230,7 @@ struct HfTreeCreatorOmegacSt { Preslice trackIndicesPerCollision = aod::track_association::collisionId; Preslice assignedTrackedCascadesPerCollision = aod::track::collisionId; + std::shared_ptr hCandidatesPrPi, hCandidatesV0Pi, hCandidatesCascPi; HistogramRegistry registry{ "registry", { @@ -272,6 +275,14 @@ struct HfTreeCreatorOmegacSt { auto* lut = o2::base::MatLayerCylSet::rectifyPtrFromFile(ccdb->get("GLO/Param/MatLUT")); o2::base::Propagator::Instance(true)->setMatLUT(lut); } + + /// candidate monitoring + hCandidatesPrPi = registry.add("hCandidatesPrPi", "Pr-Pi candidates counter", {HistType::kTH1D, {axisCands}}); + hCandidatesV0Pi = registry.add("hCandidatesV0Pi", "V0-Pi candidates counter", {HistType::kTH1D, {axisCands}}); + hCandidatesCascPi = registry.add("hCandidatesCascPi", "Casc-Pi candidates counter", {HistType::kTH1D, {axisCands}}); + setLabelHistoCands(hCandidatesPrPi); + setLabelHistoCands(hCandidatesV0Pi); + setLabelHistoCands(hCandidatesCascPi); } // processMC: loop over MC objects @@ -357,9 +368,18 @@ struct HfTreeCreatorOmegacSt { const auto& v0TrackPi = trackCasc.sign() < 0 ? v0TrackNeg : v0TrackPos; // track propagation - if (!df2.process(getTrackParCov(v0TrackPr), getTrackParCov(v0TrackPi))) { + hCandidatesPrPi->Fill(SVFitting::BeforeFit); + try { + if (!df2.process(getTrackParCov(v0TrackPr), getTrackParCov(v0TrackPi))) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for Pr-Pi cannot work, skipping the candidate."; + hCandidatesPrPi->Fill(SVFitting::Fail); continue; } + hCandidatesPrPi->Fill(SVFitting::FitOk); + std::array massesV0Daughters{o2::constants::physics::MassProton, o2::constants::physics::MassPiMinus}; std::array, 2> momentaV0Daughters; o2::track::TrackPar trackParV0Pr = df2.getTrackParamAtPCA(0); @@ -369,9 +389,18 @@ struct HfTreeCreatorOmegacSt { const auto massV0 = RecoDecay::m(momentaV0Daughters, massesV0Daughters); o2::track::TrackParCov trackParCovV0 = df2.createParentTrackParCov(0); - if (!df2.process(trackParCovV0, getTrackParCov(bachelor))) { + hCandidatesV0Pi->Fill(SVFitting::BeforeFit); + try { + if (!df2.process(trackParCovV0, getTrackParCov(bachelor))) { + continue; + } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for V0-bachelor cannot work, skipping the candidate."; + hCandidatesV0Pi->Fill(SVFitting::Fail); continue; } + hCandidatesV0Pi->Fill(SVFitting::FitOk); + const auto& secondaryVertex = df2.getPCACandidate(); const auto decayLengthCasc = RecoDecay::distance(secondaryVertex, primaryVertexPos); const auto decayLengthCascXY = RecoDecay::distanceXY(secondaryVertex, primaryVertexPos); @@ -448,75 +477,83 @@ struct HfTreeCreatorOmegacSt { o2::base::Propagator::Instance()->propagateToDCABxByBz(primaryVertex, trackParCovPion, 2.f, matCorr, &impactParameterPion); } - if (df2.process(trackParCovCasc, trackParCovPion)) { - const auto& secondaryVertex = df2.getPCACandidate(); - const auto decayLength = RecoDecay::distance(secondaryVertex, primaryVertexPos); - const auto decayLengthXY = RecoDecay::distanceXY(secondaryVertex, primaryVertexPos); - const auto chi2TopCharmedBaryon = df2.getChi2AtPCACandidate(); - std::array pCharmedBaryon; - df2.createParentTrackParCov().getPxPyPzGlo(pCharmedBaryon); - const auto cpaCharmedBaryon = RecoDecay::cpa(primaryVertexPos, df2.getPCACandidate(), pCharmedBaryon); - const auto cpaXYCharmedBaryon = RecoDecay::cpaXY(primaryVertexPos, df2.getPCACandidate(), pCharmedBaryon); - - df2.getTrackParamAtPCA(0).getPxPyPzGlo(momenta[0]); - df2.getTrackParamAtPCA(1).getPxPyPzGlo(momenta[1]); - const auto massOmegaC = RecoDecay::m(momenta, massesOmegacDaughters); - const auto massXiC = RecoDecay::m(momenta, massesXicDaughters); - registry.fill(HIST("hMassOmegac"), massOmegaC); - registry.fill(HIST("hMassOmegacVsPt"), massOmegaC, RecoDecay::pt(momenta[0], momenta[1])); - - if ((std::abs(massOmegaC - o2::constants::physics::MassOmegaC0) < massWindowOmegaC) || - (std::abs(massXiC - o2::constants::physics::MassXiC0) < massWindowXiC)) { - registry.fill(HIST("hDecayLength"), decayLength * 1e4); - registry.fill(HIST("hDecayLengthScaled"), decayLength * o2::constants::physics::MassOmegaC0 / RecoDecay::p(momenta[0], momenta[1]) * 1e4); - outputTable(massOmega, - massXi, - massV0, - track.tpcNSigmaPi(), - track.tofNSigmaPi(), - v0TrackPr.tpcNSigmaPr(), - v0TrackPr.tofNSigmaPr(), - v0TrackPi.tpcNSigmaPi(), - v0TrackPi.tofNSigmaPi(), - bachelor.tpcNSigmaPi(), - bachelor.tofNSigmaPi(), - bachelor.tpcNSigmaKa(), - bachelor.tofNSigmaKa(), - momenta[0][0], // cascade momentum - momenta[0][1], - momenta[0][2], - trackCasc.sign() > 0 ? true : false, - momenta[1][0], // pion momentum - momenta[1][1], - momenta[1][2], - track.sign() > 0 ? true : false, - track.itsClusterMap(), - cpaCharmedBaryon, - cpaXYCharmedBaryon, - cpaCasc, - cpaXYCasc, - impactParameterCasc.getY(), - std::sqrt(impactParameterCasc.getSigmaY2()), - impactParameterCasc.getZ(), - std::sqrt(impactParameterCasc.getSigmaZ2()), - impactParameterPion.getY(), - std::sqrt(impactParameterPion.getSigmaY2()), - impactParameterPion.getZ(), - std::sqrt(impactParameterPion.getSigmaZ2()), - impactParameterPr.getY(), - impactParameterPr.getZ(), - impactParameterKa.getY(), - impactParameterKa.getZ(), - impactParameterPi.getY(), - impactParameterPi.getZ(), - chi2TopCharmedBaryon, - trackedCascade.topologyChi2(), - decayLength, - decayLengthXY, - decayLengthCasc, - decayLengthCascXY); + hCandidatesCascPi->Fill(SVFitting::BeforeFit); + try { + if (df2.process(trackParCovCasc, trackParCovPion)) { + const auto& secondaryVertex = df2.getPCACandidate(); + const auto decayLength = RecoDecay::distance(secondaryVertex, primaryVertexPos); + const auto decayLengthXY = RecoDecay::distanceXY(secondaryVertex, primaryVertexPos); + const auto chi2TopCharmedBaryon = df2.getChi2AtPCACandidate(); + std::array pCharmedBaryon; + df2.createParentTrackParCov().getPxPyPzGlo(pCharmedBaryon); + const auto cpaCharmedBaryon = RecoDecay::cpa(primaryVertexPos, df2.getPCACandidate(), pCharmedBaryon); + const auto cpaXYCharmedBaryon = RecoDecay::cpaXY(primaryVertexPos, df2.getPCACandidate(), pCharmedBaryon); + + df2.getTrackParamAtPCA(0).getPxPyPzGlo(momenta[0]); + df2.getTrackParamAtPCA(1).getPxPyPzGlo(momenta[1]); + const auto massOmegaC = RecoDecay::m(momenta, massesOmegacDaughters); + const auto massXiC = RecoDecay::m(momenta, massesXicDaughters); + registry.fill(HIST("hMassOmegac"), massOmegaC); + registry.fill(HIST("hMassOmegacVsPt"), massOmegaC, RecoDecay::pt(momenta[0], momenta[1])); + + if ((std::abs(massOmegaC - o2::constants::physics::MassOmegaC0) < massWindowOmegaC) || + (std::abs(massXiC - o2::constants::physics::MassXiC0) < massWindowXiC)) { + registry.fill(HIST("hDecayLength"), decayLength * 1e4); + registry.fill(HIST("hDecayLengthScaled"), decayLength * o2::constants::physics::MassOmegaC0 / RecoDecay::p(momenta[0], momenta[1]) * 1e4); + outputTable(massOmega, + massXi, + massV0, + track.tpcNSigmaPi(), + track.tofNSigmaPi(), + v0TrackPr.tpcNSigmaPr(), + v0TrackPr.tofNSigmaPr(), + v0TrackPi.tpcNSigmaPi(), + v0TrackPi.tofNSigmaPi(), + bachelor.tpcNSigmaPi(), + bachelor.tofNSigmaPi(), + bachelor.tpcNSigmaKa(), + bachelor.tofNSigmaKa(), + momenta[0][0], // cascade momentum + momenta[0][1], + momenta[0][2], + trackCasc.sign() > 0 ? true : false, + momenta[1][0], // pion momentum + momenta[1][1], + momenta[1][2], + track.sign() > 0 ? true : false, + track.itsClusterMap(), + cpaCharmedBaryon, + cpaXYCharmedBaryon, + cpaCasc, + cpaXYCasc, + impactParameterCasc.getY(), + std::sqrt(impactParameterCasc.getSigmaY2()), + impactParameterCasc.getZ(), + std::sqrt(impactParameterCasc.getSigmaZ2()), + impactParameterPion.getY(), + std::sqrt(impactParameterPion.getSigmaY2()), + impactParameterPion.getZ(), + std::sqrt(impactParameterPion.getSigmaZ2()), + impactParameterPr.getY(), + impactParameterPr.getZ(), + impactParameterKa.getY(), + impactParameterKa.getZ(), + impactParameterPi.getY(), + impactParameterPi.getZ(), + chi2TopCharmedBaryon, + trackedCascade.topologyChi2(), + decayLength, + decayLengthXY, + decayLengthCasc, + decayLengthCascXY); + } } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for Casc-Pi cannot work, skipping the candidate."; + hCandidatesCascPi->Fill(SVFitting::Fail); + continue; } + hCandidatesCascPi->Fill(SVFitting::FitOk); } } } @@ -614,26 +651,34 @@ struct HfTreeCreatorOmegacSt { registry.fill(HIST("hDeltaPtVsPt"), mcpart.pt(), (trackParCovPion.getPt() - mcpart.pt()) / mcpart.pt()); registry.fill(HIST("hMassOmegacId"), RecoDecay::m(momenta, masses)); - if (df2.process(trackParCovCasc, trackParCovPion)) { - const auto& secondaryVertex = df2.getPCACandidate(); - const auto decayLength = RecoDecay::distance(secondaryVertex, primaryVertexPos); - if (mother.has_mothers()) { - const auto& cand = mother.template mothers_first_as(); - if (std::abs(cand.pdgCode()) == constants::physics::Pdg::kOmegaC0 && mcpart.has_mothers()) { - if (mcpart.mothersIds()[0] == cand.globalIndex()) { - registry.fill(HIST("hDecayLengthId"), decayLength * 1e4); - registry.fill(HIST("hDecayLengthScaledId"), decayLength * o2::constants::physics::MassOmegaC0 / RecoDecay::p(momenta[0], momenta[1]) * 1e4); - - std::array secondaryVertexGen = {mother.vx(), mother.vy(), mother.vz()}; - const auto decayLengthGen = RecoDecay::distance(secondaryVertexGen, primaryVertexPosGen); - registry.fill(HIST("hDecayLengthGen"), decayLengthGen * 1e4); - registry.fill(HIST("hDecayLengthScaledGen"), decayLengthGen * o2::constants::physics::MassOmegaC0 / RecoDecay::p(momenta[0], momenta[1]) * 1e4); - - registry.fill(HIST("hDeltaDecayLength"), (decayLength - decayLengthGen) * 1e4); + hCandidatesCascPi->Fill(SVFitting::BeforeFit); + try { + if (df2.process(trackParCovCasc, trackParCovPion)) { + const auto& secondaryVertex = df2.getPCACandidate(); + const auto decayLength = RecoDecay::distance(secondaryVertex, primaryVertexPos); + if (mother.has_mothers()) { + const auto& cand = mother.template mothers_first_as(); + if (std::abs(cand.pdgCode()) == constants::physics::Pdg::kOmegaC0 && mcpart.has_mothers()) { + if (mcpart.mothersIds()[0] == cand.globalIndex()) { + registry.fill(HIST("hDecayLengthId"), decayLength * 1e4); + registry.fill(HIST("hDecayLengthScaledId"), decayLength * o2::constants::physics::MassOmegaC0 / RecoDecay::p(momenta[0], momenta[1]) * 1e4); + + std::array secondaryVertexGen = {mother.vx(), mother.vy(), mother.vz()}; + const auto decayLengthGen = RecoDecay::distance(secondaryVertexGen, primaryVertexPosGen); + registry.fill(HIST("hDecayLengthGen"), decayLengthGen * 1e4); + registry.fill(HIST("hDecayLengthScaledGen"), decayLengthGen * o2::constants::physics::MassOmegaC0 / RecoDecay::p(momenta[0], momenta[1]) * 1e4); + + registry.fill(HIST("hDeltaDecayLength"), (decayLength - decayLengthGen) * 1e4); + } } } } + } catch (const std::runtime_error& error) { + LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for Casc-Pi cannot work, skipping the candidate."; + hCandidatesCascPi->Fill(SVFitting::Fail); + continue; } + hCandidatesCascPi->Fill(SVFitting::FitOk); // MC-based mass momenta[0] = {mother.px(), mother.py(), mother.pz()}; From 31c54d735a94472b20343b8ad686eb5a0e8a3201 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 17:51:08 +0200 Subject: [PATCH 11/14] Trivial fix. --- PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx b/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx index 062f887683c..84dca3429fe 100644 --- a/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx +++ b/PWGHF/D2H/TableProducer/dataCreatorCharmHadPiReduced.cxx @@ -237,9 +237,9 @@ struct HfDataCreatorCharmHadPiReduced { registry.add(Form("hCpa%s", histMassTitle0.data()), Form("%s candidates;%s cosine of pointing angle;entries", charmHadTitle0.data(), charmHadTitle0.data()), {HistType::kTH1F, {{110, -1.1, 1.1}}}); /// candidate monitoring - hCandidatesD00 = registry.add("hCandidatesD00", "D candidate counter", {HistType::kTH1D, {axisCands}}); + hCandidatesD0 = registry.add("hCandidatesD0", "D candidate counter", {HistType::kTH1D, {axisCands}}); hCandidatesDPlus = registry.add("hCandidatesDPlus", "B candidate counter", {HistType::kTH1D, {axisCands}}); - setLabelHistoCands(hCandidatesD00); + setLabelHistoCands(hCandidatesD0); setLabelHistoCands(hCandidatesDPlus); } From 4f1257a0765a941e48bca3a1591b1fb3b5d9e0b9 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 17:59:05 +0200 Subject: [PATCH 12/14] Fix Clang format. --- PWGHF/Utils/utilsTrkCandHf.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/PWGHF/Utils/utilsTrkCandHf.h b/PWGHF/Utils/utilsTrkCandHf.h index 90f63ec56a0..6ccb0270798 100644 --- a/PWGHF/Utils/utilsTrkCandHf.h +++ b/PWGHF/Utils/utilsTrkCandHf.h @@ -22,10 +22,10 @@ namespace o2::hf_trkcandsel { // secondary vertex fitting monitoring enum SVFitting { - BeforeFit = 0, - FitOk, - Fail, - NCases + BeforeFit = 0, + FitOk, + Fail, + NCases }; o2::framework::AxisSpec axisCands = {SVFitting::NCases, -0.5f, static_cast(SVFitting::NCases) - 0.5f, ""}; From e27dc488835c7eff13f00d1825af1069b2da7d92 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 18:04:41 +0200 Subject: [PATCH 13/14] Fix MegaLinter error. --- PWGHF/Utils/utilsTrkCandHf.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGHF/Utils/utilsTrkCandHf.h b/PWGHF/Utils/utilsTrkCandHf.h index 6ccb0270798..073e416236d 100644 --- a/PWGHF/Utils/utilsTrkCandHf.h +++ b/PWGHF/Utils/utilsTrkCandHf.h @@ -43,4 +43,4 @@ void setLabelHistoCands(Histo& hCandidates) } // namespace o2::hf_trkcandsel -#endif // PWGHF_UTILS_UTILSTRKCANDHF_H_ \ No newline at end of file +#endif // PWGHF_UTILS_UTILSTRKCANDHF_H_ From 247dca62c44a7d567e389b9b8a93f95561e1df33 Mon Sep 17 00:00:00 2001 From: Mattia Faggin Date: Thu, 18 Apr 2024 18:17:26 +0200 Subject: [PATCH 14/14] Fix FitOk filling in treeCreatorOmegaSt.cxx. --- PWGHF/TableProducer/treeCreatorOmegacSt.cxx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/PWGHF/TableProducer/treeCreatorOmegacSt.cxx b/PWGHF/TableProducer/treeCreatorOmegacSt.cxx index fd503131096..fb566346bf3 100644 --- a/PWGHF/TableProducer/treeCreatorOmegacSt.cxx +++ b/PWGHF/TableProducer/treeCreatorOmegacSt.cxx @@ -547,6 +547,8 @@ struct HfTreeCreatorOmegacSt { decayLengthCasc, decayLengthCascXY); } + } else { + continue; } } catch (const std::runtime_error& error) { LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for Casc-Pi cannot work, skipping the candidate."; @@ -672,13 +674,13 @@ struct HfTreeCreatorOmegacSt { } } } + hCandidatesCascPi->Fill(SVFitting::FitOk); } } catch (const std::runtime_error& error) { LOG(info) << "Run time error found: " << error.what() << ". DCFitterN for Casc-Pi cannot work, skipping the candidate."; hCandidatesCascPi->Fill(SVFitting::Fail); continue; } - hCandidatesCascPi->Fill(SVFitting::FitOk); // MC-based mass momenta[0] = {mother.px(), mother.py(), mother.pz()};