]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/MakePMDResMisAlignment.C
Mapping file put in the CDB
[u/mrichter/AliRoot.git] / PMD / MakePMDResMisAlignment.C
index e95c29d6c93fb1b8742494a9eba8373e7a7dab9e..f83902db11dbcf62e689cce94326afe64eb2063f 100644 (file)
@@ -34,18 +34,39 @@ void MakePMDResMisAlignment(){
     // Steel plate 
  */
   
-  if(!AliGeomManager::GetGeometry()){
-    if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
-      AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
-      AliCDBManager::Instance()->SetRun(0);
-    AliGeomManager::LoadGeometry();
-  }
-  // needed for the constructors with local coordinates not to fail
+  const char* macroname = "MakePMDResMisAlignment.C";
+
+  // Activate CDB storage and load geometry from CDB
+  AliCDBManager* cdb = AliCDBManager::Instance();
+  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  cdb->SetRun(0);
+  
+  AliCDBStorage* storage;
+  
+  if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
+    TString Storage = gSystem->Getenv("STORAGE");
+    if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
+      Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
+      return;
+    }
+    storage = cdb->GetStorage(Storage.Data());
+    if(!storage){
+      Error(macroname,"Unable to open storage %s\n",Storage.Data());
+      return;
+    }
+    AliCDBPath path("GRP","Geometry","Data");
+    AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
+    if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
+    entry->SetOwner(0);
+    TGeoManager* geom = (TGeoManager*) entry->GetObject();
+    AliGeomManager::SetGeometry(geom);
+  }else{
+    AliGeomManager::LoadGeometry(); //load geom from default CDB storage
+  }    
 
   Float_t max_trans=0.1;
   Float_t max_rot=0.1;
 
-  TString path;
   const char *Sector1="PMD/Sector1"; 
   const char *Sector2="PMD/Sector2";
   const char *Sector3="PMD/Sector3"; 
@@ -95,8 +116,6 @@ void MakePMDResMisAlignment(){
   TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
   TClonesArray &alobj = *array;
   
-  AliAlignObjParams o;
-  
   Int_t iIndex=0; //  let all modules have index=0 in a layer with no LUT
   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
   UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
@@ -106,8 +125,7 @@ void MakePMDResMisAlignment(){
   new(alobj[2]) AliAlignObjParams(Sector3, volid, dx23, dy23, dz23, dpsi23, dtheta23, dphi23, kFALSE);
   new(alobj[3]) AliAlignObjParams(Sector4, volid, dx23, dy23, dz23, dpsi23, dtheta23, dphi23, kFALSE);
   
-  const char* macroname = "MakePMDResMisAlignment.C";
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // Create a File to store the alignment data
     const char* filename = "PMDresidualMisalignment.root";
     TFile f(filename,"RECREATE");
@@ -121,19 +139,6 @@ void MakePMDResMisAlignment(){
     f.Close();
   }else{
   // save in CDB storage
-    TString Storage = gSystem->Getenv("STORAGE");
-    if(!Storage.BeginsWith("local://") && !Storage.BeginsWith("alien://")) {
-      Error(macroname,"STORAGE variable set to %s is not valid. Exiting\n",Storage.Data());
-      return;
-    }
-    Info(macroname,"Saving alignment objects in CDB storage %s",
-        Storage.Data());
-    AliCDBManager* cdb = AliCDBManager::Instance();
-    AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
-    if(!storage){
-      Error(macroname,"Unable to open storage %s\n",Storage.Data());
-      return;
-    }
     AliCDBMetaData* md = new AliCDBMetaData();
     md->SetResponsible("");
     md->SetComment("Residual misalignment for PMD, produced with sigmatr=0.1 and sigmarot=0.1 in the local RS");