* 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
+// (AliAlignObjParams, 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 <TGeoManager.h>
+#include <TGeoMatrix.h>
#include <TGeoPhysicalNode.h>
+#include <TGeoOverlap.h>
+#include <TMath.h>
#include "AliAlignObj.h"
#include "AliTrackPointArray.h"
#include "AliLog.h"
-#include "AliAlignObjAngles.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
- 1638, // TOF
- 1, 1, // PHOS ??
- 7, // RICH ??
- 1 // MUON ??
-};
-
-const char* AliAlignObj::fgLayerName[kLastLayer - kFirstLayer] = {
- "ITS inner pixels layer", "ITS outer pixels layer",
- "ITS inner drifts layer", "ITS outer drifts layer",
- "ITS inner strips layer", "ITS outer strips layer",
- "TPC inner chambers layer", "TPC outer chambers layer",
- "TRD chambers layer 1", "TRD chambers layer 2", "TRD chambers layer 3",
- "TRD chambers layer 4", "TRD chambers layer 5", "TRD chambers layer 6",
- "TOF layer",
- "?","?",
- "RICH layer",
- "?"
-};
-
-TString* AliAlignObj::fgVolPath[kLastLayer - kFirstLayer] = {
- 0x0,0x0,
- 0x0,0x0,
- 0x0,0x0,
- 0x0,0x0,
- 0x0,0x0,0x0,
- 0x0,0x0,0x0,
- 0x0,
- 0x0,0x0,
- 0x0,
- 0x0
-};
-
-AliAlignObj** AliAlignObj::fgAlignObjs[kLastLayer - kFirstLayer] = {
- 0x0,0x0,
- 0x0,0x0,
- 0x0,0x0,
- 0x0,0x0,
- 0x0,0x0,0x0,
- 0x0,0x0,0x0,
- 0x0,
- 0x0,0x0,
- 0x0,
- 0x0
-};
-
//_____________________________________________________________________________
AliAlignObj::AliAlignObj():
+ fVolPath(),
fVolUID(0)
{
// default constructor
- InitVolPaths();
+ for(Int_t i=0; i<6; i++) fDiag[i]=-999.;
+ for(Int_t i=0; i<15; i++) fODia[i]=-999.;
}
//_____________________________________________________________________________
-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;
+ for(Int_t i=0; i<6; i++) fDiag[i]=-999.;
+ for(Int_t i=0; i<15; i++) fODia[i]=-999.;
}
-AliAlignObj::AliAlignObj(const char* volpath, ELayerID detId, Int_t volId) : TObject()
+//_____________________________________________________________________________
+AliAlignObj::AliAlignObj(const char* symname, UShort_t voluid, Double_t* cmat) :
+ TObject(),
+ fVolPath(symname),
+ fVolUID(voluid)
{
// standard constructor
- //
- fVolPath=volpath;
- SetVolUID(detId,volId);
+ //
+ SetCorrMatrix(cmat);
}
//_____________________________________________________________________________
AliAlignObj::AliAlignObj(const AliAlignObj& theAlignObj) :
- TObject(theAlignObj)
+ TObject(theAlignObj),
+ fVolPath(theAlignObj.GetSymName()),
+ fVolUID(theAlignObj.GetVolUID())
{
//copy constructor
- fVolPath = theAlignObj.GetVolPath();
- fVolUID = theAlignObj.GetVolUID();
+ for(Int_t i=0; i<6; i++) fDiag[i]=theAlignObj.fDiag[i];
+ for(Int_t i=0; i<15; i++) fODia[i]=theAlignObj.fODia[i];
}
//_____________________________________________________________________________
{
// assignment operator
if(this==&theAlignObj) return *this;
- fVolPath = theAlignObj.GetVolPath();
+ fVolPath = theAlignObj.GetSymName();
fVolUID = theAlignObj.GetVolUID();
+ for(Int_t i=0; i<6; i++) fDiag[i]=theAlignObj.fDiag[i];
+ for(Int_t i=0; i<15; i++) fODia[i]=theAlignObj.fODia[i];
return *this;
}
theAlignObj.GetMatrix(m2);
m1.MultiplyLeft(&m2);
SetMatrix(m1);
+ // temporary solution: the covariance matrix of the resulting combined object
+ // is set equal to the covariance matrix of the right operand
+ // (not to be used for combining alignment objects for different levels)
+ for(Int_t i=0; i<6; i++) fDiag[i] = theAlignObj.fDiag[i];
+ for(Int_t i=0; i<15; i++) fODia[i] = theAlignObj.fODia[i];
return *this;
}
}
//_____________________________________________________________________________
-void AliAlignObj::SetVolUID(ELayerID detId, Int_t modId)
+void AliAlignObj::SetVolUID(AliGeomManager::ELayerID detId, Int_t modId)
{
// 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).
//
- fVolUID = LayerToVolUID(detId,modId);
+ fVolUID = AliGeomManager::LayerToVolUID(detId,modId);
}
//_____________________________________________________________________________
-void AliAlignObj::GetVolUID(ELayerID &layerId, Int_t &modId) const
+void AliAlignObj::GetVolUID(AliGeomManager::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);
+ layerId = AliGeomManager::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 open: 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 pathStr = path;
+ if(pathStr[0]!='/') pathStr.Prepend('/');
+ return pathStr.CountChar('/');
}
//_____________________________________________________________________________
// 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)
return ((level > level2) ? 1 : -1);
}
+//______________________________________________________________________________
+void AliAlignObj::GetCovMatrix(Double_t *cmat) const
+{
+ // Fills the cmat argument with the coefficients of the external cov matrix (21 elements)
+ // calculating them from the correlation matrix data member
+ //
+
+ for(Int_t i=0; i<6; ++i) {
+ // Off diagonal elements
+ for(Int_t j=0; j<i; ++j) {
+ cmat[i*(i+1)/2+j] = (fDiag[j] >= 0. && fDiag[i] >= 0.) ? fODia[(i-1)*i/2+j]*fDiag[j]*fDiag[i]: -999.;
+ }
+
+ // Diagonal elements
+ cmat[i*(i+1)/2+i] = (fDiag[i] >= 0.) ? fDiag[i]*fDiag[i] : -999.;
+ }
+
+ return;
+}
+
+//______________________________________________________________________________
+void AliAlignObj::GetCovMatrix(TMatrixDSym& mcov) const
+{
+ // Fills the matrix m passed as argument as the covariance matrix calculated
+ // from the coefficients of the reduced covariance matrix data members
+ //
+
+ for(Int_t i=0; i<6; ++i) {
+ // Off diagonal elements
+ for(Int_t j=0; j<i; ++j) {
+ mcov(j,i) = mcov(i,j) = (fDiag[j] >= 0. && fDiag[i] >= 0.) ? fODia[(i-1)*i/2+j]*fDiag[j]*fDiag[i]: -999.;
+ }
+
+ // Diagonal elements
+ mcov(i,i) = (fDiag[i] >= 0.) ? fDiag[i]*fDiag[i] : -999.;
+ }
+
+}
+
+//______________________________________________________________________________
+Bool_t AliAlignObj::GetLocalCovMatrix(TMatrixDSym& lCov) const
+{
+ // Calculates the covariance matrix (6x6) associated to the six parameters
+ // defining the current alignment in the global coordinates system (and sets
+ // in the internal data members) from the covariance matrix (6x6) for the six
+ // parameters defining the alignment transformation in the local coordinates
+ // system, passed as an argument.
+ //
+ TMatrixD mJ(6,6);// the jacobian of the transformation from local to global parameters
+ if(!GetJacobian(mJ)) return kFALSE;
+
+ TMatrixDSym gCov(6);
+ GetCovMatrix(gCov);
+
+ // Compute the local covariance matrix lcov = mJ^T gcov mJ
+ TMatrixD gcovJ(gCov,TMatrixD::kMult,mJ);
+ TMatrixD lCovM(mJ,TMatrixD::kTransposeMult,gcovJ);
+ // To be done: somehow check that lCovM is close enough to be symmetric
+ for(Int_t i=0; i<6; i++)
+ {
+ lCov(i,i) = lCovM(i,i);
+ for(Int_t j=i+1; j<6; j++)
+ {
+ lCov(i,j)=lCovM(i,j);
+ lCov(j,i)=lCovM(i,j);
+ }
+ }
+
+ return kTRUE;
+
+}
+
+//______________________________________________________________________________
+Bool_t AliAlignObj::GetLocalCovMatrix(Double_t *lCov) const
+{
+ // Calculates the covariance matrix (6x6) associated to the six parameters
+ // defining the current alignment in the global coordinates system (and sets
+ // in the internal data members) from the covariance matrix (6x6) for the six
+ // parameters defining the alignment transformation in the local coordinates
+ // system, passed as an argument.
+ //
+ TMatrixDSym lCovMatrix(6);
+ GetLocalCovMatrix(lCovMatrix);
+
+ Int_t k=0;
+ for(Int_t i=0; i<6; i++)
+ for(Int_t j=i; j<6; j++)
+ {
+ lCov[k++] = lCovMatrix(i,j);
+ }
+
+ return kTRUE;
+}
+
+//______________________________________________________________________________
+Bool_t AliAlignObj::GetJacobian(TMatrixD& mJ) const
+{
+ // Compute the jacobian J of the transformation of the six local to the six global delta parameters
+ //
+ // R00 R01 R02 | (R01Rk2 - R02Rk1)Tk (R02Rk0 - R00Rk2)Tk (R00Rk1 - R01Rk0)Tk
+ // R00 R01 R02 | (R11Rk2 - R12Rk1)Tk (R12Rk0 - R10Rk2)Tk (R10Rk1 - R11Rk0)Tk
+ // R00 R01 R02 | (R21Rk2 - R22Rk1)Tk (R22Rk0 - R20Rk2)Tk (R20Rk1 - R21Rk0)Tk
+ // - - - - - - - - - - - - - - - - - - - - - - -
+ // 0 0 0 | R11R22 - R12R21 R12R20 - R10R22 R10R21 - R11R20
+ // 0 0 0 | R21R02 - R22R01 R22R00 - R20R02 R20R01 - R21R00
+ // 0 0 0 | R01R12 - R02R11 R02R10 - R00R12 R00R11 - R01R10
+ //
+ if (!gGeoManager || !gGeoManager->IsClosed()) {
+ AliError("Can't compute the global covariance matrix from the local one without an open geometry!");
+ return kFALSE;
+ }
+
+ const char* symname = GetSymName();
+ TGeoPhysicalNode* node;
+ TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
+ if(pne){
+ if(!pne->GetPhysicalNode()){
+ node = gGeoManager->MakeAlignablePN(pne);
+ }else{
+ node = pne->GetPhysicalNode();
+ }
+ }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;
+ }
+
+ TGeoHMatrix gm; //global matrix
+ gm = *node->GetMatrix();
+ Double_t *tr = gm.GetTranslation();
+ Double_t *rot = gm.GetRotationMatrix();
+
+ TGeoHMatrix m; // global delta transformation matrix
+ GetMatrix(m);
+ // We should probably check that it's sufficinetly close to identity
+ // if it's not return because the "small angles" approximation cannot hold
+
+ // 3x3 upper left part (global shifts derived w.r.t. local shifts)
+ for(Int_t i=0; i<3; i++)
+ {
+ for(Int_t j=0; j<3; j++)
+ {
+ mJ(i,j) = rot[i+3*j];
+ }
+ }
+
+ // 3x3 lower left part (global angles derived w.r.t. local shifts)
+ for(Int_t i=0; i<3; i++)
+ {
+ for(Int_t j=0; j<3; j++)
+ {
+ mJ(i+3,j) = 0.;
+ }
+ }
+
+ // 3x3 upper right part (global shifts derived w.r.t. local angles)
+ for(Int_t i=0; i<3; i++)
+ {
+ for(Int_t j=0; j<3; j++)
+ {
+ Double_t mEl = 0.;
+ Int_t b = (j+1)%3;
+ Int_t d = (j+2)%3;
+ for(Int_t k=0; k<3; k++)
+ {
+ mEl += (rot[3*i+b]*rot[3*k+d])*tr[k]-(rot[3*i+d]*rot[3*k+b])*tr[k];
+ }
+ mJ(i,j+3) = mEl;
+ }
+ }
+
+ // 3x3 lower right part (global angles derived w.r.t. local angles)
+ for(Int_t i=0; i<3; i++)
+ for(Int_t j=0; j<3; j++)
+ {
+ Int_t a = (i+1)%3;
+ Int_t b = (j+1)%3;
+ Int_t c = (i+2)%3;
+ Int_t d = (j+2)%3;
+ mJ(i+3,j+3) = rot[3*a+b]*rot[3*c+d]-rot[3*a+d]*rot[3*c+b];
+ }
+
+ return kTRUE;
+
+}
+
+//______________________________________________________________________________
+Bool_t AliAlignObj::SetFromLocalCov(TMatrixDSym& lCov)
+{
+ // Calculates the covariance matrix (6x6) associated to the six parameters
+ // defining the current alignment in the global coordinates system (and sets
+ // in the internal data members) from the covariance matrix (6x6) for the six
+ // parameters defining the alignment transformation in the local coordinates
+ // system, passed as an argument.
+ //
+ TMatrixD mJ(6,6);// the jacobian of the transformation from local to global parameters
+ if(!GetJacobian(mJ)) return kFALSE;
+
+ // Compute the global covariance matrix gcov = mJ lcov mJ'
+ TMatrixD trJ(TMatrixD::kTransposed, mJ);
+ TMatrixD lcovTrJ(lCov,TMatrixD::kMult,trJ);
+ TMatrixD gCovM(mJ,TMatrixD::kMult,lcovTrJ);
+ // To be done: somehow check that gCovM is close enough to be symmetric
+ TMatrixDSym gCov(6);
+ for(Int_t i=0; i<6; i++)
+ {
+ gCov(i,i) = gCovM(i,i);
+ for(Int_t j=i+1; j<6; j++)
+ {
+ gCov(i,j)=gCovM(i,j);
+ gCov(j,i)=gCovM(i,j);
+ }
+ }
+ SetCorrMatrix(gCov);
+
+ return kTRUE;
+
+}
+
+//______________________________________________________________________________
+Bool_t AliAlignObj::SetFromLocalCov(Double_t *lCov)
+{
+ // Calculates the covariance matrix (6x6) associated to the six parameters
+ // defining the current alignment in the global coordinates system, and sets
+ // in the internal data members, from the 21 coefficients, passed as argument,
+ // of the covariance matrix (6x6) for the six parameters defining the
+ // alignment transformation in the local coordinates system.
+ //
+ TMatrixDSym lCovMatrix(6);
+
+ Int_t k=0;
+ for(Int_t i=0; i<6; i++)
+ for(Int_t j=i; j<6; j++)
+ {
+ lCovMatrix(i,j) = lCov[k++];
+ if(j!=i) lCovMatrix(j,i) = lCovMatrix(i,j);
+ }
+
+ return SetFromLocalCov(lCovMatrix);
+
+}
+
+
+//______________________________________________________________________________
+void AliAlignObj::SetCorrMatrix(Double_t *cmat)
+{
+ // Sets the correlation matrix data member from the coefficients of the external covariance
+ // matrix (21 elements passed as argument).
+ //
+ if(cmat) {
+
+ // Diagonal elements first
+ for(Int_t i=0; i<6; ++i) {
+ fDiag[i] = (cmat[i*(i+1)/2+i] >= 0.) ? TMath::Sqrt(cmat[i*(i+1)/2+i]) : -999.;
+ }
+
+ // ... then the ones off diagonal
+ for(Int_t i=0; i<6; ++i)
+ // Off diagonal elements
+ for(Int_t j=0; j<i; ++j) {
+ 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).
+ if (fODia[(i-1)*i/2+j]>1.) fODia[(i-1)*i/2+j] = 1.; // check upper boundary
+ if (fODia[(i-1)*i/2+j]<-1.) fODia[(i-1)*i/2+j] = -1.; // check lower boundary
+ }
+ } else {
+ for(Int_t i=0; i< 6; ++i) fDiag[i]=-999.;
+ for(Int_t i=0; i< 6*(6-1)/2; ++i) fODia[i]=0.;
+ }
+
+ return;
+}
+
+//______________________________________________________________________________
+void AliAlignObj::SetCorrMatrix(TMatrixDSym& mcov)
+{
+ // Sets the correlation matrix data member from the covariance matrix mcov passed
+ // passed as argument.
+ //
+ if(mcov.IsValid()) {
+
+ // Diagonal elements first
+ for(Int_t i=0; i<6; ++i) {
+ fDiag[i] = (mcov(i,i) >= 0.) ? TMath::Sqrt(mcov(i,i)) : -999.;
+ }
+
+ // ... then the ones off diagonal
+ for(Int_t i=0; i<6; ++i)
+ // Off diagonal elements
+ for(Int_t j=0; j<i; ++j) {
+ fODia[(i-1)*i/2+j] = (fDiag[i] > 0. && fDiag[j] > 0.) ? mcov(i,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).
+ if (fODia[(i-1)*i/2+j]>1.) fODia[(i-1)*i/2+j] = 1.; // check upper boundary
+ if (fODia[(i-1)*i/2+j]<-1.) fODia[(i-1)*i/2+j] = -1.; // check lower boundary
+ }
+ } else {
+ for(Int_t i=0; i< 6; ++i) fDiag[i]=-999.;
+ for(Int_t i=0; i< 6*(6-1)/2; ++i) fODia[i]=0.;
+ }
+
+ return;
+}
+
//_____________________________________________________________________________
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]);
{
// 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]);
}
//______________________________________________________________________________
-void AliAlignObj::Transform(AliTrackPoint &p) const
+void AliAlignObj::Transform(AliTrackPoint &p, Bool_t copycov) const
{
// The method transforms the space-point coordinates using the
// transformation matrix provided by the AliAlignObj
- // The covariance matrix is not affected since we assume
- // that the transformations are sufficiently small
-
+ // In case the copycov flag is set to kTRUE, the covariance matrix
+ // of the alignment object is copied into the space-point
+ //
if (fVolUID != p.GetVolumeID())
AliWarning(Form("Alignment object ID is not equal to the space-point ID (%d != %d)",fVolUID,p.GetVolumeID()));
xyzin[1]*rot[3*i+1]+
xyzin[2]*rot[3*i+2];
p.SetXYZ(xyzout);
+
+ if(copycov){
+ TMatrixDSym covmat(6);
+ GetCovMatrix(covmat);
+ p.SetAlignCovMatrix(covmat);
+ }
}
{
// 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);
// Print the contents of the
// alignment object in angles and
// matrix representations
+ //
Double_t tr[3];
GetTranslation(tr);
Double_t angles[3];
GetMatrix(m);
const Double_t *rot = m.GetRotationMatrix();
- printf("Volume=%s\n",GetVolPath());
+ printf("Volume=%s\n",GetSymName());
if (GetVolUID() != 0) {
- ELayerID layerId;
+ AliGeomManager::ELayerID layerId;
Int_t modId;
GetVolUID(layerId,modId);
- printf("VolumeID=%d LayerID=%d ( %s ) ModuleID=%d\n", GetVolUID(),layerId,LayerName(layerId),modId);
+ printf("VolumeID=%d LayerID=%d ( %s ) ModuleID=%d\n", GetVolUID(),layerId,AliGeomManager::LayerName(layerId),modId);
}
printf("%12.8f%12.8f%12.8f Tx = %12.8f Psi = %12.8f\n", rot[0], rot[1], rot[2], tr[0], angles[0]);
printf("%12.8f%12.8f%12.8f Ty = %12.8f Theta = %12.8f\n", rot[3], rot[4], rot[5], tr[1], angles[1]);
}
//_____________________________________________________________________________
-Int_t AliAlignObj::LayerSize(Int_t layerId)
+void AliAlignObj::SetPars(Double_t x, Double_t y, Double_t z,
+ Double_t psi, Double_t theta, Double_t phi)
{
- // Get the corresponding layer size.
- // Implemented only for ITS,TPC,TRD,TOF and RICH
- if (layerId < kFirstLayer || layerId >= kLastLayer) {
- AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
- return 0;
- }
- else {
- return fgLayerSize[layerId - kFirstLayer];
- }
-}
-
-//_____________________________________________________________________________
-const char* AliAlignObj::LayerName(Int_t layerId)
-{
- // Get the corresponding layer name.
- // Implemented only for ITS,TPC,TRD,TOF and RICH
- if (layerId < kFirstLayer || layerId >= kLastLayer) {
- AliErrorClass(Form("Invalid layer index %d ! Layer range is (%d -> %d) !",layerId,kFirstLayer,kLastLayer));
- return "Invalid Layer!";
- }
- else {
- return fgLayerName[layerId - kFirstLayer];
- }
+ // 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);
}
//_____________________________________________________________________________
-UShort_t AliAlignObj::LayerToVolUID(ELayerID layerId, Int_t modId)
+Bool_t AliAlignObj::SetLocalPars(Double_t x, Double_t y, Double_t z,
+ Double_t psi, Double_t theta, Double_t phi)
{
- // 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).
+ // 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.
//
- return ((UShort_t(layerId) << 11) | UShort_t(modId));
-}
+ 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);
-//_____________________________________________________________________________
-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
- // fVolUID is 16 bits, first 5 reserved for layerID (32 possible values),
- // remaining 11 for module ID inside det (2048 possible values).
- //
- return ((UShort_t(layerId) << 11) | UShort_t(modId));
}
//_____________________________________________________________________________
-AliAlignObj::ELayerID AliAlignObj::VolUIDToLayer(UShort_t voluid, Int_t &modId)
+Bool_t AliAlignObj::SetLocalTranslation(Double_t x, Double_t y, Double_t z)
{
- // 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).
+ // 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.
//
- modId = voluid & 0x7ff;
+ TGeoHMatrix m;
+ Double_t tr[3] = {x, y, z};
+ m.SetTranslation(tr);
+
+ return SetLocalMatrix(m);
- return VolUIDToLayer(voluid);
}
//_____________________________________________________________________________
-AliAlignObj::ELayerID AliAlignObj::VolUIDToLayer(UShort_t voluid)
+Bool_t AliAlignObj::SetLocalTranslation(const TGeoMatrix& m)
{
- // 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).
+ // 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.
//
- return ELayerID((voluid >> 11) & 0x1f);
+ const Double_t* tr = m.GetTranslation();
+ TGeoHMatrix mtr;
+ mtr.SetTranslation(tr);
+
+ return SetLocalMatrix(mtr);
+
}
//_____________________________________________________________________________
-Bool_t AliAlignObj::SetLocalPars(Double_t x, Double_t y, Double_t z,
- Double_t psi, Double_t theta, Double_t phi)
+Bool_t AliAlignObj::SetLocalRotation(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.
- 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);
- if (!node) {
- AliError(Form("Volume path %s not valid!",volpath));
- return kFALSE;
- }
- if (node->IsAligned())
- AliWarning(Form("Volume %s has been already misaligned!",volpath));
-
+ // 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 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 align,gprime,gprimeinv;
- gprime = *node->GetMatrix();
- gprimeinv = gprime.Inverse();
- m.Multiply(&gprimeinv);
- m.MultiplyLeft(&gprime);
-
- SetMatrix(m);
+ return SetLocalMatrix(m);
- return kTRUE;
}
//_____________________________________________________________________________
-Bool_t AliAlignObj::ApplyToGeometry()
+Bool_t AliAlignObj::SetLocalRotation(const TGeoMatrix& m)
{
- // Apply the current alignment object
- // to the TGeo geometry
-
- if (!gGeoManager || !gGeoManager->IsClosed()) {
- AliError("Can't apply the alignment object! 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));
- return kFALSE;
- }
+ // 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);
- if (!gGeoManager->cd(volpath)) {
- AliError(Form("Volume path %s not valid!",volpath));
- return kFALSE;
- }
+ return SetLocalMatrix(rotm);
- TGeoPhysicalNode* node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(volpath);
- if (!node) {
- AliError(Form("Volume path %s not valid!",volpath));
- return kFALSE;
- }
-
- TGeoHMatrix align,gprime;
- gprime = *node->GetMatrix();
- GetMatrix(align);
- gprime.MultiplyLeft(&align);
- TGeoHMatrix *ginv = new TGeoHMatrix;
- 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
- GetVolUID(layerId, modId);
- AliDebug(2,Form("Aligning volume %s of detector layer %d with local ID %d",volpath,layerId,modId));
- node->Align(ginv);
-
- return kTRUE;
}
//_____________________________________________________________________________
-Bool_t AliAlignObj::GetFromGeometry(const char *path, AliAlignObj &alobj)
+Bool_t AliAlignObj::SetLocalMatrix(const TGeoMatrix& m)
{
- // 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!!
-
- // Reset the alignment object
- alobj.SetPars(0,0,0,0,0,0);
- alobj.SetVolPath(path);
-
+ // 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()) {
- AliErrorClass("Can't get the alignment object! gGeoManager doesn't exist or it is still opened!");
+ AliError("Can't set the local alignment object parameters! gGeoManager doesn't exist or it is still open!");
return kFALSE;
}
- if (!gGeoManager->GetListOfPhysicalNodes()) {
- AliErrorClass("Can't get the alignment object! gGeoManager doesn't contain any aligned nodes!");
- return kFALSE;
+ const char* symname = GetSymName();
+ TGeoPhysicalNode* node;
+ TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
+ if(pne){
+ if(!pne->GetPhysicalNode()){
+ node = gGeoManager->MakeAlignablePN(pne);
+ }else{
+ node = pne->GetPhysicalNode();
+ }
+ }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);
}
- 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;
- }
if (!node) {
- if (!gGeoManager->cd(path)) {
- AliErrorClass(Form("Volume path %s not found!",path));
- return kFALSE;
- }
- else {
- AliWarningClass(Form("Volume (%s) has not been misaligned!",path));
- return kTRUE;
- }
+ AliError(Form("Volume name or path %s not valid!",symname));
+ return kFALSE;
}
+ if (node->IsAligned())
+ AliWarning(Form("Volume %s has been already misaligned!",symname));
- TGeoHMatrix align,gprime,g,ginv,l;
+ 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();
- l = *node->GetOriginalMatrix();
- g = *node->GetMatrix(node->GetLevel()-1);
- g *= l;
- ginv = g.Inverse();
- align = gprime * ginv;
- alobj.SetMatrix(align);
+ gprimeinv = gprime.Inverse();
+ m1.Multiply(&gprimeinv);
+ m1.MultiplyLeft(&gprime);
- return kTRUE;
+ return SetMatrix(m1);
}
//_____________________________________________________________________________
-void AliAlignObj::InitAlignObjFromGeometry()
+Bool_t AliAlignObj::SetMatrix(const TGeoMatrix& m)
{
- // Loop over all alignable volumes and extract
- // the corresponding alignment objects from
- // the TGeo geometry
-
- if(fgAlignObjs[0]) return;
-
- InitVolPaths();
-
- 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));
- }
- }
-
-}
-
-//_____________________________________________________________________________
-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);
+ // Set the global delta transformation by passing the TGeoMatrix
+ // for it
+ //
+ SetTranslation(m);
+ return SetRotation(m);
}
//_____________________________________________________________________________
-AliAlignObj* AliAlignObj::GetAlignObj(ELayerID layerId, Int_t modId)
+Bool_t AliAlignObj::GetLocalPars(Double_t transl[], Double_t angles[]) const
{
- // Returns pointer to alignment object givent 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;
- }
- return fgAlignObjs[layerId-kFirstLayer][modId];
+ // 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);
}
//_____________________________________________________________________________
-const char* AliAlignObj::GetVolPath(UShort_t voluid) {
- // Returns the volume path for given volume ID
- Int_t modId;
- ELayerID layerId = VolUIDToLayer(voluid,modId);
- return GetVolPath(layerId,modId);
+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;
}
//_____________________________________________________________________________
-const char* AliAlignObj::GetVolPath(ELayerID layerId, Int_t modId)
+Bool_t AliAlignObj::GetLocalAngles(Double_t* angles) const
{
- // Returns volume path to alignment object givent 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;
- }
- return fgVolPath[layerId-kFirstLayer][modId].Data();
+ // 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);
}
//_____________________________________________________________________________
-void AliAlignObj::InitVolPaths()
+Bool_t AliAlignObj::GetLocalMatrix(TGeoHMatrix& m) const
{
- // 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
-
- if (fgVolPath[0]) return;
-
- for (Int_t iLayer = 0; iLayer < (kLastLayer - kFirstLayer); iLayer++)
- fgVolPath[iLayer] = new TString[fgLayerSize[iLayer]];
-
- /********************* 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;
-
- for(Int_t c1 = 1; c1<=10; c1++){
- volpath = str0;
- volpath += c1;
- volpath += str1;
- for(Int_t c2 =1; c2<=2; c2++){
- volpath1 = volpath;
- volpath1 += c2;
- volpath1 += str2;
- for(Int_t c3 =1; c3<=4; c3++){
- volpath2 = volpath1;
- volpath2 += c3;
- // volpath2 += str3;
- fgVolPath[kSPD1-kFirstLayer][modnum] = volpath2.Data();
- modnum++;
- }
- }
- }
- }
-
- /********************* 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;
-
- for(Int_t c1 = 1; c1<=10; c1++){
- volpath = str0;
- volpath += c1;
- volpath += str1;
- for(Int_t c2 =1; c2<=4; c2++){
- volpath1 = volpath;
- volpath1 += c2;
- volpath1 += str2;
- for(Int_t c3 =1; c3<=4; c3++){
- volpath2 = volpath1;
- volpath2 += c3;
- // volpath2 += str3;
- fgVolPath[kSPD2-kFirstLayer][modnum] = volpath2.Data();
- modnum++;
- }
- }
- }
+ // 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 get the local alignment object parameters! gGeoManager doesn't exist or it is still open!");
+ return kFALSE;
}
- /********************* 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;
-
- for(Int_t c1 = 1; c1<=14; c1++){
- volpath = str0;
- volpath += c1;
- volpath += str1;
- for(Int_t c2 =1; c2<=6; c2++){
- volpath1 = volpath;
- volpath1 += c2;
- // volpath1 += str2;
- fgVolPath[kSDD1-kFirstLayer][modnum] = volpath1.Data();
- modnum++;
- }
+ const char* symname = GetSymName();
+ TGeoPhysicalNode* node;
+ TGeoPNEntry* pne = gGeoManager->GetAlignableEntry(symname);
+ if(pne){
+ if(!pne->GetPhysicalNode()){
+ node = gGeoManager->MakeAlignablePN(pne);
+ }else{
+ node = pne->GetPhysicalNode();
}
+ }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);
}
- /********************* 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;
-
- for(Int_t c1 = 1; c1<=22; c1++){
- volpath = str0;
- volpath += c1;
- volpath += str1;
- for(Int_t c2 = 1; c2<=8; c2++){
- volpath1 = volpath;
- volpath1 += c2;
- // volpath1 += str2;
- fgVolPath[kSDD2-kFirstLayer][modnum] = volpath1.Data();
- modnum++;
- }
- }
+ 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));
- /********************* 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;
-
- for(Int_t c1 = 1; c1<=34; c1++){
- volpath = str0;
- volpath += c1;
- volpath += str1;
- for(Int_t c2 = 1; c2<=22; c2++){
- volpath1 = volpath;
- volpath1 += c2;
- // volpath1 += str2;
- fgVolPath[kSSD1-kFirstLayer][modnum] = volpath1.Data();
- modnum++;
- }
- }
- }
+ GetMatrix(m);
+ TGeoHMatrix gprime,gprimeinv;
+ gprime = *node->GetMatrix();
+ gprimeinv = gprime.Inverse();
+ m.Multiply(&gprime);
+ m.MultiplyLeft(&gprimeinv);
- /********************* SSD layer1 ***********************/
- {
- 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;
-
- for(Int_t c1 = 1; c1<=38; c1++){
- volpath = str0;
- volpath += c1;
- volpath += str1;
- for(Int_t c2 = 1; c2<=25; c2++){
- volpath1 = volpath;
- volpath1 += c2;
- // volpath1 += str2;
- fgVolPath[kSSD2-kFirstLayer][modnum] = volpath1.Data();
- modnum++;
- }
- }
+ return kTRUE;
+}
+
+//_____________________________________________________________________________
+Bool_t AliAlignObj::ApplyToGeometry(Bool_t ovlpcheck)
+{
+ // 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 open!");
+ return kFALSE;
}
- /*************** 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;
-
- for(Int_t cnt=1; cnt<=18; cnt++){
- volpath = str1;
- volpath += cnt;
- volpath += strIn;
- fgVolPath[kTPC1-kFirstLayer][modnum] = volpath.Data();
- modnum++;
- }
- for(Int_t cnt=1; cnt<=18; cnt++){
- volpath = str2;
- volpath += cnt;
- volpath += strIn;
- fgVolPath[kTPC1-kFirstLayer][modnum] = volpath.Data();
- modnum++;
- }
+ if (gGeoManager->IsLocked()){
+ AliError("Can't apply the alignment object! Geometry is locked!");
+ return kFALSE;
}
- /*************** 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;
-
- for(Int_t cnt=1; cnt<=18; cnt++){
- volpath = str1;
- volpath += cnt;
- volpath += strOut;
- fgVolPath[kTPC2-kFirstLayer][modnum] = volpath.Data();
- modnum++;
- }
- for(Int_t cnt=1; cnt<=18; cnt++){
- volpath = str2;
- volpath += cnt;
- volpath += strOut;
- fgVolPath[kTPC2-kFirstLayer][modnum] = volpath.Data();
- modnum++;
+ 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;
}
- }
-
- /********************* TOF layer ***********************/
- {
- 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;
+ if (gGeoManager->GetListOfPhysicalNodes()->FindObject(path)) {
+ AliError(Form("Volume %s has already been misaligned!",path));
+ return kFALSE;
}
- }
-
- /********************* RICH layer ***********************/
- {
- TString str = "ALIC_1/RICH_";
- TString volpath;
+ node = (TGeoPhysicalNode*) gGeoManager->MakePhysicalNode(path);
+ }
- for (Int_t modnum=0; modnum < 7; modnum++) {
- volpath = str;
- volpath += (modnum+1);
- fgVolPath[kRICH-kFirstLayer][modnum] = volpath.Data();
- }
+ if (!node) {
+ AliError(Form("Volume path %s not valid!",path));
+ return kFALSE;
}
- /********************* TRD layers 0-6 *******************/
+ // Double_t threshold = 0.001;
+
+ TGeoHMatrix align,gprime;
+ gprime = *node->GetMatrix();
+ GetMatrix(align);
+ gprime.MultiplyLeft(&align);
+ TGeoHMatrix *ginv = new TGeoHMatrix;
+ TGeoHMatrix *g = node->GetMatrix(node->GetLevel()-1);
+ *ginv = g->Inverse();
+ *ginv *= gprime;
+ AliGeomManager::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",symname,layerId,modId));
+ if(ovlpcheck){
+ node->Align(ginv,0,kTRUE); //(trunk of root takes threshold as additional argument)
+ }else{
+ node->Align(ginv,0,kFALSE);
+ }
+ if(ovlpcheck)
{
- 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};
-
- 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++;
- }
- }
+ TObjArray* ovlpArray = gGeoManager->GetListOfOverlaps();
+ Int_t nOvlp = ovlpArray->GetEntriesFast();
+ if(nOvlp)
+ {
+ AliInfo(Form("Misalignment of node %s generated the following overlaps/extrusions:",node->GetName()));
+ for(Int_t i=0; i<nOvlp; i++)
+ ((TGeoOverlap*)ovlpArray->UncheckedAt(i))->PrintInfo();
}
}
-
+
+ return kTRUE;
}
+
+