#include #include #include #include #include #include ClassImp(OrientationInfo) using namespace std; OrientationInfo::OrientationInfo() : TObject(){ a = 360/(2*TMath::Pi()); Re = 6000000; } OrientationInfo::~OrientationInfo(){ } TMatrixD OrientationInfo::QuatoECI(Float_t q0, Float_t q1, Float_t q2, Float_t q3){ TMatrixD Pij(3,3); Pij(0,0) = pow(q0,2)+pow(q1,2)-pow(q2,2)-pow(q3,2); Pij(0,1) = /*2*(q1*q2+q0*q3);/*/ 2*(q1*q2-q0*q3); Pij(0,2) = /*2*(q1*q3-q0*q2);/*/ 2*(q1*q3+q0*q2); Pij(1,0) = /*2*(q1*q2-q0*q3);/*/ 2*(q1*q2+q0*q3); Pij(1,1) = pow(q0,2)-pow(q1,2)+pow(q2,2)-pow(q3,2); Pij(1,2) = /*2*(q2*q3+q0*q1);/*/ 2*(q2*q3-q0*q1); Pij(2,0) = /*2*(q1*q3+q0*q2);/*/ 2*(q1*q3-q0*q2); Pij(2,1) = /*2*(q2*q3-q0*q1);/*/ 2*(q2*q3+q0*q1); Pij(2,2) = pow(q0,2)-pow(q1,2)-pow(q2,2)+pow(q3,2); return Pij; } TMatrixD OrientationInfo::ECItoGreenwich(TMatrixD Aij, UInt_t t){ TMatrixD Gij(3,3); 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; Double_t T = d/36525; //Number of Julian centuries; Double_t Se = 6*3600+41*60+236.555367908*d+0.093104*pow(T,2)-(6.2e-6)*pow(T,3); Int_t tr = (t-10957*86400)%86400; Double_t Somg = (Se+49.077+omg*86400*tr/360)*360/86400; //Somg = 25; //for test transition Gij(0,0) = cos(Somg/a); Gij(0,1) = -sin(Somg/a); Gij(0,2) = 0; Gij(1,0) = sin(Somg/a); Gij(1,1) = cos(Somg/a); Gij(1,2) = 0; Gij(2,0) = 0; Gij(2,1) = 0; Gij(2,2) = 1; Gij.Invert(); return Gij*Aij; } TMatrixD OrientationInfo::GreenwichtoGEO(Double_t lat, Double_t lon, TMatrixD Aij){ TMatrixD Gij(3,3); TMatrixD Fij(3,3); 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; // | 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; Fij(0,0) = cos(lat); // rotation around y-axis at angle -lat, cause rotation around y from x to z axis is negative Fij(0,1) = 0; // Fij(0,2) = -sin(lat); // |cos(-lat) 0 sin(-lat)| |cos(lat) 0 -sin(lat)| Fij(1,0) = 0; // | 0 1 0 | ==> | 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); return Fij*(Gij*Aij); } TMatrixD OrientationInfo::GEOtoGeomag(TMatrixD Aij,Double_t Bnorth, Double_t Beast, Double_t Bup){ //Geomagnetic geodetic reference frame Double_t alpha = 0; if(Beast==0. && Bnorth>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); TMatrixD Bij(3,1); Bij(0,0) = B1; Bij(1,0) = B2; Bij(2,0) = B3; Hij=Aij*Bij; return Hij; } TMatrixD OrientationInfo::ColPermutation(TMatrixD Aij){ TMatrixD Gij(3,3); Gij(0,0) = 1; Gij(0,1) = 0; Gij(0,2) = 0; Gij(1,0) = 0; Gij(1,1) = 0; Gij(1,2) = 1; Gij(2,0) = 0; Gij(2,1) = -1; Gij(2,2) = 0; return Aij*Gij; } 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; 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(); }