From 3fc54a2ec2285577b0f3a7e2e25c5656a59dc866 Mon Sep 17 00:00:00 2001 From: tmadlener Date: Fri, 16 Feb 2024 14:55:43 +0100 Subject: [PATCH] Make sure to propagate type information into the relation --- source/Refitting/src/RefitProcessor.cc | 27 +++++++++----------------- 1 file changed, 9 insertions(+), 18 deletions(-) diff --git a/source/Refitting/src/RefitProcessor.cc b/source/Refitting/src/RefitProcessor.cc index e6fff06..3ef22b9 100644 --- a/source/Refitting/src/RefitProcessor.cc +++ b/source/Refitting/src/RefitProcessor.cc @@ -207,12 +207,11 @@ void RefitProcessor::processEvent( LCEvent * evt ) { LCFlagImpl trkFlag(0) ; trkFlag.setBit( LCIO::TRBIT_HITS ) ; trackVec->setFlag( trkFlag.getFlag() ) ; - - // establish the track relations collection that will be created - LCCollectionVec* trackRelVec = new LCCollectionVec( LCIO::LCRELATION ) ; - + + // establish the track relations collection that will be created + auto trackRelNav = UTIL::LCRelationNavigator(LCIO::TRACK, LCIO::MCPARTICLE); + int nTracks = input_track_col->getNumberOfElements() ; - streamlog_out(DEBUG4) << "Processing input collection " << _input_track_col_name << " with " << nTracks << " tracks\n"; // loop over the input tacks and refit using KalTest @@ -394,25 +393,17 @@ void RefitProcessor::processEvent( LCEvent * evt ) { // assign the relations previously assigned to the input tracks if(input_track_rels){ - LCObjectVec objVec = input_track_rels->getRelatedToObjects( track_to_refit ); - FloatVec weights = input_track_rels->getRelatedToWeights( track_to_refit ); + const auto& objVec = input_track_rels->getRelatedToObjects( track_to_refit ); + const auto& weights = input_track_rels->getRelatedToWeights( track_to_refit ); for( unsigned int irel=0 ; irel < objVec.size() ; ++irel ){ - - LCRelationImpl* rel = new LCRelationImpl ; - rel->setFrom (refittedTrack) ; - rel->setTo ( objVec[irel] ) ; - rel->setWeight(weights[irel]) ; - trackRelVec->addElement( rel ); - + trackRelNav.addRelation(refittedTrack, objVec[irel], weights[irel]); } } - - - - } + } evt->addCollection( trackVec , _output_track_col_name) ; + auto trackRelVec = trackRelNav.createLCCollection(); evt->addCollection( trackRelVec , _output_track_rel_name) ; } ++_n_evt ;