]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - PMD/MakePMDResMisAlignment.C
MUON DAs
[u/mrichter/AliRoot.git] / PMD / MakePMDResMisAlignment.C
index 7b7f0aa13c0676d5c0dcdff85acaab2e5dc7c314..f83902db11dbcf62e689cce94326afe64eb2063f 100644 (file)
@@ -34,13 +34,39 @@ void MakePMDResMisAlignment(){
     // Steel plate 
  */
   
-  if(!gGeoManager) TGeoManager::Import("geometry.root");
-  // needed for the constructors with local coordinates not to fail
+  const char* macroname = "MakePMDResMisAlignment.C";
+
+  // Activate CDB storage and load geometry from CDB
+  AliCDBManager* cdb = AliCDBManager::Instance();
+  if(!cdb->IsDefaultStorageSet()) cdb->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
+  cdb->SetRun(0);
+  
+  AliCDBStorage* storage;
+  
+  if( TString(gSystem->Getenv("TOCDB")) == TString("kTRUE") ){
+    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;
+    }
+    storage = cdb->GetStorage(Storage.Data());
+    if(!storage){
+      Error(macroname,"Unable to open storage %s\n",Storage.Data());
+      return;
+    }
+    AliCDBPath path("GRP","Geometry","Data");
+    AliCDBEntry *entry = storage->Get(path.GetPath(),cdb->GetRun());
+    if(!entry) Fatal(macroname,"Could not get the specified CDB entry!");
+    entry->SetOwner(0);
+    TGeoManager* geom = (TGeoManager*) entry->GetObject();
+    AliGeomManager::SetGeometry(geom);
+  }else{
+    AliGeomManager::LoadGeometry(); //load geom from default CDB storage
+  }    
 
   Float_t max_trans=0.1;
   Float_t max_rot=0.1;
 
-  TString path;
   const char *Sector1="PMD/Sector1"; 
   const char *Sector2="PMD/Sector2";
   const char *Sector3="PMD/Sector3"; 
@@ -87,38 +113,37 @@ void MakePMDResMisAlignment(){
   
   
   //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
-  AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
-  UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
+  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
+  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
 
-  new(alobj[0]) AliAlignObjAngles(Sector1, volid, dx14, dy14, dz14, dpsi14, dtheta14, dphi14, kFALSE);
-  new(alobj[1]) AliAlignObjAngles(Sector2, volid, dx14, dy14, dz14, dpsi14, dtheta14, dphi14, kFALSE);
-  new(alobj[2]) AliAlignObjAngles(Sector3, volid, dx23, dy23, dz23, dpsi23, dtheta23, dphi23, kFALSE);
-  new(alobj[3]) AliAlignObjAngles(Sector4, volid, dx23, dy23, dz23, dpsi23, dtheta23, dphi23, kFALSE);
+  new(alobj[0]) AliAlignObjParams(Sector1, volid, dx14, dy14, dz14, dpsi14, dtheta14, dphi14, kFALSE);
+  new(alobj[1]) AliAlignObjParams(Sector2, volid, dx14, dy14, dz14, dpsi14, dtheta14, dphi14, kFALSE);
+  new(alobj[2]) AliAlignObjParams(Sector3, volid, dx23, dy23, dz23, dpsi23, dtheta23, dphi23, kFALSE);
+  new(alobj[3]) AliAlignObjParams(Sector4, volid, dx23, dy23, dz23, dpsi23, dtheta23, dphi23, kFALSE);
   
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // Create a File to store the alignment data
-    TFile f("PMDresidualMisalignment.root","RECREATE");
-    if(!f) {cerr<<"cannot open file for output\n";}
-    
+    const char* filename = "PMDresidualMisalignment.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");
-    AliCDBManager* cdb = AliCDBManager::Instance();
-    AliCDBStorage* storage = cdb->GetStorage(Storage);
     AliCDBMetaData* md = new AliCDBMetaData();
     md->SetResponsible("");
     md->SetComment("Residual misalignment for PMD, produced with sigmatr=0.1 and sigmarot=0.1 in the local RS");
     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();