Message: Re: information on ancestor particles Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question Re: information on ancestor particles  

Keywords: ancestor particles mother particles
Forum: Event and Track Management
Re: None information on ancestor particles (Holger Gottschlag)
Re: None Re: information on ancestor particles (Makoto Asai)
Date: 11 May, 2007
From: Holger Gottschlag <hgottsch@uni-muenster.de>

Thanks for your reply! 

As shown in http://geant4.slac.stanford.edu/Tips/event/3.html
i put this into my code: 

----------------------------------------
T01Trajectory* SteppingAction::GetParentTrajectory(G4int parentID)
{
  G4TrajectoryContainer* container = 
   G4RunManager::GetRunManager()->GetCurrentEvent()->GetTrajectoryContainer();
  if(container==0) return 0;
  TrajectoryVector* vect = container->GetVector();
  G4VTrajectory** tr = vect->begin();      // did not compile
  while(tr!=vect->end())
  { 
    T01Trajectory* tr1 = (T01Trajectory*)tr;
    if(tr1->GetTrackID()==parentID) return tr1;  //segmentation fault here
    tr++;
    debug++;
    G4cout<<"debug: " << debug << endl;
  }
  return 0;
}
----------------------------------------
which unfortunaly leads to this error message:

src/SteppingAction.cc:106: error: cannot convert `
   __gnu_cxx::__normal_iterator<G4VTrajectory**, std::vector<G4VTrajectory*,
   std::allocator<G4VTrajectory*> > >' to `G4VTrajectory**' in initialization
src/SteppingAction.cc:107: error: no match for 'operator!=' in 'tr !=
   std::vector<_Tp, _Alloc>::end() [with _Tp = G4VTrajectory*, _Alloc =
   std::allocator<G4VTrajectory*>]()'

so it looks like "G4VTrajectory" does not fit to "vect->begin()", which is an iterator.  

when i change the lines

"G4VTrajectory** tr = vect->begin();"
  and 
"while(tr!=vect->end())"

to 

"G4VTrajectory* tr = *(vect->begin());"
  and
"while(tr!=*(vect->end()))"

The Code compiles well, but i get a Segmentation Fault at Run Time 
in Line 

"if(tr1->GetTrackID()==parentID) return tr1;"


Did anyone solve that problem yet? 



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

1 Note: Re: information on ancestor particles   (Holger Gottschlag - 11 May, 2007)
 Add Message Add Message
to: "Re: information on ancestor particles "

 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 ]