Skip to content

Commit 2a8e518

Browse files
authored
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.
1 parent bc0a078 commit 2a8e518

1 file changed

Lines changed: 15 additions & 1 deletion

File tree

PWGLF/Tasks/Strangeness/derivedlambdakzeroanalysis.cxx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -857,36 +857,50 @@ struct derivedlambdakzeroanalysis {
857857
auto hOmegaMinus = histos.get<TH2>(HIST("h2dGenOmegaMinus"));
858858
auto hOmegaPlus = histos.get<TH2>(HIST("h2dGenOmegaPlus"));
859859
for (auto& gVec : geK0Short) {
860+
if(gVec.size()!=hK0Short->GetNcells())
861+
LOGF(fatal, "K0Short: Number of elements in generated array and number of cells in receiving histogram differ!");
860862
for (uint32_t iv = 0; iv < hK0Short->GetNcells(); iv++) {
861-
hK0Short->SetBinContent(iv, hK0Short->GetBinContent(iv) + gVec.generatedK0Short()[iv]);
863+
hK0Short->SetBinContent(iv + 1, hK0Short->GetBinContent(iv + 1) + gVec.generatedK0Short()[iv]);
862864
}
863865
}
864866
for (auto& gVec : geLambda) {
867+
if(gVec.size()!=hLambda->GetNcells())
868+
LOGF(fatal, "Lambda: Number of elements in generated array and number of cells in receiving histogram differ!");
865869
for (uint32_t iv = 0; iv < hLambda->GetNcells(); iv++) {
866870
hLambda->SetBinContent(iv, hLambda->GetBinContent(iv) + gVec.generatedLambda()[iv]);
867871
}
868872
}
869873
for (auto& gVec : geAntiLambda) {
874+
if(gVec.size()!=hAntiLambda->GetNcells())
875+
LOGF(fatal, "AntiLambda: Number of elements in generated array and number of cells in receiving histogram differ!");
870876
for (uint32_t iv = 0; iv < hAntiLambda->GetNcells(); iv++) {
871877
hAntiLambda->SetBinContent(iv, hAntiLambda->GetBinContent(iv) + gVec.generatedAntiLambda()[iv]);
872878
}
873879
}
874880
for (auto& gVec : geXiMinus) {
881+
if(gVec.size()!=hXiMinus->GetNcells())
882+
LOGF(fatal, "XiMinus: Number of elements in generated array and number of cells in receiving histogram differ!");
875883
for (uint32_t iv = 0; iv < hXiMinus->GetNcells(); iv++) {
876884
hXiMinus->SetBinContent(iv, hXiMinus->GetBinContent(iv) + gVec.generatedXiMinus()[iv]);
877885
}
878886
}
879887
for (auto& gVec : geXiPlus) {
888+
if(gVec.size()!=hXiPlus->GetNcells())
889+
LOGF(fatal, "XiPlus: Number of elements in generated array and number of cells in receiving histogram differ!");
880890
for (uint32_t iv = 0; iv < hXiPlus->GetNcells(); iv++) {
881891
hXiPlus->SetBinContent(iv, hXiPlus->GetBinContent(iv) + gVec.generatedXiPlus()[iv]);
882892
}
883893
}
884894
for (auto& gVec : geOmegaMinus) {
895+
if(gVec.size()!=hOmegaMinus->GetNcells())
896+
LOGF(fatal, "OmegaMinus: Number of elements in generated array and number of cells in receiving histogram differ!");
885897
for (uint32_t iv = 0; iv < hOmegaMinus->GetNcells(); iv++) {
886898
hOmegaMinus->SetBinContent(iv, hOmegaMinus->GetBinContent(iv) + gVec.generatedOmegaMinus()[iv]);
887899
}
888900
}
889901
for (auto& gVec : geOmegaPlus) {
902+
if(gVec.size()!=hOmegaPlus->GetNcells())
903+
LOGF(fatal, "OmegaPlus: Number of elements in generated array and number of cells in receiving histogram differ!");
890904
for (uint32_t iv = 0; iv < hOmegaPlus->GetNcells(); iv++) {
891905
hOmegaPlus->SetBinContent(iv, hOmegaPlus->GetBinContent(iv) + gVec.generatedOmegaPlus()[iv]);
892906
}

0 commit comments

Comments
 (0)