Message: Re: Segmentation fault for primary particles process name Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: Segmentation fault for primary particles process name 

Forum: Analysis
Re: Question Segmentation fault for primary particles process name (Volodymyr Rodin)
Date: Feb 13, 15:59
From: Michael H. Kelsey <Michael H. Kelsey>

On Wed, 13 Feb 2019 14:32:42 GMT, Volodymy Rodin wrote:
> I am saving information about detected particles in NTuples using
> SteppingAction. But after the last update of Geant4, this line doesn't
> work properly anymore and segmentation fault happens:
> 
>  analysisManager->FillNtupleSColumn(0,BranchId=2,aStep->GetTrack()->GetCreatorProcess()->GetProcessName()); (SteppingAction)

That line should never have worked properly without a null pointer check. Primary particles (those with parentID == 0) do not have a creator process. Thus, GetCreatorProcess() returns 0, and the ->GetProcessName() call is dereferencing a null pointer.

You should test for aStep->GetTrack()->GetCreatorProcess() == 0 before the above line, or you can be tricky with the ternary operator, for example:

  G4VProcess* trkProc = aStep->GetTrack()->GetCreatorProcess();
  analysisManager->FillNtupleSColumn(0,2,(trkProc?trkcProc->GetProcessName():G4String("Primary")));

That way, you have something human readable for the primary tracks.

     -- Michael Kelsey

Inline Depth:
 1 1
 All All
Outline Depth:
 1 1
 2 2
 All All
Add message: (add)

1 Ok: Re: Segmentation fault for primary particles process name   (Volodymyr Rodin - Feb 14, 03:39)
 Add Message Add Message
to: "Re: Segmentation fault for primary particles process name"

 Subscribe Subscribe

This site runs SLAC HyperNews version 1.11-slac-98, derived from the original HyperNews


[ Geant 4 Home | Geant 4 HyperNews | Search | Request New Forum | Feedback ]