--- DarthVader/OrbitalInfo/src/OrientationInfo.cpp 2008/10/01 15:26:35 1.1 +++ DarthVader/OrbitalInfo/src/OrientationInfo.cpp 2014/03/28 20:47:15 1.4 @@ -3,6 +3,7 @@ #include #include #include +#include #include @@ -34,37 +35,20 @@ } TMatrixD OrientationInfo::ECItoGreenwich(TMatrixD Aij, UInt_t t){ - //t=1154304000+86400*365; TMatrixD Gij(3,3); - Double_t omg = (7.292115e-5)*a; // Earth rotation velosity (Around polar axis); - //Double_t t1 = 0; - //if(t<=1158883200) t1 = 1127347200+229.2732; //absTime at 22/09/2005 + diference between Solar midnight and Greenwich sidereal midnight - //if(t>1158883200&&t<=1190419200) t1 = 1158883200+172.3415;//absTime at 22/09/2006 + diference between Solar midnight and Greenwich sidereal midnight - //if(t>=1190419200&&t<1222041600) t1 = 1190419200+115.39; //absTime at 22/09/2007 + diference between Solar midnight and Greenwich sidereal midnight - //if(t>=1222041600) t1 = 1222041600 + 294.9361; //absTime at 22/09/2008 + diference between Solar midnight and Greenwich sidereal midnight - //UInt_t Nd = (t-t1)/86400; - //Int_t DifSuSt = Nd*236.55; + Double_t omg = (7.292115e-5)*a; // Earth rotation velosity (Around polar axis); Double_t d = (t-10957*86400-43200); //Number of day, passing from 01/01/2000 12:00:00 to t; d = d/86400; - //d = t-da*86400+DifSuSt - //cout<<"t = "<-0.1)){ - //cout<<"lon = "<0&&x0<0) Sa=-Sa+90; - //if (y0<0&&x0<0) Sa=Sa-90; - //if (y0>0&&x0==0) Sa=90; - //if (y0<0&&x0==0) Sa=-90; - Gij(0,0) = cos(lon); + lon=(-lon)/a; lat=(-lat)/a; // here has the same result as Gij.Invert() in ECItoGreenwich function + + Gij(0,0) = cos(lon); // rotation around z-axis: Gij(0,1) = -sin(lon); - Gij(0,2) = 0; - Gij(1,0) = sin(lon); - Gij(1,1) = cos(lon); + Gij(0,2) = 0; // | cos(lon) -sin(lon) 0| + Gij(1,0) = sin(lon); // | sin(lon) cos(lon) 0| + Gij(1,1) = cos(lon); // | 0 0 1| Gij(1,2) = 0; Gij(2,0) = 0; Gij(2,1) = 0; Gij(2,2) = 1; - - //cout<<"First rotation"< | 0 1 0 | + Fij(1,1) = 1; // |-sin(-lat) 0 cos(-lat)| |sin(lat) 0 cos(lat) | Fij(1,2) = 0; Fij(2,0) = sin(lat); Fij(2,1) = 0; Fij(2,2) = cos(lat); - - //Fij.Invert(); - - //if((lat<0.1)&&(lat>-0.1)){ - /* Hij=Gij*Aij; //TEST - - cout<<"First rotation"<>ret;*/ -// } + return Fij*(Gij*Aij); } +TMatrixD OrientationInfo::EulertoEci(Double_t x0, Double_t y0, Double_t z0, Double_t Vx0, Double_t Vy0, Double_t Vz0, Double_t Bank, Double_t Yaw, Double_t SPitch){ +//cerr.precision(12); +//cerr<<"Position:\t"<0 && TMath::Sign(1.,Yaw)>0) fj=-1; +// cout<<"bla-bla-bla"<0) alpha = 0; else + if(Beast==0. && Bnorth<0) alpha = 180.; else{ + if(Beast > 0) alpha = TMath::ATan(Bnorth/Beast)*TMath::RadToDeg() - 90.; + if(Beast < 0) alpha = TMath::ATan(Bnorth/Beast)*TMath::RadToDeg() + 90.; + } + alpha = alpha*TMath::DegToRad(); + Double_t beta = TMath::ATan(Bup/sqrt(pow(Bnorth,2)+pow(Beast,2))); + //if(Bup<0.0) beta = TMath::ATan(TMath::Abs(Bup/sqrt(pow(Bnorth,2)+pow(Beast,2)))); + //if(Bup>0.0) beta = TMath::ATan(TMath::Abs(sqrt(pow(Bnorth,2)+pow(Beast,2))/Bup)); + //cout<<"GEOtomag:alpha = "<> tri; + return Fij*(Gij*Aij); +} + TMatrixD OrientationInfo::PamelatoGEO(TMatrixD Aij, Double_t B1, Double_t B2, Double_t B3){ //TMatrixD Gij(3,3); TMatrixD Hij(3,1); @@ -164,23 +268,8 @@ Bij(0,0) = B1; Bij(1,0) = B2; Bij(2,0) = B3; - //Double_t alfa = TMath::ASin(sqrt(1/((Aij(1,2))/Aij(0,2)+1))) * TMath::RadToDeg(); - //Gij(0,0) = cos(alfa/a); - //Gij(0,1) = -sin(alfa/a); - //Gij(0,2) = 0; - //Gij(1,0) = 0; - //Gij(1,1) = 1; - //Gij(1,2) = 0; - //Gij(2,0) = sin(alfa/a); - //Gij(2,1) = cos(alfa/a); - //Gij(2,2) = 0; - Hij=Aij*Bij; return Hij; - //cout<<0.25-Aij(2,2)/(Aij(2,1)*Aij(2,0))<0. && YY <0.) RASun=RASun+2*TMath::Pi(); + Float_t DESun = asin(sin(eps)*sin(theta)); +//SAV +// cout << "DE = " << DESun << "\t" << RASun << endl; +//SAV + sunout.SetMagThetaPhi(1.0,TMath::Pi()/2.-DESun,RASun); + return sunout; +} + +Float_t OrientationInfo::Larmor(Float_t Ek,Float_t Bm,Int_t iZ,Float_t xA){ //Ek in MeV, Bm in nT, Pitch-angle, rad + Float_t mp = 938.272029;// Float_t amu = 931.494043e0; + Float_t cc = 299792458.; + Float_t ee = 1.60217653e-19; + Float_t kg = 1.7826619e-30; + Float_t gam = (Ek+mp)/mp; + Float_t mm = mp*kg; + Float_t omega = iZ*ee*Bm*1e-9/(gam*mm); + Float_t larmor = 1e-3*sqrt(1e0-1e0/pow(gam,2))*cc/omega; + larmor = 1e-3*Ek*cc/omega; //Ek here is p or for onecharged particle R; larmor in m + return larmor; +} + +TMatrixD OrientationInfo::GetDirectiontoGirocenter(Float_t R, Float_t Px, Float_t Py){ + TMatrixD GirDir(3,1); + if(R>0){ + GirDir(0,0) = Py; + GirDir(1,0) = -Px; + }else{ + GirDir(0,0) = -Py; + GirDir(1,0) = Px; + } + GirDir(2,0) = 0.; + return GirDir; +} + Double_t OrientationInfo::GetPitchAngle(Double_t x1, Double_t y1, Double_t z1, Double_t x2, Double_t y2, Double_t z2){ return TMath::ACos((x1*x2 + y1*y2 + z1*z2)/(sqrt(pow(x1,2)+pow(y1,2)+pow(z1,2))*sqrt(pow(x2,2)+pow(y2,2)+pow(z2,2)))) * TMath::RadToDeg(); }