#include "STEER/AliCDBManager.h" #include "STEER/AliCDBStorage.h" #include "STEER/AliCDBEntry.h" #include "VZERO/AliVZEROSurveyData.h" void VZEROSurveyToAlignment(){ // Macro to convert survey data into alignment data. // The position of four fiducial marks, sticked on the // entrance face of the V0C box is converted into the // global position of the box. Positions given by surveyers // are extracted from Survey Data Base. if(!gGeoManager) TGeoManager::Import("geometry.root"); TClonesArray *array = new TClonesArray("AliAlignObjMatrix",10); TClonesArray &mobj = *array; Double_t l_vect[3]={0.,0.,0.}; // a 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 gGeoManager->cd("/ALIC_1/VZERO_1/V0RI_1"); // ************* get global matrix ******************* TGeoHMatrix* g3 = gGeoManager->GetCurrentMatrix(); // this is used below as the ideal global matrix // ************* get local matrix ******************* 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<GetStorage("local://$ALICE_ROOT"); AliCDBEntry *entry=0; entry = storLoc->Get("VZERO/Survey/Data", 0); AliVZEROSurveyData * surveyda = 0; if (entry) surveyda = (AliVZEROSurveyData*) entry->GetObject(); if (!surveyda) AliError("No survey data from survey database !"); Double_t ngA[3], ngB[3], ngC[3], ngD[3]; for(Int_t i=0; i<3; i++) { ngA[i] = surveyda->GetPointA(i) ; ngB[i] = surveyda->GetPointB(i) ; ngC[i] = surveyda->GetPointC(i) ; ngD[i] = surveyda->GetPointD(i) ; } 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<1.e-8){ for(i=0;i<3;i++){ bc[i] /= sy; } cout<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: // AliAlignObj::LayerToVolUID(AliAlignObj::kTOF,i); //AliAlignObjMatrix* mobj[0] = new AliAlignObjMatrix("VZERO/V0C",index,gdelta,kTRUE); new(mobj[0]) AliAlignObjMatrix("VZERO/V0C",index,gdelta,kTRUE); if(!gSystem->Getenv("$TOCDB")){ // save on file TFile f("V0Survey.root","RECREATE"); if(!f) cerr<<"cannot open file for output\n"; f.cd(); f.WriteObject(array,"V0SurveyObjs ","kSingleKey"); f.Close(); }else{ // save in CDB storage const char* Storage = gSystem->Getenv("$STORAGE"); AliCDBManager* cdb = AliCDBManager::Instance(); AliCDBStorage* storage = cdb->GetStorage(Storage); AliCDBMetaData* md = new AliCDBMetaData(); md->SetResponsible("Brigitte Cheynis"); md->SetComment("Alignment objects for V0 survey"); md->SetAliRootVersion(gSystem->Getenv("$ARVERSION")); AliCDBId id("VZERO/Align/Data",0,9999999); storage->Put(array,id,md); } array->Delete(); }