Message: Re: Kill Paricle in Volume Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: Kill Paricle in Volume 

Forum: Event and Track Management
Re: None Kill Paricle in Volume (A. Hod)
Date: 23 Oct, 2014
From: Zach Hartwig <Zach Hartwig>

Hello,

The most efficient way to kill any particle generated as a secondary is to implement the G4UserStackingAction::ClassifyNewTrack() method in your derived user stacking action class. This method is called _after_ secondaries are generated (thus giving you access to all their vertex information) but _before_ the secondaries have been added to the stack for tracking (thus enabling you to flag them to be "killed" before they waste CPU/memory, for example). You can return a value of "fUrgent" to continue tracking; returning a value of "fKill" based on conditional testing will terminate particle tracking.

Because you may generate an enormous number of secondaries, it is important to efficiently test for the volume in which they are generated. I would recommend in the G4UserStackingAction constructor to set a pointer to the G4VPhysicalVolume that you want to kill photons in (assuming of course, you have initialized your geometry BEFORE your stacking action class, otherwise you'll get a seg. fault).

Once you have this pointer, something like the following code will work

  G4ClassificationOfNewTrack stackingAction::ClassifyNewTrack(const G4Track* currentTrack){

  // ... other code you might want to implement here ... 

  // Kill optical photons within volume pointed to by VolumePointer
  if(currentTrack->GetDefinition() == G4OpticalPhoton::OpticalPhoton() and
     currentTrack->GetVolume() == VolumePointer)
    return fKill;
  else
    return fUrgent;
  }

  // ... other code you might want to implement here ...

  }

 Add Message Add Message
to: "Re: Kill Paricle in 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 ]