Message: Re: only apply field only to one particle and energy range Not Logged In (login)
 Next-in-Thread Next-in-Thread
 Next-in-Forum Next-in-Forum

Idea Re: only apply field only to one particle and energy range 

Forum: Fields: Magnetic and Otherwise
Re: Question only apply field only to one particle and energy range (John Leacock)
Date: 12 Nov, 2013
From: Gumplinger Peter <Gumplinger Peter>

Sorry John,

this fell through the cracks. (I didn't at first know how to answer, and no time, and now almost forgot your post.)

> After profiling my program I've found that most time is spent
> calculating the field at each step. I'm using a gravity field derived
> from a magnetic field using posts on this site.
> 
> Gravity is negligible for most of the particles I'm interested in. Is
> there a way to only call the Field if a particle matches some criteria?

Good question! Since your field inherits from a magn.field, in turn from a G4Field, you'd want to overwrite:

http://www-geant4.kek.jp/lxr/source/geometry/magneticfield/include/G4Field.hh#L97

IsGravityActive

Your aim should be to only execute:

http://www-geant4.kek.jp/lxr/source/processes/transportation/src/G4Transportation.cc#L224

e.g. (fieldExertsForce== true) for the particle you want.

Another approach may be to inherit from and customize a G4FieldManager::GetDetectorField() such that it returns true only when inside a volume with a field AND for a specified particle:

http://www-geant4.kek.jp/lxr/source/processes/transportation/src/G4Transportation.cc#L226

Both of these ideas are not possible from source/geometry/magneticfield directory because there is no dependence on G4DynamicParticle.hh but perhaps from your application's directory.

Peter

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

1 None: Re: only apply field only to one particle and energy range   (John Leacock - 17 Feb, 2014)
 Add Message Add Message
to: "Re: only apply field only to one particle and energy range"

 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 ]