]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - EMCAL/MakeEMCALZeroMisAlignment.C
add correction factors for energy calibration of MC production LHC14a1a
[u/mrichter/AliRoot.git] / EMCAL / MakeEMCALZeroMisAlignment.C
index c0db87e90403920b8b53541db9f274501ee2c381..c55cc95e23741fe2d385aef09f69cb19a5290b24 100644 (file)
@@ -1,14 +1,18 @@
-void MakeEMCALZeroMisAlignment(){
+void MakeEMCALZeroMisAlignment(TString geoname = "EMCAL_COMPLETE12SMV1_DCAL_8SM"){
   // 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";
@@ -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") != TString("kTRUE") ){
+  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);
+    AliCDBId id("EMCAL/Align/Data",0,AliCDBRunRange::Infinity());
     storage->Put(array,id,md);
   }