]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/MakePMDZeroMisAlignment.C
Bug fix
[u/mrichter/AliRoot.git] / PMD / MakePMDZeroMisAlignment.C
index b178f3fe0282f5cadf9a208c58ad06aa1de17453..9931cbaa4a0c559d0ce347faebf1e7f33facb193 100644 (file)
@@ -33,16 +33,13 @@ void MakePMDZeroMisAlignment(){
     // As these will be mounted on the same
     // Steel plate 
  */
-  
-  if(!gGeoManager) TGeoManager::Import("geometry.root");
-  // needed for the constructors with local coordinates not to fail
+
+  const char* macroname = "MakePMDZeroMisAlignment.C";
 
   //Create a TClonesArray of Align Object to store displacement Angles
-  TClonesArray *array = new TClonesArray("AliAlignObjAngles",10);
+  TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
   TClonesArray &alobj = *array;
   
-  AliAlignObjAngles o;
-  
   Int_t iIndex=0; //  let all modules have index=0 in a layer with no LUT
   AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
   UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
@@ -51,27 +48,41 @@ void MakePMDZeroMisAlignment(){
 
   for(i=1; i<=4; i++){
     TString snSector(Form("PMD/Sector%d",i));
-    new(alobj[j++]) AliAlignObjAngles(snSector.Data(), volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
+    new(alobj[j++]) AliAlignObjParams(snSector.Data(), volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
   }
 
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // Create a File to store the alignment data
-    TFile f("PMDzeroMisalignment.root","RECREATE");
-    if(!f) {cerr<<"cannot open file for output\n";}
-    
+    const char* filename = "PMDzeroMisalignment.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,"PMDAlignObjs ","kSingleKey");
+    f.WriteObject(array,"PMDAlignObjs","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("");
     md->SetComment("Zero misalignment for PMD");
     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
-    AliCDBId id("PMD/Align/Data",0,9999999);
+    AliCDBId id("PMD/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);
   }
   array->Delete();