BLUserTrackFilter Class Reference

#include <BLUserCode.hh>

Inheritance diagram for BLUserTrackFilter:

BLUserCode

List of all members.


Detailed Description

class BLUserTrackFilter -- used by BLCMDusertrackfilter.

User code can use any library used by G4beamline simply by putting the appropriate include into the .cc file and building with g4blmake -- it automatically adds the appropriate include paths and libraries. These are: CLHEP, Geant4, Root, Gsl, and the C/C++ libraries. Coin and Xwindows are used by G4beamline for visualization, but are not available to user code.

Additional user libraries can be used if they are added to the CCFLAGS and EXTRALIBS environment variables to g4blmake -- do NOT do this for libraries used by G4beamline. Do not attempt to use the Coin or Xwindows libraries.

The user .cc file(s) can contain local class definitions and static instances of them; the latter will be constructed when the shared- object is loaded. NOTE: there is no guarantee that their destructors will be called (and they usually aren't), so if destruction is important, use setup() and complete().

filter() will be called by the "usertrackfilter" element whenever a track enters the physical volume of the element. The input track will be setup. The function can kill the track, and/or add pointers to new G4Track-s to the secondaries vector, as necessary.

Note that the Tune particle has eventID -2 and the Reference particle has eventID -1 -- these events may need special treatment, and their tracks should not be killed or modified.

The secondaries vector is initially empty; add pointers to G4Track-s to it to create secondaries.

verbose is the value of the parameter steppingVerbose. If it is nonzero you should print debugging information.

Note: for secondaries the trackID will be set to a unique value and the parentID will be set to the trackID of the input track, after filter() returns; all secondaries remain part of the current event. So there's no need to set trackID or parentID in G4Track-s put into the secondaries vector, and whatever values they have will be ignored.

The secondaries are created inside the volume, and do not get filtered.

Public Member Functions

 BLUserTrackFilter ()
 Constructor.
virtual ~BLUserTrackFilter ()
 Destructor.
const char * getType ()
 getType() return "usertrackfilter"
virtual const char * getName ()=0
 getName() returns the name of the user-supplied instance
virtual void filter (G4Track *track, int eventID, std::vector< G4Track * > &secondaries, int verbose)=0
 user function to filter tracks. Global coordinates are used. NOTE: do NOT delete the input track, or those you create and put into secondaries -- they are deleted by Geant4 internally.
virtual void setup (const char *init)=0
 setup() will be called during initialization; its argument is the string passed to the "usertrackfilter" command as its "init" argument. The init string can be used in any way by the user code (it passes information from the G4beamline input file to the user code, in a manner defined by the user code; the input file should be written to match this usage). If desired, multiple usertrackfilter commands can use a single user-supplied class instance, using the init string to differentiate among them. The init string need not be used at all.
virtual void complete (const char *init)=0
 complete() will be called after tracking is complete. It is intended for printing summaries and generally closing down. If multiple usertrackfilter commands reference this class instance, complete() will be called for each one, with the corresponding init string (do not depend on any particular ordering).

Static Public Member Functions

static int getPDGid (G4Track *track)
 getPDGid() returns the PDGid of a G4Track. User code can of course use the usual Geant4 functions to do this, this is merely for convenience.
static void setMomentum (G4Track *track, G4ThreeVector momentum)
 setMomentum() will set the momentum of a G4Track. User code can of course use the usual Geant4 functions to do this, this is merely for convenience.
static G4double getMass (int PDGid)
 getMass() returns the mass of a particle with known PDGid. User code can of course use the usual Geant4 functions to do this, this is merely for convenience.
static void killTrack (G4Track *track)
 killTrack() will kill a track.
static G4Track * constructTrack (G4ThreeVector position, G4ThreeVector momentum, G4double time, int PDGid, G4double weight=1.0)
 constructTrack() creates a new G4Track from position, momentum, time, and PDGid. Global coordinates are used. User code can of course use the usual Geant4 functions to do this, this is merely for convenience. Note that eventID is not contained in a G4Track.


Constructor & Destructor Documentation

BLUserTrackFilter::BLUserTrackFilter (  )  [inline]

Constructor.

00136 : BLUserCode() { }

virtual BLUserTrackFilter::~BLUserTrackFilter (  )  [inline, virtual]

Destructor.

00139 { }


Member Function Documentation

const char* BLUserTrackFilter::getType (  )  [inline, virtual]

getType() return "usertrackfilter"

Implements BLUserCode.

00142 { return "usertrackfilter"; }

int BLUserTrackFilter::getPDGid ( G4Track *  track  )  [static]

getPDGid() returns the PDGid of a G4Track. User code can of course use the usual Geant4 functions to do this, this is merely for convenience.

00030 {
00031         return track->GetDefinition()->GetPDGEncoding();
00032 }

void BLUserTrackFilter::setMomentum ( G4Track *  track,
G4ThreeVector  momentum 
) [static]

setMomentum() will set the momentum of a G4Track. User code can of course use the usual Geant4 functions to do this, this is merely for convenience.

References KE.

00035 {
00036         G4double mass=track->GetDefinition()->GetPDGMass();
00037         G4double KE=sqrt(momentum.mag2()+mass*mass) - mass;
00038         track->SetMomentumDirection(momentum.unit());
00039         track->SetKineticEnergy(KE);
00040 }

G4double BLUserTrackFilter::getMass ( int  PDGid  )  [static]

getMass() returns the mass of a particle with known PDGid. User code can of course use the usual Geant4 functions to do this, this is merely for convenience.

00044 {
00045         return G4ParticleTable::GetParticleTable()->FindParticle(PDGid)->
00046                                                                 GetPDGMass();
00047 }

void BLUserTrackFilter::killTrack ( G4Track *  track  )  [static]

killTrack() will kill a track.

00050 {
00051         track->SetTrackStatus(fStopAndKill);
00052 }

G4Track * BLUserTrackFilter::constructTrack ( G4ThreeVector  position,
G4ThreeVector  momentum,
G4double  time,
int  PDGid,
G4double  weight = 1.0 
) [static]

constructTrack() creates a new G4Track from position, momentum, time, and PDGid. Global coordinates are used. User code can of course use the usual Geant4 functions to do this, this is merely for convenience. Note that eventID is not contained in a G4Track.

00056 {
00057         G4ParticleDefinition *particle = 
00058                     G4ParticleTable::GetParticleTable()->FindParticle(PDGid);
00059         G4DynamicParticle *dyn = new G4DynamicParticle(particle,momentum);
00060         G4Track *track = new G4Track(dyn,time,position);
00061         track->SetWeight(weight);
00062         return track;
00063 }

virtual const char* BLUserTrackFilter::getName (  )  [pure virtual]

getName() returns the name of the user-supplied instance

Implements BLUserCode.

Referenced by BLCMDusertrackfilter::command().

virtual void BLUserTrackFilter::filter ( G4Track *  track,
int  eventID,
std::vector< G4Track * > &  secondaries,
int  verbose 
) [pure virtual]

user function to filter tracks. Global coordinates are used. NOTE: do NOT delete the input track, or those you create and put into secondaries -- they are deleted by Geant4 internally.

Referenced by BLCMDusertrackfilter::UserSteppingAction().

virtual void BLUserTrackFilter::setup ( const char *  init  )  [pure virtual]

setup() will be called during initialization; its argument is the string passed to the "usertrackfilter" command as its "init" argument. The init string can be used in any way by the user code (it passes information from the G4beamline input file to the user code, in a manner defined by the user code; the input file should be written to match this usage). If desired, multiple usertrackfilter commands can use a single user-supplied class instance, using the init string to differentiate among them. The init string need not be used at all.

Referenced by BLCMDusertrackfilter::command().

virtual void BLUserTrackFilter::complete ( const char *  init  )  [pure virtual]

complete() will be called after tracking is complete. It is intended for printing summaries and generally closing down. If multiple usertrackfilter commands reference this class instance, complete() will be called for each one, with the corresponding init string (do not depend on any particular ordering).

Referenced by BLCMDusertrackfilter::callback().


The documentation for this class was generated from the following files:
g4beamline