StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
StFgtCosmicAlignment.cxx
1 #include "StFgtCosmicAlignment.h"
2 #include <math.h>
3 const int MaxDisc=3;
4 //initial z offsets for disks
5 float z0[MaxDisc]={0.0, 16.51, 2.0*16.51};
6 //center of rotaion
7 float x00=2.0, y00=-26.0, z00=0.0;
8 //Alignment xyz offsets and Euler angles for each disc
9 float par[MaxDisc][6]= { {0.0, 0.0, 0.0, 0.0, 0.0, 0.0},
10  {-0.0314,-0.1427, 0.1298, -0.0746, 0.0247, -0.0311},
11  {0.0228, 0.3543, 0.0815, -0.1006, -0.0110, -0.0372}};
12 
13 
14 void rot(float x, float y, float z,
15  float x0,float y0,float z0,
16  float o, float p, float q,
17  float &xx,float &yy,float &zz){
18  //printf("inp = %8.3f %8.3f %8.3f\n",x,y,z);
19  //printf("off = %8.3f %8.3f %8.3f\n",x0,y0,z0);
20  float co=cos(o), so=sin(o);
21  float cp=cos(p), sp=sin(p);
22  float cq=cos(q), sq=sin(q);
23  float x1=x+x0-x00;
24  float y1=y+y0-y00;
25  float z1=z+z0-z00;
26  //printf("opq = %8.3f %8.3f %8.3f\n",o,p,q);
27  //printf("out1 = %8.3f %8.3f %8.3f\n",xx,yy,zz);
28  //printf("cos = %8.3f %8.3f %8.3f\n",co,cp,cq);
29  //printf("sin = %8.3f %8.3f %8.3f\n",so,sp,sq);
30  xx=x1*co*cp + y1*(-cq*sp+sq*so*cp) + z1*( sq*sp+cq*so*cp) + x00;
31  yy=x1*co*sp + y1*( cq*cp+sq*so*sp) + z1*(-sq*cp+cq*so*sp) + y00;
32  zz=x1*(-so) + y1*( sq*co ) + z1*( cq*co ) + z00;
33  //printf("out2 = %8.3f %8.3f %8.3f\n",xx,yy,zz);
34 };
35 void getAlign(int idisc, float pl, float rl, float &x, float &y, float &z, float &p, float &r){
36  float xx=rl * cos(pl);
37  float yy=rl * sin(pl);
38  rot(xx,yy,0.0,par[idisc][0],par[idisc][1],par[idisc][2],par[idisc][3],par[idisc][4],par[idisc][5],x,y,z);
39  z+=z0[idisc];
40  r=sqrt(x*x + y*y);
41  p=atan2(y,x);
42 };