]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/MakeTPCResMisAlignment.C
Corrected UInt_t <-> Int_t conversion
[u/mrichter/AliRoot.git] / TPC / MakeTPCResMisAlignment.C
index 62dabeb5d14bf46d7c913ca2bf25cd5e8c0edc2c..2462b0d983438f7e0e560b52cca3a19580639053 100644 (file)
@@ -1,19 +1,40 @@
 void MakeTPCResMisAlignment(){
   // Create TClonesArray of residual misalignment objects for TPC
   //
-  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 = "MakeTPCResMisAlignment.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
+  }    
 
   TClonesArray *array = new TClonesArray("AliAlignObjParams",100);
   TClonesArray &alobj = *array;
   
   TRandom *rnd   = new TRandom(4357);
-  AliAlignObjParams o;
   Double_t dx, dy, dz, dpsi, dtheta, dphi;
   Int_t j = 0;
 
@@ -39,9 +60,7 @@ void MakeTPCResMisAlignment(){
     }
   }
 
-
-  const char* macroname = "MakeTPCResMisAlignment.C";
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // save on file
     const char* filename = "TPCresidualMisalignment.root";
     TFile f(filename,"RECREATE");
@@ -55,19 +74,6 @@ void MakeTPCResMisAlignment(){
     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("Marian Ivanov");
     md->SetComment("Residual misalignment for TPC, sigmatr=0.01 and sigmarot=0.6 in the local RS");