]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/MakeEMCALFullMisAlignment.C
Fix for backward compatibility of TOF structures (needed for tenders)
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALFullMisAlignment.C
index 404f094790a639ff9fc472c0ca4635980e2a8755..8689aaccf17451585155112888302185ae125d0b 100644 (file)
@@ -1,61 +1,54 @@
-void MakeEMCALFullMisAlignment(){
+enum SurveyDataType_t { kSurvey = 0, kDummy = 1};
+
+void MakeEMCALFullMisAlignment(TString geoname = "EMCAL_FIRSTYEARv1",TString surveyFilename = "emcal_survey_FIRSTYEARv1.txt",SurveyDataType_t type = kSurvey){
   // Create TClonesArray of full misalignment objects for EMCAL
   //
-  TClonesArray *array = new TClonesArray("AliAlignObjParams",10);
-  TClonesArray &alobj = *array;
-
-  if(!AliGeomManager::GetGeometry()){
-    if(!(AliCDBManager::Instance())->IsDefaultStorageSet())
-      AliCDBManager::Instance()->SetDefaultStorage("local://$ALICE_ROOT");
-      AliCDBManager::Instance()->SetRun(0);
-    AliGeomManager::LoadGeometry();
+  const char* macroname = "MakeEMCALFullMisAlignment.C";
+  if(geoname=="")geoname=AliEMCALGeometry::GetDefaultGeometryName();
+  const AliEMCALGeometry *emcalGeom = AliEMCALGeometry::GetInstance(geoname,"");
+  if(!emcalGeom) {
+    Error("MakeEMCALFullMisAlignment","Cannot obtain AliEMCALGeometry singleton\n");
+    return;
   }
-  AliAlignObjParams a;
-
-  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. local RS
-  Double_t sigmarot = 0.1; // max rot in degrees w.r.t. local RS
-
-  // null shifts and rotations
+  TClonesArray *array = new TClonesArray("AliAlignObjParams",emcalGeom->GetNumberOfSuperModules());
+  TClonesArray &alobj = *array;
 
-  const TString basepath = "EMCAL/FullSupermodule";
-  const TString hbasepath = "EMCAL/HalfSupermodule";
-  TString pathstr;
+  // 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
+  }    
 
-  Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
-  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
-  UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy volume identity
-  Int_t i;
-  Int_t j=0;
 
-  for(i=0; i<10; i++){
-    dx = rnd->Gaus(0.,sigmatr);
-    dy = rnd->Gaus(0.,sigmatr);
-    dz = rnd->Gaus(0.,sigmatr);
-    dpsi = rnd->Gaus(0.,sigmarot);
-    dtheta = rnd->Gaus(0.,sigmarot);
-    dphi = rnd->Gaus(0.,sigmarot);
-    pathstr=basepath;
-    pathstr+=(i+1);
-    cout<<pathstr<<"  "<<dx<<"  "<<dy<<"  "<<dz<<"  "<<dpsi<<"  "<<dtheta<<"  "<<dphi<<"\n";
-    new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kFALSE);
-  }
+  AliEMCALSurvey emcalSurvey(surveyFilename,type);
+  emcalSurvey.CreateAliAlignObjParams(alobj);
 
-  for(i=0; i<2; i++){
-    dx = rnd->Gaus(0.,sigmatr);
-    dy = rnd->Gaus(0.,sigmatr);
-    dz = rnd->Gaus(0.,sigmatr);
-    dpsi = rnd->Gaus(0.,sigmarot);
-    dtheta = rnd->Gaus(0.,sigmarot);
-    dphi = rnd->Gaus(0.,sigmarot);
-    pathstr=hbasepath;
-    pathstr+=(i+1);
-    new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
-  }
+  // *************************    2nd step    ***************
 
-  const char* macroname = "MakeEMCALFullMisAlignment.C";
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // save on file
     const char* filename = "EMCALfullMisalignment.root";
     TFile f(filename,"RECREATE");
@@ -69,22 +62,10 @@ void MakeEMCALFullMisAlignment(){
     f.Close();
   }else{
     // save in CDB 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.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->SetResponsible("Jennifer Klay");
+    md->SetComment("Full misalignment for EMCAL_FIRSTYEAR based on survey information");
+    md->AddDateToComment();
     md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
     AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);