#include "PamVMC2PiAux.h" void PamVMC2PiAux::gsurf(){ Double_t th1 = DegToRad()*17.; Double_t th2 = DegToRad()*20.; Double_t z1 = 87.4389954 + 0.150935784 + 0.4*Sin(th1) + 18.15*Cos(th1)/2.; Double_t z2 = 87.4389954 + 0.00949157123 + 0.4*Sin(th2) + 18.15*Cos(th2)/2.; Double_t xcard = GPAXCARD - 0.4*Cos(th2) + 18.15*Sin(th2)/2.; Double_t ycard = GPAYCARD - 0.4*Cos(th1) + ( z2-(87.4389954 + 0.150935784 + 0.4*Sin(th1)) )*Sin(th1); Double_t th = ATan(Sqrt(Power((xcard-XS2),2.) + Power((ycard-YS2),2.))/(z2-ZS2MAX)); Double_t ph = ATan((ycard-YS2)/(xcard-XS2)); if (TWOPIDEBUG){ cout<<"th1="<Uniform(); Double_t the; Double_t ct, st, cf, sf, xbeam, ybeam, zbeam; //POSITIONS if( (frandom->Uniform()) > fsphar ){ //generation on the lateral cylindrical surface the = Pi()/2.; ct = Cos(the); st = Sin(the); cf = Cos(phi); sf = Sin(phi); xbeam = RCY * cf; ybeam = RCY * sf; zbeam = -(fzminc+frandom->Uniform()*(fzmins-fzminc)); } else { //generation from top spherical surface the = ASin( Sqrt(frandom->Uniform())*Sin(fthmax) ); //CORRECT! ct = Cos(the); st = Sin(the); cf = Cos(phi); sf = Sin(phi); xbeam = SHELL3RR * st * cf; ybeam = SHELL3RR * st * sf; zbeam = -SHELL3RR * ct + SHELL3RZ; } pos.SetXYZ(xbeam,ybeam,-zbeam); //DIRECTION COSINES // local angles. COS^2 generation (theta_min=0, theta_max=90) Double_t lthe = ASin(Sqrt(frandom->Uniform())); Double_t lphi = TwoPi() * frandom->Uniform(); // local director cosines Double_t aaa = Sin(lthe) * Cos(lphi); Double_t bbb = Sin(lthe) * Sin(lphi); Double_t ccc = Cos(lthe); // global director cosines //MY CORRECT COSINES Double_t ubeam = aaa*cf*ct - bbb*sf - ccc*cf*st; //cos(px) Double_t vbeam = aaa*sf*ct + bbb*cf - ccc*sf*st; //cos(py) Double_t wbeam = aaa*st + ccc*ct; //cos(pz) Double_t theta_dir = ACos(wbeam); Double_t phi_dir = ATan2(vbeam,ubeam); if(phi_dir<0.) phi_dir+=TwoPi(); ang.Set(theta_dir,phi_dir); }