]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TPC/MakeTPCFullMisAlignment.C
ATO-78 a.) adding aliases used for gain correction fitting \n b)Kr and QA prefix...
[u/mrichter/AliRoot.git] / TPC / MakeTPCFullMisAlignment.C
index 7e864fffc156cd7f68669d2384555be30bd90779..6d01a793353ffcb36eca61e3242d0c628ff6b961 100644 (file)
@@ -1,14 +1,39 @@
 void MakeTPCFullMisAlignment(){
   // Create TClonesArray of full misalignment objects for TPC
   //
-  if(!gGeoManager) TGeoManager::Import("geometry.root");
-  // needed for the constructors with local coordinates not to fail
-
-  TClonesArray *array = new TClonesArray("AliAlignObjAngles",100);
+  const char* macroname = "MakeTPCFullMisAlignment.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
+  }    
+                 
+  TClonesArray *array = new TClonesArray("AliAlignObjParams",100);
   TClonesArray &alobj = *array;
   
   TRandom *rnd   = new TRandom(4357);
-  AliAlignObjAngles o;
   Int_t j = 0;
   Double_t dx, dy, dz, dpsi, dtheta, dphi;
 
@@ -30,28 +55,29 @@ void MakeTPCFullMisAlignment(){
 
       UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iModule);
       const char *symname = AliGeomManager::SymName(volid);
-      new(alobj[j++]) AliAlignObjAngles(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
+      new(alobj[j++]) AliAlignObjParams(symname, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
     }
   }
 
-
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // save on file
-    TFile f("TPCfullMisalignment.root","RECREATE");
-    if(!f) cerr<<"cannot open file for output\n";
+    const char* filename = "TPCfullMisalignment.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,"TPCAlignObjs","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("Marian Ivanov");
     md->SetComment("Full misalignment for TPC, sigmatr=0.01 and sigmarot=0.6 in the local RS");
     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
-    AliCDBId id("TPC/Align/Data",0,9999999);
+    AliCDBId id("TPC/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);
   }