]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - HMPID/MakeHMPIDZeroMisAlignment.C
From Boris - revival of AliEveCascade classes.
[u/mrichter/AliRoot.git] / HMPID / MakeHMPIDZeroMisAlignment.C
index c372b8b36a3dd8ff8d1269ee5f85cd1569b519e7..1f7306b15283960f07040350dcab6d0b5a14e6e4 100644 (file)
@@ -1,6 +1,36 @@
 void MakeHMPIDZeroMisAlignment(){
   // Create TClonesArray of zero misalignment objects for HMPID
   //
+  const char* macroname = "MakeHMPIDZeroMisAlignment.C";
+  // Activate CDB storage and load geometry from CDB
+  AliCDBManager* cdb = AliCDBManager::Instance();
+  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
+  cdb->SetRun(0);
+  
+  AliCDBStorage* storage;
+  TString Storage;
+  
+  if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
+    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 *pCA = new TClonesArray("AliAlignObjMatrix",10);
   
   Double_t dX=0.,dY=0.,dZ=0.,dPsi=0.,dTheta=0.,dPhi=0.;
@@ -11,8 +41,7 @@ void MakeHMPIDZeroMisAlignment(){
   }
 
 //   pCA->Print();
-  const char* macroname = "MakeHMPIDZeroMisAlignment.C";  
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // save on file
     const char* filename = "HMPIDzeroMisalignment.root";
     TFile f(filename,"RECREATE");
@@ -26,19 +55,8 @@ void MakeHMPIDZeroMisAlignment(){
     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 *pMeta= new AliCDBMetaData();  
     pMeta->SetResponsible("HMPID Expert");
     pMeta->SetComment("Zero alignment objects for HMPID");