From d9f00daf3f9cc0f16d1fd13691622909f1ce23fc Mon Sep 17 00:00:00 2001 From: Paolo Andreetto Date: Fri, 21 Apr 2023 14:40:27 +0200 Subject: [PATCH] Fixed output collection in event --- src/MuonCVXDRealDigitiser.cc | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/MuonCVXDRealDigitiser.cc b/src/MuonCVXDRealDigitiser.cc index d958466..74d6900 100644 --- a/src/MuonCVXDRealDigitiser.cc +++ b/src/MuonCVXDRealDigitiser.cc @@ -299,6 +299,18 @@ void MuonCVXDRealDigitiser::processRunHeader(LCRunHeader* run) void MuonCVXDRealDigitiser::processEvent(LCEvent * evt) { + LCCollectionVec *THcol = new LCCollectionVec(LCIO::TRACKERHITPLANE); + CellIDEncoder cellid_encoder(lcio::LCTrackerCellID::encoding_string(), THcol); + + LCCollectionVec* relCol = new LCCollectionVec(LCIO::LCRELATION); + // to store the weights + LCFlagImpl lcFlag { 0 }; + lcFlag.setBit(LCIO::LCREL_WEIGHTED); + relCol->setFlag(lcFlag.getFlag()); + + evt->addCollection(THcol, _outputCollectionName.c_str()); + evt->addCollection(relCol, _colVTXRelation.c_str()); + LCCollection* STHcol = nullptr; try { @@ -312,18 +324,13 @@ void MuonCVXDRealDigitiser::processEvent(LCEvent * evt) STHcol = nullptr; } - if (STHcol == nullptr or STHcol->getNumberOfElements() == 0) return; + if (STHcol == nullptr or STHcol->getNumberOfElements() == 0) + { + streamlog_out(MESSAGE) << "Number of produced hits: " << THcol->getNumberOfElements() << std::endl; + } std::string encoder_str { STHcol->getParameters().getStringVal(lcio::LCIO::CellIDEncoding) }; CellIDDecoder cellid_decoder { encoder_str }; - LCCollectionVec *THcol = new LCCollectionVec(LCIO::TRACKERHITPLANE); - - LCCollectionVec* relCol = new LCCollectionVec(LCIO::LCRELATION); - // to store the weights - LCFlagImpl lcFlag { 0 }; - lcFlag.setBit(LCIO::LCREL_WEIGHTED); - relCol->setFlag(lcFlag.getFlag()); - std::size_t RELHISTOSIZE { 10 }; vector relHisto {}; relHisto.assign(RELHISTOSIZE, 0); @@ -565,8 +572,6 @@ void MuonCVXDRealDigitiser::processEvent(LCEvent * evt) } } streamlog_out(MESSAGE) << "Number of produced hits: " << THcol->getNumberOfElements() << std::endl; - evt->addCollection(THcol, _outputCollectionName.c_str()); - evt->addCollection(relCol, _colVTXRelation.c_str()); int count = 0; streamlog_out(DEBUG) << "Hit relation histogram:" << std::endl; for (std::size_t k = 0; k < RELHISTOSIZE; k++)