Skip to content

Segmentation fault during tracking#92

Open
eduard322 wants to merge 3 commits intoSND-LHC:tracking_no_excavationfrom
eduard322:tracking_no_exc_fix
Open

Segmentation fault during tracking#92
eduard322 wants to merge 3 commits intoSND-LHC:tracking_no_excavationfrom
eduard322:tracking_no_exc_fix

Conversation

@eduard322
Copy link
Contributor

Fixed the segmentation fault during the tracking that appeared at some point during processing of the neutrino events in the SND upgrade. Apparently, this kind of issue has never appeared neither in the previous studies of the advsnd, nor in the relevant sndsw. The issue was caused by TClonesArray and the python assignment for them (self.kalman_tracks[i_muon] = this_track). See the changed code. I replaced the assigment to the cpp one, which gave the positive results. I have tested the tracks and compared them with the ones stored in genfit_track format (worked without problems, but is disabled by default). Event display and with the fitted track:

image

Hope we can get rid of TClonesArray and use STL vectors, but so far here is the workaround. Maybe also useful for the sndsw, because it can happen any time due to the incorrect memory assignment.

this_track.setTrackType(self.track_type)
# Save the track in sndRecoTrack format
self.kalman_tracks[i_muon] = this_track
self.kalman_tracks.ExpandCreate(nStored + 1)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be avoided, as this might involve copying the entire array. It's probably better to only expand the array by a growth factor whenever we reach its capacity.

# Save the track in sndRecoTrack format
self.kalman_tracks[i_muon] = this_track
self.kalman_tracks.ExpandCreate(nStored + 1)
ROOT.EmplaceSndRecoTrack(self.kalman_tracks, int(nStored), this_track)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we don't want to define our own function, TClonesArray::ConstructedAt() followed by std::swap() can be used.

#include "sndRecoTrack.h"

// Construct a *copy* of src inside arr at index i (placement new).
sndRecoTrack* EmplaceSndRecoTrack(TClonesArray* arr, int i, const sndRecoTrack& src) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we're stuck with many TCAs, it might be worth making this a template function for any object inheriting from TObject and declare it somewhere centrally.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants