Message: Re: tracking particle path length travelled in a volume Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Feedback Re: tracking particle path length travelled in a volume 

Forum: Event and Track Management
Re: Question tracking particle path length travelled in a volume (David Sangcheol Lee)
Date: 29 May, 2017
From: Gumplinger Peter <Gumplinger Peter>

in SteppingAction:

G4Track* theTrack = theStep->GetTrack();

G4StepPoint* point1 = theStep->GetPreStepPoint();
G4StepPoint* point2 = theStep->GetPostStepPoint();

G4VPhysicalVolume* volume1 = point1->GetTouchableHandle()->GetVolume();
G4VPhysicalVolume* volume2 = point2->GetTouchableHandle()->GetVolume();

if (point2->GetStepStatus() == fGeomBoundary) {
   if(volume1->GetName() == "name1" && volume2->GetName() == "name") 
      fL1 = theTrack->GetTrackLength(); // leaving volume1
  if(volume1->GetName() == "name" && volume2->GetName() == "name2") 
      fL2 = theTrack->GetTrackLength(); // entering volume2
}

if (fL2 > fL1) {
   G4double diff = fL2 - fL1;
   G4cout << "Neutron Track Length between volume2 and volume1: " << diff/cm << "cm" << G4endl;
   fL2 = fL1 = 0;
}

fL1 and fL2 are class members of SteppingAction and you initialize them both to zero in the constructor.

I am assuming the space between volume1 and volume2 has the name "name"

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

1 None: Re: tracking particle path length travelled in a volume   (David Sangcheol Lee - 29 May, 2017)
2 Question: Re: tracking particle path length travelled in a volume   (David Sangcheol Lee - 06 Jun, 2017)
3 Question: Re: tracking particle path length travelled in a volume   (David Sangcheol Lee - 11 Jul, 2017)
 Add Message Add Message
to: "Re: tracking particle path length travelled in a volume"

 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 ]