6 TGeoHMatrix GetResSurvAlign(Int_t survNch);
8 void SurveyToAlignHmpid(){
11 AliSurveyObj *so = new AliSurveyObj();
14 Int_t size = so->GetEntries();
15 printf("-> %d\n", size);
17 so->FillFromLocalFile("Survey_781282_HMPID.txt");
18 size = so->GetEntries();
19 printf("--> %d\n", size);
22 TObjArray *points = so->GetData();
25 for (Int_t i = 0; i < points->GetEntries(); ++i)
27 AliSurveyPoint *p=(AliSurveyPoint *) points->At(i);
28 v[i].SetXYZ(p->GetX()*100.,p->GetY()*100.,p->GetZ()*100.);
32 // // To produce the alignment object for the given volume you would
33 // // then do something like this:
34 // // Calculate the global delta transformation as ng * g3-1
35 // TGeoHMatrix gdelta = g3->Inverse(); //now equal to the inverse of g3
36 // gdelta.MultiplyLeft(&ng);
38 // // if the volume is in the look-up table use something like this instead:
39 // // AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,i);
40 // AliAlignObjMatrix* mobj = new AliAlignObjMatrix("symname",index,gdelta,kTRUE);
43 TGeoHMatrix mtx = GetResSurvAlign(5);
45 TGeoManager::Import("/home/mserio/tstesdtrk/geometry.root");
46 gGeoManager->cd(Form("ALIC_1/Hmp_%1i",nCh));
47 TGeoHMatrix g0 = *gGeoManager->GetCurrentMatrix();
48 cout<<"\n\n*********Ideal Matrix (chamber "<<nCh<<")*********"<<endl;
50 TGeoHMatrix gdelta = g0.Inverse();
51 gdelta.MultiplyLeft(&mtx);
55 AliAlignObjMatrix* mobj = new
56 AliAlignObjMatrix(AliGeomManager::SymName(AliGeomManager::LayerToVolUID(AliGeomManager::kHMPID,nCh)),
57 AliGeomManager::LayerToVolUID(AliGeomManager::kHMPID,nCh),gdelta,kTRUE);
59 cout<<"\n************* obtained AliAlignObjMatrix************\n";
63 TGeoHMatrix pa=gdelta*g0;
70 TGeoHMatrix GetResSurvAlign(Int_t survNch)
72 cout<<" ************Survey numbering********Offline Numbering**********"<<endl;
73 cout<<"\nChamber No 0 4 "<<endl;
74 cout<<"Chamber No 1 3 "<<endl;
75 cout<<"Chamber No 2 5 "<<endl;
76 cout<<"Chamber No 3 1 "<<endl;
77 cout<<"Chamber No 4 6 "<<endl;
78 cout<<"Chamber No 5 2 "<<endl;
79 cout<<"Chamber No 6 0 "<<endl;
82 // From the new fiducial marks coordinates derive back the
83 // new global position of the surveyed volume
84 //*** The 4 fiducial marks are assumed on a rectangle
85 //*** parallel to a surface of the Hmp (main volume)
86 //*** at a certain offset from the origin (zdepth) and with
87 //*** x and y sides parallel to the box's x and y axes.
97 Double_t ab[3], bc[3], n[3];
99 Double_t ngA[3]={v[0+4*survNch].X(),v[0+4*survNch].Y(),v[0+4*survNch].Z()};
100 Double_t ngB[3]={v[1+4*survNch].X(),v[1+4*survNch].Y(),v[1+4*survNch].Z()};
101 Double_t ngC[3]={v[2+4*survNch].X(),v[2+4*survNch].Y(),v[2+4*survNch].Z()};
102 Double_t ngD[3]={v[3+4*survNch].X(),v[3+4*survNch].Y(),v[3+4*survNch].Z()};
105 // first vector on the plane of the fiducial marks
106 for(Int_t i=0;i<3;i++){
107 ab[i] = ngB[i] - ngA[i];
110 // second vector on the plane of the fiducial marks
111 for(Int_t i=0;i<3;i++){
112 bc[i] = ngC[i] - ngB[i];
117 // first vector on the plane of the fiducial marks
118 for(Int_t i=0;i<3;i++){
119 ab[i] = ngB[i] - ngA[i];
122 // second vector on the plane of the fiducial marks
123 for(Int_t i=0;i<3;i++){
124 bc[i] = ngD[i] - ngB[i];
128 // vector normal to the plane of the fiducial marks obtained
129 // as cross product of the two vectors on the plane d0^d1
130 n[0] = ab[1] * bc[2] - ab[2] * bc[1];
131 n[1] = ab[2] * bc[0] - ab[0] * bc[2];
132 n[2] = ab[0] * bc[1] - ab[1] * bc[0];
134 Double_t sizen = TMath::Sqrt( n[0]*n[0] + n[1]*n[1] + n[2]*n[2] );
136 s = Double_t(1.)/sizen ; //normalization factor
141 // plane expressed in the hessian normal form, see:
142 // http://mathworld.wolfram.com/HessianNormalForm.html
143 // the first three are the coordinates of the orthonormal vector
144 // the fourth coordinate is equal to the distance from the origin
149 plane[3] = -( plane[0] * ngA[0] + plane[1] * ngA[1] + plane[2] * ngA[2] );
150 cout<<"normal to plane and distance from IP: "<<plane[0]<<" "<<plane[1]<<" "<<plane[2]<<" "<<plane[3]<<" "<<endl;
152 // The center of the square with fiducial marks as corners
153 // as the middle point of one diagonal - md
154 // Used below to get the center - orig - of the surveyed box
155 Double_t orig[3], md[3];
159 md[i] = (ngA[i] + ngC[i]) * 0.5;//modified!!!!!!!!!
166 md[i] = (ngA[i] + ngD[i]) * 0.5;//modified!!!!!!!!!
169 cout<<endl<<"The center of the box from Survey data: "<<md[0]<<" "<<md[1]<<" "<<md[2]<<endl;
170 const Double_t zdepth=-0.9-4.85; //the survey data are down the radiator (behind the honeycomb structure). They
171 //lay on 4 cylinders whose height is 9 mm.
173 // The center of the box
175 orig[i] = md[i] - (-plane[i])*(zdepth+plane[3]);
177 orig[1] = md[1] - (-plane[1])*(zdepth+plane[3]);
178 orig[2] = md[2] - (-plane[2])*(zdepth+plane[3]);
180 cout<<endl<<"The origin of the box: "<<orig[0]<<" "<<orig[1]<<" "<<orig[2]<<endl;
182 // get x,y local directions needed to write the global rotation matrix
183 // for the surveyed volume by normalising vectors ab and bc
184 Double_t sx = TMath::Sqrt(ab[0]*ab[0] + ab[1]*ab[1] + ab[2]*ab[2]);
189 cout<<endl<<"x "<<ab[0]<<" "<<ab[1]<<" "<<ab[2]<<endl;
191 Double_t sy = TMath::Sqrt(bc[0]*bc[0] + bc[1]*bc[1] + bc[2]*bc[2]);
196 cout<<endl<<"y "<<bc[0]<<" "<<bc[1]<<" "<<bc[2]<<endl;
200 // the global matrix for the surveyed volume - ng
201 Double_t rot[9] = {-ab[0],bc[0],-plane[0],-ab[1],bc[1],-plane[1],-ab[2],bc[2],-plane[2]};
203 ng.SetTranslation(md);
206 cout<<"\n********* global matrix inferred from surveyed fiducial marks for chamber"<<survNch<<"***********\n";