void VZEROASurveyToAlignment(){ // Macro to convert survey data into alignment data. // The position of four fiducial marks, sticked on the // entrance face of the V0A box is converted into the // global position of the box. Positions given by surveyers // are extracted from Survey Data Base. Thanks to Brigitte Cheynis // for providing this macro witch just had to be modified in order // to obtain the desired results. if(!gGeoManager) TGeoManager::Import("geometry.root"); // TClonesArray *array = new TClonesArray("AliAlignObjMatrix",10); TClonesArray *array = new TClonesArray("AliAlignObjParams",10); TClonesArray &mobj = *array; Double_t l_vect[3]={0.,0.,0.}; // local vector (the origin) Double_t g_vect[3]; // vector corresp. to it in global RS Double_t m_vect[3]; // vector corresp. to it in mother RS // ************* get global matrix g3 ******************* // TGeoHMatrix *g3 = AliGeomManager::GetMatrix("VZERO/V0A"); TGeoHMatrix *g3 = gGeoManager->GetCurrentMatrix(); // this is used below as the IDEAL global matrix // ************* get local matrix l3 ******************* TGeoNode* n3 = gGeoManager->GetCurrentNode(); TGeoHMatrix *l3 = n3->GetMatrix(); // point coordinates in the global RS g3->LocalToMaster(l_vect,g_vect); cout<LocalToMaster(l_vect,m_vect); cout< local x // | | | // | | | // | | | // | | | // | | | // | | | // A-------------|-------------B // // local z exiting the plane of the screen Double_t gA[3], gB[3], gC[3], gD[3]; g3->LocalToMaster(A,gA); g3->LocalToMaster(B,gB); g3->LocalToMaster(C,gC); g3->LocalToMaster(D,gD); cout<FillFromLocalFile("Survey_943928_V0.txt"); Int_t size = so->GetEntries(); Printf("Title: \"%s\"", so->GetReportTitle().Data()); Printf("Date: \"%s\"", so->GetReportDate().Data()); Printf("Detector: \"%s\"", so->GetDetector().Data()); Printf("URL: \"%s\"", so->GetURL().Data()); Printf("Number: \"%d\"", so->GetReportNumber()); Printf("Version: \"%d\"", so->GetReportVersion()); Printf("Observations: \"%s\"", so->GetObservations().Data()); Printf("Coordinate System: \"%s\"", so->GetCoordSys().Data()); Printf("Measurement Units: \"%s\"", so->GetUnits().Data()); Printf("Nr Columns: \"%d\" \n", so->GetNrColumns()); TObjArray *colNames = so->GetColumnNames(); TObjArray *points = so->GetData(); const char namePoint[4] = "6001"; Double_t coordinates[4][3]; // Printf(" ******* %c ******* \n\n ", namePoint[0]); Printf("Relevant points to be used for alignment procedure (in mm):"); for (Int_t i = 0; i < points->GetEntries(); ++i) { if(((AliSurveyPoint *) points->At(i))->GetPointName()[0] == namePoint[0]) { Printf("Point %d --> \"%s\" %f %f %f ", i, ((AliSurveyPoint *) points->At(i))->GetPointName().Data(), ((AliSurveyPoint *) points->At(i))->GetX(), ((AliSurveyPoint *) points->At(i))->GetY(), ((AliSurveyPoint *) points->At(i))->GetZ() ); if(i > 17){ coordinates[i-18][0] = (AliSurveyPoint *) points->At(i))->GetX(); coordinates[i-18][1] = (AliSurveyPoint *) points->At(i))->GetY(); coordinates[i-18][2] = (AliSurveyPoint *) points->At(i))->GetZ(); } } } Double_t ngA[3], ngB[3], ngC[3], ngD[3]; for(Int_t i=0; i<3; i++) { ngA[i] = coordinates[0][i] / 10.0 ; ngD[i] = coordinates[1][i] / 10.0 ; ngB[i] = coordinates[2][i] / 10.0 ; ngC[i] = coordinates[3][i] / 10.0 ; } cout<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<1.e-8){ for(i=0;i<3;i++){ ab[i] /= sx; } cout<<"x direction "<1.e-8){ for(i=0;i<3;i++){ bc[i] /= sy; } cout<<"y direction "<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[0] = new AliAlignObjMatrix("VZERO/V0A",index,gdelta,kTRUE); // new(mobj[0]) AliAlignObjMatrix("VZERO/V0C",index,gdelta,kTRUE); new(mobj[0]) AliAlignObjParams("VZERO/V0A",index,gdelta,kTRUE); if(!gSystem->Getenv("$TOCDB")){ // save on file TFile f("V0ASurvey.root","RECREATE"); if(!f) cerr<<"cannot open file for output\n"; f.cd(); f.WriteObject(array,"V0ASurveyObjs ","kSingleKey"); f.Close(); }else{ // save in CDB storage AliCDBManager* cdb = AliCDBManager::Instance(); AliCDBStorage* storage = cdb->GetStorage("local://$ALICE_ROOT"); AliCDBMetaData* mda = new AliCDBMetaData(); mda->SetResponsible("Lizardo Valencia"); mda->SetComment("Alignment objects for V0A survey"); mda->SetAliRootVersion(gSystem->Getenv("$ARVERSION")); AliCDBId id("VZERO/Align/Data",0,9999999); storage->Put(array,id,mda); } cout<<"\n********* Alignment constants contained in alignment object ***********\n"; cout<<"*************** deduced from surveyed fiducial marks : ****************\n"; array->Print(); AliAlignObjParams* itsalobj = (AliAlignObjParams*) mobj.UncheckedAt(0); itsalobj->ApplyToGeometry(); array->Delete(); }