]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/MakeT0ZeroMisAlignment.C
Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / T0 / MakeT0ZeroMisAlignment.C
index f4228dbd04962cfb07f23dac6c0cdf2b4285d744..fd435e70f5348da17e2e540af0f66b300fb8716a 100644 (file)
@@ -11,8 +11,8 @@ void MakeT0ZeroMisAlignment(){
   TString symName, sn;
 
   Int_t iIndex=0;
-  AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
-  UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
+  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
+  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
 
   Int_t j=0;
   for (Int_t imod=0; imod<24; imod++)
@@ -28,23 +28,39 @@ void MakeT0ZeroMisAlignment(){
       new(alobj[j++]) AliAlignObjAngles(symName.Data(), volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
     }
 
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+  const char* macroname = "MakeT0ZeroMisAlignment.C";
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // save on file
-    TFile f("T0zeroMisalignment.root","RECREATE");
-    if(!f) cerr<<"cannot open file for output\n";
+    const char* filename = "T0zeroMisalignment.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,"T0ZeroObjs","kSingleKey");
+    f.WriteObject(array,"T0AlignObjs","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("Tomasz Malkiewicz");
     md->SetComment("Zero misalignment for T0, produced with sigmatr=0.05 and sigmarot=0.3 in the local RS");
-    md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
-    AliCDBId id("T0/Align/Data",0,9999999);
+    md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
+    AliCDBId id("T0/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);
   }