00001
00002
00003 #include "musrAtRestSpinRotation.hh"
00004
00005 #include "G4ThreeVector.hh"
00006 #include "G4MagneticField.hh"
00007 #include "G4Track.hh"
00008 #include "G4FieldManager.hh"
00009 #include <iomanip>
00010 #include "globals.hh"
00011 #include "G4ParticleChange.hh"
00012 #include "G4ios.hh"
00013 #include "G4Transform3D.hh"
00014 #include "G4UnitsTable.hh"
00015 #include "G4TransportationManager.hh"
00016 #include "G4ParticleTable.hh"
00017 #include "G4ParticleDefinition.hh"
00018 #include "G4VParticleChange.hh"
00019 #include "G4ProcessVector.hh"
00020 #include "G4ProcessManager.hh"
00021
00022 musrAtRestSpinRotation::musrAtRestSpinRotation(const G4String& processName)
00023 : G4VRestProcess (processName)
00024 {
00025 G4cout << GetProcessName() << " is created "<< G4endl;
00026 pointer = this;
00027 }
00028
00029
00030 musrAtRestSpinRotation::~musrAtRestSpinRotation()
00031 {;}
00032
00033
00034 musrAtRestSpinRotation* musrAtRestSpinRotation::pointer=0;
00035 musrAtRestSpinRotation* musrAtRestSpinRotation::GetInstance()
00036 {
00037 return pointer;
00038 }
00039
00040
00041
00042
00043 G4VParticleChange* musrAtRestSpinRotation::AtRestDoIt(const G4Track& theTrack, const G4Step& aStep)
00044 {
00045
00046 theParticleChange.Initialize(theTrack);
00047 theParticleChange.ProposeTrackStatus(fAlive);
00048
00049 theParticleChange.ProposePosition(theTrack.GetPosition());
00050 theParticleChange.ProposeMomentumDirection(theTrack.GetMomentumDirection());
00051 theParticleChange.ProposeEnergy(theTrack.GetKineticEnergy());
00052
00053
00054 itime = theTrack.GetProperTime();
00055 G4double gtime = theTrack.GetGlobalTime();
00056 ftime = theTrack.GetDynamicParticle()->GetPreAssignedDecayProperTime();
00057
00058
00059 deltatime = ftime - itime;
00060 theParticleChange.ProposeGlobalTime(deltatime + itime -gtime);
00061 theParticleChange.ProposeProperTime(deltatime);
00062
00063 polar = aStep.GetTrack()->GetPolarization();
00064
00065
00066
00067
00068
00069 if(G4TransportationManager::GetTransportationManager()->GetFieldManager())
00070 {
00071
00072 G4FieldManager *fMgr=G4TransportationManager::GetTransportationManager()->GetFieldManager();
00073
00074
00075
00076 if(!fMgr->DoesFieldChangeEnergy())
00077 {
00078
00079
00080
00081
00082
00083
00084 point[0]=theTrack.GetPosition().x();
00085 point[1]=theTrack.GetPosition().y();
00086 point[2]=theTrack.GetPosition().z();
00087
00088 mfield = fMgr->GetDetectorField();
00089
00090 mfield->GetFieldValue(point,B);
00091
00092
00093
00094
00095
00096
00097 #ifdef G4SRVERBOSE
00098 G4cout <<"AT REST::: TIME= proper: "<< itime <<" ; global: " << gtime <<" decay: " << ftime <<G4endl;
00099 #endif
00100
00101
00102 G4ThreeVector magField(B[0],B[1],B[2]);
00103 RotateSpin(aStep,magField,deltatime);
00104
00105
00106 #ifdef G4SRVERBOSE
00107 G4cout<<"AT REST::: spin rotated";
00108 #endif
00109
00110 }
00111
00112
00113 theParticleChange.ProposePolarization(polar);
00114
00115
00116
00117 #ifdef G4SRVERBOSE
00118 theParticleChange.DumpInfo();
00119 #endif
00120
00121
00122 return &theParticleChange;
00123
00124
00125
00126 }
00127
00128 else
00129 {
00130
00131 return &theParticleChange;
00132
00133
00134
00135 }
00136
00137
00138
00139
00140 }
00141
00142
00143
00144 void musrAtRestSpinRotation::RotateSpin( const G4Step& aStep, G4ThreeVector B, G4double deltatime )
00145 {
00146
00147
00148 G4Transform3D Spin_rotation;
00149
00150 G4double Bnorm = sqrt(sqr(B[0]) + sqr(B[1]) +sqr(B[2]) );
00151
00152
00153
00154
00155
00156 G4double omega,q,a,fqz;
00157
00158 q= aStep.GetTrack()->GetDefinition()->GetPDGCharge();
00159 a= 1.165922e-3;
00160 fqz = 8.5062e+7*rad/(s*kilogauss);
00161
00162 #ifdef G4SRVERBOSE
00163 G4cout<< "AT REST::: PARAMETERS\n"
00164 << "Charge : " << q <<"\n";
00165 #endif
00166
00167 omega= - (fqz)*(1.+a) * Bnorm;
00168
00169 #ifdef G4SRVERBOSE
00170 G4cout<< "AT REST::: PARAMETERS\n"
00171 << "Frequency: " << G4BestUnit(omega/(2*M_PI*rad),"Frequency") <<"\n";
00172 #endif
00173
00174
00175 rotation_angle = deltatime*omega;
00176
00177
00178 Spin_rotation= G4Rotate3D(rotation_angle,B/Bnorm);
00179
00180 HepVector3D spin = aStep.GetTrack()->GetPolarization();
00181 HepVector3D newspin;
00182 newspin = Spin_rotation*spin;
00183
00184 G4double x,y,z,alpha;
00185 x = sqrt(spin*spin);
00186 y = sqrt(newspin*newspin);
00187 z = spin*newspin/x/y;
00188 alpha = acos(z);
00189
00190 #ifdef G4SRVERBOSE
00191 G4cout<< "AT REST::: PARAMETERS\n"
00192 << "Initial spin : " << spin <<"\n"
00193 << "Delta time : " << deltatime <<"\n"
00194 << "Rotation angle: " << rotation_angle/rad <<"\n"
00195 << "New spin : " << newspin <<"\n"
00196 << "Checked norms : " << x <<" " <<y <<" \n"
00197 << G4endl;
00198 #endif
00199
00200 polar = newspin;
00201
00202 }