]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/MakeEMCALFullMisAlignment.C
Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALFullMisAlignment.C
index 563cf1600e482fef4cdc366711851d653b87d264..ee4a92fb1f13f43498011bc180bbcf75d0ca17be 100644 (file)
@@ -4,9 +4,12 @@ void MakeEMCALFullMisAlignment(){
   TClonesArray *array = new TClonesArray("AliAlignObjAngles",10);
   TClonesArray &alobj = *array;
 
-  if(!gGeoManager) TGeoManager::Import("geometry.root");
-  // needed for the constructors with local coordinates not to fail
-
+  if(!AliGeomManager::GetGeometry()){
+    if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
+      AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
+      AliCDBManager::Instance()->SetRun(0);
+    AliGeomManager::LoadGeometry();
+  }
   AliAlignObjAngles a;
 
   Double_t dx, dy, dz, dpsi, dtheta, dphi;
@@ -21,8 +24,8 @@ void MakeEMCALFullMisAlignment(){
   TString pathstr;
 
   Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
-  AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
-  UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex); //dummy volume identity
+  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
+  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy volume identity
   Int_t i;
   Int_t j=0;
 
@@ -51,23 +54,39 @@ void MakeEMCALFullMisAlignment(){
     new(alobj[j++]) AliAlignObjAngles(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
   }
 
-  if(!gSystem->Getenv("$TOCDB")){
+  const char* macroname = "MakeEMCALFullMisAlignment.C";
+  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
     // save on file
-    TFile f("EMCALfullMisalignment.root","RECREATE");
-    if(!f) cerr<<"cannot open file for output\n";
+    const char* filename = "EMCALfullMisalignment.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,"T0FullObjs ","kSingleKey");
+    f.WriteObject(array,"EMCALAlignObjs","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("Jennifer Clay");
     md->SetComment("Full misalignment for EMCAL");
-    md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
-    AliCDBId id("EMCAL/Align/Data",0,9999999);
+    md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
+    AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);
   }