bug in MuonSpoiler magnetic field

Issue #35 resolved
Jochem Snuverink created an issue

As reported by Belgin. Slicing a 5m MuonSpoiler into 5 1m pieces gives different tracking results.

Comments (2)

  1. Jochem Snuverink reporter

    There were 2 issues in the develop version:

    1) field attached to wrong pointer, so that magnetic field was zero. this was a recent change

    2) field calculation was wrong:

    G4double BFactor=itsBField/LocalR.mag(); Bfield[0]= LocalR.y()BFactor; Bfield[1]= -LocalR.x()BFactor;

    idea is right, however LocalR.mag() is the 3d radius instead of the 2d radius. z-component is not relevant and will give arbitrary results.

    it has been changed to:

    G4double LocalX = LocalR.x(); G4double LocalY = LocalR.y(); G4double LocalRadius = std::sqrt(LocalXLocalX + LocalYLocalY);

    Bfield[0]= LocalY/LocalRadius * itsBField; Bfield[1]= -LocalX/LocalRadius * itsBField;

    tracking for the single and sliced spoiler is now consistent.

  2. Log in to comment