]> git.uio.no Git - u/mrichter/AliRoot.git/blobdiff - STEER/AliAlignObj.cxx
Bug fix
[u/mrichter/AliRoot.git] / STEER / AliAlignObj.cxx
index 6d32d3e2a773651a070ffa147437d09468e2c73b..183e391d520ca54fa781586f95b8f25918964be8 100644 (file)
  * provided "as is" without express or implied warranty.                  *
  **************************************************************************/
 
+/* $Id$ */
+
 //-----------------------------------------------------------------
-//   Implementation of the alignment object class through the abstract
-//  class AliAlignObj. From it two derived concrete representation of
-//  alignment object class (AliAlignObjAngles, AliAlignObjMatrix) are
-//  derived in separate files.
+//  Implementation of the alignment object class, holding the alignment
+//  constants for a single volume, through the abstract class AliAlignObj.
+//  From it two derived concrete representation of alignment object class
+//  (AliAlignObjAngles, AliAlignObjMatrix) are derived in separate files.
 //-----------------------------------------------------------------
-/*****************************************************************************
- * AliAlignObjAngles: derived alignment class storing alignment information  *
- *   for a single volume in form of three doubles for the translation        *
- *   and three doubles for the rotation expressed with the euler angles      *
- *   in the xyz-convention (http://mathworld.wolfram.com/EulerAngles.html),  *
- *   also known as roll, pitch, yaw. PLEASE NOTE THE ANGLES SIGNS ARE        *
- *   INVERSE WITH RESPECT TO THIS REFERENCE!!! In this way the representation*
- *   is fully consistent with the TGeo Rotation methods.                     *
- *****************************************************************************/
 
+#include <TClass.h>
 #include <TGeoManager.h>
 #include <TGeoPhysicalNode.h>
+#include <TMath.h>
+#include "TObjString.h"
 
 #include "AliAlignObj.h"
 #include "AliTrackPointArray.h"
 ClassImp(AliAlignObj)
 
 Int_t AliAlignObj::fgLayerSize[kLastLayer - kFirstLayer] = {
-  80, 160,  // ITS SPD
-  84, 176,  // ITS SDD
-  748, 950, // ITS SSD
-  36, 36,   // TPC
-  90, 90, 90, 90, 90, 90,  // TRD
+  80, 160,  // ITS SPD first and second layer
+  84, 176,  // ITS SDD first and second layer
+  748, 950, // ITS SSD first and second layer
+  36, 36,   // TPC inner and outer chambers
+  90, 90, 90, 90, 90, 90,  // 6 TRD chambers' layers
   1638,     // TOF
   1, 1,     // PHOS ??
-  7,        // RICH ??
+  7,        // HMPID ??
   1         // MUON ??
 };
 
@@ -60,7 +56,7 @@ const char* AliAlignObj::fgLayerName[kLastLayer - kFirstLayer] = {
   "TRD chambers layer 4", "TRD chambers layer 5", "TRD chambers layer 6",
   "TOF layer",
   "?","?",
-  "RICH layer",
+  "HMPID layer",
   "?"
 };
 
@@ -92,36 +88,30 @@ AliAlignObj** AliAlignObj::fgAlignObjs[kLastLayer - kFirstLayer] = {
 
 //_____________________________________________________________________________
 AliAlignObj::AliAlignObj():
+  fVolPath(),
   fVolUID(0)
 {
   // default constructor
-  InitVolPaths();
+  InitSymNames();
 }
 
 //_____________________________________________________________________________
-AliAlignObj::AliAlignObj(const char* volpath, UShort_t voluid) : TObject()
+AliAlignObj::AliAlignObj(const char* symname, UShort_t voluid) :
+  TObject(),
+  fVolPath(symname),
+  fVolUID(voluid)
 {
   // standard constructor
   //
-  fVolPath=volpath;
-  fVolUID=voluid;
-}
-
-AliAlignObj::AliAlignObj(const char* volpath, ELayerID detId, Int_t volId) : TObject()
-{
-  // standard constructor
-  // 
-  fVolPath=volpath;
-  SetVolUID(detId,volId); 
 }
 
 //_____________________________________________________________________________
 AliAlignObj::AliAlignObj(const AliAlignObj& theAlignObj) :
-  TObject(theAlignObj)
+  TObject(theAlignObj),
+  fVolPath(theAlignObj.GetSymName()),
+  fVolUID(theAlignObj.GetVolUID())
 {
   //copy constructor
-  fVolPath = theAlignObj.GetVolPath();
-  fVolUID = theAlignObj.GetVolUID();
 }
 
 //_____________________________________________________________________________
@@ -129,7 +119,7 @@ AliAlignObj &AliAlignObj::operator =(const AliAlignObj& theAlignObj)
 {
   // assignment operator
   if(this==&theAlignObj) return *this;
-  fVolPath = theAlignObj.GetVolPath();
+  fVolPath = theAlignObj.GetSymName();
   fVolUID = theAlignObj.GetVolUID();
   return *this;
 }
@@ -169,22 +159,46 @@ void AliAlignObj::SetVolUID(ELayerID detId, Int_t modId)
 //_____________________________________________________________________________
 void AliAlignObj::GetVolUID(ELayerID &layerId, Int_t &modId) const
 {
-  // From detector name and module number (according to detector numbering)
-  // build fVolUID, unique numerical identity of that volume inside ALICE
-  // fVolUID is 16 bits, first 5 reserved for detID (32 possible values),
-  // remaining 11 for module ID inside det (2048 possible values).
+  // From the fVolUID, unique numerical identity of that volume inside ALICE,
+  // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
+  // remaining 11 for module ID inside det (2048 possible values)), sets
+  // the argument layerId to the identity of the layer to which that volume
+  // belongs and sets the argument modId to the identity of that volume
+  // internally to the layer.
   //
   layerId = VolUIDToLayer(fVolUID,modId);
 }
 
+//_____________________________________________________________________________
+Bool_t AliAlignObj::GetPars(Double_t tr[], Double_t angles[]) const
+{
+  GetTranslation(tr);
+  return GetAngles(angles);
+}
+
 //_____________________________________________________________________________
 Int_t AliAlignObj::GetLevel() const
 {
-  // Return the geometry level of
-  // the alignable volume to which
-  // the alignment object is associated
-  TString volpath = fVolPath;
-  return (volpath.CountChar('/')+1);
+  // Return the geometry level of the alignable volume to which
+  // the alignment object is associated; this is the number of
+  // slashes in the corresponding volume path
+  //
+  if(!gGeoManager){
+    AliWarning("gGeoManager doesn't exist or it is still opened: unable to return meaningful level value.");
+    return (-1);
+  }
+  const char* symname = GetSymName();
+  const char* path;
+  TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
+  if(pne){
+    path = pne->GetTitle();
+  }else{
+    path = symname;
+  }
+
+  TString path_str = path;
+  if(path_str[0]!='/') path_str.Prepend('/');
+  return path_str.CountChar('/');
 }
 
 //_____________________________________________________________________________
@@ -195,6 +209,7 @@ Int_t AliAlignObj::Compare(const TObject *obj) const
   // Used in the sorting during
   // the application of alignment
   // objects to the geometry
+  //
   Int_t level = GetLevel();
   Int_t level2 = ((AliAlignObj *)obj)->GetLevel();
   if (level == level2)
@@ -208,6 +223,7 @@ void AliAlignObj::AnglesToMatrix(const Double_t *angles, Double_t *rot) const
 {
   // Calculates the rotation matrix using the 
   // Euler angles in "x y z" notation
+  //
   Double_t degrad = TMath::DegToRad();
   Double_t sinpsi = TMath::Sin(degrad*angles[0]);
   Double_t cospsi = TMath::Cos(degrad*angles[0]);
@@ -232,7 +248,13 @@ Bool_t AliAlignObj::MatrixToAngles(const Double_t *rot, Double_t *angles) const
 {
   // Calculates the Euler angles in "x y z" notation
   // using the rotation matrix
-  if(TMath::Abs(rot[0])<1e-7 || TMath::Abs(rot[8])<1e-7) return kFALSE;
+  // Returns false in case the rotation angles can not be
+  // extracted from the matrix
+  //
+  if(TMath::Abs(rot[0])<1e-7 || TMath::Abs(rot[8])<1e-7) {
+    AliError("Failed to extract roll-pitch-yall angles!");
+    return kFALSE;
+  }
   Double_t raddeg = TMath::RadToDeg();
   angles[0]=raddeg*TMath::ATan2(-rot[5],rot[8]);
   angles[1]=raddeg*TMath::ASin(rot[2]);
@@ -247,7 +269,7 @@ void AliAlignObj::Transform(AliTrackPoint &p) const
   // transformation matrix provided by the AliAlignObj
   // The covariance matrix is not affected since we assume
   // that the transformations are sufficiently small
-
+  //
   if (fVolUID != p.GetVolumeID())
     AliWarning(Form("Alignment object ID is not equal to the space-point ID (%d != %d)",fVolUID,p.GetVolumeID())); 
 
@@ -272,6 +294,7 @@ void AliAlignObj::Transform(AliTrackPointArray &array) const
 {
   // This method is used to transform all the track points
   // from the input AliTrackPointArray
+  // 
   AliTrackPoint p;
   for (Int_t i = 0; i < array.GetNPoints(); i++) {
     array.GetPoint(p,i);
@@ -286,6 +309,7 @@ void AliAlignObj::Print(Option_t *) const
   // Print the contents of the
   // alignment object in angles and
   // matrix representations
+  //
   Double_t tr[3];
   GetTranslation(tr);
   Double_t angles[3];
@@ -294,7 +318,7 @@ void AliAlignObj::Print(Option_t *) const
   GetMatrix(m);
   const Double_t *rot = m.GetRotationMatrix();
 
-  printf("Volume=%s\n",GetVolPath());
+  printf("Volume=%s\n",GetSymName());
   if (GetVolUID() != 0) {
     ELayerID layerId;
     Int_t modId;
@@ -310,8 +334,9 @@ void AliAlignObj::Print(Option_t *) const
 //_____________________________________________________________________________
 Int_t AliAlignObj::LayerSize(Int_t layerId)
 {
-  // Get the corresponding layer size.
-  // Implemented only for ITS,TPC,TRD,TOF and RICH
+  // Get the layer size for layer corresponding to layerId.
+  // Implemented only for ITS,TPC,TRD,TOF and HMPID
+  //
   if (layerId < kFirstLayer || layerId >= kLastLayer) {
     AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
     return 0;
@@ -324,8 +349,9 @@ Int_t AliAlignObj::LayerSize(Int_t layerId)
 //_____________________________________________________________________________
 const char* AliAlignObj::LayerName(Int_t layerId)
 {
-  // Get the corresponding layer name.
-  // Implemented only for ITS,TPC,TRD,TOF and RICH
+  // Get the layer name corresponding to layerId.
+  // Implemented only for ITS,TPC,TRD,TOF and HMPID
+  //
   if (layerId < kFirstLayer || layerId >= kLastLayer) {
     AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
     return "Invalid Layer!";
@@ -338,8 +364,9 @@ const char* AliAlignObj::LayerName(Int_t layerId)
 //_____________________________________________________________________________
 UShort_t AliAlignObj::LayerToVolUID(ELayerID layerId, Int_t modId)
 {
-  // From detector (layer) name and module number (according to detector numbering)
-  // build fVolUID, unique numerical identity of that volume inside ALICE
+  // From detector (layer) name and module number (according to detector
+  // internal numbering) build the unique numerical identity of that volume
+  // inside ALICE
   // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
   // remaining 11 for module ID inside det (2048 possible values).
   //
@@ -349,8 +376,9 @@ UShort_t AliAlignObj::LayerToVolUID(ELayerID layerId, Int_t modId)
 //_____________________________________________________________________________
 UShort_t AliAlignObj::LayerToVolUID(Int_t   layerId, Int_t modId)
 {
-  // From detector (layer) index and module number (according to detector numbering)
-  // build fVolUID, unique numerical identity of that volume inside ALICE
+  // From detector (layer) name and module number (according to detector
+  // internal numbering) build the unique numerical identity of that volume
+  // inside ALICE
   // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
   // remaining 11 for module ID inside det (2048 possible values).
   //
@@ -360,10 +388,11 @@ UShort_t AliAlignObj::LayerToVolUID(Int_t   layerId, Int_t modId)
 //_____________________________________________________________________________
 AliAlignObj::ELayerID AliAlignObj::VolUIDToLayer(UShort_t voluid, Int_t &modId)
 {
-  // From detector (layer) name and module number (according to detector numbering)
-  // build fVolUID, unique numerical identity of that volume inside ALICE
-  // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
-  // remaining 11 for module ID inside det (2048 possible values).
+  // From voluid, unique numerical identity of that volume inside ALICE,
+  // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
+  // remaining 11 for module ID inside det (2048 possible values)), return
+  // the identity of the layer to which that volume belongs and sets the
+  // argument modId to the identity of that volume internally to the layer.
   //
   modId = voluid & 0x7ff;
 
@@ -373,83 +402,287 @@ AliAlignObj::ELayerID AliAlignObj::VolUIDToLayer(UShort_t voluid, Int_t &modId)
 //_____________________________________________________________________________
 AliAlignObj::ELayerID AliAlignObj::VolUIDToLayer(UShort_t voluid)
 {
-  // From detector (layer) name and module number (according to detector numbering)
-  // build fVolUID, unique numerical identity of that volume inside ALICE
-  // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
-  // remaining 11 for module ID inside det (2048 possible values).
+  // From voluid, unique numerical identity of that volume inside ALICE,
+  // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
+  // remaining 11 for module ID inside det (2048 possible values)), return
+  // the identity of the layer to which that volume belongs
   //
   return ELayerID((voluid >> 11) & 0x1f);
 }
 
+//_____________________________________________________________________________
+void AliAlignObj::SetPars(Double_t x, Double_t y, Double_t z,
+                         Double_t psi, Double_t theta, Double_t phi)
+{
+  // Set the global delta transformation by passing 3 angles (expressed in
+  // degrees) and 3 shifts (in centimeters)
+  // 
+  SetTranslation(x,y,z);
+  SetRotation(psi,theta,phi);
+}
+
 //_____________________________________________________________________________
 Bool_t AliAlignObj::SetLocalPars(Double_t x, Double_t y, Double_t z,
                                 Double_t psi, Double_t theta, Double_t phi)
 {
-  // Set the translations and angles by using parameters
-  // defined in the local (in TGeo means) coordinate system
-  // of the alignable volume. In case that the TGeo was
-  // initialized, returns false and the object parameters are
-  // not set.
+  // Set the global delta transformation by passing the parameters
+  // for the local delta transformation (3 shifts and 3 angles).
+  // In case that the TGeo was not initialized or not closed,
+  // returns false and the object parameters are not set.
+  //
+  TGeoHMatrix m;
+  Double_t tr[3] = {x, y, z};
+  m.SetTranslation(tr);
+  Double_t angles[3] = {psi, theta, phi};
+  Double_t rot[9];
+  AnglesToMatrix(angles,rot);
+  m.SetRotation(rot);
+
+  return SetLocalMatrix(m);
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliAlignObj::SetLocalTranslation(Double_t x, Double_t y, Double_t z)
+{
+  // Set the global delta transformation by passing the three shifts giving
+  // the translation in the local reference system of the alignable
+  // volume (known by TGeo geometry).
+  // In case that the TGeo was not initialized or not closed,
+  // returns false and the object parameters are not set.
+  //
+  TGeoHMatrix m;
+  Double_t tr[3] = {x, y, z};
+  m.SetTranslation(tr);
+
+  return SetLocalMatrix(m);
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliAlignObj::SetLocalTranslation(const TGeoMatrix& m)
+{
+  // Set the global delta transformation by passing the matrix of
+  // the local delta transformation and taking its translational part
+  // In case that the TGeo was not initialized or not closed,
+  // returns false and the object parameters are not set.
+  //
+  const Double_t* tr = m.GetTranslation();
+  TGeoHMatrix mtr;
+  mtr.SetTranslation(tr);
+
+  return SetLocalMatrix(mtr);
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliAlignObj::SetLocalRotation(Double_t psi, Double_t theta, Double_t phi)
+{
+  // Set the global delta transformation by passing the three angles giving
+  // the rotation in the local reference system of the alignable
+  // volume (known by TGeo geometry).
+  // In case that the TGeo was not initialized or not closed,
+  // returns false and the object parameters are not set.
+  //
+  TGeoHMatrix m;
+  Double_t angles[3] = {psi, theta, phi};
+  Double_t rot[9];
+  AnglesToMatrix(angles,rot);
+  m.SetRotation(rot);
+
+  return SetLocalMatrix(m);
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliAlignObj::SetLocalRotation(const TGeoMatrix& m)
+{
+  // Set the global delta transformation by passing the matrix of
+  // the local delta transformation and taking its rotational part
+  // In case that the TGeo was not initialized or not closed,
+  // returns false and the object parameters are not set.
+  //
+  TGeoHMatrix rotm;
+  const Double_t* rot = m.GetRotationMatrix();
+  rotm.SetRotation(rot);
+
+  return SetLocalMatrix(rotm);
+
+}
+
+//_____________________________________________________________________________
+Bool_t AliAlignObj::SetLocalMatrix(const TGeoMatrix& m)
+{
+  // Set the global delta transformation by passing the TGeo matrix
+  // for the local delta transformation.
+  // In case that the TGeo was not initialized or not closed,
+  // returns false and the object parameters are not set.
+  //
   if (!gGeoManager || !gGeoManager->IsClosed()) {
     AliError("Can't set the alignment object parameters! gGeoManager doesn't exist or it is still opened!");
     return kFALSE;
   }
 
-  const char* volpath = GetVolPath();
-  TGeoPhysicalNode* node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(volpath);
+  const char* symname = GetSymName();
+  TGeoPhysicalNode* node;
+  TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
+  if(pne){
+    node = gGeoManager->MakeAlignablePN(pne);
+  }else{
+    AliWarning(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as volume path!",symname));
+    node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(symname);
+  }
+
   if (!node) {
-    AliError(Form("Volume path %s not valid!",volpath));
+    AliError(Form("Volume name or path %s not valid!",symname));
     return kFALSE;
   }
   if (node->IsAligned())
-    AliWarning(Form("Volume %s has been already misaligned!",volpath));
+    AliWarning(Form("Volume %s has been already misaligned!",symname));
 
-  TGeoHMatrix m;
-  Double_t tr[3];
-  tr[0]=x; tr[1]=y; tr[2]=z;
-  m.SetTranslation(tr);
-  Double_t angles[3] = {psi, theta, phi};
-  Double_t rot[9];
-  AnglesToMatrix(angles,rot);
-  m.SetRotation(rot);
+  TGeoHMatrix m1;
+  const Double_t *tr = m.GetTranslation();
+  m1.SetTranslation(tr);
+  const Double_t* rot = m.GetRotationMatrix();
+  m1.SetRotation(rot);
 
   TGeoHMatrix align,gprime,gprimeinv;
   gprime = *node->GetMatrix();
   gprimeinv = gprime.Inverse();
-  m.Multiply(&gprimeinv);
-  m.MultiplyLeft(&gprime);
+  m1.Multiply(&gprimeinv);
+  m1.MultiplyLeft(&gprime);
 
-  SetMatrix(m);
+  return SetMatrix(m1);
+}
 
+//_____________________________________________________________________________
+Bool_t AliAlignObj::SetMatrix(const TGeoMatrix& m)
+{
+  // Set the global delta transformation by passing the TGeoMatrix
+  // for it
+  //
+  SetTranslation(m);
+  return SetRotation(m);
+}
+
+//_____________________________________________________________________________
+Bool_t AliAlignObj::GetLocalPars(Double_t transl[], Double_t angles[]) const
+{
+  // Get the translations and angles (in degrees) expressing the
+  // local delta transformation.
+  // In case that the TGeo was not initialized or not closed,
+  // returns false and the object parameters are not set.
+  //
+  if(!GetLocalTranslation(transl)) return kFALSE;
+  return GetLocalAngles(angles);
+}
+
+//_____________________________________________________________________________
+Bool_t AliAlignObj::GetLocalTranslation(Double_t* tr) const
+{
+  // Get the 3 shifts giving the translational part of the local
+  // delta transformation.
+  // In case that the TGeo was not initialized or not closed,
+  // returns false and the object parameters are not set.
+  //
+  TGeoHMatrix ml;
+  if(!GetLocalMatrix(ml)) return kFALSE;
+  const Double_t* transl;
+  transl = ml.GetTranslation();
+  tr[0]=transl[0];
+  tr[1]=transl[1];
+  tr[2]=transl[2];
   return kTRUE;
 }
 
 //_____________________________________________________________________________
-Bool_t AliAlignObj::ApplyToGeometry()
+Bool_t AliAlignObj::GetLocalAngles(Double_t* angles) const
 {
-  // Apply the current alignment object
-  // to the TGeo geometry
+  // Get the 3 angles giving the rotational part of the local
+  // delta transformation.
+  // In case that the TGeo was not initialized or not closed,
+  // returns false and the object parameters are not set.
+  //
+  TGeoHMatrix ml;
+  if(!GetLocalMatrix(ml)) return kFALSE;
+  const Double_t *rot = ml.GetRotationMatrix();
+  return MatrixToAngles(rot,angles);
+}
 
+//_____________________________________________________________________________
+Bool_t AliAlignObj::GetLocalMatrix(TGeoHMatrix& m) const
+{
+  // Get the matrix for the local delta transformation.
+  // In case that the TGeo was not initialized or not closed,
+  // returns false and the object parameters are not set.
+  //
   if (!gGeoManager || !gGeoManager->IsClosed()) {
-    AliError("Can't apply the alignment object! gGeoManager doesn't exist or it is still opened!");
+    AliError("Can't set the alignment object parameters! gGeoManager doesn't exist or it is still opened!");
     return kFALSE;
   }
-  
-  const char* volpath = GetVolPath();
 
-  if (gGeoManager->GetListOfPhysicalNodes()->FindObject(volpath)) {
-    AliError(Form("Volume %s has been already misaligned!",volpath));
+  const char* symname = GetSymName();
+  TGeoPhysicalNode* node;
+  TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
+  if(pne){
+    node = gGeoManager->MakeAlignablePN(pne);
+  }else{
+    AliWarning(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as volume path!",symname));
+    node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(symname);
+  }
+
+  if (!node) {
+    AliError(Form("Volume name or path %s not valid!",symname));
     return kFALSE;
   }
+  if (node->IsAligned())
+    AliWarning(Form("Volume %s has been already misaligned!",symname));
 
-  if (!gGeoManager->cd(volpath)) {
-    AliError(Form("Volume path %s not valid!",volpath));
+  GetMatrix(m);
+  TGeoHMatrix gprime,gprimeinv;
+  gprime = *node->GetMatrix();
+  gprimeinv = gprime.Inverse();
+  m.Multiply(&gprime);
+  m.MultiplyLeft(&gprimeinv);
+
+  return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAlignObj::ApplyToGeometry()
+{
+  // Apply the current alignment object to the TGeo geometry
+  // This method returns FALSE if the symname of the object was not
+  // valid neither to get a TGeoPEntry nor as a volume path
+  //
+  if (!gGeoManager || !gGeoManager->IsClosed()) {
+    AliError("Can't apply the alignment object! gGeoManager doesn't exist or it is still opened!");
     return kFALSE;
   }
+  
+  const char* symname = GetSymName();
+  const char* path;
+  TGeoPhysicalNode* node;
+  TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
+  if(pne){
+    path = pne->GetTitle();
+    node = gGeoManager->MakeAlignablePN(pne);
+  }else{
+    AliDebug(1,Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
+    path=symname;
+    if (!gGeoManager->CheckPath(path)) {
+      AliDebug(1,Form("Volume path %s not valid!",path));
+      return kFALSE;
+    }
+    if (gGeoManager->GetListOfPhysicalNodes()->FindObject(path)) {
+      AliError(Form("Volume %s has already been misaligned!",path));
+      return kFALSE;
+    }
+    node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(path);
+  }
 
-  TGeoPhysicalNode* node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(volpath);
   if (!node) {
-    AliError(Form("Volume path %s not valid!",volpath));
+    AliError(Form("Volume path %s not valid!",path));
     return kFALSE;
   }
 
@@ -461,27 +694,30 @@ Bool_t AliAlignObj::ApplyToGeometry()
   TGeoHMatrix *g = node->GetMatrix(node->GetLevel()-1);
   *ginv = g->Inverse();
   *ginv *= gprime;
-  AliAlignObj::ELayerID layerId; // unique identity for volume in the alobj
-  Int_t modId; // unique identity for volume in the alobj
+  AliAlignObj::ELayerID layerId; // unique identity for layer in the alobj
+  Int_t modId; // unique identity for volume inside layer in the alobj
   GetVolUID(layerId, modId);
-  AliDebug(2,Form("Aligning volume %s of detector layer %d with local ID %d",volpath,layerId,modId));
+  AliDebug(2,Form("Aligning volume %s of detector layer %d with local ID %d",symname,layerId,modId));
   node->Align(ginv);
 
   return kTRUE;
 }
 
 //_____________________________________________________________________________
-Bool_t AliAlignObj::GetFromGeometry(const char *path, AliAlignObj &alobj)
+Bool_t AliAlignObj::GetFromGeometry(const char *symname, AliAlignObj &alobj)
 {
-  // Get the alignment object which correspond
-  // to the TGeo volume defined by the 'path'.
-  // The method is extremely slow due to the
-  // searching by string. Therefore it should
-  // be used with great care!!
+  // Get the alignment object which corresponds to the symbolic volume name
+  // symname (in case equal to the TGeo volume path)
+  // The method is extremely slow due to the searching by string.
+  // Therefore it should be used with great care!!
+  // This method returns FALSE if the symname of the object was not
+  // valid neither to get a TGeoPEntry nor as a volume path, or if the path
+  // associated to the TGeoPNEntry was not valid.
+  //
 
   // Reset the alignment object
   alobj.SetPars(0,0,0,0,0,0);
-  alobj.SetVolPath(path);
+  alobj.SetSymName(symname);
 
   if (!gGeoManager || !gGeoManager->IsClosed()) {
     AliErrorClass("Can't get the alignment object! gGeoManager doesn't exist or it is still opened!");
@@ -493,16 +729,28 @@ Bool_t AliAlignObj::GetFromGeometry(const char *path, AliAlignObj &alobj)
     return kFALSE;
   }
 
+  const char *path;
+  TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
+  if(pne){
+    path = pne->GetTitle();
+  }else{
+    AliWarningClass(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
+    path = symname;
+  }
   TObjArray* nodesArr = gGeoManager->GetListOfPhysicalNodes();
   TGeoPhysicalNode* node = NULL;
   for (Int_t iNode = 0; iNode < nodesArr->GetEntriesFast(); iNode++) {
-    node = (TGeoPhysicalNode*) nodesArr->UncheckedAt(iNode);
-    const char *nodePath = node->GetName();
-    if (strcmp(path,nodePath) == 0) break;
+    TGeoPhysicalNode* tempNode = (TGeoPhysicalNode*) nodesArr->UncheckedAt(iNode);
+    const char *nodePath = tempNode->GetName();
+    if (strcmp(path,nodePath) == 0) {
+      node = tempNode;
+      break;
+    }
   }
+
   if (!node) {
     if (!gGeoManager->cd(path)) {
-      AliErrorClass(Form("Volume path %s not found!",path));
+      AliErrorClass(Form("%s not valid neither as symbolic volume name nor as volume path!",path));
       return kFALSE;
     }
     else {
@@ -518,7 +766,75 @@ Bool_t AliAlignObj::GetFromGeometry(const char *path, AliAlignObj &alobj)
   g *= l;
   ginv = g.Inverse();
   align = gprime * ginv;
-  alobj.SetMatrix(align);
+
+  return alobj.SetMatrix(align);
+}
+
+//_____________________________________________________________________________
+Bool_t AliAlignObj::GetOrigGlobalMatrix(const char *symname, TGeoHMatrix &m)
+{
+  // The method returns global matrix for the ideal detector geometry
+  // Symname identifies either the corresponding TGeoPNEntry or directly
+  // the volume path. The output global matrix is stored in 'm'.
+  // Returns kFALSE in case, TGeo has not been initialized or the symname
+  // is invalid.
+  //
+
+  if (!gGeoManager || !gGeoManager->IsClosed()) {
+    AliErrorClass("Can't get the original global matrix! gGeoManager doesn't exist or it is still opened!");
+    return kFALSE;
+  }
+  
+  if (!gGeoManager->GetListOfPhysicalNodes()) {
+    AliWarningClass("gGeoManager doesn't contain any aligned nodes!");
+    if (!gGeoManager->cd(symname)) {
+      AliErrorClass(Form("Volume path %s not valid!",symname));
+      return kFALSE;
+    }
+    else {
+      m = *gGeoManager->GetCurrentMatrix();
+      return kTRUE;
+    }
+  }
+
+  const char* path = NULL;
+  TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
+  if(pne){
+    path = pne->GetTitle();
+  }else{
+    AliWarningClass(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
+    path=symname;
+  }
+
+  if (!gGeoManager->CheckPath(path)) {
+    AliErrorClass(Form("Volume path %s not valid!",path));
+    return kFALSE;
+  }
+
+  m.Clear();
+
+  TIter next(gGeoManager->GetListOfPhysicalNodes());
+  gGeoManager->cd(path);
+
+  while(gGeoManager->GetLevel()){
+
+    TGeoPhysicalNode *physNode = NULL;
+    next.Reset();
+    TGeoNode *node = gGeoManager->GetCurrentNode();
+    while ((physNode=(TGeoPhysicalNode*)next())) 
+      if (physNode->GetNode() == node) break;
+
+    TGeoMatrix *lm = NULL;
+    if (physNode) {
+        lm = physNode->GetOriginalMatrix();
+       if (!lm) lm = node->GetMatrix();
+    } else
+      lm = node->GetMatrix();
+
+    m.MultiplyLeft(lm);
+
+    gGeoManager->CdUp();
+  }
 
   return kTRUE;
 }
@@ -532,16 +848,16 @@ void  AliAlignObj::InitAlignObjFromGeometry()
 
   if(fgAlignObjs[0]) return;
   
-  InitVolPaths();
+  InitSymNames();
 
   for (Int_t iLayer = kFirstLayer; iLayer < AliAlignObj::kLastLayer; iLayer++) {
     fgAlignObjs[iLayer-kFirstLayer] = new AliAlignObj*[AliAlignObj::LayerSize(iLayer)];
     for (Int_t iModule = 0; iModule < AliAlignObj::LayerSize(iLayer); iModule++) {
       UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iModule);
-      fgAlignObjs[iLayer-kFirstLayer][iModule] = new AliAlignObjAngles("",volid,0,0,0,0,0,0);
-      const char *path = GetVolPath(volid);
-      if (!GetFromGeometry(path, *fgAlignObjs[iLayer-kFirstLayer][iModule]))
-       AliErrorClass(Form("Failed to extract the alignment object for the volume (ID=%d and path=%s) !",volid,path));
+      fgAlignObjs[iLayer-kFirstLayer][iModule] = new AliAlignObjAngles("",volid,0,0,0,0,0,0,kTRUE);
+      const char *symname = SymName(volid);
+      if (!GetFromGeometry(symname, *fgAlignObjs[iLayer-kFirstLayer][iModule]))
+       AliErrorClass(Form("Failed to extract the alignment object for the volume (ID=%d and path=%s) !",volid,symname));
     }
   }
   
@@ -550,6 +866,7 @@ void  AliAlignObj::InitAlignObjFromGeometry()
 //_____________________________________________________________________________
 AliAlignObj* AliAlignObj::GetAlignObj(UShort_t voluid) {
   // Returns the alignment object for given volume ID
+  //
   Int_t modId;
   ELayerID layerId = VolUIDToLayer(voluid,modId);
   return GetAlignObj(layerId,modId);
@@ -558,70 +875,86 @@ AliAlignObj* AliAlignObj::GetAlignObj(UShort_t voluid) {
 //_____________________________________________________________________________
 AliAlignObj* AliAlignObj::GetAlignObj(ELayerID layerId, Int_t modId)
 {
-  // Returns pointer to alignment object givent its layer and module ID
+  // Returns pointer to alignment object given its layer and module ID
+  //
   if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
     AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
     return NULL;
   }
+  InitAlignObjFromGeometry();
+
   return fgAlignObjs[layerId-kFirstLayer][modId];
 }
 
 //_____________________________________________________________________________
-const char* AliAlignObj::GetVolPath(UShort_t voluid) {
-  // Returns the volume path for given volume ID
+const char* AliAlignObj::SymName(UShort_t voluid) {
+  // Returns the symbolic volume name for given volume ID
+  //
   Int_t modId;
   ELayerID layerId = VolUIDToLayer(voluid,modId);
-  return GetVolPath(layerId,modId);
+  return SymName(layerId,modId);
 }
 
 //_____________________________________________________________________________
-const char* AliAlignObj::GetVolPath(ELayerID layerId, Int_t modId)
+const char* AliAlignObj::SymName(ELayerID layerId, Int_t modId)
 {
-  // Returns volume path to alignment object givent its layer and module ID
+  // Returns the symbolic volume name given for a given layer
+  // and module ID
+  //
   if(modId<0 || modId>=fgLayerSize[layerId-kFirstLayer]){
     AliWarningClass(Form("Module number %d not in the valid range (0->%d) !",modId,fgLayerSize[layerId-kFirstLayer]-1));
     return NULL;
   }
+  InitSymNames();
+
   return fgVolPath[layerId-kFirstLayer][modId].Data();
 }
 
 //_____________________________________________________________________________
-void AliAlignObj::InitVolPaths()
+void AliAlignObj::InitSymNames()
 {
-  // Initialize the LUTs which contain
-  // the TGeo volume paths for each
-  // alignable volume. The LUTs are
-  // static, so they are created during
-  // the creation of the first intance
-  // of AliAlignObj
-
+  // Initialize the LUTs which associate the symbolic volume names
+  // for each alignable volume with their unique numerical identity.
+  // The LUTs are static, so they are created during the instantiation
+  // of the first intance of AliAlignObj
+  //
   if (fgVolPath[0]) return;
 
   for (Int_t iLayer = 0; iLayer < (kLastLayer - kFirstLayer); iLayer++)
     fgVolPath[iLayer] = new TString[fgLayerSize[iLayer]];
 
+  TString symname;
+  Int_t modnum; // in the following, set it to 0 at the start of each layer
+
+  /*********************       ITS layers  ***********************/
+  TString strSPD = "ITS/SPD";
+  TString strSDD = "ITS/SDD";
+  TString strSSD = "ITS/SSD";
+  TString strStave = "/Stave";
+  TString strLadder = "/Ladder";
+  TString strSector = "/Sector";
+  TString strSensor = "/Sensor";
+  TString strEntryName1;
+  TString strEntryName2;
+
   /*********************       SPD layer1  ***********************/
   {
-    Int_t modnum = 0;
-    TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT12_1/I12B_"; //".../I12A_"
-    TString str1 = "/I10B_";    //"/I10A_";
-    TString str2 = "/I107_";    //"/I103_"
-    //    TString str3 = "/I101_1/ITS1_1";
-    TString volpath, volpath1, volpath2;
+    modnum = 0;
 
     for(Int_t c1 = 1; c1<=10; c1++){
-      volpath = str0;
-      volpath += c1;
-      volpath += str1;
+      strEntryName1 = strSPD;
+      strEntryName1 += 0;
+      strEntryName1 += strSector;
+      strEntryName1 += (c1-1);
       for(Int_t c2 =1; c2<=2; c2++){
-       volpath1 = volpath;
-       volpath1 += c2;
-       volpath1 += str2;
+       strEntryName2 = strEntryName1;
+       strEntryName2 += strStave;
+       strEntryName2 += (c2-1);
        for(Int_t c3 =1; c3<=4; c3++){
-         volpath2 = volpath1;
-         volpath2 += c3;
-         //      volpath2 += str3;
-         fgVolPath[kSPD1-kFirstLayer][modnum] = volpath2.Data();
+         symname = strEntryName2;
+         symname += strLadder;
+         symname += (c3-1);
+         fgVolPath[kSPD1-kFirstLayer][modnum] = symname.Data();
          modnum++;
        }
       }
@@ -630,26 +963,22 @@ void AliAlignObj::InitVolPaths()
   
   /*********************       SPD layer2  ***********************/
   {
-    Int_t modnum = 0;
-    TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT12_1/I12B_";  //".../I12A_"
-    TString str1 = "/I20B_";  //"/I20A"
-    TString str2 = "/I1D7_";  //"/I1D3"
-    //    TString str3 = "/I1D1_1/ITS2_1";
-    TString volpath, volpath1, volpath2;
+    modnum = 0;
 
     for(Int_t c1 = 1; c1<=10; c1++){
-      volpath = str0;
-      volpath += c1;
-      volpath += str1;
+      strEntryName1 = strSPD;
+      strEntryName1 += 1;
+      strEntryName1 += strSector;
+      strEntryName1 += (c1-1);
       for(Int_t c2 =1; c2<=4; c2++){
-       volpath1 = volpath;
-       volpath1 += c2;
-       volpath1 += str2;
+       strEntryName2 = strEntryName1;
+       strEntryName2 += strStave;
+       strEntryName2 += (c2-1);
        for(Int_t c3 =1; c3<=4; c3++){
-         volpath2 = volpath1;
-         volpath2 += c3;
-         //      volpath2 += str3;
-         fgVolPath[kSPD2-kFirstLayer][modnum] = volpath2.Data();
+         symname = strEntryName2;
+         symname += strLadder;
+         symname += (c3-1);
+         fgVolPath[kSPD2-kFirstLayer][modnum] = symname.Data();
          modnum++;
        }
       }
@@ -658,21 +987,18 @@ void AliAlignObj::InitVolPaths()
 
   /*********************       SDD layer1  ***********************/
   {
-    Int_t modnum=0;
-    TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT34_1/I004_";
-    TString str1 = "/I302_";
-    //    TString str2 = "/ITS3_1";
-    TString volpath, volpath1;
+    modnum=0;
 
     for(Int_t c1 = 1; c1<=14; c1++){
-      volpath = str0;
-      volpath += c1;
-      volpath += str1;
+      strEntryName1 = strSDD;
+      strEntryName1 += 2;
+      strEntryName1 +=strLadder;
+      strEntryName1 += (c1-1);
       for(Int_t c2 =1; c2<=6; c2++){
-       volpath1 = volpath;
-       volpath1 += c2;
-       //      volpath1 += str2;
-       fgVolPath[kSDD1-kFirstLayer][modnum] = volpath1.Data();
+       symname = strEntryName1;
+       symname += strSensor;
+       symname += (c2-1);
+       fgVolPath[kSDD1-kFirstLayer][modnum] = symname.Data();
        modnum++;
       }
     }
@@ -680,21 +1006,18 @@ void AliAlignObj::InitVolPaths()
 
   /*********************       SDD layer2  ***********************/
   {
-    Int_t modnum=0;
-    TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT34_1/I005_";
-    TString str1 = "/I402_";
-    //    TString str2 = "/ITS4_1";
-    TString volpath, volpath1;
+    modnum=0;
 
     for(Int_t c1 = 1; c1<=22; c1++){
-      volpath = str0;
-      volpath += c1;
-      volpath += str1;
+      strEntryName1 = strSDD;
+      strEntryName1 += 3;
+      strEntryName1 +=strLadder;
+      strEntryName1 += (c1-1);
       for(Int_t c2 = 1; c2<=8; c2++){
-       volpath1 = volpath;
-       volpath1 += c2;
-       //      volpath1 += str2;
-       fgVolPath[kSDD2-kFirstLayer][modnum] = volpath1.Data();
+       symname = strEntryName1;
+       symname += strSensor;
+       symname += (c2-1);
+       fgVolPath[kSDD2-kFirstLayer][modnum] = symname.Data();
        modnum++;
       }
     }
@@ -702,180 +1025,149 @@ void AliAlignObj::InitVolPaths()
 
   /*********************       SSD layer1  ***********************/
   {
-    Int_t modnum=0;
-    TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT56_1/I565_";
-    TString str1 = "/I562_";
-    //    TString str2 = "/ITS5_1";
-    TString volpath, volpath1;
+    modnum=0;
 
     for(Int_t c1 = 1; c1<=34; c1++){
-      volpath = str0;
-      volpath += c1;
-      volpath += str1;
+      strEntryName1 = strSSD;
+      strEntryName1 += 4;
+      strEntryName1 +=strLadder;
+      strEntryName1 += (c1-1);
       for(Int_t c2 = 1; c2<=22; c2++){
-       volpath1 = volpath;
-       volpath1 += c2;
-       //      volpath1 += str2;
-       fgVolPath[kSSD1-kFirstLayer][modnum] = volpath1.Data();
+       symname = strEntryName1;
+       symname += strSensor;
+       symname += (c2-1);
+       fgVolPath[kSSD1-kFirstLayer][modnum] = symname.Data();
        modnum++;
       }
     }
   }
 
-  /*********************       SSD layer1  ***********************/
+  /*********************       SSD layer2  ***********************/
   {
-    Int_t modnum=0;
-    TString str0 = "ALIC_1/ITSV_1/ITSD_1/IT56_1/I569_";
-    TString str1 = "/I566_";
-    //    TString str2 = "/ITS6_1";
-    TString volpath, volpath1;
+    modnum=0;
 
     for(Int_t c1 = 1; c1<=38; c1++){
-      volpath = str0;
-      volpath += c1;
-      volpath += str1;
+      strEntryName1 = strSSD;
+      strEntryName1 += 5;
+      strEntryName1 +=strLadder;
+      strEntryName1 += (c1-1);
       for(Int_t c2 = 1; c2<=25; c2++){
-       volpath1 = volpath;
-       volpath1 += c2;
-       //      volpath1 += str2;
-       fgVolPath[kSSD2-kFirstLayer][modnum] = volpath1.Data();
+       symname = strEntryName1;
+       symname += strSensor;
+       symname += (c2-1);
+       fgVolPath[kSSD2-kFirstLayer][modnum] = symname.Data();
        modnum++;
       }
     }
   }
 
+
+  /***************    TPC inner and outer layers    ****************/
+  TString sAsector="TPC/EndcapA/Sector";
+  TString sCsector="TPC/EndcapC/Sector";
+  TString sInner="/InnerChamber";
+  TString sOuter="/OuterChamber";
+  
   /***************    TPC inner chambers' layer    ****************/
   {
-    Int_t modnum = 0;
-    TString str1 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_1/TPC_SECT_";
-    TString str2 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_2/TPC_SECT_";
-    TString strIn = "/TPC_IROC_1";
-    TString volpath;
+    modnum = 0;
     
     for(Int_t cnt=1; cnt<=18; cnt++){
-      volpath = str1;
-      volpath += cnt;
-      volpath += strIn;
-      fgVolPath[kTPC1-kFirstLayer][modnum] = volpath.Data();
+      symname = sAsector;
+      symname += cnt;
+      symname += sInner;
+      fgVolPath[kTPC1-kFirstLayer][modnum] = symname.Data();
       modnum++;
     }
     for(Int_t cnt=1; cnt<=18; cnt++){
-      volpath = str2;
-      volpath += cnt;
-      volpath += strIn;
-      fgVolPath[kTPC1-kFirstLayer][modnum] = volpath.Data();
+      symname = sCsector;
+      symname += cnt;
+      symname += sInner;
+      fgVolPath[kTPC1-kFirstLayer][modnum] = symname.Data();
       modnum++;
     }
   }
 
   /***************    TPC outer chambers' layer    ****************/
   {
-    Int_t modnum = 0;
-    TString str1 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_1/TPC_SECT_";
-    TString str2 = "ALIC_1/TPC_M_1/TPC_Drift_1/TPC_ENDCAP_2/TPC_SECT_";
-    TString strOut = "/TPC_OROC_1";
-    TString volpath;
+    modnum = 0;
     
     for(Int_t cnt=1; cnt<=18; cnt++){
-      volpath = str1;
-      volpath += cnt;
-      volpath += strOut;
-      fgVolPath[kTPC2-kFirstLayer][modnum] = volpath.Data();
+      symname = sAsector;
+      symname += cnt;
+      symname += sOuter;
+      fgVolPath[kTPC2-kFirstLayer][modnum] = symname.Data();
       modnum++;
     }
     for(Int_t cnt=1; cnt<=18; cnt++){
-      volpath = str2;
-      volpath += cnt;
-      volpath += strOut;
-      fgVolPath[kTPC2-kFirstLayer][modnum] = volpath.Data();
+      symname = sCsector;
+      symname += cnt;
+      symname += sOuter;
+      fgVolPath[kTPC2-kFirstLayer][modnum] = symname.Data();
       modnum++;
     }
   }    
 
   /*********************       TOF layer   ***********************/
   {
+    modnum=0;
+    
     Int_t nstrA=15;
     Int_t nstrB=19;
     Int_t nstrC=19;
-    Int_t nsec=18;
-    Int_t nStripSec=nstrA+2*nstrB+2*nstrC;
-    Int_t nStrip=nStripSec*nsec;
-
-    for (Int_t modnum=0; modnum < nStrip; modnum++) {
-
-      Int_t sector = modnum/nStripSec;
-      Char_t  string1[100];
-      Char_t  string2[100];
-      Int_t icopy=-1;
-      if(sector<13){
-       icopy=sector+5;}  
-      else{ icopy=sector-13;}
-
-      sprintf(string1,"/ALIC_1/B077_1/BSEGMO%i_1/BTOF%i_1/FTOA_0/FLTA_0",sector,sector);
-      
-      Int_t strInSec=modnum%nStripSec;
-      icopy= strInSec;
-      icopy++;
-      sprintf(string2,"FSTR_%i",icopy);      
-      Char_t  path[100];
-      sprintf(path,"%s/%s",string1,string2); 
-      //      printf("%d  %s\n",modnum,path);
-      fgVolPath[kTOF-kFirstLayer][modnum] = path;
+    Int_t nSectors=18;
+    Int_t nStrips=nstrA+2*nstrB+2*nstrC;
+    
+    TString snSM  = "TOF/sm";
+    TString snSTRIP = "/strip";
+    
+    for (Int_t isect = 0; isect < nSectors; isect++) {
+      for (Int_t istr = 1; istr <= nStrips; istr++) {  
+       symname  = snSM;
+       symname += Form("%02d",isect);
+       symname += snSTRIP;
+       symname += Form("%02d",istr);
+       fgVolPath[kTOF-kFirstLayer][modnum] = symname.Data();   
+       modnum++;
+      }
     }
   } 
 
-  /*********************      RICH layer   ***********************/
+  /*********************      HMPID layer   ***********************/
   {
-    TString str = "ALIC_1/RICH_";
-    TString volpath;
+    TString str = "/HMPID/Chamber";
 
-    for (Int_t modnum=0; modnum < 7; modnum++) {
-      volpath = str;
-      volpath += (modnum+1);
-      fgVolPath[kRICH-kFirstLayer][modnum] = volpath.Data();
+    for (modnum=0; modnum < 7; modnum++) {
+      symname = str;
+      symname += modnum;
+      fgVolPath[kHMPID-kFirstLayer][modnum] = symname.Data();
     }
   }
 
-  /*********************      TRD layers 0-6   *******************/
+  /*********************      TRD layers 1-6   *******************/
+  //!! 6 layers with index increasing in outwards direction
   {
-    TString strSM[18]={"ALIC_1/B077_1/B075_1/BTR3_1/UTR1_3/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B075_2/BTR3_1/UTR1_3/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B075_3/BTR3_1/UTR1_3/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_6/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_7/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_8/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_9/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_10/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_11/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_12/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_13/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B074_1/BTR2_1/UTR1_2/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B074_2/BTR2_1/UTR1_2/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_1/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_2/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_3/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_4/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT",
-                      "ALIC_1/B077_1/B071_5/BTR1_1/UTR1_1/UTS1_1/UTI1_1/UT"};
-    TString strPost = "_1";
-    TString zeroStr = "0";
-    TString volpath;
-
     Int_t arTRDlayId[6] = {kTRD1, kTRD2, kTRD3, kTRD4, kTRD5, kTRD6};
 
+    TString snStr  = "TRD/sm";
+    TString snApp1 = "/st";
+    TString snApp2 = "/pl";
+    
     for(Int_t layer=0; layer<6; layer++){
-      Int_t modnum=0;
-      for(Int_t sm = 0; sm < 18; sm++){
-       for(Int_t stacknum = 0; stacknum < 5; stacknum++){
-         Int_t chnum = layer + stacknum*6;
-         volpath = strSM[sm];
-         if(chnum<10) volpath += zeroStr;
-         volpath += chnum;
-         volpath += strPost;
-         fgVolPath[arTRDlayId[layer]-kFirstLayer][modnum] = volpath.Data();
+      modnum=0;
+      for (Int_t isect = 0; isect < 18; isect++) {
+       for (Int_t icham = 0; icham < 5; icham++) {
+         symname  = snStr;
+         symname += Form("%02d",isect);
+         symname += snApp1;
+         symname += icham;
+         symname += snApp2;
+         symname += layer;
+         fgVolPath[arTRDlayId[layer]-kFirstLayer][modnum] = symname.Data();
          modnum++;
        }
       }
     }
   }
-
 }
+