]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - MUON/AliMUONGeometryTransformer.cxx
Updated list of MUON libraries
[u/mrichter/AliRoot.git] / MUON / AliMUONGeometryTransformer.cxx
index 18238d9181002df8e037b19d98897b2fd4889497..9665ec067b4540315f13a8c2327269d544b7cc16 100644 (file)
 #include "AliMUONGeometryTransformer.h"
 #include "AliMUONGeometryModuleTransformer.h"
 #include "AliMUONGeometryDetElement.h"
-#include "AliMUONGeometryStore.h"
 #include "AliMUONGeometryBuilder.h"
 
+#include "AliMpDEManager.h"
+#include "AliMpExMap.h"
+
 #include "AliLog.h"
 #include "AliAlignObjMatrix.h"
+#include "AliAlignObj.h"
 
 #include <Riostream.h>
 #include <TSystem.h>
 
 #include <sstream>
 
+/// \cond CLASSIMP
 ClassImp(AliMUONGeometryTransformer)
+/// \endcond
  
 //______________________________________________________________________________
-AliMUONGeometryTransformer::AliMUONGeometryTransformer(Bool_t isOwner)
+AliMUONGeometryTransformer::AliMUONGeometryTransformer(Bool_t isOwner,
+                                          const TString& detectorName)
+
   : TObject(),
+    fDetectorName(detectorName),
     fModuleTransformers(0),
     fMisAlignArray(0)
 {
 /// Standard constructor
 
   // Create array for geometry modules
-  fModuleTransformers = new TObjArray();
+  fModuleTransformers = new TObjArray(100);
   fModuleTransformers->SetOwner(isOwner);
 }
 
 //______________________________________________________________________________
 AliMUONGeometryTransformer::AliMUONGeometryTransformer() 
   : TObject(),
+    fDetectorName(),
     fModuleTransformers(0),
     fMisAlignArray(0)
 {
 /// Default constructor
 } 
 
-//______________________________________________________________________________
-AliMUONGeometryTransformer::AliMUONGeometryTransformer(
-                                   const AliMUONGeometryTransformer& right) 
-  : TObject(right) 
-{  
-/// Copy constructor (not implemented)
-
-  AliFatal("Copy constructor not provided.");
-}
-
 //______________________________________________________________________________
 AliMUONGeometryTransformer::~AliMUONGeometryTransformer()
 {
@@ -82,20 +81,6 @@ AliMUONGeometryTransformer::~AliMUONGeometryTransformer()
   delete fMisAlignArray;
 }
 
-//______________________________________________________________________________
-AliMUONGeometryTransformer& 
-AliMUONGeometryTransformer::operator=(const AliMUONGeometryTransformer& right)
-{
-/// Assignement operator (not implemented)
-
-  // check assignement to self
-  if (this == &right) return *this;
-
-  AliFatal("Assignement operator not provided.");
-    
-  return *this;  
-}    
-
 //
 // private methods
 //
@@ -124,8 +109,7 @@ TGeoHMatrix AliMUONGeometryTransformer::GetTransform(
                  Double_t a1, Double_t a2, Double_t a3, 
                  Double_t a4, Double_t a5, Double_t a6) const
 {                
-// Builds the transformation from the given parameters
-// ---
+/// Build the transformation from the given parameters
 
   // Compose transform
   return TGeoCombiTrans(TGeoTranslation(x, y, z), 
@@ -137,8 +121,7 @@ TGeoHMatrix AliMUONGeometryTransformer::GetTransform(
 void AliMUONGeometryTransformer::FillModuleVolPath(Int_t moduleId,
                                            const TString& volPath) 
 {
-// Create module with the given moduleId and volPath
-// ---
+/// Create module with the given moduleId and volPath
 
   // Get/Create geometry module transformer
   AliMUONGeometryModuleTransformer* moduleTransformer
@@ -155,13 +138,13 @@ void AliMUONGeometryTransformer::FillModuleVolPath(Int_t moduleId,
 void AliMUONGeometryTransformer::FillDetElemVolPath(Int_t detElemId, 
                                            const TString& volPath) 
 {
-// Create detection element with the given detElemId and volPath
+/// Create detection element with the given detElemId and volPath
 
   // Module Id
-  Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
+  Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
 
   // Get detection element store
-  AliMUONGeometryStore* detElements = 
+  AliMpExMap* detElements = 
     GetModuleTransformer(moduleId)->GetDetElementStore();     
 
   // Add detection element
@@ -177,12 +160,7 @@ void AliMUONGeometryTransformer::FillModuleTransform(Int_t moduleId,
                  Double_t a1, Double_t a2, Double_t a3,
                  Double_t a4, Double_t a5, Double_t a6) 
 {
-// Fill the transformation of the module.
-// ---
-
-  // Get/Create geometry module transformer
-  moduleId--;
-      // Modules numbers in the file are starting from 1
+/// Fill the transformation of the module.
 
   AliMUONGeometryModuleTransformer* moduleTransformer
     = GetModuleTransformerNonConst(moduleId, false);
@@ -206,11 +184,10 @@ void AliMUONGeometryTransformer::FillDetElemTransform(
                  Double_t a1, Double_t a2, Double_t a3,
                  Double_t a4, Double_t a5, Double_t a6) 
 {
-// Fill the transformation of the detection element.
-// ---
+/// Fill the transformation of the detection element.
 
   // Module Id
-  Int_t moduleId = AliMUONGeometryStore::GetModuleId(detElemId);
+  Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
 
   // Get module transformer
   const AliMUONGeometryModuleTransformer* kModuleTransformer
@@ -247,8 +224,7 @@ void AliMUONGeometryTransformer::FillDetElemTransform(
 Bool_t  
 AliMUONGeometryTransformer::ReadVolPaths(ifstream& in)
 {
-// Reads modules and detection element volume paths from stream
-// ---
+/// Read modules and detection element volume paths from stream
 
   Int_t id;
   TString key, volumePath;
@@ -262,10 +238,10 @@ AliMUONGeometryTransformer::ReadVolPaths(ifstream& in)
     //          << "volPath= " << volumePath
     //  << endl;   
 
-    if ( key == TString("CH") ) 
+    if ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() ) 
       FillModuleVolPath(id, volumePath);
   
-    else if ( key == TString("DE") )
+    else if ( key == AliMUONGeometryDetElement::GetDENamePrefix() )
       FillDetElemVolPath(id, volumePath);
   
     else {
@@ -281,12 +257,11 @@ AliMUONGeometryTransformer::ReadVolPaths(ifstream& in)
 //______________________________________________________________________________
 TString  AliMUONGeometryTransformer::ReadModuleTransforms(ifstream& in)
 {
-// Reads and fills modules transformations from a file
-// Returns true, if reading finished correctly.
-// ---
+/// Read and fill modules transformations from the stream.
+/// Return true, if reading finished correctly.
 
-  TString key("CH");
-  while ( key == TString("CH") ) {
+  TString key(AliMUONGeometryModuleTransformer::GetModuleNamePrefix());
+  while ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() ) {
     Int_t id;
     Double_t  x, y, z;
     Double_t  a1, a2, a3, a4, a5, a6;
@@ -324,12 +299,11 @@ TString  AliMUONGeometryTransformer::ReadModuleTransforms(ifstream& in)
 //______________________________________________________________________________
 TString  AliMUONGeometryTransformer::ReadDetElemTransforms(ifstream& in)
 {
-// Reads detection elements transformations from a file
-// Returns true, if reading finished correctly.
-// ---
+/// Read detection elements transformations from the stream.
+/// Return true, if reading finished correctly.
 
-  TString key("DE");
-  while ( key == TString("DE") ) {
+  TString key(AliMUONGeometryDetElement::GetDENamePrefix());
+  while ( key == AliMUONGeometryDetElement::GetDENamePrefix() ) {
 
     // Input data
     Int_t detElemId;
@@ -370,9 +344,14 @@ TString  AliMUONGeometryTransformer::ReadDetElemTransforms(ifstream& in)
 Bool_t  
 AliMUONGeometryTransformer::LoadTransforms(TGeoManager* tgeoManager)
 {
-/// Loads transformations for defined modules and detection elements
+/// Load transformations for defined modules and detection elements
 /// from the root file
 
+  if ( !tgeoManager) {
+    AliFatal("No TGeoManager defined.");
+    return false;
+  }   
+
   for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
     AliMUONGeometryModuleTransformer* moduleTransformer 
       = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
@@ -394,12 +373,11 @@ AliMUONGeometryTransformer::LoadTransforms(TGeoManager* tgeoManager)
     moduleTransformer->SetTransformation(matrix);
     
     // Loop over detection elements
-    AliMUONGeometryStore* detElements 
-      = moduleTransformer->GetDetElementStore();    
+    AliMpExMap* detElements = moduleTransformer->GetDetElementStore();    
    
-    for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
+    for (Int_t j=0; j<detElements->GetSize(); j++) {
       AliMUONGeometryDetElement* detElement
-        = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
+        = (AliMUONGeometryDetElement*)detElements->GetObject(j);
 
       // Det element path
       TString dePath = detElement->GetVolumePath();
@@ -431,9 +409,8 @@ AliMUONGeometryTransformer::LoadTransforms(TGeoManager* tgeoManager)
 Bool_t  
 AliMUONGeometryTransformer::ReadVolPaths(const TString& fileName)
 {
-// Reads detection element volume paths from a file
-// Returns true, if reading finished correctly.
-// ---
+/// Read detection element volume paths from a file.
+/// Return true, if reading finished correctly.
 
   // File path
   TString filePath = gSystem->Getenv("ALICE_ROOT");
@@ -456,9 +433,8 @@ AliMUONGeometryTransformer::ReadVolPaths(const TString& fileName)
 Bool_t  
 AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
 {
-// Reads transformations from a file
-// Returns true, if reading finished correctly.
-// ---
+/// Read transformations from a file.
+/// Return true, if reading finished correctly.
 
   // File path
   TString filePath = gSystem->Getenv("ALICE_ROOT");
@@ -476,9 +452,9 @@ AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
   TString key;
   in >> key;
   while ( !in.eof() ) {
-    if (key == TString("CH")
+    if ( key == AliMUONGeometryModuleTransformer::GetModuleNamePrefix() 
       key = ReadModuleTransforms(in);
-    else if (key == TString("DE"))
+    else if ( key == AliMUONGeometryDetElement::GetDENamePrefix() )
       key = ReadDetElemTransforms(in);
     else {
       AliFatal(Form("%s key not recognized",  key.Data()));
@@ -493,9 +469,8 @@ AliMUONGeometryTransformer::ReadTransformations(const TString& fileName)
 Bool_t  
 AliMUONGeometryTransformer::ReadTransformations2(const TString& fileName)
 {
-// Reads transformations from root geometry file
-// Returns true, if reading finished correctly.
-// ---
+/// Read transformations from root geometry file.
+/// Return true, if reading finished correctly.
 
   // File path
   TString filePath = gSystem->Getenv("ALICE_ROOT");
@@ -503,11 +478,13 @@ AliMUONGeometryTransformer::ReadTransformations2(const TString& fileName)
   filePath += fileName;
   
   // Load root geometry
-  TGeoManager* tgeoManager = TGeoManager::Import(fileName);
+  TGeoManager* tgeoManager = gGeoManager;
+  if (!tgeoManager)
+    tgeoManager = TGeoManager::Import(fileName);
 
   // Retrieve matrices
   LoadTransforms(tgeoManager);     
-
+  
   return true;
 }
 
@@ -515,8 +492,7 @@ AliMUONGeometryTransformer::ReadTransformations2(const TString& fileName)
 void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
                                    const TGeoMatrix* transform) const
 {
-// Writes the transformations 
-// ---
+/// Write given transformation 
 
   out << "   pos: ";
   const Double_t* xyz = transform->GetTranslation();
@@ -542,14 +518,14 @@ void AliMUONGeometryTransformer::WriteTransform(ofstream& out,
 //______________________________________________________________________________
 void AliMUONGeometryTransformer::WriteModuleVolPaths(ofstream& out) const
 {
-// Write modules volume paths
+/// Write module volume paths for all module transformers
 
   for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
     AliMUONGeometryModuleTransformer* moduleTransformer 
       = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
 
     // Write data on out
-    out << "CH " 
+    out << AliMUONGeometryModuleTransformer::GetModuleNamePrefix() << " "
         << setw(4) << moduleTransformer->GetModuleId() << "    " 
         << moduleTransformer->GetVolumePath() << endl;
   }     
@@ -559,20 +535,20 @@ void AliMUONGeometryTransformer::WriteModuleVolPaths(ofstream& out) const
 //______________________________________________________________________________
 void AliMUONGeometryTransformer::WriteDetElemVolPaths(ofstream& out) const
 {
-// Write detection elements volume paths
+/// Write detection element volume paths for all detection elements in all 
+/// module transformers
 
   for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
     AliMUONGeometryModuleTransformer* moduleTransformer 
       = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
-    AliMUONGeometryStore* detElements 
-      = moduleTransformer->GetDetElementStore();    
+    AliMpExMap* detElements = moduleTransformer->GetDetElementStore();    
 
-    for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
+    for (Int_t j=0; j<detElements->GetSize(); j++) {
       AliMUONGeometryDetElement* detElement
-        = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
+        = (AliMUONGeometryDetElement*)detElements->GetObject(j);
        
       // Write data on out
-      out << "DE " 
+      out << AliMUONGeometryDetElement::GetDENamePrefix() << " " 
           << setw(4) << detElement->GetId() << "    " 
           << detElement->GetVolumePath() << endl;
     }
@@ -583,7 +559,7 @@ void AliMUONGeometryTransformer::WriteDetElemVolPaths(ofstream& out) const
 //______________________________________________________________________________
 void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
 {
-// Write modules transformations
+/// Write module transformations for all module transformers
 
   for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
     AliMUONGeometryModuleTransformer* moduleTransformer 
@@ -592,8 +568,8 @@ void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
       = moduleTransformer->GetTransformation();    
 
     // Write data on out
-    out << "CH " 
-        << setw(4) << moduleTransformer->GetModuleId() + 1;
+    out << AliMUONGeometryModuleTransformer::GetModuleNamePrefix() << " " 
+        << setw(4) << moduleTransformer->GetModuleId();
     
     WriteTransform(out, transform);
   }
@@ -603,23 +579,23 @@ void AliMUONGeometryTransformer::WriteModuleTransforms(ofstream& out) const
 //______________________________________________________________________________
 void AliMUONGeometryTransformer::WriteDetElemTransforms(ofstream& out) const
 {
-// Writes detection elements transformations
-// ---
+/// Write detection element transformations for all detection elements in all 
+/// module transformers
 
   for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
     AliMUONGeometryModuleTransformer* moduleTransformer 
       = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
-    AliMUONGeometryStore* detElements 
-      = moduleTransformer->GetDetElementStore();    
+    AliMpExMap* detElements = moduleTransformer->GetDetElementStore();    
 
-    for (Int_t j=0; j<detElements->GetNofEntries(); j++) {
+    for (Int_t j=0; j<detElements->GetSize(); j++) {
       AliMUONGeometryDetElement* detElement
-        = (AliMUONGeometryDetElement*)detElements->GetEntry(j);
+        = (AliMUONGeometryDetElement*)detElements->GetObject(j);
       const TGeoMatrix* transform 
         = detElement->GetLocalTransformation(); 
        
       // Write data on out
-      out << "DE " << setw(4) << detElement->GetId();
+      out << AliMUONGeometryDetElement::GetDENamePrefix() << " " 
+          << setw(4) << detElement->GetId();
      
       WriteTransform(out, transform);
     }
@@ -627,6 +603,39 @@ void AliMUONGeometryTransformer::WriteDetElemTransforms(ofstream& out) const
   }     
 }
 
+//______________________________________________________________________________
+TString AliMUONGeometryTransformer::GetModuleSymName(Int_t moduleId) const
+{
+/// Return the module symbolic name (use for alignment)
+
+  const AliMUONGeometryModuleTransformer* kTransformer 
+    = GetModuleTransformer(moduleId);
+  if ( ! kTransformer ) {
+    AliErrorStream() << "Module " << moduleId << " not found." << endl; 
+    return "";
+  }   
+  
+  return "/" + fDetectorName + "/" + kTransformer->GetModuleName();
+}  
+
+//______________________________________________________________________________
+TString AliMUONGeometryTransformer::GetDESymName(Int_t detElemId) const
+{
+/// Return the detection element symbolic name (used for alignment)
+
+  const AliMUONGeometryDetElement* kDetElement 
+    = GetDetElement(detElemId);
+  if ( ! kDetElement ) {
+    AliErrorStream() << "Det element " << detElemId << " not found." << endl; 
+    return "";
+  }   
+  
+  // Module Id
+  Int_t moduleId = AliMpDEManager::GetGeomModuleId(detElemId);
+
+  return GetModuleSymName(moduleId) + "/" + kDetElement->GetDEName();
+}  
+
 //
 // public functions
 //
@@ -663,7 +672,7 @@ AliMUONGeometryTransformer::ReadGeometryData(
                                 TGeoManager* tgeoManager)
 {
 /// Load geometry data from root geometry using defined
-/// voluem paths from file
+/// volume paths from file
 
   Bool_t result1 = ReadVolPaths(volPathFileName);
 
@@ -695,9 +704,8 @@ AliMUONGeometryTransformer::WriteGeometryData(
 Bool_t  
 AliMUONGeometryTransformer::WriteVolumePaths(const TString& fileName) const
 {
-// Writes volume paths for modules and detection element volumes into a file
-// Returns true, if writing finished correctly.
-// ---
+/// Write volume paths for modules and detection element volumes into a file.
+/// Return true, if writing finished correctly.
 
   // No writing
   // if builder is not associated with any geometry module
@@ -728,9 +736,8 @@ AliMUONGeometryTransformer::WriteVolumePaths(const TString& fileName) const
 Bool_t  
 AliMUONGeometryTransformer::WriteTransformations(const TString& fileName) const
 {
-// Writes transformations into a file
-// Returns true, if writing finished correctly.
-// ---
+/// Write transformations into a file.
+/// Return true, if writing finished correctly.
 
   // No writing
   // if builder is not associated with any geometry module
@@ -761,9 +768,8 @@ AliMUONGeometryTransformer::WriteTransformations(const TString& fileName) const
 Bool_t  
 AliMUONGeometryTransformer::WriteMisAlignmentData(const TString& fileName) const
 {
-// Writes misalignment data into a file
-// Returns true, if writing finished correctly.
-// ---
+/// Write misalignment data into a file
+/// Return true, if writing finished correctly.
 
   // No writing
   // if builder is not associated with any geometry module
@@ -796,17 +802,21 @@ AliMUONGeometryTransformer::WriteMisAlignmentData(const TString& fileName) const
 void AliMUONGeometryTransformer::AddModuleTransformer(
                           AliMUONGeometryModuleTransformer* moduleTransformer)
 {
-/// Add the geometrymodule to the array
+/// Add the module transformer to the array
+
+  // Expand the size if not sufficient
+  Int_t moduleId = moduleTransformer->GetModuleId();
+  if (  moduleId >= fModuleTransformers->GetSize() )
+    fModuleTransformers->Expand(moduleId+1);
 
-  fModuleTransformers->AddAt(moduleTransformer, 
-                             moduleTransformer->GetModuleId());
+  fModuleTransformers->AddAt(moduleTransformer, moduleId);
 }
 
 //_____________________________________________________________________________
 void  AliMUONGeometryTransformer::AddMisAlignModule(Int_t moduleId, 
                                               const TGeoHMatrix& matrix)
 {
-/// Build AliAlignObjMatrix with module ID, its volumePaths
+/// Build AliAlignObjMatrix with module ID, its volumePath
 /// and the given delta transformation matrix                                        
 
   if ( ! fMisAlignArray )
@@ -819,21 +829,21 @@ void  AliMUONGeometryTransformer::AddMisAlignModule(Int_t moduleId,
     return;
   }   
   
-  // Get path  
-  TString path = kTransformer->GetVolumePath(); 
-  
+  // Get unique align object ID
+  Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, moduleId); 
+
   // Create mis align matrix
   TClonesArray& refArray =*fMisAlignArray;
   Int_t pos = fMisAlignArray->GetEntriesFast();
-  new (refArray[pos]) AliAlignObjMatrix(path.Data(), moduleId, 
-                              const_cast<TGeoHMatrix&>(matrix));
+  new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId, 
+                                       const_cast<TGeoHMatrix&>(matrix),kTRUE);
 }
 
 //_____________________________________________________________________________
 void  AliMUONGeometryTransformer::AddMisAlignDetElement(Int_t detElemId, 
                                               const TGeoHMatrix& matrix)
 {
-/// Build AliAlignObjMatrix with detection element ID, its volumePaths
+/// Build AliAlignObjMatrix with detection element ID, its volumePath
 /// and the given delta transformation matrix                                        
 
   if ( ! fMisAlignArray )
@@ -847,16 +857,125 @@ void  AliMUONGeometryTransformer::AddMisAlignDetElement(Int_t detElemId,
     return;
   }   
   
-  // Get path  
-  TString path = kDetElement->GetVolumePath(); 
-  
+  // Get unique align object ID
+  Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, detElemId); 
+
   // Create mis align matrix
   TClonesArray& refArray =*fMisAlignArray;
   Int_t pos = fMisAlignArray->GetEntriesFast();
-  new(refArray[pos]) AliAlignObjMatrix(path.Data(), detElemId, 
-                              const_cast<TGeoHMatrix&>(matrix));
+  new(refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId, 
+                                      const_cast<TGeoHMatrix&>(matrix),kTRUE);
 }
 
+//_____________________________________________________________________________
+void AliMUONGeometryTransformer::AddAlignableVolumes() const
+{
+/// Set symbolic names and matrices to alignable objects to TGeo
+
+  if ( ! gGeoManager ) {
+    AliWarning("TGeoManager not defined.");
+    return;
+  }  
+
+  // Modules 
+  for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
+    AliMUONGeometryModuleTransformer* module 
+      = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
+
+    // Set module symbolic name
+    TGeoPNEntry* pnEntry
+      = gGeoManager->SetAlignableEntry(GetModuleSymName(module->GetModuleId()), 
+                                       module->GetVolumePath());
+    // Set module matrix
+    pnEntry->SetMatrix(new TGeoHMatrix(*module->GetTransformation()));  
+       // the matrix will be deleted via TGeoManager                                    
+
+    //cout << "Module sym name: " << GetModuleSymName(module->GetModuleId()) 
+    //     << "  volPath: " << module->GetVolumePath() << endl;
+
+    // Detection elements
+    AliMpExMap* detElements = module->GetDetElementStore();    
+
+    for (Int_t j=0; j<detElements->GetSize(); j++) {
+      AliMUONGeometryDetElement* detElement
+        = (AliMUONGeometryDetElement*)detElements->GetObject(j);
+       
+      // Set detection element symbolic name
+      TGeoPNEntry* pnEntry
+        = gGeoManager->SetAlignableEntry(GetDESymName(detElement->GetId()), 
+                                         detElement->GetVolumePath());
+      // Set detection element matrix
+      pnEntry->SetMatrix(new TGeoHMatrix(*detElement->GetGlobalTransformation()));                                      
+       // the matrix will be deleted via TGeoManager                                    
+
+      //cout << "DE name: " << GetDESymName(detElement->GetId()) 
+      //     << "  volPath: " << detElement->GetVolumePath() << endl;
+    }  
+  }     
+}           
+    
+//_____________________________________________________________________________
+TClonesArray* AliMUONGeometryTransformer::CreateZeroAlignmentData() const
+{
+/// Create array with zero alignment data
+                              
+  // Create array for zero-alignment objects
+  TClonesArray* array = new TClonesArray("AliAlignObjMatrix", 200);
+  TClonesArray& refArray =*array;
+  array->SetOwner(true);
+
+  // Identity matrix
+  TGeoHMatrix matrix;
+
+  // Modules 
+  for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
+    AliMUONGeometryModuleTransformer* module 
+      = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
+
+    Int_t moduleId = module->GetModuleId();
+  
+    // Align object ID
+    Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, moduleId); 
+
+    // Create mis align matrix
+    Int_t pos = array->GetEntriesFast();
+    new (refArray[pos]) AliAlignObjMatrix(GetModuleSymName(moduleId), volId, matrix, kTRUE);
+  }     
+
+  // Detection elements
+  for (Int_t i=0; i<fModuleTransformers->GetEntriesFast(); i++) {
+    AliMUONGeometryModuleTransformer* moduleTransformer 
+      = (AliMUONGeometryModuleTransformer*)fModuleTransformers->At(i);
+    AliMpExMap* detElements = moduleTransformer->GetDetElementStore();    
+
+    for (Int_t j=0; j<detElements->GetSize(); j++) {
+      AliMUONGeometryDetElement* detElement
+        = (AliMUONGeometryDetElement*)detElements->GetObject(j);
+       
+      Int_t detElemId = detElement->GetId();
+  
+      // Align object ID
+      Int_t volId = AliAlignObj::LayerToVolUID(AliAlignObj::kMUON, detElemId); 
+
+      // Create mis align matrix
+      Int_t pos = array->GetEntriesFast();
+      new (refArray[pos]) AliAlignObjMatrix(GetDESymName(detElemId), volId, matrix, kTRUE);
+    }
+  }
+  
+  return array;
+}       
+
+//_____________________________________________________________________________
+void AliMUONGeometryTransformer::ClearMisAlignmentData()
+{
+/// Clear the array of misalignment data
+
+  if ( ! fMisAlignArray ) return;
+  
+  fMisAlignArray->Delete();
+}  
+                              
 //_____________________________________________________________________________
 void AliMUONGeometryTransformer::Global2Local(Int_t detElemId,
                  Float_t xg, Float_t yg, Float_t zg, 
@@ -923,7 +1042,7 @@ void AliMUONGeometryTransformer::Local2Global(Int_t detElemId,
 const AliMUONGeometryModuleTransformer* 
 AliMUONGeometryTransformer::GetModuleTransformer(Int_t index, Bool_t warn) const
 {
-/// Return the geometry module specified by index
+/// Return the geometry module transformer specified by index
 
   return GetModuleTransformerNonConst(index, warn);
 }    
@@ -933,10 +1052,10 @@ const AliMUONGeometryModuleTransformer*
 AliMUONGeometryTransformer::GetModuleTransformerByDEId(Int_t detElemId, 
                                                        Bool_t warn) const
 {
-/// Return the geometry module specified by index
+/// Return the geometry module transformer specified by detection element ID
 
   // Get module index
-  Int_t index = AliMUONGeometryStore::GetModuleId(detElemId);
+  Int_t index = AliMpDEManager::GetGeomModuleId(detElemId);
 
   return GetModuleTransformer(index, warn);
 }    
@@ -945,7 +1064,7 @@ AliMUONGeometryTransformer::GetModuleTransformerByDEId(Int_t detElemId,
 const AliMUONGeometryDetElement* 
 AliMUONGeometryTransformer::GetDetElement(Int_t detElemId, Bool_t warn) const
 {
-/// Return detection ellemnt with given detElemId                             
+/// Return detection element with given detElemId                             
 
   const AliMUONGeometryModuleTransformer* kTransformer 
     = GetModuleTransformerByDEId(detElemId, warn);