diff --git a/source/Refitting/include/RefitProcessor.h b/source/Refitting/include/RefitProcessor.h index 541bed1..4be228e 100644 --- a/source/Refitting/include/RefitProcessor.h +++ b/source/Refitting/include/RefitProcessor.h @@ -9,6 +9,8 @@ #include +#include + namespace MarlinTrk{ class IMarlinTrkSystem ; } @@ -79,7 +81,7 @@ class RefitProcessor : public marlin::Processor { lcio::LCCollection* GetCollection( lcio::LCEvent * evt, std::string colName ) ; /* helper function to get relations using try catch block */ - lcio::LCRelationNavigator* GetRelations(lcio::LCEvent * evt, std::string RelName ) ; + std::unique_ptr GetRelations(lcio::LCEvent * evt, std::string RelName ) ; /** Input track collection name for refitting. */ diff --git a/source/Refitting/src/RefitProcessor.cc b/source/Refitting/src/RefitProcessor.cc index e6e92bd..e6fff06 100644 --- a/source/Refitting/src/RefitProcessor.cc +++ b/source/Refitting/src/RefitProcessor.cc @@ -195,7 +195,7 @@ void RefitProcessor::processEvent( LCEvent * evt ) { // get input collection and relations LCCollection* input_track_col = this->GetCollection( evt, _input_track_col_name ) ; - LCRelationNavigator* input_track_rels = this->GetRelations( evt, _input_track_rel_name ) ; + auto input_track_rels = this->GetRelations( evt, _input_track_rel_name ) ; if( input_track_col != 0 ){ @@ -414,8 +414,6 @@ void RefitProcessor::processEvent( LCEvent * evt ) { evt->addCollection( trackVec , _output_track_col_name) ; evt->addCollection( trackRelVec , _output_track_rel_name) ; - delete input_track_rels; input_track_rels = 0; - } ++_n_evt ; } @@ -452,13 +450,13 @@ LCCollection* RefitProcessor::GetCollection( LCEvent * evt, std::string colName } -LCRelationNavigator* RefitProcessor::GetRelations(LCEvent * evt , std::string RelName ) { +std::unique_ptr RefitProcessor::GetRelations(LCEvent * evt , std::string RelName ) { - LCRelationNavigator* nav = 0 ; + std::unique_ptr nav = nullptr; try{ - nav = new LCRelationNavigator(evt->getCollection( RelName.c_str() )); - streamlog_out( DEBUG2 ) << "RefitProcessor --> " << RelName << " track relation collection in event = " << nav << std::endl; + nav.reset(new LCRelationNavigator(evt->getCollection( RelName.c_str() ))); + streamlog_out( DEBUG2 ) << "RefitProcessor --> " << RelName << " track relation collection in event = " << nav.get() << std::endl; } catch(DataNotAvailableException &e){ streamlog_out( DEBUG2 ) << "RefitProcessor --> " << RelName.c_str() << " track relation collection absent in event" << std::endl;