]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/MakeFMDResMisAlignment.C
Updated Detector Algorithm base class to write the conditions data to file. The class...
[u/mrichter/AliRoot.git] / FMD / MakeFMDResMisAlignment.C
index 276cd5bb25a5037bd96366fd9ade99e8f86c8a89..bbf01b8db77891419483fad9050b6700c8fa6f0a 100644 (file)
@@ -2,30 +2,59 @@ void MakeFMDResMisAlignment()
 {
   // Create TClonesArray of residual misalignment objects for FMD
   //
-  if(!AliGeomManager::GetGeometry()){
-    if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
-      AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
-    AliCDBManager::Instance()->SetRun(0);
-    AliGeomManager::LoadGeometry();
-  }
+  const char* macroname = "MakeFMDResMisAlignment.C";
+
+  // Activate CDB storage and load geometry from CDB
+  AliCDBManager* cdb = AliCDBManager::Instance();
+  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT");
+  cdb->SetRun(0);
+
+  Bool_t  toCdb   = TString(gSystem->Getenv("TOCDB")) == TString("kTRUE");
+  TString storage = gSystem->Getenv("STORAGE");
   
-  gSystem->Load("libFMDutil.so");
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
-    // save on file
-    AliFMDAlignFaker faker(AliFMDAlignFaker::kAll, "geometry.root","FMDresidualMisalignment.root");
-  }else{
-    // save in CDB storage
-    const char* Storage = gSystem->Getenv("STORAGE");
-    AliFMDAlignFaker faker(AliFMDAlignFaker::kAll, "geometry.root", Storage);
-  }
+  if(toCdb) {
+    if(!storage.BeginsWith("local://") && 
+       !storage.BeginsWith("alien://")) {
+      Error(macroname,"STORAGE=\"%s\" is not valid. Exiting\n", storage.Data());
+      return;
+    }
 
-  // fRunMax should be changed in the constructor
+    AliCDBStorage* store = cdb->GetStorage(storage.Data());
+    if(!store){
+      Error(macroname,"Unable to open storage %s\n", storage.Data());
+      return;
+    }
 
-  faker.SetSensorDisplacement(-0.005, -0.005, -0.005, 0.005, 0.005, 0.005);
-  faker.SetSensorRotation(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5);
-  faker.SetHalfDisplacement(-0.25, -0.25, -0.25, 0.25, 0.25, 0.25);
-  faker.SetHalfRotation(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5);
-  faker.Exec();
+    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 = static_cast<TGeoManager*>(entry->GetObject());
+    AliGeomManager::SetGeometry(geom);
+  }else
+    //load geom from default CDB storage
+    AliGeomManager::LoadGeometry(); 
+  
+  gSystem->Load("libFMDutil.so");
+  AliFMDAlignFaker* faker = (toCdb ? 
+                            // save on file
+                            new AliFMDAlignFaker(AliFMDAlignFaker::kAll, 
+                                                 "geometry.root",
+                                                 "FMDfullMisalignment.root") :
+                            // save in CDB storage
+                            new AliFMDAlignFaker(AliFMDAlignFaker::kAll, 
+                                                 "geometry.root", 
+                                                 storage.Data()));
 
+  faker->SetSensorDisplacement(-0.005, -0.005, -0.005, 0.005, 0.005, 0.005);
+  faker->SetSensorRotation(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5);
+  faker->SetHalfDisplacement(-0.25, -0.25, -0.25, 0.25, 0.25, 0.25);
+  faker->SetHalfRotation(-0.5, -0.5, -0.5, 0.5, 0.5, 0.5);
+  faker->Exec();
+  delete faker;
 
 }
+//
+// EOF
+//