From bb93ee57bc85f08409e420381f3766eee261e5f9 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Sun, 12 Oct 2025 15:23:16 +0200 Subject: [PATCH 1/2] Set cellID encoding string whenever possible Set the encoding as soon as we have the necessary information instead of waiting until the end as that might be jumped over in case parts of the loop are skipped. --- CaloDigi/Realistic/src/RealisticCaloDigi.cc | 5 +++-- CaloDigi/Realistic/src/RealisticCaloReco.cc | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CaloDigi/Realistic/src/RealisticCaloDigi.cc b/CaloDigi/Realistic/src/RealisticCaloDigi.cc index c98b51c0..af1a3859 100644 --- a/CaloDigi/Realistic/src/RealisticCaloDigi.cc +++ b/CaloDigi/Realistic/src/RealisticCaloDigi.cc @@ -270,6 +270,8 @@ void RealisticCaloDigi::processEvent( LCEvent * evt ) { try{ LCCollection * col = evt->getCollection( colName.c_str() ) ; string initString = col->getParameters().getStringVal(LCIO::CellIDEncoding); + newcol->parameters().setValue(LCIO::CellIDEncoding,initString); + CHT::CaloType cht_type = caloTypeFromString(colName); CHT::CaloID cht_id = caloIDFromString(colName); CHT::Layout cht_lay = layoutFromString(colName); @@ -316,13 +318,12 @@ void RealisticCaloDigi::processEvent( LCEvent * evt ) { } // theshold } // input hits - // add collection to event - newcol->parameters().setValue(LCIO::CellIDEncoding,initString); } catch(DataNotAvailableException &e){ streamlog_out(DEBUG1) << "could not find input collection " << colName << std::endl; } + // add collection to event evt->addCollection(newcol,_outputCollections[i].c_str()); // add relation collection to event diff --git a/CaloDigi/Realistic/src/RealisticCaloReco.cc b/CaloDigi/Realistic/src/RealisticCaloReco.cc index c8869b46..c9793397 100644 --- a/CaloDigi/Realistic/src/RealisticCaloReco.cc +++ b/CaloDigi/Realistic/src/RealisticCaloReco.cc @@ -148,6 +148,8 @@ void RealisticCaloReco::processEvent( LCEvent * evt ) { int numElements = col->getNumberOfElements(); + newcol->parameters().setValue(LCIO::CellIDEncoding,initString); + streamlog_out ( DEBUG ) << colName << " number of elements = " << numElements << endl; for (int j(0); j < numElements; ++j) { @@ -181,14 +183,13 @@ void RealisticCaloReco::processEvent( LCEvent * evt ) { } - // add collection to event - newcol->parameters().setValue(LCIO::CellIDEncoding,initString); - + } catch(DataNotAvailableException &e){ streamlog_out(DEBUG) << "could not find input ECAL collection " << colName << std::endl; } + // add collection to event evt->addCollection(newcol,_outputHitCollections[i].c_str()); evt->addCollection(relcol, _outputRelCollections[i].c_str()); } From 9c4bb28c0606aa0b08c4e3b66e22f306841805a8 Mon Sep 17 00:00:00 2001 From: Thomas Madlener Date: Sun, 12 Oct 2025 15:24:12 +0200 Subject: [PATCH 2/2] Make sure to not jump loop and skip collection registration We will not enter the loop over the hits in any case if we have 0 hits. But with the continue in place we jump adding the collection to the event. --- CaloDigi/Realistic/src/RealisticCaloDigi.cc | 3 --- 1 file changed, 3 deletions(-) diff --git a/CaloDigi/Realistic/src/RealisticCaloDigi.cc b/CaloDigi/Realistic/src/RealisticCaloDigi.cc index af1a3859..a030ccf1 100644 --- a/CaloDigi/Realistic/src/RealisticCaloDigi.cc +++ b/CaloDigi/Realistic/src/RealisticCaloDigi.cc @@ -281,9 +281,6 @@ void RealisticCaloDigi::processEvent( LCEvent * evt ) { int numElements = col->getNumberOfElements(); streamlog_out ( DEBUG1 ) << colName << " number of elements = " << numElements << endl; - if ( numElements==0 ) continue; - - // loop over input hits for (int j=0; j < numElements; ++j) { SimCalorimeterHit * simhit = dynamic_cast( col->getElementAt( j ) ) ;