Message: segmentation fault in getting geometry name Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Question segmentation fault in getting geometry name  

Forum: Geometry
Date: 20 Dec, 2012
From: kitty <kitty>

Hi Geant4 experts:

  I want to record the protons cross section  position when they are incident on the detector in hadrontherapy. I add some code to Hadrontherapysteppingaction.cc as following( followed the example of microbean in advanced example&#65289; :

 G4String volume1= aStep -> GetPreStepPoint() -> GetPhysicalVolume() -> GetName();
 G4String volume21= aStep -> GetPostStepPoint() -> GetPhysicalVolume() -> GetName();
 G4String volume22= aStep -> GetPostStepPoint() -> GetPhysicalVolume() -> GetName();

if ( 
     ((volume1== "TreatmentRoom")&&(volume21== "DetectorPhys") 
&&  (aStep->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "proton"))
 || 
 ((volume1== "TreatmentRoom")&&(volume22== "phantomPhys")
   &&  (aStep->GetTrack()->GetDynamicParticle()->GetDefinition() ->GetParticleName() == "proton"))
)
	{

	 G4StepPoint* p1 = aStep->GetPreStepPoint();
         G4ThreeVector coord1 = p1->GetPosition();
         const G4AffineTransform transformation1 = p1->GetTouchable()->GetHistory()->GetTopTransform();
         G4ThreeVector localPosition1 = transformation1.TransformPoint(coord1);

	 G4StepPoint* p2 = aStep->GetPostStepPoint();
         G4ThreeVector coord2 = p2->GetPosition();
         const G4AffineTransform transformation2 = p2->GetTouchable()->GetHistory()->GetTopTransform();
         G4ThreeVector localPosition2 = transformation2.TransformPoint(coord2);

         G4ThreeVector localPosition = localPosition1 + G4UniformRand()*(localPosition2-localPosition1);

	 // G4cout << "localPositionx=" <<   localPosition.x()/micrometer << " localPositiony =" << localPosition.y()/micrometer << G4endl;
        //  G4cout  <<"theta " <<   theta/rad <<"phi " <<phi/rad << G4endl;
	 // end

	 FILE *myFile;
	 myFile=fopen("beamPosition.txt","a");
	 fprintf 
	 ( 
	  myFile,"%e %e \n",
	  localPosition.x()/micrometer,
	  localPosition.y()/micrometer
	 );
	 fclose (myFile);				
	} 
Segment fault appears when I run the example. I  have looked into some topics  in this forum.I think this error maybe caused by using aStep -> GetPostStepPoint() -> GetPhysicalVolume() -> GetName().But I don't know how to solve the problem of Segment fault. And I don't know how to obtain the incident positon on the detector for protons in this example. I am anxious about this. who can tell me?  I will appreciate  this very much&#65281;

                                                           kitty

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

1 More: Re: segmentation fault in getting geometry name   (kitty - 20 Dec, 2012)
(_ Idea: Re: segmentation fault in getting geometry name   (C Mos - 03 Jan, 2013)
(_ Feedback: Re: segmentation fault in getting geometry name   (kitty - 14 Jan, 2013)
 Add Message Add Message
to: "segmentation fault in getting geometry 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 ]