]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliAlignObj.cxx
Removal of AliAODTowers (will appear as AliAODCaloCells again).
[u/mrichter/AliRoot.git] / STEER / AliAlignObj.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //-----------------------------------------------------------------
19 //  Implementation of the alignment object class, holding the alignment
20 //  constants for a single volume, through the abstract class AliAlignObj.
21 //  From it two derived concrete representation of alignment object class
22 //  (AliAlignObjParams, AliAlignObjMatrix) are derived in separate files.
23 //-----------------------------------------------------------------
24
25 #include <TClass.h>
26 #include <TGeoManager.h>
27 #include <TGeoPhysicalNode.h>
28 #include <TMath.h>
29 #include "TObjString.h"
30
31 #include "AliAlignObj.h"
32 #include "AliTrackPointArray.h"
33 #include "AliLog.h"
34 #include "AliAlignObjParams.h"
35  
36 ClassImp(AliAlignObj)
37
38 //_____________________________________________________________________________
39 AliAlignObj::AliAlignObj():
40   fVolPath(),
41   fVolUID(0)
42 {
43   // default constructor
44   for(Int_t i=0; i<6; i++) fDiag[i]=-999.;
45   for(Int_t i=0; i<21; i++) fODia[i]=-999.;
46 }
47
48 //_____________________________________________________________________________
49 AliAlignObj::AliAlignObj(const char* symname, UShort_t voluid) :
50   TObject(),
51   fVolPath(symname),
52   fVolUID(voluid)
53 {
54   // standard constructor
55   //
56   for(Int_t i=0; i<6; i++) fDiag[i]=-999.;
57   for(Int_t i=0; i<21; i++) fODia[i]=-999.;
58 }
59
60 //_____________________________________________________________________________
61 AliAlignObj::AliAlignObj(const char* symname, UShort_t voluid, Double_t* cmat) :
62   TObject(),
63   fVolPath(symname),
64   fVolUID(voluid)
65 {
66   // standard constructor
67   //
68   SetCorrMatrix(cmat);
69 }
70
71 //_____________________________________________________________________________
72 AliAlignObj::AliAlignObj(const AliAlignObj& theAlignObj) :
73   TObject(theAlignObj),
74   fVolPath(theAlignObj.GetSymName()),
75   fVolUID(theAlignObj.GetVolUID())
76 {
77   //copy constructor
78   for(Int_t i=0; i<6; i++) fDiag[i]=theAlignObj.fDiag[i];
79   for(Int_t i=0; i<21; i++) fODia[i]=theAlignObj.fODia[i];
80 }
81
82 //_____________________________________________________________________________
83 AliAlignObj &AliAlignObj::operator =(const AliAlignObj& theAlignObj)
84 {
85   // assignment operator
86   if(this==&theAlignObj) return *this;
87   fVolPath = theAlignObj.GetSymName();
88   fVolUID = theAlignObj.GetVolUID();
89   for(Int_t i=0; i<6; i++) fDiag[i]=theAlignObj.fDiag[i];
90   for(Int_t i=0; i<21; i++) fODia[i]=theAlignObj.fODia[i];
91   return *this;
92 }
93
94 //_____________________________________________________________________________
95 AliAlignObj &AliAlignObj::operator*=(const AliAlignObj& theAlignObj)
96 {
97   // multiplication operator
98   // The operator can be used to 'combine'
99   // two alignment objects
100   TGeoHMatrix m1;
101   GetMatrix(m1);
102   TGeoHMatrix m2;
103   theAlignObj.GetMatrix(m2);
104   m1.MultiplyLeft(&m2);
105   SetMatrix(m1);
106   // temporary solution: consider parameters indipendent 
107   for(Int_t i=0; i<6; i++)  fDiag[i] = TMath::Sqrt((fDiag[i]*fDiag[i])+(theAlignObj.fDiag[i]*theAlignObj.fDiag[i]));
108   return *this;
109 }
110
111 //_____________________________________________________________________________
112 AliAlignObj::~AliAlignObj()
113 {
114   // dummy destructor
115 }
116
117 //_____________________________________________________________________________
118 void AliAlignObj::SetVolUID(AliGeomManager::ELayerID detId, Int_t modId)
119 {
120   // From detector name and module number (according to detector numbering)
121   // build fVolUID, unique numerical identity of that volume inside ALICE
122   // fVolUID is 16 bits, first 5 reserved for detID (32 possible values),
123   // remaining 11 for module ID inside det (2048 possible values).
124   //
125   fVolUID = AliGeomManager::LayerToVolUID(detId,modId);
126 }
127
128 //_____________________________________________________________________________
129 void AliAlignObj::GetVolUID(AliGeomManager::ELayerID &layerId, Int_t &modId) const
130 {
131   // From the fVolUID, unique numerical identity of that volume inside ALICE,
132   // (voluid is 16 bits, first 5 reserved for layerID (32 possible values),
133   // remaining 11 for module ID inside det (2048 possible values)), sets
134   // the argument layerId to the identity of the layer to which that volume
135   // belongs and sets the argument modId to the identity of that volume
136   // internally to the layer.
137   //
138   layerId = AliGeomManager::VolUIDToLayer(fVolUID,modId);
139 }
140
141 //_____________________________________________________________________________
142 Bool_t AliAlignObj::GetPars(Double_t tr[], Double_t angles[]) const
143 {
144   GetTranslation(tr);
145   return GetAngles(angles);
146 }
147
148 //_____________________________________________________________________________
149 Int_t AliAlignObj::GetLevel() const
150 {
151   // Return the geometry level of the alignable volume to which
152   // the alignment object is associated; this is the number of
153   // slashes in the corresponding volume path
154   //
155   if(!gGeoManager){
156     AliWarning("gGeoManager doesn't exist or it is still opened: unable to return meaningful level value.");
157     return (-1);
158   }
159   const char* symname = GetSymName();
160   const char* path;
161   TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
162   if(pne){
163     path = pne->GetTitle();
164   }else{
165     path = symname;
166   }
167
168   TString path_str = path;
169   if(path_str[0]!='/') path_str.Prepend('/');
170   return path_str.CountChar('/');
171 }
172
173 //_____________________________________________________________________________
174 Int_t AliAlignObj::Compare(const TObject *obj) const
175 {
176   // Compare the levels of two
177   // alignment objects
178   // Used in the sorting during
179   // the application of alignment
180   // objects to the geometry
181   //
182   Int_t level = GetLevel();
183   Int_t level2 = ((AliAlignObj *)obj)->GetLevel();
184   if (level == level2)
185     return 0;
186   else
187     return ((level > level2) ? 1 : -1);
188 }
189
190 //______________________________________________________________________________
191 void AliAlignObj::GetCovMatrix(Double_t *cmat) const
192 {
193   // Fills the cmat argument with the coefficients of the external cov matrix (21 elements)
194   // calculating them from the correlation matrix data member
195   //
196
197   for(Int_t i=0; i<6; ++i) {
198     // Off diagonal elements
199     for(Int_t j=0; j<i; ++j) {
200       cmat[i*(i+1)/2+j] = (fDiag[j] >= 0. && fDiag[i] >= 0.) ? fODia[(i-1)*i/2+j]*fDiag[j]*fDiag[i]: -999.;
201     }
202
203     // Diagonal elements
204     cmat[i*(i+1)/2+i] = (fDiag[i] >= 0.) ? fDiag[i]*fDiag[i] : -999.;
205   }
206 }
207
208 //______________________________________________________________________________
209 void AliAlignObj::SetCorrMatrix(Double_t *cmat)
210 {
211   // Sets the correlation matrix data member from the coefficients of the external covariance
212   // matrix (21 elements passed as argument). 
213   //
214   if(cmat) {
215
216     // Diagonal elements first
217     for(Int_t i=0; i<6; ++i) {
218       fDiag[i] = (cmat[i*(i+1)/2+i] >= 0.) ? TMath::Sqrt(cmat[i*(i+1)/2+i]) : -999.;
219     }
220
221     // ... then the ones off diagonal
222     for(Int_t i=0; i<6; ++i)
223       // Off diagonal elements
224       for(Int_t j=0; j<i; ++j) {
225         fODia[(i-1)*i/2+j] = (fDiag[i] > 0. && fDiag[j] > 0.) ? cmat[i*(i+1)/2+j]/(fDiag[j]*fDiag[i]) : 0.;       // check for division by zero (due to diagonal element of 0) and for fDiag != -999. (due to negative input diagonal element).
226         if (fODia[(i-1)*i/2+j]>1.)  fODia[(i-1)*i/2+j] =  1.; // check upper boundary
227         if (fODia[(i-1)*i/2+j]<-1.) fODia[(i-1)*i/2+j] = -1.; // check lower boundary
228       }
229   } else {
230     for(Int_t i=0; i< 6; ++i) fDiag[i]=-999.;
231     for(Int_t i=0; i< 6*(6-1)/2; ++i) fODia[i]=0.;
232   }
233
234   return;
235 }
236
237 //_____________________________________________________________________________
238 void AliAlignObj::AnglesToMatrix(const Double_t *angles, Double_t *rot) const
239 {
240   // Calculates the rotation matrix using the 
241   // Euler angles in "x y z" notation
242   //
243   Double_t degrad = TMath::DegToRad();
244   Double_t sinpsi = TMath::Sin(degrad*angles[0]);
245   Double_t cospsi = TMath::Cos(degrad*angles[0]);
246   Double_t sinthe = TMath::Sin(degrad*angles[1]);
247   Double_t costhe = TMath::Cos(degrad*angles[1]);
248   Double_t sinphi = TMath::Sin(degrad*angles[2]);
249   Double_t cosphi = TMath::Cos(degrad*angles[2]);
250
251   rot[0] =  costhe*cosphi;
252   rot[1] = -costhe*sinphi;
253   rot[2] =  sinthe;
254   rot[3] =  sinpsi*sinthe*cosphi + cospsi*sinphi;
255   rot[4] = -sinpsi*sinthe*sinphi + cospsi*cosphi;
256   rot[5] = -costhe*sinpsi;
257   rot[6] = -cospsi*sinthe*cosphi + sinpsi*sinphi;
258   rot[7] =  cospsi*sinthe*sinphi + sinpsi*cosphi;
259   rot[8] =  costhe*cospsi;
260 }
261
262 //_____________________________________________________________________________
263 Bool_t AliAlignObj::MatrixToAngles(const Double_t *rot, Double_t *angles) const
264 {
265   // Calculates the Euler angles in "x y z" notation
266   // using the rotation matrix
267   // Returns false in case the rotation angles can not be
268   // extracted from the matrix
269   //
270   if(TMath::Abs(rot[0])<1e-7 || TMath::Abs(rot[8])<1e-7) {
271     AliError("Failed to extract roll-pitch-yall angles!");
272     return kFALSE;
273   }
274   Double_t raddeg = TMath::RadToDeg();
275   angles[0]=raddeg*TMath::ATan2(-rot[5],rot[8]);
276   angles[1]=raddeg*TMath::ASin(rot[2]);
277   angles[2]=raddeg*TMath::ATan2(-rot[1],rot[0]);
278   return kTRUE;
279 }
280
281 //______________________________________________________________________________
282 void AliAlignObj::Transform(AliTrackPoint &p) const
283 {
284   // The method transforms the space-point coordinates using the
285   // transformation matrix provided by the AliAlignObj
286   // The covariance matrix is not affected since we assume
287   // that the transformations are sufficiently small
288   //
289   if (fVolUID != p.GetVolumeID())
290     AliWarning(Form("Alignment object ID is not equal to the space-point ID (%d != %d)",fVolUID,p.GetVolumeID())); 
291
292   TGeoHMatrix m;
293   GetMatrix(m);
294   Double_t *rot = m.GetRotationMatrix();
295   Double_t *tr  = m.GetTranslation();
296
297   Float_t xyzin[3],xyzout[3];
298   p.GetXYZ(xyzin);
299   for (Int_t i = 0; i < 3; i++)
300     xyzout[i] = tr[i]+
301                 xyzin[0]*rot[3*i]+
302                 xyzin[1]*rot[3*i+1]+
303                 xyzin[2]*rot[3*i+2];
304   p.SetXYZ(xyzout);
305   
306 }
307
308 //_____________________________________________________________________________
309 void AliAlignObj::Transform(AliTrackPointArray &array) const
310 {
311   // This method is used to transform all the track points
312   // from the input AliTrackPointArray
313   // 
314   AliTrackPoint p;
315   for (Int_t i = 0; i < array.GetNPoints(); i++) {
316     array.GetPoint(p,i);
317     Transform(p);
318     array.AddPoint(i,&p);
319   }
320 }
321
322 //_____________________________________________________________________________
323 void AliAlignObj::Print(Option_t *) const
324 {
325   // Print the contents of the
326   // alignment object in angles and
327   // matrix representations
328   //
329   Double_t tr[3];
330   GetTranslation(tr);
331   Double_t angles[3];
332   GetAngles(angles);
333   TGeoHMatrix m;
334   GetMatrix(m);
335   const Double_t *rot = m.GetRotationMatrix();
336
337   printf("Volume=%s\n",GetSymName());
338   if (GetVolUID() != 0) {
339     AliGeomManager::ELayerID layerId;
340     Int_t modId;
341     GetVolUID(layerId,modId);
342     printf("VolumeID=%d LayerID=%d ( %s ) ModuleID=%d\n", GetVolUID(),layerId,AliGeomManager::LayerName(layerId),modId);
343   }
344   printf("%12.8f%12.8f%12.8f    Tx = %12.8f    Psi   = %12.8f\n", rot[0], rot[1], rot[2], tr[0], angles[0]);
345   printf("%12.8f%12.8f%12.8f    Ty = %12.8f    Theta = %12.8f\n", rot[3], rot[4], rot[5], tr[1], angles[1]);
346   printf("%12.8f%12.8f%12.8f    Tz = %12.8f    Phi   = %12.8f\n", rot[6], rot[7], rot[8], tr[2], angles[2]);
347
348 }
349
350 //_____________________________________________________________________________
351 void AliAlignObj::SetPars(Double_t x, Double_t y, Double_t z,
352                           Double_t psi, Double_t theta, Double_t phi)
353 {
354   // Set the global delta transformation by passing 3 angles (expressed in
355   // degrees) and 3 shifts (in centimeters)
356   // 
357   SetTranslation(x,y,z);
358   SetRotation(psi,theta,phi);
359 }
360
361 //_____________________________________________________________________________
362 Bool_t AliAlignObj::SetLocalPars(Double_t x, Double_t y, Double_t z,
363                                  Double_t psi, Double_t theta, Double_t phi)
364 {
365   // Set the global delta transformation by passing the parameters
366   // for the local delta transformation (3 shifts and 3 angles).
367   // In case that the TGeo was not initialized or not closed,
368   // returns false and the object parameters are not set.
369   //
370   TGeoHMatrix m;
371   Double_t tr[3] = {x, y, z};
372   m.SetTranslation(tr);
373   Double_t angles[3] = {psi, theta, phi};
374   Double_t rot[9];
375   AnglesToMatrix(angles,rot);
376   m.SetRotation(rot);
377
378   return SetLocalMatrix(m);
379
380 }
381
382 //_____________________________________________________________________________
383 Bool_t AliAlignObj::SetLocalTranslation(Double_t x, Double_t y, Double_t z)
384 {
385   // Set the global delta transformation by passing the three shifts giving
386   // the translation in the local reference system of the alignable
387   // volume (known by TGeo geometry).
388   // In case that the TGeo was not initialized or not closed,
389   // returns false and the object parameters are not set.
390   //
391   TGeoHMatrix m;
392   Double_t tr[3] = {x, y, z};
393   m.SetTranslation(tr);
394
395   return SetLocalMatrix(m);
396
397 }
398
399 //_____________________________________________________________________________
400 Bool_t AliAlignObj::SetLocalTranslation(const TGeoMatrix& m)
401 {
402   // Set the global delta transformation by passing the matrix of
403   // the local delta transformation and taking its translational part
404   // In case that the TGeo was not initialized or not closed,
405   // returns false and the object parameters are not set.
406   //
407   const Double_t* tr = m.GetTranslation();
408   TGeoHMatrix mtr;
409   mtr.SetTranslation(tr);
410
411   return SetLocalMatrix(mtr);
412
413 }
414
415 //_____________________________________________________________________________
416 Bool_t AliAlignObj::SetLocalRotation(Double_t psi, Double_t theta, Double_t phi)
417 {
418   // Set the global delta transformation by passing the three angles giving
419   // the rotation in the local reference system of the alignable
420   // volume (known by TGeo geometry).
421   // In case that the TGeo was not initialized or not closed,
422   // returns false and the object parameters are not set.
423   //
424   TGeoHMatrix m;
425   Double_t angles[3] = {psi, theta, phi};
426   Double_t rot[9];
427   AnglesToMatrix(angles,rot);
428   m.SetRotation(rot);
429
430   return SetLocalMatrix(m);
431
432 }
433
434 //_____________________________________________________________________________
435 Bool_t AliAlignObj::SetLocalRotation(const TGeoMatrix& m)
436 {
437   // Set the global delta transformation by passing the matrix of
438   // the local delta transformation and taking its rotational part
439   // In case that the TGeo was not initialized or not closed,
440   // returns false and the object parameters are not set.
441   //
442   TGeoHMatrix rotm;
443   const Double_t* rot = m.GetRotationMatrix();
444   rotm.SetRotation(rot);
445
446   return SetLocalMatrix(rotm);
447
448 }
449
450 //_____________________________________________________________________________
451 Bool_t AliAlignObj::SetLocalMatrix(const TGeoMatrix& m)
452 {
453   // Set the global delta transformation by passing the TGeo matrix
454   // for the local delta transformation.
455   // In case that the TGeo was not initialized or not closed,
456   // returns false and the object parameters are not set.
457   //
458   if (!gGeoManager || !gGeoManager->IsClosed()) {
459     AliError("Can't set the alignment object parameters! gGeoManager doesn't exist or it is still opened!");
460     return kFALSE;
461   }
462
463   const char* symname = GetSymName();
464   TGeoPhysicalNode* node;
465   TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
466   if(pne){
467     node = gGeoManager->MakeAlignablePN(pne);
468   }else{
469     AliWarning(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as volume path!",symname));
470     node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(symname);
471   }
472
473   if (!node) {
474     AliError(Form("Volume name or path %s not valid!",symname));
475     return kFALSE;
476   }
477   if (node->IsAligned())
478     AliWarning(Form("Volume %s has been already misaligned!",symname));
479
480   TGeoHMatrix m1;
481   const Double_t *tr = m.GetTranslation();
482   m1.SetTranslation(tr);
483   const Double_t* rot = m.GetRotationMatrix();
484   m1.SetRotation(rot);
485
486   TGeoHMatrix align,gprime,gprimeinv;
487   gprime = *node->GetMatrix();
488   gprimeinv = gprime.Inverse();
489   m1.Multiply(&gprimeinv);
490   m1.MultiplyLeft(&gprime);
491
492   return SetMatrix(m1);
493 }
494
495 //_____________________________________________________________________________
496 Bool_t AliAlignObj::SetMatrix(const TGeoMatrix& m)
497 {
498   // Set the global delta transformation by passing the TGeoMatrix
499   // for it
500   //
501   SetTranslation(m);
502   return SetRotation(m);
503 }
504
505 //_____________________________________________________________________________
506 Bool_t AliAlignObj::GetLocalPars(Double_t transl[], Double_t angles[]) const
507 {
508   // Get the translations and angles (in degrees) expressing the
509   // local delta transformation.
510   // In case that the TGeo was not initialized or not closed,
511   // returns false and the object parameters are not set.
512   //
513   if(!GetLocalTranslation(transl)) return kFALSE;
514   return GetLocalAngles(angles);
515 }
516
517 //_____________________________________________________________________________
518 Bool_t AliAlignObj::GetLocalTranslation(Double_t* tr) const
519 {
520   // Get the 3 shifts giving the translational part of the local
521   // delta transformation.
522   // In case that the TGeo was not initialized or not closed,
523   // returns false and the object parameters are not set.
524   //
525   TGeoHMatrix ml;
526   if(!GetLocalMatrix(ml)) return kFALSE;
527   const Double_t* transl;
528   transl = ml.GetTranslation();
529   tr[0]=transl[0];
530   tr[1]=transl[1];
531   tr[2]=transl[2];
532   return kTRUE;
533 }
534
535 //_____________________________________________________________________________
536 Bool_t AliAlignObj::GetLocalAngles(Double_t* angles) const
537 {
538   // Get the 3 angles giving the rotational part of the local
539   // delta transformation.
540   // In case that the TGeo was not initialized or not closed,
541   // returns false and the object parameters are not set.
542   //
543   TGeoHMatrix ml;
544   if(!GetLocalMatrix(ml)) return kFALSE;
545   const Double_t *rot = ml.GetRotationMatrix();
546   return MatrixToAngles(rot,angles);
547 }
548
549 //_____________________________________________________________________________
550 Bool_t AliAlignObj::GetLocalMatrix(TGeoHMatrix& m) const
551 {
552   // Get the matrix for the local delta transformation.
553   // In case that the TGeo was not initialized or not closed,
554   // returns false and the object parameters are not set.
555   //
556   if (!gGeoManager || !gGeoManager->IsClosed()) {
557     AliError("Can't set the alignment object parameters! gGeoManager doesn't exist or it is still opened!");
558     return kFALSE;
559   }
560
561   const char* symname = GetSymName();
562   TGeoPhysicalNode* node;
563   TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
564   if(pne){
565     node = gGeoManager->MakeAlignablePN(pne);
566   }else{
567     AliWarning(Form("The symbolic volume name %s does not correspond to a physical entry. Using it as volume path!",symname));
568     node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(symname);
569   }
570
571   if (!node) {
572     AliError(Form("Volume name or path %s not valid!",symname));
573     return kFALSE;
574   }
575   if (node->IsAligned())
576     AliWarning(Form("Volume %s has been already misaligned!",symname));
577
578   GetMatrix(m);
579   TGeoHMatrix gprime,gprimeinv;
580   gprime = *node->GetMatrix();
581   gprimeinv = gprime.Inverse();
582   m.Multiply(&gprime);
583   m.MultiplyLeft(&gprimeinv);
584
585   return kTRUE;
586 }
587
588 //_____________________________________________________________________________
589 Bool_t AliAlignObj::ApplyToGeometry()
590 {
591   // Apply the current alignment object to the TGeo geometry
592   // This method returns FALSE if the symname of the object was not
593   // valid neither to get a TGeoPEntry nor as a volume path
594   //
595   if (!gGeoManager || !gGeoManager->IsClosed()) {
596     AliError("Can't apply the alignment object! gGeoManager doesn't exist or it is still opened!");
597     return kFALSE;
598   }
599   
600   const char* symname = GetSymName();
601   const char* path;
602   TGeoPhysicalNode* node;
603   TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
604   if(pne){
605     path = pne->GetTitle();
606     node = gGeoManager->MakeAlignablePN(pne);
607   }else{
608     AliDebug(1,Form("The symbolic volume name %s does not correspond to a physical entry. Using it as a volume path!",symname));
609     path=symname;
610     if (!gGeoManager->CheckPath(path)) {
611       AliDebug(1,Form("Volume path %s not valid!",path));
612       return kFALSE;
613     }
614     if (gGeoManager->GetListOfPhysicalNodes()->FindObject(path)) {
615       AliError(Form("Volume %s has already been misaligned!",path));
616       return kFALSE;
617     }
618     node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(path);
619   }
620
621   if (!node) {
622     AliError(Form("Volume path %s not valid!",path));
623     return kFALSE;
624   }
625
626   TGeoHMatrix align,gprime;
627   gprime = *node->GetMatrix();
628   GetMatrix(align);
629   gprime.MultiplyLeft(&align);
630   TGeoHMatrix *ginv = new TGeoHMatrix;
631   TGeoHMatrix *g = node->GetMatrix(node->GetLevel()-1);
632   *ginv = g->Inverse();
633   *ginv *= gprime;
634   AliGeomManager::ELayerID layerId; // unique identity for layer in the alobj
635   Int_t modId; // unique identity for volume inside layer in the alobj
636   GetVolUID(layerId, modId);
637   AliDebug(2,Form("Aligning volume %s of detector layer %d with local ID %d",symname,layerId,modId));
638   node->Align(ginv);
639
640   return kTRUE;
641 }
642