]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HMPID/SurveyToAlignHmpid.C
Corrected branching ratio (Francesco)
[u/mrichter/AliRoot.git] / HMPID / SurveyToAlignHmpid.C
CommitLineData
e4c1cb11 1
2TVector3 v[28];
3Int_t nCh;
4
5
6TGeoHMatrix GetResSurvAlign(Int_t survNch);
7
8void SurveyToAlignHmpid(){
9
10
11 AliSurveyObj *so = new AliSurveyObj();
12
13
14 Int_t size = so->GetEntries();
15 printf("-> %d\n", size);
16
17 so->FillFromLocalFile("Survey_781282_HMPID.txt");
18 size = so->GetEntries();
19 printf("--> %d\n", size);
20
21
22 TObjArray *points = so->GetData();
23// TVector3 v[28];
24
25 for (Int_t i = 0; i < points->GetEntries(); ++i)
26 {
27 AliSurveyPoint *p=(AliSurveyPoint *) points->At(i);
28 v[i].SetXYZ(p->GetX()*100.,p->GetY()*100.,p->GetZ()*100.);
29 }
30
31
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);
37// Int_t index = 0;
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);
41
42
43TGeoHMatrix mtx = GetResSurvAlign(5);
44
45TGeoManager::Import("/home/mserio/tstesdtrk/geometry.root");
46gGeoManager->cd(Form("ALIC_1/Hmp_%1i",nCh));
47TGeoHMatrix g0 = *gGeoManager->GetCurrentMatrix();
48cout<<"\n\n*********Ideal Matrix (chamber "<<nCh<<")*********"<<endl;
49g0.Print();
50TGeoHMatrix gdelta = g0.Inverse();
51gdelta.MultiplyLeft(&mtx);
52
53//gdelta.Print();
54
55AliAlignObjMatrix* mobj = new
56AliAlignObjMatrix(AliGeomManager::SymName(AliGeomManager::LayerToVolUID(AliGeomManager::kHMPID,nCh)),
57 AliGeomManager::LayerToVolUID(AliGeomManager::kHMPID,nCh),gdelta,kTRUE);
58/*
59cout<<"\n************* obtained AliAlignObjMatrix************\n";
60mobj->Print();
61cout<<""<<endl;
62
63TGeoHMatrix pa=gdelta*g0;
64
65pa.Print();
66*/
67}
68
69
70TGeoHMatrix GetResSurvAlign(Int_t survNch)
71{
72cout<<" ************Survey numbering********Offline Numbering**********"<<endl;
73cout<<"\nChamber No 0 4 "<<endl;
74cout<<"Chamber No 1 3 "<<endl;
75cout<<"Chamber No 2 5 "<<endl;
76cout<<"Chamber No 3 1 "<<endl;
77cout<<"Chamber No 4 6 "<<endl;
78cout<<"Chamber No 5 2 "<<endl;
79cout<<"Chamber No 6 0 "<<endl;
80
81
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.
88
89if(survNch==0) nCh=4;
90if(survNch==1) nCh=3;
91if(survNch==2) nCh=5;
92if(survNch==3) nCh=1;
93if(survNch==4) nCh=6;
94if(survNch==5) nCh=2;
95if(survNch==6) nCh=0;
96
97 Double_t ab[3], bc[3], n[3];
98 Double_t plane[4], s;
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()};
103if(survNch>4)
104{
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];
108 }
109
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];
113 }
114}
115
116 else{
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];
120 }
121
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];
125 }
126
127}
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];
133
134 Double_t sizen = TMath::Sqrt( n[0]*n[0] + n[1]*n[1] + n[2]*n[2] );
135 if(sizen>1.e-8){
136 s = Double_t(1.)/sizen ; //normalization factor
137 }else{
138 return 0;
139 }
140
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
145
146 for(i=0;i<3;i++){
147 plane[i] = n[i] * s;
148 }
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;
151
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];
156
157if(survNch>4){
158 for(i=0;i<3;i++){
159 md[i] = (ngA[i] + ngC[i]) * 0.5;//modified!!!!!!!!!
160 }
161
162}
163
164else {
165 for(i=0;i<3;i++){
166 md[i] = (ngA[i] + ngD[i]) * 0.5;//modified!!!!!!!!!
167 }
168}
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.
172
173 // The center of the box
174 for(i=0;i<1;i++){
175 orig[i] = md[i] - (-plane[i])*(zdepth+plane[3]);
176 }
177 orig[1] = md[1] - (-plane[1])*(zdepth+plane[3]);
178 orig[2] = md[2] - (-plane[2])*(zdepth+plane[3]);
179
180 cout<<endl<<"The origin of the box: "<<orig[0]<<" "<<orig[1]<<" "<<orig[2]<<endl;
181
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]);
185 if(sx>1.e-8){
186 for(i=0;i<3;i++){
187 ab[i] /= sx;
188 }
189 cout<<endl<<"x "<<ab[0]<<" "<<ab[1]<<" "<<ab[2]<<endl;
190 }
191 Double_t sy = TMath::Sqrt(bc[0]*bc[0] + bc[1]*bc[1] + bc[2]*bc[2]);
192 if(sy>1.e-8){
193 for(i=0;i<3;i++){
194 bc[i] /= sy;
195 }
196 cout<<endl<<"y "<<bc[0]<<" "<<bc[1]<<" "<<bc[2]<<endl;
197 }
198
199
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]};
202 TGeoHMatrix ng;
203 ng.SetTranslation(md);
204 ng.SetRotation(rot);
205
206 cout<<"\n********* global matrix inferred from surveyed fiducial marks for chamber"<<survNch<<"***********\n";
207 ng.Print();
208
209
210return ng;
211
212}
213
214
215
216