]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - VZERO/MakeVZEROFullMisAlignment.C
Using AliGeomManager in the macros (Raffaele)
[u/mrichter/AliRoot.git] / VZERO / MakeVZEROFullMisAlignment.C
index cf1d6832776a26676cfbede1d1a5a50819e4fdae..1cbb06e41eb194f0d401fb71ca65b04b7860ccc4 100644 (file)
@@ -1,7 +1,12 @@
 void MakeVZEROFullMisAlignment(){
   // Create TClonesArray of full misalignment objects for VZERO
   // 
-  if(!gGeoManager) TGeoManager::Import("geometry.root");
+  if(!AliGeomManager::GetGeometry()){
+    if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
+      AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
+      AliCDBManager::Instance()->SetRun(0);
+    AliGeomManager::LoadGeometry();
+  }
   // needed for the constructors with local coordinates not to fail
 
   TClonesArray *array = new TClonesArray("AliAlignObjAngles",10);
@@ -11,17 +16,17 @@ void MakeVZEROFullMisAlignment(){
 
   Double_t dx, dy, dz, dpsi, dtheta, dphi;
   TRandom *rnd   = new TRandom(4321);
-  Double_t sigmatr = 0.1; // max shift in cm w.r.t. RS
-  Double_t sigmarot = 0.5; // max rot in degrees w.r.t. RS
+  Double_t sigmatr = 0.1; // max shift in cm
+  Double_t sigmarot = 0.5; // max rot in degrees
 
   // null shifts and rotations
 
-  const char *V0right="/ALIC_1/VZERO_1/V0RI_1";
-  const char *V0left="/ALIC_1/VZERO_1/V0LE_1";
+  const char *V0right="VZERO/V0C";
+  const char *V0left="VZERO/V0A";
 
   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);
 
   dx = rnd->Gaus(0.,sigmatr);
   dy = rnd->Gaus(0.,sigmatr);
@@ -40,23 +45,39 @@ void MakeVZEROFullMisAlignment(){
   new(alobj[1]) AliAlignObjAngles(V0left, volid, dx, dy, dz, dpsi, dtheta,
                                   dphi,kFALSE);
 
-  if(!gSystem->Getenv("$TOCDB")){
+  const char* macroname = "MakeVZEROFullMisAlignment.C";
+  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
     // save on file
-    TFile f("V0fullMisalignment.root","RECREATE");
-    if(!f) cerr<<"cannot open file for output\n";
+    const char* filename = "VZEROfullMisalignment.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,"V0FullObjs ","kSingleKey");
+    f.WriteObject(array,"VZEROAlignObjs","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("Brigitte Cheynis");
     md->SetComment("Alignment objects for V0 full misalignment");
-    md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
-    AliCDBId id("VZERO/Align/Data",0,9999999);
+    md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
+    AliCDBId id("VZERO/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);
   }