]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/MakeTPCResMisAlignment.C
Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / TPC / MakeTPCResMisAlignment.C
index f6f635ea7513ee57f94b239683cc87340e049eca..0fa4084f79bcb96e3270ac9c96e3c08c23b25f40 100644 (file)
@@ -1,7 +1,12 @@
 void MakeTPCResMisAlignment(){
   // Create TClonesArray of residual misalignment objects for TPC
   //
-  if(!gGeoManager) TGeoManager::Import("geometry.root");
+  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
 
   TClonesArray *array = new TClonesArray("AliAlignObjAngles",100);
@@ -35,23 +40,39 @@ void MakeTPCResMisAlignment(){
   }
 
 
+  const char* macroname = "MakeTPCResMisAlignment.C";
   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
     // save on file
-    TFile f("TPCresidualMisalignment.root","RECREATE");
-    if(!f) cerr<<"cannot open file for output\n";
+    const char* filename = "TPCresidualMisalignment.root";
+    TFile f(filename,"RECREATE");
+    if(!f){
+      Error(macroname,"cannot open file for output\n");
+      return;
+    }
+    Info(macroname,"Saving alignment objects to the file %s", filename);
     f.cd();
     f.WriteObject(array,"TPCAlignObjs","kSingleKey");
     f.Close();
   }else{
     // save in CDB storage
-    const char* Storage = gSystem->Getenv("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);
+    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");
     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
-    AliCDBId id("TPC/Align/Data",0,9999999);
+    AliCDBId id("TPC/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);
   }