]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - TOF/MakeTOFZeroMisAlignment.C
Corrected define guard
[u/mrichter/AliRoot.git] / TOF / MakeTOFZeroMisAlignment.C
index e2d00e55e181cd3d6b138f7debdfba6e44e59475..18a4af5d9120436dd2e1cfbcd02d484d5572a781 100644 (file)
@@ -1,21 +1,76 @@
-void MakeTOFZeroMisAlignment(){
+void MakeTOFZeroMisAlignment() {
+  //
   // Create TClonesArray of zero misalignment objects for TOF
   //
+
+  const char* macroname = "MakeTOFZeroMisAlignment.C";
+
   TClonesArray *array = new TClonesArray("AliAlignObjParams",2000);
   TClonesArray &alobj = *array;
-  const char* macroname = "MakeTOFZeroMisAlignment.C";
 
-   
+  // Activate CDB storage to 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 = (AliCDBEntry*)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
+
+
+  Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
   AliGeomManager::ELayerID idTOF = AliGeomManager::kTOF;
-  Int_t i;
   Int_t j=0;
-  Double_t dx=0., dy=0., dz=0., dpsi=0., dtheta=0., dphi=0.;
+  Int_t nSectors=18;
+
+  Int_t iIndex=0; //let all modules have index=0 in a layer with no LUT
+  AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
+  UShort_t dvoluid = AliGeomManager::LayerToVolUID(iLayer,iIndex); //dummy vol id
 
-  for(i=0; i<AliGeomManager::LayerSize(idTOF); i++) {
-    new(alobj[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,i), AliGeomManager::LayerToVolUID(idTOF,i), dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
+  for (Int_t isect = 0; isect < nSectors; isect++) {
+    TString symname(Form("TOF/sm%02d",isect));
+    new(alobj[j++]) AliAlignObjParams(symname.Data(),
+                                     dvoluid,
+                                     dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
   }
 
-  if( gSystem->Getenv("TOCDB") != TString("kTRUE") ){
+  Int_t strId=-1;
+  Int_t nstrA=15;
+  Int_t nstrB=19;
+  Int_t nstrC=19;
+  Int_t nStrips=nstrA+2*nstrB+2*nstrC;
+
+  for (Int_t isect = 0; isect < nSectors; isect++) {
+    for (Int_t istr = 1; istr <= nStrips; istr++) {
+      strId++;
+      if ((isect==13 || isect==14 || isect==15) && (istr >= 39 && istr <= 53)) continue;
+      new(alobj[j++]) AliAlignObjParams(AliGeomManager::SymName(idTOF,strId),
+                                       AliGeomManager::LayerToVolUID(idTOF,strId),
+                                       dx, dy, dz, dpsi, dtheta, dphi, kTRUE);
+    }
+  }
+
+  if ( TString(gSystem->Getenv("TOCDB")) != TString("kTRUE") ) {
     // save on file
     const char* filename = "TOFzeroMisalignment.root";
     TFile f(filename,"RECREATE");
@@ -27,21 +82,8 @@ void MakeTOFZeroMisAlignment(){
     f.cd();
     f.WriteObject(array,"TOFAlignObjs","kSingleKey");
     f.Close();
-  }else{
+  } 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("Silvia Arcelli");
     md->SetComment("Zero misalignment for TOF");
@@ -53,5 +95,3 @@ void MakeTOFZeroMisAlignment(){
   array->Delete();
 
 }
-
-