]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
Corrected treatment of the misalignment (Andrei, Raffaele)
authorhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 29 May 2007 14:36:21 +0000 (14:36 +0000)
committerhristov <hristov@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 29 May 2007 14:36:21 +0000 (14:36 +0000)
STEER/AliMC.cxx
STEER/AliSimulation.cxx

index bd7b9f1cb4e5d4d2bea69fa45bbb86d1a31cbd08..933b21824e18c4ce83611e065eaef91b11104897 100644 (file)
@@ -183,6 +183,10 @@ void  AliMC::ConstructGeometry()
 Bool_t  AliMC::MisalignGeometry() 
 {
 // Call misalignment code if AliSimulation object was defined.
+
+   //Set alignable volumes for the whole geometry
+   SetAllAlignableVolumes();
+   // Misalign geometry via AliSimulation instance
    if (!AliSimulation::GetInstance()) return kFALSE;
    return AliSimulation::GetInstance()->MisalignGeometry(gAlice->GetRunLoader());
 }   
@@ -664,8 +668,6 @@ void AliMC::Init()
 
    //=================Create Materials and geometry
    gMC->Init();
-   //Set alignable volumes for the whole geometry
-   SetAllAlignableVolumes();
    //Read the cuts for all materials
    ReadTransPar();
    //Build the special IMEDIA table
index f7a3a0cc27c29b60e5fa2ba4d3c63a2677337f9a..8accf2583c55188c1b106a2c27062be5f2786e9b 100644 (file)
@@ -369,6 +369,10 @@ Bool_t AliSimulation::MisalignGeometry(AliRunLoader *runLoader)
   // then applied to the TGeo geometry.
   // Finally an overlaps check is performed.
 
+  if (!gGeoManager || !gGeoManager->IsClosed()) {
+    AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
+    return kFALSE;
+  }  
   Bool_t delRunLoader = kFALSE;
   if (!runLoader) {
     runLoader = LoadRun("READ");
@@ -377,7 +381,7 @@ Bool_t AliSimulation::MisalignGeometry(AliRunLoader *runLoader)
   }
 
   // Export ideal geometry 
-  if (gGeoManager) gGeoManager->Export("geometry.root");
+  gGeoManager->Export("geometry.root");
 
   // Load alignment data from CDB and apply to geometry through AliGeomManager
   if(fLoadAlignFromCDB){
@@ -390,9 +394,9 @@ Bool_t AliSimulation::MisalignGeometry(AliRunLoader *runLoader)
       AliModule* det = (AliModule*) detArray->At(iDet);
       if (!det || !det->IsActive()) continue;
       if (IsSelected(det->GetName(), detStr)) {
-       //add det to list of dets to be aligned from CDB
-       loadAlObjsListOfDets += det->GetName();
-       loadAlObjsListOfDets += " ";
+        //add det to list of dets to be aligned from CDB
+        loadAlObjsListOfDets += det->GetName();
+        loadAlObjsListOfDets += " ";
       }
     } // end loop over detectors
     (AliGeomManager::Instance())->ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
@@ -401,18 +405,11 @@ Bool_t AliSimulation::MisalignGeometry(AliRunLoader *runLoader)
     // provided by the user. If yes, apply the objects
     // to the present TGeo geometry
     if (fAlignObjArray) {
-      if (gGeoManager && gGeoManager->IsClosed()) {
-       if ((AliGeomManager::Instance())->ApplyAlignObjsToGeom(fAlignObjArray) == kFALSE) {
-         AliError("The misalignment of one or more volumes failed!"
-                  "Compare the list of simulated detectors and the list of detector alignment data!");
-         if (delRunLoader) delete runLoader;
-         return kFALSE;
-       }
-      }
-      else {
-       AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
-       if (delRunLoader) delete runLoader;
-       return kFALSE;
+      if ((AliGeomManager::Instance())->ApplyAlignObjsToGeom(fAlignObjArray) == kFALSE) {
+        AliError("The misalignment of one or more volumes failed!"
+                 "Compare the list of simulated detectors and the list of detector alignment data!");
+        if (delRunLoader) delete runLoader;
+        return kFALSE;
       }
     }
   }
@@ -435,6 +432,9 @@ Bool_t AliSimulation::MisalignGeometry(AliRunLoader *runLoader)
   // Update the TGeoPhysicalNodes
   gGeoManager->RefreshPhysicalNodes();
 
+  // Export (mis)aligned geometry 
+  gGeoManager->Export("misaligned_geometry.root");
+
   return kTRUE;
 }
 
@@ -646,9 +646,6 @@ Bool_t AliSimulation::RunSimulation(Int_t nEvents)
   MisalignGeometry(runLoader);
 #endif
 
-  // Export (mis)aligned geometry 
-  if (gGeoManager) gGeoManager->Export("misaligned_geometry.root");
-
 //   AliRunLoader* runLoader = gAlice->GetRunLoader();
 //   if (!runLoader) {
 //     AliError(Form("gAlice has no run loader object. "