]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - ZDC/MakeZDCZeroMisAlignment.C
Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / ZDC / MakeZDCZeroMisAlignment.C
index 4fe27992faccefcf7399232a720c3fd6217e5aac..a0204af81089eb7f9547848587f4201e438f5485 100644 (file)
@@ -1,7 +1,12 @@
 void MakeZDCZeroMisAlignment(){
   // Create TClonesArray of zero misalignment objects for ZDC
   // 
-  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",10);
@@ -22,23 +27,39 @@ void MakeZDCZeroMisAlignment(){
   new(alobj[0]) AliAlignObjAngles(ZDCn, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
   new(alobj[1]) AliAlignObjAngles(ZDCp, volid, dx, dy, dz, dpsi, dtheta, dphi,kTRUE);
 
+  const char* macroname = "MakeZDCZeroMisAlignment.C";
   if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
     // save in file
-    TFile f("ZDCzeroMisalignment.root","RECREATE");
-    if(!f) cerr<<"cannot open file for output\n";
+    const char* filename = "ZDCzeroMisalignment.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,"ZDCZeroAlObjs ","kSingleKey");
+    f.WriteObject(array,"ZDCAlignObjs","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("Chiara Oppedisano");
     md->SetComment("Alignment objects for ZDC zero misalignment");
     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
-    AliCDBId id("ZDC/Align/Data",0,9999999);
+    AliCDBId id("ZDC/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);
   }