Skip to content

Commit

Permalink
[EMCAL-688] Add protection for MCClusterLabel access in case of nullp…
Browse files Browse the repository at this point in the history
…tr (#12684)

- Bug introduced in #12660
- If MC labels not there (e.g. in data) the object was still accessed and orderLabels() was called
- Protection added to check that clusterLabel is actually present

Co-authored-by: jokonig <[email protected]>
  • Loading branch information
jokonig and jokonig authored Feb 12, 2024
1 parent dfbb4f0 commit 314755c
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions Detectors/EMCAL/base/src/ClusterFactory.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -90,18 +90,21 @@ o2::emcal::AnalysisCluster ClusterFactory<InputType>::buildCluster(int clusterIn
std::vector<unsigned short> cellsIdices;

size_t iCell = 0;
bool addClusterLabels = ((clusterLabel != nullptr) && (mCellLabelContainer.size() > 0));
for (auto cellIndex : inputsIndices) {
cellsIdices.push_back(cellIndex);
if ((clusterLabel != nullptr) && (mCellLabelContainer.size() > 0)) {
if (addClusterLabels) {
for (size_t iLabel = 0; iLabel < mCellLabelContainer[iCell].GetLabelSize(); iLabel++) {
clusterLabel->addValue(mCellLabelContainer[iCell].GetLabel(iLabel),
mCellLabelContainer[iCell].GetAmplitudeFraction(iLabel) * mInputsContainer[iCell].getEnergy());
}
iCell++;
}
}
clusterLabel->orderLabels();
clusterLabel->normalize(cellAmp);
if (addClusterLabels) {
clusterLabel->orderLabels();
clusterLabel->normalize(cellAmp);
}

clusterAnalysis.setCellsIndices(cellsIdices);

Expand Down

0 comments on commit 314755c

Please sign in to comment.