#ifndef LEMUSRATRESTSPINROTATION_H
#define LEMUSRATRESTSPINROTATION_H 1

#include "G4VRestProcess.hh"
#include "G4DynamicParticle.hh"
#include "G4MagneticField.hh"
#include "G4ParticleTypes.hh"
#include "globals.hh"
#include "G4VParticleChange.hh"
#include "G4ios.hh"
#include "G4ForceCondition.hh"
#include "G4ParticleChangeForTransport.hh"
#include "LEMuSRParticleChangeForSR.hh"
class LEMuSRAtRestSpinRotation : public G4VRestProcess
{
public:
      LEMuSRAtRestSpinRotation(const G4String& processName =  "SpinRotationAtRest" );
      LEMuSRAtRestSpinRotation(G4VRestProcess& );

      virtual ~LEMuSRAtRestSpinRotation();

  static LEMuSRAtRestSpinRotation* GetInstance();
private: 
 static LEMuSRAtRestSpinRotation* pointer;
 
public:
  G4VParticleChange* AtRestDoIt(const G4Track& theTrack, const G4Step& theStep);

  //  G4Track
  void  RotateSpin(const G4Step&, G4ThreeVector, G4double);

  G4double point[4];
  G4double B[3], rotation_angle;

  G4double itime, ftime, deltatime;
  G4ThreeVector SpinDirection;


  G4ParticleChange thePParticleChange;
  G4VParticleChange theVParticleChange;
  G4ParticleChangeForTransport theTParticleChange;
  LEMuSRParticleChangeForSR theParticleChange;
  const G4Field *mfield;

  inline G4double GetMeanLifeTime(const G4Track&, G4ForceCondition* condition)
     {
       *condition = Forced;
       return DBL_MAX;
     }
   G4ThreeVector polar;  

 

};
#endif
