diff --git a/geant4/LEMuSR/src/LEMuSRMUONIUMScatt.cc b/geant4/LEMuSR/src/LEMuSRMUONIUMScatt.cc index 06c5eaf..ef7bfa7 100644 --- a/geant4/LEMuSR/src/LEMuSRMUONIUMScatt.cc +++ b/geant4/LEMuSR/src/LEMuSRMUONIUMScatt.cc @@ -4,6 +4,10 @@ #include "G4TransportationManager.hh" #include "Randomize.hh" #include "G4ProductionCutsTable.hh" +#include "G4FieldManager.hh" +#include "G4Field.hh" + + //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... @@ -26,11 +30,11 @@ G4VParticleChange* LEMuSRMUONIUMScatt::PostStepDoIt( fParticleChange.Initialize(trackData); // tao :: Get Time - G4double itime = trackData.GetProperTime(); - G4double gtime = trackData.GetGlobalTime(); - G4double ftime = trackData.GetDynamicParticle()->GetPreAssignedDecayProperTime(); + itime = trackData.GetProperTime(); + gtime = trackData.GetGlobalTime(); + ftime = trackData.GetDynamicParticle()->GetPreAssignedDecayProperTime(); - G4double deltatime = ftime - itime; + deltatime = ftime - itime; fParticleChange.ProposeGlobalTime(deltatime + itime -gtime); // set position momentum energy @@ -46,15 +50,18 @@ G4VParticleChange* LEMuSRMUONIUMScatt::PostStepDoIt( // fParticleChange.ProposeEnergy(0); fParticleChange.ProposePosition(trackData.GetStep()->GetPreStepPoint()->GetPosition()); - fParticleChange.ProposePolarization(trackData.GetPolarization()); + // fParticleChange.ProposePolarization(trackData.GetPolarization()); // G4cout<<" at rest "<< trackData.GetStep()->GetPreStepPoint()->GetPosition() <GetVolume()->GetLogicalVolume()->GetFieldManager()) + { + + + G4FieldManager *fMgr = theTrack.GetVolume()->GetLogicalVolume()->GetFieldManager(); + + + // if(!fMgr->DoesFieldChangeEnergy())//then we have a magnetic field + if(fMgr->FieldHasMagComponent())//then we have a magnetic field + { + +#ifdef G4SRVERBOSE + G4cout<<"IN FLIGHT::: MAGNETIC FIELD HERE" <GetDetectorField(); + + mfield->GetFieldValue(point,B); + +#ifdef G4SRVERBOSE + G4cout <<"IN FLIGHT::: MAGNETIC FIELD B="<< B[0]/gauss <<" G, " << B[1]/gauss <<" G, " << B[2]/gauss<<" G" <GetDefinition()->GetPDGCharge(); + a= 1.165922e-3; + fqz = 8.5062e+7*rad/(s*kilogauss); + + gamma = aStep.GetTrack()->GetDefinition()->GetGyromagneticRatio()*rad; + + // G4cout<< fqz*(s*tesla)<GetPolarization(); + HepVector3D newspin; + newspin = Spin_rotation*spin; + + G4double x,y,z,alpha; + x = sqrt(spin*spin); + y = sqrt(newspin*newspin); + z = spin*newspin/x/y; + alpha = acos(z); + +#ifdef G4SRVERBOSE + G4cout<< "IN FLIGHT::: PARAMETERS\n" + << "Initial spin : " << spin <<"\n" + << "Delta time : " << deltatime <<"\n" + << "Rotation angle: " << rotation_angle/(M_PI*rad) <<"\n" + << "New spin : " << newspin <<"\n" + << "Checked norms : " << x <<" " <