#include "AliAlignObj.h"
#include "AliAlignObjAngles.h"
-//#include "AliLog.h"
ClassImp(AliAlignObjAngles)
}
//_____________________________________________________________________________
-AliAlignObjAngles::AliAlignObjAngles(const char* volpath, UShort_t voluid, Double_t x, Double_t y, Double_t z, Double_t psi, Double_t theta, Double_t phi) : AliAlignObj()
+AliAlignObjAngles::AliAlignObjAngles(const char* volpath, UShort_t volUId, Double_t x, Double_t y, Double_t z, Double_t psi, Double_t theta, Double_t phi, Bool_t global) throw (const Char_t *) : AliAlignObj(volpath,volUId)
{
// standard constructor with 3 translation + 3 rotation parameters
- //
- fVolPath=volpath;
- fVolUID=voluid;
- fTranslation[0]=x; fTranslation[1]=y; fTranslation[2]=z;
- fRotation[0]=psi; fRotation[1]=theta; fRotation[2]=phi;
-}
-
-//_____________________________________________________________________________
-AliAlignObjAngles::AliAlignObjAngles(const char* volpath, ELayerID detId, Int_t volId, Double_t x, Double_t y, Double_t z, Double_t psi, Double_t theta, Double_t phi) : AliAlignObj()
-{
- // standard constructor with 3 translation + 3 rotation parameters
- //
- fVolPath=volpath;
- SetVolUID(detId,volId);
- fTranslation[0]=x; fTranslation[1]=y; fTranslation[2]=z;
- fRotation[0]=psi; fRotation[1]=theta; fRotation[2]=phi;
+ // If the user explicitly sets the global variable to kFALSE then the
+ // parameters are interpreted as giving the local transformation.
+ // This requires to have a gGeoMenager active instance, otherwise the
+ // constructor will fail (no object created)
+ //
+ if(global){
+ SetPars(x, y, z, psi, theta, phi);
+ }else{
+ if(!SetLocalPars(x,y,z,psi,theta,phi)) throw "Alignment object creation failed (TGeo instance needed)!\n";
+ }
}
//_____________________________________________________________________________
-AliAlignObjAngles::AliAlignObjAngles(const char* volpath, UShort_t voluid, TGeoMatrix& m) : AliAlignObj()
+AliAlignObjAngles::AliAlignObjAngles(const char* volpath, UShort_t volUId, TGeoMatrix& m, Bool_t global) throw (const Char_t *) : AliAlignObj(volpath,volUId)
{
// standard constructor with TGeoMatrix
+ // If the user explicitly sets the global variable to kFALSE then the
+ // parameters are interpreted as giving the local transformation.
+ // This requires to have a gGeoMenager active instance, otherwise the
+ // constructor will fail (no object created)
//
- fVolPath=volpath;
- fVolUID=voluid;
- SetTranslation(m);
- SetRotation(m);
+
+ if (!SetMatrix(m)) throw "Alignment object creation failed (can't extract roll-pitch-yall angles from the matrix)!\n";
+
+ if (!global) {
+ if (!SetLocalPars(fTranslation[0],fTranslation[1],fTranslation[2],fRotation[0],fRotation[1],fRotation[2])) throw "Alignment object creation failed (TGeo instance needed)!\n";
+ }
}
//_____________________________________________________________________________
theAlignObj.GetTranslation(tr);
SetTranslation(tr[0],tr[1],tr[2]);
Double_t rot[3];
- theAlignObj.GetAngles(rot);
- SetRotation(rot[0],rot[1],rot[2]);
+ if (theAlignObj.GetAngles(rot))
+ SetRotation(rot[0],rot[1],rot[2]);
}
//_____________________________________________________________________________
theAlignObj.GetTranslation(tr);
SetTranslation(tr[0],tr[1],tr[2]);
Double_t rot[3];
- theAlignObj.GetAngles(rot);
- SetRotation(rot[0],rot[1],rot[2]);
+ if (theAlignObj.GetAngles(rot))
+ SetRotation(rot[0],rot[1],rot[2]);
+
return *this;
}
//_____________________________________________________________________________
void AliAlignObjAngles::SetTranslation(const TGeoMatrix& m)
{
+ // set the translation parameters extracting them from the matrix
+ // passed as argument
+ //
if(m.IsTranslation()){
const Double_t* tr = m.GetTranslation();
fTranslation[0]=tr[0]; fTranslation[1]=tr[1]; fTranslation[2]=tr[2];
}else{
-// AliWarning("Argument matrix is not a translation! Setting zero-translation.");
fTranslation[0] = fTranslation[1] = fTranslation[2] = 0.;
}
}
//_____________________________________________________________________________
Bool_t AliAlignObjAngles::SetRotation(const TGeoMatrix& m)
{
+ // set the rotation parameters extracting them from the matrix
+ // passed as argument
+ //
if(m.IsRotation()){
const Double_t* rot = m.GetRotationMatrix();
return MatrixToAngles(rot,fRotation);
}else{
-// AliWarning("Argument matrix is not a rotation! Setting yaw-pitch-roll to zero.");
fRotation[0] = fRotation[1] = fRotation[2] = 0.;
return kTRUE;
}
}
-//_____________________________________________________________________________
-void AliAlignObjAngles::SetMatrix(const TGeoMatrix& m)
-{
- SetTranslation(m);
- SetRotation(m);
-}
-
-//_____________________________________________________________________________
-void AliAlignObjAngles::GetPars(Double_t tr[], Double_t angles[]) const
-{
- GetTranslation(tr);
- GetAngles(angles);
-}
-
//_____________________________________________________________________________
void AliAlignObjAngles::GetMatrix(TGeoHMatrix& m) const
{
+ // get the transformation matrix from the data memebers parameters
m.SetTranslation(&fTranslation[0]);
Double_t rot[9];
AnglesToMatrix(fRotation,rot);
//_____________________________________________________________________________
AliAlignObj& AliAlignObjAngles::Inverse() const
{
- // Return a temporary inverse of the alignment
- // object. This means 'mis
+ // Return a temporary "inverse" of the alignment object, that is return
+ // an object with inverted transformation matrix.
+ //
static AliAlignObjAngles a;
a = *this;