]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/MakeEMCALZeroMisAlignment.C
after successful nightly shuttle test : turn of debug AliInfo lines and and only...
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALZeroMisAlignment.C
index 5e9d194a846991f0fc6015fb9e089db224d06e82..31a2464b03f2f9209d53dd20f15444b877ab29ef 100644 (file)
@@ -1,14 +1,18 @@
-void MakeEMCALZeroMisAlignment(){
+void MakeEMCALZeroMisAlignment(TString geoname = "EMCAL_COMPLETE"){
   // Create TClonesArray of zero misalignment objects for EMCAL
   //
-  TClonesArray *array = new TClonesArray("AliAlignObjAngles",10);
-  TClonesArray &alobj = *array;
-
-  if(!gGeoManager) TGeoManager::Import("geometry.root");
-  // needed for the constructors with local coordinates not to fail
+  const char* macroname = "MakeEMCALZeroMisAlignment.C";
+  if(geoname=="")geoname=AliEMCALGeometry::GetDefaultGeometryName();
+  const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance(geoname,"");
+  if(!geom) {
+    Error("MakeEMCALZeroMisAlignment","Cannot obtain AliEMCALGeometry singleton\n");
+    return;
+  }
 
-  AliAlignObjAngles a;
+  TClonesArray *array = new TClonesArray("AliAlignObjParams",geom->GetNumberOfSuperModules());
+  TClonesArray &alobj = *array;
 
+  /*
   Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
 
   const TString fbasepath = "EMCAL/FullSupermodule";
@@ -16,8 +20,8 @@ void MakeEMCALZeroMisAlignment(){
   TString pathstr;
 
   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);
 
   Int_t i;
   Int_t j=0;
@@ -25,32 +29,51 @@ void MakeEMCALZeroMisAlignment(){
   for(i=0; i<10; i++){
     pathstr=fbasepath;
     pathstr+=(i+1);
-    new(alobj[j++]) AliAlignObjAngles(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
+    new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
   }
 
   for(i=0; i<2; i++){
     pathstr=hbasepath;
     pathstr+=(i+1);
-    new(alobj[j++]) AliAlignObjAngles(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
+    new(alobj[j++]) AliAlignObjParams(pathstr, volid, dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
   }
+  */
+
+  AliEMCALSurvey emcalSurvey;
+  emcalSurvey.CreateNullObjects(alobj,geom);
 
-  if(!gSystem->Getenv("$TOCDB")){
+  if( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ){
     // save on file
-    TFile f("EMCALzeroMisalignment.root","RECREATE");
-    if(!f) cerr<<"cannot open file for output\n";
+    const char* filename = "EMCALzeroMisalignment.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,"EMCALAlignObjs","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("Jennifer Clay");
+    md->SetResponsible("Jennifer Klay");
     md->SetComment("Zero misalignment for EMCAL");
-    md->SetAliRootVersion(gSystem->Getenv("$ARVERSION"));
-    AliCDBId id("EMCAL/Align/Data",0,9999999);
+    md->SetAliRootVersion(gSystem->Getenv("ARVERSION"));
+    AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);
   }