]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - T0/MakeT0ResMisAlignment.C
correct: no newline at end of file
[u/mrichter/AliRoot.git] / T0 / MakeT0ResMisAlignment.C
index 5f61b9e197d2c684ef428816e33c8764d3c99d06..5a89ebd0986a83c148770be804134cf7adb457ca 100644 (file)
@@ -1,14 +1,9 @@
 void MakeT0ResMisAlignment(){
   // Create TClonesArray of residual misalignment objects for T0
   //
-  TClonesArray *array = new TClonesArray("AliAlignObjAngles",30);
+  TClonesArray *array = new TClonesArray("AliAlignObjParams",30);
   TClonesArray &alobj = *array;
 
-  if(!gGeoManager) TGeoManager::Import("geometry.root");
-  // needed for the constructors with local coordinates not to fail
-
-  AliAlignObjAngles a;
-
   Double_t dx, dy, dz, dpsi, dtheta, dphi;
   TRandom *rnd   = new TRandom(4321);
   Double_t sigmatr = 0.05; // max shift in cm
@@ -17,8 +12,8 @@ void MakeT0ResMisAlignment(){
   TString symName, sn;
 
   Int_t iIndex=0;
-  AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
-  UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
+  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
+  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
 
   Int_t j=0;
   for (Int_t imod=0; imod<24; imod++){
@@ -37,26 +32,42 @@ void MakeT0ResMisAlignment(){
     dtheta = rnd->Gaus(0.,sigmarot);
     dphi = rnd->Gaus(0.,sigmarot);
     
-    new(alobj[j++]) AliAlignObjAngles(symName.Data(), volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
+    new(alobj[j++]) AliAlignObjParams(symName.Data(), volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
   }
   
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+  const char* macroname = "MakeT0ResMisAlignment.C";
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // save on file
-    TFile f("T0residualMisalignment.root","RECREATE");
-    if(!f) cerr<<"cannot open file for output\n";
+    const char* filename = "T0residualMisalignment.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,"T0ResidualObjs ","kSingleKey");
+    f.WriteObject(array,"T0AlignObjs","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("Tomasz Malkiewicz");
     md->SetComment("Residual misalignment for T0, produced with sigmatr=0.05 and sigmarot=0.3 in the local RS");
-    md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
-    AliCDBId id("T0/Align/Data",0,9999999);
+    md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
+    AliCDBId id("T0/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);
   }