I have a line like > _equation = new G4Mag_SpinEqRhs(_miceMagneticField); > int n_vars = 9; > _stepper = new G4ClassicalRK4(_equation, n_vars); > _chordFinder = new G4ChordFinder(_miceMagneticField, 0.1*mm, _stepper); > fieldMgr->SetChordFinder(_chordFinder); in my code. When I run tracking, I look in my UserSteppingAction at the track polarization > void MAUSSteppingAction::UserSteppingAction(const G4Step * aStep) { > std::cerr << "SteppingAction::UserSteppingAction " > << aStep->GetTrack()->GetPolarization() << std::endl; > } and see that the track polarization is always 0, even when it is set to be initially non-zero in the PrimaryGeneratorAction. I repeat the test, but with > _equation = new G4EqEMFieldWithSpin(_miceElectroMagneticField); > int n_vars = 12; > _stepper = new G4ClassicalRK4(_equation, n_vars); > _chordFinder = new G4ChordFinder(_miceMagneticField, 0.1*mm, _stepper); > fieldMgr->SetChordFinder(_chordFinder); and now the non-zero polarization has gone away - i.e. the polarization is apparently propagated correctly. I believe the polarization should be propagated correctly in both cases.
Apologies, I should add that I am using G4.9.6.p02
Dear Chris, Thank you for reporting this. The examples for the propagation in field are potentially not clear enough, but the correct value for the number of variables required is 12. To be certain, you can refer to the "G4FieldTrack" class and its method DumpToArray which turns the information from data members of a class into variables which will be integrated by the stepper. You can see that the polarization (called spin) resides in elements 9-11, so the size must be at least 12: valArr[9]=fSpin.x(); valArr[10]=fSpin.y(); valArr[11]=fSpin.z(); Here is a link to the relevant lines of code in release 10.0. http://www-geant4.kek.jp/lxr/source/geometry/magneticfield/include/G4FieldTrack.icc?v=10.0#L213 ( This code has been stable for an extended period of time. ) Best regards, John
There is a chapter specifically for 'spin tracking' in the Application Developer's Guide: http://geant4.web.cern.ch/geant4/UserDocumentation/UsersGuides/ForApplicationDeveloper/html/ch04s03.html#sect.EMField.Spin In it, you'll find: In order to track the spin of a particle in a magnetic field, you need to code the following: 1. in your DetectorConstruction #include "G4Mag_SpinEqRhs.hh" G4Mag_EqRhs* fEquation = new G4Mag_SpinEqRhs(magField); G4MagIntegratorStepper* pStepper = new G4ClassicalRK4(fEquation,12); notice the 12 The 'notice the 12' is in bold letters.