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 ;