]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - FMD/MakeFMDZeroMisAlignment.C
Code clean up
[u/mrichter/AliRoot.git] / FMD / MakeFMDZeroMisAlignment.C
index b3048eddc64d01d3e722b8356373614238473969..1cba6e5a290ba1693632482e797dad0f2b956e10 100644 (file)
@@ -8,46 +8,52 @@ void MakeFMDZeroMisAlignment()
   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");
   
-  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());
+  if(toCdb) {
+    if(!storage.BeginsWith("local://") && 
+       !storage.BeginsWith("alien://")) {
+      Error(macroname,"STORAGE=\"%s\" is not valid. Exiting\n", storage.Data());
       return;
     }
-    AliCDBStorage* storage = cdb->GetStorage(Storage.Data());
-    if(!storage){
-      Error(macroname,"Unable to open storage %s\n",Storage.Data());
+
+    AliCDBStorage* store = cdb->GetStorage(storage.Data());
+    if(!store){
+      Error(macroname,"Unable to open storage %s\n", storage.Data());
       return;
     }
-    AliCDBPath path("GRP","Geometry","Data");
-    AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
+
+    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();
+    TGeoManager* geom = static_cast<TGeoManager*>(entry->GetObject());
     AliGeomManager::SetGeometry(geom);
-  }else{
-    AliGeomManager::LoadGeometry(); //load geom from default CDB storage
-  }    
+  }else
+    //load geom from default CDB storage
+    AliGeomManager::LoadGeometry(); 
   
   gSystem->Load("libFMDutil.so");
-  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
-    // save on file
-    AliFMDAlignFaker faker(AliFMDAlignFaker::kAll, "geometry.root","FMDAlignObjs.root");
-  }else{
-    // save in CDB storage
-    AliFMDAlignFaker faker(AliFMDAlignFaker::kAll, "geometry.root", Storage.Data());
-  }
-
-  // fRunMax should be changed in the constructor
-
-  faker.SetSensorDisplacement(0., 0., 0., 0., 0., 0.);
-  faker.SetSensorRotation(0., 0., 0., 0., 0., 0.);
-  faker.SetHalfDisplacement(0., 0., 0., 0., 0., 0.);
-  faker.SetHalfRotation(0., 0., 0., 0., 0., 0.);
-  faker.Exec();
+  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., 0., 0., 0., 0., 0.);
+  faker->SetSensorRotation(0., 0., 0., 0., 0., 0.);
+  faker->SetHalfDisplacement(0., 0., 0., 0., 0., 0.);
+  faker->SetHalfRotation(0., 0., 0., 0., 0., 0.);
+  faker->Exec();
+  delete faker;
 
 
 }