From 0fb181d2240b4318ca6b2d23ef0efc4c6a09f8f6 Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Wed, 13 Mar 2024 20:22:29 -0300 Subject: [PATCH 1/4] PWGLF: Fix decoding of generated information from derived AO2Ds --- .../derivedlambdakzeroanalysis.cxx | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx index f135af2d07f..a391742ef82 100644 --- a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx @@ -857,38 +857,38 @@ struct derivedlambdakzeroanalysis { auto hOmegaMinus = histos.get(HIST("h2dGenOmegaMinus")); auto hOmegaPlus = histos.get(HIST("h2dGenOmegaPlus")); for (auto& gVec : geK0Short) { - for (uint32_t iv = 0; iv < gVec.generatedK0Short().size(); iv++) { + for (uint32_t iv = 0; iv < hK0Short->GetNcells(); iv++) { hK0Short->SetBinContent(iv + 1, hK0Short->GetBinContent(iv + 1) + gVec.generatedK0Short()[iv]); } } for (auto& gVec : geLambda) { - for (uint32_t iv = 0; iv < gVec.generatedLambda().size(); iv++) { - hLambda->SetBinContent(iv + 1, hLambda->GetBinContent(iv + 1) + gVec.generatedLambda()[iv]); + for (uint32_t iv = 0; iv < hLambda->GetNcells(); iv++) { + hLambda->SetBinContent(iv, hLambda->GetBinContent(iv) + gVec.generatedLambda()[iv]); } } for (auto& gVec : geAntiLambda) { - for (uint32_t iv = 0; iv < gVec.generatedAntiLambda().size(); iv++) { - hAntiLambda->SetBinContent(iv + 1, hAntiLambda->GetBinContent(iv + 1) + gVec.generatedAntiLambda()[iv]); + for (uint32_t iv = 0; iv < hAntiLambda->GetNcells(); iv++) { + hAntiLambda->SetBinContent(iv, hAntiLambda->GetBinContent(iv) + gVec.generatedAntiLambda()[iv]); } } for (auto& gVec : geXiMinus) { - for (uint32_t iv = 0; iv < gVec.generatedXiMinus().size(); iv++) { - hXiMinus->SetBinContent(iv + 1, hXiMinus->GetBinContent(iv + 1) + gVec.generatedXiMinus()[iv]); + for (uint32_t iv = 0; iv < hXiMinus->GetNcells(); iv++) { + hXiMinus->SetBinContent(iv, hXiMinus->GetBinContent(iv) + gVec.generatedXiMinus()[iv]); } } for (auto& gVec : geXiPlus) { - for (uint32_t iv = 0; iv < gVec.generatedXiPlus().size(); iv++) { - hXiPlus->SetBinContent(iv + 1, hXiPlus->GetBinContent(iv + 1) + gVec.generatedXiPlus()[iv]); + for (uint32_t iv = 0; iv < hXiPlus->GetNcells(); iv++) { + hXiPlus->SetBinContent(iv, hXiPlus->GetBinContent(iv) + gVec.generatedXiPlus()[iv]); } } for (auto& gVec : geOmegaMinus) { - for (uint32_t iv = 0; iv < gVec.generatedOmegaMinus().size(); iv++) { - hOmegaMinus->SetBinContent(iv + 1, hOmegaMinus->GetBinContent(iv + 1) + gVec.generatedOmegaMinus()[iv]); + for (uint32_t iv = 0; iv < hOmegaMinus->GetNcells(); iv++) { + hOmegaMinus->SetBinContent(iv, hOmegaMinus->GetBinContent(iv) + gVec.generatedOmegaMinus()[iv]); } } for (auto& gVec : geOmegaPlus) { - for (uint32_t iv = 0; iv < gVec.generatedOmegaPlus().size(); iv++) { - hOmegaPlus->SetBinContent(iv + 1, hOmegaPlus->GetBinContent(iv + 1) + gVec.generatedOmegaPlus()[iv]); + for (uint32_t iv = 0; iv < hOmegaPlus->GetNcells(); iv++) { + hOmegaPlus->SetBinContent(iv, hOmegaPlus->GetBinContent(iv) + gVec.generatedOmegaPlus()[iv]); } } } From bc0a0786af4197b18abdd8f5854f216ac11ee280 Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Wed, 13 Mar 2024 20:26:20 -0300 Subject: [PATCH 2/4] Minor fix --- PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx index a391742ef82..a1d7bb7102b 100644 --- a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx @@ -858,7 +858,7 @@ struct derivedlambdakzeroanalysis { auto hOmegaPlus = histos.get(HIST("h2dGenOmegaPlus")); for (auto& gVec : geK0Short) { for (uint32_t iv = 0; iv < hK0Short->GetNcells(); iv++) { - hK0Short->SetBinContent(iv + 1, hK0Short->GetBinContent(iv + 1) + gVec.generatedK0Short()[iv]); + hK0Short->SetBinContent(iv, hK0Short->GetBinContent(iv) + gVec.generatedK0Short()[iv]); } } for (auto& gVec : geLambda) { From 2a8e51843210b387b61bfc81777b4b2c742ee8bd Mon Sep 17 00:00:00 2001 From: ddobrigk Date: Wed, 13 Mar 2024 20:31:49 -0300 Subject: [PATCH 3/4] Add FATAL in case of Ncells mismatch As a safety feature, if the number of cells in the receiving histogram differs from the number of elements in the incoming array, the decoder will FATAL. This should pick up 99.9% of mistakes automatically. --- .../Strangeness/derivedlambdakzeroanalysis.cxx | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx index a1d7bb7102b..bb8fa663bdc 100644 --- a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx @@ -857,36 +857,50 @@ struct derivedlambdakzeroanalysis { auto hOmegaMinus = histos.get(HIST("h2dGenOmegaMinus")); auto hOmegaPlus = histos.get(HIST("h2dGenOmegaPlus")); for (auto& gVec : geK0Short) { + if(gVec.size()!=hK0Short->GetNcells()) + LOGF(fatal, "K0Short: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hK0Short->GetNcells(); iv++) { - hK0Short->SetBinContent(iv, hK0Short->GetBinContent(iv) + gVec.generatedK0Short()[iv]); + hK0Short->SetBinContent(iv + 1, hK0Short->GetBinContent(iv + 1) + gVec.generatedK0Short()[iv]); } } for (auto& gVec : geLambda) { + if(gVec.size()!=hLambda->GetNcells()) + LOGF(fatal, "Lambda: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hLambda->GetNcells(); iv++) { hLambda->SetBinContent(iv, hLambda->GetBinContent(iv) + gVec.generatedLambda()[iv]); } } for (auto& gVec : geAntiLambda) { + if(gVec.size()!=hAntiLambda->GetNcells()) + LOGF(fatal, "AntiLambda: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hAntiLambda->GetNcells(); iv++) { hAntiLambda->SetBinContent(iv, hAntiLambda->GetBinContent(iv) + gVec.generatedAntiLambda()[iv]); } } for (auto& gVec : geXiMinus) { + if(gVec.size()!=hXiMinus->GetNcells()) + LOGF(fatal, "XiMinus: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hXiMinus->GetNcells(); iv++) { hXiMinus->SetBinContent(iv, hXiMinus->GetBinContent(iv) + gVec.generatedXiMinus()[iv]); } } for (auto& gVec : geXiPlus) { + if(gVec.size()!=hXiPlus->GetNcells()) + LOGF(fatal, "XiPlus: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hXiPlus->GetNcells(); iv++) { hXiPlus->SetBinContent(iv, hXiPlus->GetBinContent(iv) + gVec.generatedXiPlus()[iv]); } } for (auto& gVec : geOmegaMinus) { + if(gVec.size()!=hOmegaMinus->GetNcells()) + LOGF(fatal, "OmegaMinus: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hOmegaMinus->GetNcells(); iv++) { hOmegaMinus->SetBinContent(iv, hOmegaMinus->GetBinContent(iv) + gVec.generatedOmegaMinus()[iv]); } } for (auto& gVec : geOmegaPlus) { + if(gVec.size()!=hOmegaPlus->GetNcells()) + LOGF(fatal, "OmegaPlus: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hOmegaPlus->GetNcells(); iv++) { hOmegaPlus->SetBinContent(iv, hOmegaPlus->GetBinContent(iv) + gVec.generatedOmegaPlus()[iv]); } From 7103fe4271ff6910abb887174b2bc2ae69e946a2 Mon Sep 17 00:00:00 2001 From: ALICE Builder Date: Thu, 14 Mar 2024 00:32:50 +0100 Subject: [PATCH 4/4] Please consider the following formatting changes (#5150) --- .../Strangeness/derivedlambdakzeroanalysis.cxx | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx index bb8fa663bdc..2282f886c29 100644 --- a/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx +++ b/PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx @@ -857,49 +857,49 @@ struct derivedlambdakzeroanalysis { auto hOmegaMinus = histos.get(HIST("h2dGenOmegaMinus")); auto hOmegaPlus = histos.get(HIST("h2dGenOmegaPlus")); for (auto& gVec : geK0Short) { - if(gVec.size()!=hK0Short->GetNcells()) + if (gVec.size() != hK0Short->GetNcells()) LOGF(fatal, "K0Short: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hK0Short->GetNcells(); iv++) { hK0Short->SetBinContent(iv + 1, hK0Short->GetBinContent(iv + 1) + gVec.generatedK0Short()[iv]); } } for (auto& gVec : geLambda) { - if(gVec.size()!=hLambda->GetNcells()) + if (gVec.size() != hLambda->GetNcells()) LOGF(fatal, "Lambda: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hLambda->GetNcells(); iv++) { hLambda->SetBinContent(iv, hLambda->GetBinContent(iv) + gVec.generatedLambda()[iv]); } } for (auto& gVec : geAntiLambda) { - if(gVec.size()!=hAntiLambda->GetNcells()) + if (gVec.size() != hAntiLambda->GetNcells()) LOGF(fatal, "AntiLambda: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hAntiLambda->GetNcells(); iv++) { hAntiLambda->SetBinContent(iv, hAntiLambda->GetBinContent(iv) + gVec.generatedAntiLambda()[iv]); } } for (auto& gVec : geXiMinus) { - if(gVec.size()!=hXiMinus->GetNcells()) + if (gVec.size() != hXiMinus->GetNcells()) LOGF(fatal, "XiMinus: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hXiMinus->GetNcells(); iv++) { hXiMinus->SetBinContent(iv, hXiMinus->GetBinContent(iv) + gVec.generatedXiMinus()[iv]); } } for (auto& gVec : geXiPlus) { - if(gVec.size()!=hXiPlus->GetNcells()) + if (gVec.size() != hXiPlus->GetNcells()) LOGF(fatal, "XiPlus: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hXiPlus->GetNcells(); iv++) { hXiPlus->SetBinContent(iv, hXiPlus->GetBinContent(iv) + gVec.generatedXiPlus()[iv]); } } for (auto& gVec : geOmegaMinus) { - if(gVec.size()!=hOmegaMinus->GetNcells()) + if (gVec.size() != hOmegaMinus->GetNcells()) LOGF(fatal, "OmegaMinus: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hOmegaMinus->GetNcells(); iv++) { hOmegaMinus->SetBinContent(iv, hOmegaMinus->GetBinContent(iv) + gVec.generatedOmegaMinus()[iv]); } } for (auto& gVec : geOmegaPlus) { - if(gVec.size()!=hOmegaPlus->GetNcells()) + if (gVec.size() != hOmegaPlus->GetNcells()) LOGF(fatal, "OmegaPlus: Number of elements in generated array and number of cells in receiving histogram differ!"); for (uint32_t iv = 0; iv < hOmegaPlus->GetNcells(); iv++) { hOmegaPlus->SetBinContent(iv, hOmegaPlus->GetBinContent(iv) + gVec.generatedOmegaPlus()[iv]);