Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix some memory leaks #10

Merged
merged 2 commits into from Jun 13, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions src/ConformalTracking.cc
Expand Up @@ -648,7 +648,7 @@ void ConformalTracking::processEvent(LCEvent* evt) {
TrackImpl* track = new TrackImpl;

// First, for some reason there are 2 track objects, one which gets saved and one which is used for fitting. Don't ask...
MarlinTrk::IMarlinTrack* marlinTrack = trackFactory->createTrack();
shared_ptr<MarlinTrk::IMarlinTrack> marlinTrack(trackFactory->createTrack());

// Make an initial covariance matrix with very broad default values
EVENT::FloatVec covMatrix(15, 0); // Size 15, filled with 0s
Expand All @@ -659,15 +659,14 @@ void ConformalTracking::processEvent(LCEvent* evt) {
covMatrix[14] = (m_initialTrackError_tanL); //sigma_tanl^2

// Try to fit
int fitError = MarlinTrk::createFinalisedLCIOTrack(marlinTrack, trackHits, track, MarlinTrk::IMarlinTrack::forward,
int fitError = MarlinTrk::createFinalisedLCIOTrack(marlinTrack.get(), trackHits, track, MarlinTrk::IMarlinTrack::forward,
covMatrix, m_magneticField, m_maxChi2perHit);

// Check track quality - if fit fails chi2 will be 0. For the moment add hits by hand to any track that fails the track fit, and store it as if it were ok...
if (track->getChi2() == 0.) {
streamlog_out(DEBUG7) << "Fit failed. Track has " << track->getTrackerHits().size() << " hits" << std::endl;
streamlog_out(DEBUG7) << "Fit fail error " << fitError << std::endl;
delete track;
delete marlinTrack;
continue;
}

Expand Down Expand Up @@ -783,6 +782,14 @@ void ConformalTracking::processEvent(LCEvent* evt) {

// Increment the event number
m_eventNumber++;

//clean up
for (auto& cluster : kdClusterMap) {
delete cluster.first;
}
for (auto* relation : relations) {
delete relation;
}
}

void ConformalTracking::end() {
Expand Down