From e4c1cb119e06b5e2b146cd5a736f71ee46d5fa6b Mon Sep 17 00:00:00 2001 From: dibari Date: Fri, 8 Jun 2007 15:46:30 +0000 Subject: [PATCH] Macro to obtain the survey points for alignment. --- HMPID/SurveyToAlignHmpid.C | 216 +++++++++++++++++++++++++++++++++++++ 1 file changed, 216 insertions(+) create mode 100644 HMPID/SurveyToAlignHmpid.C diff --git a/HMPID/SurveyToAlignHmpid.C b/HMPID/SurveyToAlignHmpid.C new file mode 100644 index 00000000000..5f53544b105 --- /dev/null +++ b/HMPID/SurveyToAlignHmpid.C @@ -0,0 +1,216 @@ + +TVector3 v[28]; +Int_t nCh; + + +TGeoHMatrix GetResSurvAlign(Int_t survNch); + +void SurveyToAlignHmpid(){ + + + AliSurveyObj *so = new AliSurveyObj(); + + + Int_t size = so->GetEntries(); + printf("-> %d\n", size); + + so->FillFromLocalFile("Survey_781282_HMPID.txt"); + size = so->GetEntries(); + printf("--> %d\n", size); + + + TObjArray *points = so->GetData(); +// TVector3 v[28]; + + for (Int_t i = 0; i < points->GetEntries(); ++i) + { + AliSurveyPoint *p=(AliSurveyPoint *) points->At(i); + v[i].SetXYZ(p->GetX()*100.,p->GetY()*100.,p->GetZ()*100.); + } + + +// // To produce the alignment object for the given volume you would +// // then do something like this: +// // Calculate the global delta transformation as ng * g3-1 +// TGeoHMatrix gdelta = g3->Inverse(); //now equal to the inverse of g3 +// gdelta.MultiplyLeft(&ng); +// Int_t index = 0; +// // if the volume is in the look-up table use something like this instead: +// // AliGeomManager::LayerToVolUID(AliGeomManager::kTOF,i); +// AliAlignObjMatrix* mobj = new AliAlignObjMatrix("symname",index,gdelta,kTRUE); + + +TGeoHMatrix mtx = GetResSurvAlign(5); + +TGeoManager::Import("/home/mserio/tstesdtrk/geometry.root"); +gGeoManager->cd(Form("ALIC_1/Hmp_%1i",nCh)); +TGeoHMatrix g0 = *gGeoManager->GetCurrentMatrix(); +cout<<"\n\n*********Ideal Matrix (chamber "<Print(); +cout<<""<4) +{ + // first vector on the plane of the fiducial marks + for(Int_t i=0;i<3;i++){ + ab[i] = ngB[i] - ngA[i]; + } + + // second vector on the plane of the fiducial marks + for(Int_t i=0;i<3;i++){ + bc[i] = ngC[i] - ngB[i]; + } +} + + else{ + // first vector on the plane of the fiducial marks + for(Int_t i=0;i<3;i++){ + ab[i] = ngB[i] - ngA[i]; + } + + // second vector on the plane of the fiducial marks + for(Int_t i=0;i<3;i++){ + bc[i] = ngD[i] - ngB[i]; + } + +} + // vector normal to the plane of the fiducial marks obtained + // as cross product of the two vectors on the plane d0^d1 + n[0] = ab[1] * bc[2] - ab[2] * bc[1]; + n[1] = ab[2] * bc[0] - ab[0] * bc[2]; + n[2] = ab[0] * bc[1] - ab[1] * bc[0]; + + Double_t sizen = TMath::Sqrt( n[0]*n[0] + n[1]*n[1] + n[2]*n[2] ); + if(sizen>1.e-8){ + s = Double_t(1.)/sizen ; //normalization factor + }else{ + return 0; + } + + // plane expressed in the hessian normal form, see: + // http://mathworld.wolfram.com/HessianNormalForm.html + // the first three are the coordinates of the orthonormal vector + // the fourth coordinate is equal to the distance from the origin + + for(i=0;i<3;i++){ + plane[i] = n[i] * s; + } + plane[3] = -( plane[0] * ngA[0] + plane[1] * ngA[1] + plane[2] * ngA[2] ); + cout<<"normal to plane and distance from IP: "<4){ + for(i=0;i<3;i++){ + md[i] = (ngA[i] + ngC[i]) * 0.5;//modified!!!!!!!!! + } + +} + +else { + for(i=0;i<3;i++){ + md[i] = (ngA[i] + ngD[i]) * 0.5;//modified!!!!!!!!! + } +} + cout<1.e-8){ + for(i=0;i<3;i++){ + ab[i] /= sx; + } + cout<1.e-8){ + for(i=0;i<3;i++){ + bc[i] /= sy; + } + cout<