Message: RE: Uninitialized volume pointers in G4Track? Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

None RE: Uninitialized volume pointers in G4Track? 

Forum: Event and Track Management
Re: Warning Uninitialized volume pointers in G4Track? (Ben Loer)
Date: 01 Oct, 2007
From: Makoto Asai <Makoto Asai>


 A primary track does not have a valid pointer to a volume, since
it has not yet been "placed". Placing (i.e. locating a track in a
geometry) is done when the track is sent to the tracking manager.
Thus, in your code,  
always returns null in this IF-block.


> -----Original Message-----
> From: Ben Loer [] 
> Sent: Monday, October 01, 2007 10:57 AM
> To: publichypernews
> Subject: Uninitialized volume pointers in G4Track?
> *** Discussion title: Event and Track Management
> Email replies to must include:
>   In-Reply-To: <"/eventtrackmanage/710">
>   Subject: ...change this to be about your reply.
> Hi all,
> I just came across a rather irritating bug(?) in G4Track. The 
> following
> code snippet is from my UserStackingAction:
> G4ClassificationOfNewTrack PUStackingAction::ClassifyNewTrack
>                                             (const G4Track* aTrack)
> {
>   G4cout<<"Starting new stage"<<G4endl;
>   if(aTrack->GetParentID()==0){/
>     //This is a primary particle
>     G4cout<<"Primary particle released!"<<G4endl;
>     if(aTrack->GetVolume()) 
>        //G4cout<<aTrack->GetVolume()->GetName()<<G4endl;
>   }
>   return fUrgent;
> }
> This causes a bus error when it encounters the if(aTrack->GetVolume())
> line. I'm no C++ expert, but I thought that just checking to 
> see if the
> pointer was empty should be safe, unless its not initialized.
> Any suggestions on what else this could be? Or should I start a bug
> report?

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

 Add Message Add Message
to: "RE: Uninitialized volume pointers in G4Track?"

 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 ]