+ // 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* 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));
+
+ 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();
+ m1.Multiply(&gprimeinv);
+ m1.MultiplyLeft(&gprime);
+
+ 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::GetLocalAngles(Double_t* angles) const
+{
+ // 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.