Skip to content

Commit

Permalink
Always record the output collection, even if it is empty.
Browse files Browse the repository at this point in the history
The output code decides what to write based on the contents of the
first event.  If we don't always record the collection, then it can
either be missing in the output, or we can get crashes when the output
code tries to access a nonexistent collection.
  • Loading branch information
scott-snyder authored and andresailer committed Apr 3, 2024
1 parent 9a2140c commit 5ac3f25
Showing 1 changed file with 18 additions and 17 deletions.
35 changes: 18 additions & 17 deletions source/LumiCalReco/src/MarlinLumiCalClusterer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,7 @@ void MarlinLumiCalClusterer::TryMarlinLumiCalClusterer(EVENT::LCEvent* evt) {
create clusters using: LumiCalClustererClass
-------------------------------------------------------------------------- */

if (!LumiCalClusterer.processEvent(evt))
return;
bool stat = LumiCalClusterer.processEvent(evt);

LCCollectionVec* LCalClusterCol = new LCCollectionVec(LCIO::CLUSTER);
IMPL::LCFlagImpl lcFlagImpl;
Expand All @@ -67,27 +66,29 @@ void MarlinLumiCalClusterer::TryMarlinLumiCalClusterer(EVENT::LCEvent* evt) {

LCCollectionVec* LCalRPCol = new LCCollectionVec(LCIO::RECONSTRUCTEDPARTICLE);

streamlog_out(DEBUG6) << " Transfering reco results to LCalClusterCollection....." << std::endl;
if (stat) {
streamlog_out(DEBUG6) << " Transfering reco results to LCalClusterCollection....." << std::endl;

for (int armNow = -1; armNow < 2; armNow += 2) {
streamlog_out(DEBUG6) << " Arm " << std::setw(4) << armNow
<< "\t Number of clusters: " << LumiCalClusterer._superClusterIdToCellId[armNow].size()
<< std::endl;
for (int armNow = -1; armNow < 2; armNow += 2) {
streamlog_out(DEBUG6) << " Arm " << std::setw(4) << armNow
<< "\t Number of clusters: " << LumiCalClusterer._superClusterIdToCellId[armNow].size()
<< std::endl;

for (auto const& pairIDCells : LumiCalClusterer._superClusterIdToCellId[armNow]) {
const int clusterId = pairIDCells.first;
LCCluster& thisClusterInfo = LumiCalClusterer._superClusterIdClusterInfo[armNow][clusterId];
thisClusterInfo.recalculatePositionFromHits(gmc);
auto objectTuple(gmc.getLCIOObjects(thisClusterInfo, _minClusterEngy, _cutOnFiducialVolume));
if (std::get<0>(objectTuple) == nullptr)
continue;
for (auto const& pairIDCells : LumiCalClusterer._superClusterIdToCellId[armNow]) {
const int clusterId = pairIDCells.first;
LCCluster& thisClusterInfo = LumiCalClusterer._superClusterIdClusterInfo[armNow][clusterId];
thisClusterInfo.recalculatePositionFromHits(gmc);
auto objectTuple(gmc.getLCIOObjects(thisClusterInfo, _minClusterEngy, _cutOnFiducialVolume));
if (std::get<0>(objectTuple) == nullptr)
continue;

LCalClusterCol->addElement(std::get<0>(objectTuple));
LCalRPCol->addElement(std::get<1>(objectTuple));
LCalClusterCol->addElement(std::get<0>(objectTuple));
LCalRPCol->addElement(std::get<1>(objectTuple));
}
}
}

//Add collections to the event if there are clusters
//Add collections to the event
evt->addCollection(LCalClusterCol, LumiClusterColName);
evt->addCollection(LCalRPCol, LumiRecoParticleColName);

Expand Down

0 comments on commit 5ac3f25

Please sign in to comment.