]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ITS/MakeITSResMisAlignment.C
Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / ITS / MakeITSResMisAlignment.C
index c8771761cf15fdcf7a752d74d633b4545e19be18..60327e6a40b7cb5b1f6e982ee6ef9535479b9f56 100644 (file)
@@ -4,7 +4,12 @@ void MakeITSResMisAlignment(){
   TClonesArray *array = new TClonesArray("AliAlignObjAngles",4000);
   TClonesArray &alobj = *array;
    
-  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
 
   Double_t globalZ = 0.005; // in cm, = 50 microns
@@ -89,22 +94,39 @@ void MakeITSResMisAlignment(){
     }
   }
 
+  const char* macroname = "MakeITSResMisAlignment.C";
   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
     // save on file
-    TFile f("ITSresidualMisalignment.root","RECREATE");
-    if(!f) {cerr<<"cannot open file for output\n";}
+    const char* filename = "ITSresidualMisalignment.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,"ITSAlignObjs","kSingleKey");
     f.Close();
   }else{
     // save in CDB storage
-    const char* Storage = gSystem->Getenv("STORAGE");
-    AliCDBManager *CDB = AliCDBManager::Instance();
-    AliCDBStorage* storage = CDB->GetStorage(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 *md= new AliCDBMetaData();
     md->SetResponsible("Ludovic Gaudichet");
     md->SetComment("Alignment objects with actual ITS misalignment");
     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
-    AliCDBId id("ITS/Align/Data",0,9999999);
+    AliCDBId id("ITS/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id, md);
   }