]>
Commit | Line | Data |
---|---|---|
447e91ca | 1 | TVector3 fFM[28]; //array of global coordinates for 28 fiducial marks |
2 | Int_t sNch, oNch; // survey and offline chamber's number | |
3 | ||
4 | ||
5 | TGeoHMatrix GetResSurvAlign(Int_t survNch, Int_t& offNch); | |
6 | ||
7 | void SurveyToAlignHmpid(const char* filename="Survey_781282_HMPID.txt"){ | |
8 | // Open file with AliSurveyPoints for the 7 HMPID chambers | |
9 | // Produce the corresponding alignment objects | |
10 | ||
11 | AliSurveyObj *so = new AliSurveyObj(); | |
12 | ||
13 | Int_t size = so->GetEntries(); | |
14 | printf("-> %d\n", size); | |
15 | ||
16 | so->FillFromLocalFile(filename); | |
17 | size = so->GetEntries(); | |
18 | printf("--> %d\n", size); | |
19 | ||
20 | TObjArray *points = so->GetData(); | |
21 | ||
22 | //AliCDBManager* cdbman = AliCDBManager::Instance(); | |
23 | //cdbman->SetSpecificStorage("local://$ALICE_ROOT"); | |
24 | //cdbman->SetRun(0); | |
25 | //cdbman->Get("GRP/Align/Geometry"); | |
26 | TGeoManager::Import("geometry.root"); | |
27 | ||
28 | for (Int_t i = 0; i < points->GetEntries(); ++i) | |
29 | { | |
30 | AliSurveyPoint *p=(AliSurveyPoint *) points->At(i); | |
31 | fFM[i].SetXYZ(p->GetX()*100.,p->GetY()*100.,p->GetZ()*100.); | |
32 | } | |
33 | ||
34 | TString chbasename("/HMPID/Chamber"); | |
35 | for(Int_t sNch=0; sNch<7; sNch++){ | |
36 | TGeoHMatrix mtx = GetResSurvAlign(sNch,oNch); //get global matrix from survey points | |
37 | ||
38 | TString chsymname = chbasename; | |
39 | chsymname += oNch; | |
40 | printf("getting global matrix for the alignable volume %s\n",chsymname.Data()); | |
41 | TGeoHMatrix *gm = AliGeomManager::GetMatrix(chsymname.Data()); | |
42 | ||
43 | if(!gm){ | |
44 | printf("unable to get global matrix for the alignable volume %s\n",chsymname.Data()); | |
45 | continue; | |
46 | } | |
47 | TGeoHMatrix gdelta = gm->Inverse(); | |
48 | gdelta.MultiplyLeft(&mtx); | |
49 | ||
50 | //gdelta.Print(); | |
51 | ||
52 | AliAlignObjMatrix* mobj = new | |
53 | AliAlignObjMatrix(AliGeomManager::SymName(AliGeomManager::LayerToVolUID(AliGeomManager::kHMPID,oNch)), | |
54 | AliGeomManager::LayerToVolUID(AliGeomManager::kHMPID,oNch),gdelta,kTRUE); | |
55 | /* | |
56 | cout<<"\n************* obtained AliAlignObjMatrix************\n"; | |
57 | mobj->Print(); | |
58 | cout<<""<<endl; | |
59 | ||
60 | TGeoHMatrix pa=gdelta*g0; | |
61 | ||
62 | pa.Print(); | |
63 | */ | |
64 | } | |
e4c1cb11 | 65 | } |
66 | ||
67 | ||
447e91ca | 68 | TGeoHMatrix GetResSurvAlign(Int_t survNch, Int_t& offNch) |
e4c1cb11 | 69 | { |
447e91ca | 70 | // For a given chamber identified by survey chamber number 'survNch', |
71 | // return the global matrix inferred from the survey points of its | |
72 | // 4 fiducial marks and set the offline chamber number 'offNch' | |
73 | // | |
74 | Int_t ChSrv2Off[7] = {4,3,5,1,6,2,0}; | |
75 | //cout<<" ********* Chamber Numbers ******"<<endl; | |
76 | //cout<<" **** Survey **** Offline *****"<<endl; | |
77 | //for(Int_t ch=0; ch<7; ch++){ | |
78 | // cout<<" "<<ch<<" "<<ChSrv2Off[ch]<<endl; | |
79 | //} | |
80 | ||
81 | offNch=ChSrv2Off[survNch]; | |
82 | ||
83 | Double_t ab[3], bc[3], n[3]; | |
84 | Double_t plane[4], s; | |
85 | Double_t ngA[3]={fFM[0+4*survNch].X(),fFM[0+4*survNch].Y(),fFM[0+4*survNch].Z()}; | |
86 | Double_t ngB[3]={fFM[1+4*survNch].X(),fFM[1+4*survNch].Y(),fFM[1+4*survNch].Z()}; | |
87 | Double_t ngC[3]={fFM[2+4*survNch].X(),fFM[2+4*survNch].Y(),fFM[2+4*survNch].Z()}; | |
88 | Double_t ngD[3]={fFM[3+4*survNch].X(),fFM[3+4*survNch].Y(),fFM[3+4*survNch].Z()}; | |
89 | if(survNch>4) | |
90 | { | |
91 | // first vector on the plane of the fiducial marks | |
92 | for(Int_t i=0;i<3;i++){ | |
93 | ab[i] = ngB[i] - ngA[i]; | |
94 | } | |
95 | ||
96 | // second vector on the plane of the fiducial marks | |
97 | for(Int_t i=0;i<3;i++){ | |
98 | bc[i] = ngC[i] - ngB[i]; | |
99 | } | |
100 | } | |
101 | else{ | |
102 | // first vector on the plane of the fiducial marks | |
103 | for(Int_t i=0;i<3;i++){ | |
104 | ab[i] = ngB[i] - ngA[i]; | |
105 | } | |
106 | ||
107 | // second vector on the plane of the fiducial marks | |
108 | for(Int_t i=0;i<3;i++){ | |
109 | bc[i] = ngD[i] - ngB[i]; | |
110 | } | |
111 | ||
112 | } | |
113 | // vector normal to the plane of the fiducial marks obtained | |
114 | // as cross product of the two vectors on the plane d0^d1 | |
115 | n[0] = ab[1] * bc[2] - ab[2] * bc[1]; | |
116 | n[1] = ab[2] * bc[0] - ab[0] * bc[2]; | |
117 | n[2] = ab[0] * bc[1] - ab[1] * bc[0]; | |
118 | ||
119 | Double_t sizen = TMath::Sqrt( n[0]*n[0] + n[1]*n[1] + n[2]*n[2] ); | |
120 | if(sizen>1.e-8){ | |
121 | s = Double_t(1.)/sizen ; //normalization factor | |
122 | }else{ | |
123 | return 0; | |
124 | } | |
125 | ||
126 | // plane expressed in the hessian normal form, see: | |
127 | // http://mathworld.wolfram.com/HessianNormalForm.html | |
128 | // the first three are the coordinates of the orthonormal vector | |
129 | // the fourth coordinate is equal to the distance from the origin | |
130 | ||
131 | for(i=0;i<3;i++){ | |
132 | plane[i] = n[i] * s; | |
133 | } | |
134 | plane[3] = -( plane[0] * ngA[0] + plane[1] * ngA[1] + plane[2] * ngA[2] ); | |
135 | cout<<"normal to plane and distance from IP: "<<plane[0]<<" "<<plane[1]<<" "<<plane[2]<<" "<<plane[3]<<" "<<endl; | |
136 | ||
137 | // The center of the square with fiducial marks as corners | |
138 | // as the middle point of one diagonal - md | |
139 | // Used below to get the center - orig - of the surveyed box | |
140 | Double_t orig[3], md[3]; | |
141 | ||
142 | if(survNch>4){ | |
143 | for(i=0;i<3;i++){ | |
144 | md[i] = (ngA[i] + ngC[i]) * 0.5;//modified!!!!!!!!! | |
145 | } | |
146 | ||
147 | } | |
148 | ||
149 | else { | |
150 | for(i=0;i<3;i++){ | |
151 | md[i] = (ngA[i] + ngD[i]) * 0.5;//modified!!!!!!!!! | |
152 | } | |
153 | } | |
154 | cout<<endl<<"The center of the box from Survey data: "<<md[0]<<" "<<md[1]<<" "<<md[2]<<endl; | |
155 | const Double_t zdepth=-0.9-4.85; //the fiducial marks are down the radiator (behind the honeycomb structure). They | |
156 | //lay on 4 cylinders whose height is 9 mm. | |
157 | ||
158 | // The center of the box | |
159 | for(i=0;i<1;i++){ | |
160 | orig[i] = md[i] - (-plane[i])*(zdepth+plane[3]); | |
161 | } | |
162 | orig[1] = md[1] - (-plane[1])*(zdepth+plane[3]); | |
163 | orig[2] = md[2] - (-plane[2])*(zdepth+plane[3]); | |
164 | ||
165 | cout<<endl<<"The origin of the box: "<<orig[0]<<" "<<orig[1]<<" "<<orig[2]<<endl; | |
166 | ||
167 | // get x,y local directions needed to write the global rotation matrix | |
168 | // for the surveyed volume by normalising vectors ab and bc | |
169 | Double_t sx = TMath::Sqrt(ab[0]*ab[0] + ab[1]*ab[1] + ab[2]*ab[2]); | |
170 | if(sx>1.e-8){ | |
171 | for(i=0;i<3;i++){ | |
172 | ab[i] /= sx; | |
173 | } | |
174 | cout<<endl<<"x "<<ab[0]<<" "<<ab[1]<<" "<<ab[2]<<endl; | |
175 | } | |
176 | Double_t sy = TMath::Sqrt(bc[0]*bc[0] + bc[1]*bc[1] + bc[2]*bc[2]); | |
177 | if(sy>1.e-8){ | |
178 | for(i=0;i<3;i++){ | |
179 | bc[i] /= sy; | |
180 | } | |
181 | cout<<endl<<"y "<<bc[0]<<" "<<bc[1]<<" "<<bc[2]<<endl; | |
182 | } | |
183 | ||
184 | ||
185 | // the global matrix for the surveyed volume - ng | |
186 | Double_t rot[9] = {-ab[0],bc[0],-plane[0],-ab[1],bc[1],-plane[1],-ab[2],bc[2],-plane[2]}; | |
187 | TGeoHMatrix ng; | |
188 | ng.SetTranslation(md); | |
189 | ng.SetRotation(rot); | |
190 | ||
191 | cout<<"\n********* global matrix inferred from surveyed fiducial marks for chamber"<<survNch<<"***********\n"; | |
192 | ng.Print(); | |
193 | ||
194 | ||
195 | return ng; | |
e4c1cb11 | 196 | |
197 | } | |
198 | ||
199 | ||
200 | ||
201 |