polarity of magnet changed depending on charge.

Issue #26 resolved
Jochem Snuverink created an issue

We change the polarity of the magnets depending on the charge. But I think we don't need to do this as the tracking takes the charge already in account. In effect this will cancel the sign of the charge and tracks negative and positive charged particles in the same way.

In more detail:

For defining the strength in all magnets (quads, sextupoles, etc.), we use the magnetic rigidity of the beam (from BDSComponentFactory.cc):

_brho = BDSGlobalConstants::Instance()->GetFFact()*( _momentum / (0.299792458 * _charge));

FFact is a factor that can be set, and is 1 by default. Note that the sign of the charge is present. This is contrary to the comments in the code:

// compute magnetic rigidity brho

// formula: B(Tesla)*rho(m) = p(GeV)/(0.299792458 * |charge(e)|)

// charge (in |e| units)

The internal quad strength is for example:

G4double bPrime = - _brho * (_element.k1 / CLHEP::m2);

Now in the stepper the charge is also taken into account with the G4Mag_EqRhs object:

G4double kappa = - fPtrMagEqOfMot->FCof()*itsBGrad/InitPMag;

So in effect the kappa will be the same regardless of the charge sign of the particle.

If I run the quad test with a positron, the output is:

q= 1e

dBy/dx= -154.15773887637T/m

k= 30.000000003442m^-2

And with an electron:

q= -1e

dBy/dx= 154.15773887637T/m

k= 30.000000003442m^-2

So the effective kappa (k) has the same sign for both, and also the trajectory is exactly the same. I checked that the magnet strength had an impact on the trajectory by changing the absolute strength.

Or maybe I am missing something?

Comments (4)

  1. Log in to comment