]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/MakeMUONFullMisAlignment.C
Move contents of EVE/Alieve to EVE/EveDet as most code will remain there.
[u/mrichter/AliRoot.git] / MUON / MakeMUONFullMisAlignment.C
index d4bce05742f114beb03512d9e9145bba90fd703a..8611ee12808c8e0a018988067e4420f3bf13211c 100644 (file)
 
 // $Id$
 
-// Macro for generating the full misalignment data.
-// The macro is trigger from AliRoot/macros/MakeAllDETsFullMisAlignment.C
-//
-// Author: I. Hrivnacova, IPN Orsay
+/// \ingroup macros
+/// \file MakeMUONFullMisAlignment.C
+/// \brief Macro for generating the full misalignment data.
+///
+/// The macro is triggered from AliRoot/macros/MakeAllDETsFullMisAlignment.C
+///
+/// \author: I. Hrivnacova, IPN Orsay
 
 #if !defined(__CINT__) || defined(__MAKECINT__)
 
 #include "AliGeomManager.h"
 #include "AliCDBManager.h"
 #include "AliCDBStorage.h"
+#include "AliCDBEntry.h"
 #include "AliCDBId.h"
 
 #include <TSystem.h>
+#include <TError.h>
 #include <TClonesArray.h>
 #include <TString.h>
 #include <TFile.h>
 
 void MakeMUONFullMisAlignment()
 {
-  // Load geometry, if not yet loaded,
-  if ( ! AliGeomManager::GetGeometry() )
-    AliGeomManager::LoadGeometry("geometry.root");
+  const char* macroname = "MakeMUONFullMisAlignment.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 = 0;
+  
+  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
+  }    
 
   AliMUONGeometryTransformer transformer;
   transformer.LoadGeometryData();
@@ -54,31 +84,25 @@ void MakeMUONFullMisAlignment()
   const TClonesArray* array = newTransform->GetMisAlignmentData();
   
   if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
-    cout << "Generating full misalignment data in a file" << endl;
-
-    // Create a File to store the alignment data
-    TFile f("MUONfullMisalignment.root","RECREATE");
-    if ( !f.IsOpen() ) {
-      cerr << "cannot open file for output" << endl;
+    // Save in file
+    const char* filename = "MUONfullMisalignment.root";
+    TFile f(filename,"RECREATE");
+    if (!f.IsOpen()) {
+      Error(macroname,"cannot open file for output\n");
+      return;
     }
-    
+    Info(macroname,"Saving alignment objects to the file %s", filename);
     f.cd();
-    f.WriteObject(array,"MUONAlignObjs ","kSingleKey");
+    f.WriteObject(array,"MUONAlignObjs","kSingleKey");
     f.Close();
   }
   else {
-    cout << "Generating full misalignment data in CDB" << endl;
-
-    // save in CDB storage
-    const char* Storage = gSystem->Getenv("STORAGE");
-    
-    AliCDBManager* cdbManager = AliCDBManager::Instance();
-    AliCDBStorage* storage = cdbManager->GetStorage(Storage);
+    // Save in CDB storage
     AliCDBMetaData* cdbData = new AliCDBMetaData();
     cdbData->SetResponsible("Dimuon Offline project");
     cdbData->SetComment("MUON alignment objects with full misalignment");
     cdbData->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
-    AliCDBId id("MUON/Align/Data", 0, 9999999); 
+    AliCDBId id("MUON/Align/Data", 0, AliCDBRunRange::Infinity()); 
     storage->Put(const_cast<TClonesArray*>(array), id, cdbData);
   }   
   delete newTransform;