ROOT logo
#ifndef ALIALIGNOBJ_H
#define ALIALIGNOBJ_H

//************************************************************************
// AliAlignObj: alignment base class for the storage of the alignment    *
//   constants for a single volume:                                      *
//   -  a displacement (a shift and a rotation) either as                *
//      - the 6 doubles which identify it or as                          *
//      - the matrix which identifies it                                 *
//   -  the identity of the volume itself in form of a symbolic volume   *
//      name for alignable volumes, in form of a TGeo path otherwise,    *
//      and as a unique integer identifier                               *
//************************************************************************
#include <TObject.h>
#include <TString.h>
#include <Rtypes.h>
#include "AliGeomManager.h"
#include <TMatrixD.h>
#include <TMatrixDSym.h>


class AliTrackPoint;
class AliTrackPointArray;
class TGeoMatrix;

class AliAlignObj : public TObject {

 public:

  AliAlignObj();
  AliAlignObj(const char* symname, UShort_t voluid);
  AliAlignObj(const char* symname, UShort_t voluid, Double_t* cmat);
  AliAlignObj(const char* symname, AliGeomManager::ELayerID detId, Int_t modId);
  AliAlignObj(const AliAlignObj& theAlignObj);
  AliAlignObj& operator= (const AliAlignObj& theAlignObj);
  AliAlignObj& operator*=(const AliAlignObj& theAlignObj);
  virtual ~AliAlignObj();

  //Setters
  virtual void SetTranslation(Double_t x, Double_t y, Double_t z) = 0;
  virtual void SetTranslation(const TGeoMatrix& m) = 0;
  virtual Bool_t SetLocalTranslation(Double_t x, Double_t y, Double_t z);
  virtual Bool_t SetLocalTranslation(const TGeoMatrix& m);
  virtual void SetRotation(Double_t psi, Double_t theta, Double_t phi) = 0;
  virtual Bool_t SetRotation(const TGeoMatrix& m) = 0;
  virtual Bool_t SetLocalRotation(Double_t psi, Double_t theta, Double_t phi);
  virtual Bool_t SetLocalRotation(const TGeoMatrix& m);
  virtual void SetPars(Double_t x, Double_t y, Double_t z, Double_t psi,
               Double_t theta, Double_t phi);
  virtual Bool_t SetLocalPars(Double_t x, Double_t y, Double_t z,
			      Double_t psi, Double_t theta, Double_t phi);
  virtual Bool_t SetMatrix(const TGeoMatrix& m);
  virtual Bool_t SetLocalMatrix(const TGeoMatrix& m);
  void  SetSymName(const TString& symname) {fVolPath=symname;}
  void  SetVolUID(UShort_t voluid) {fVolUID=voluid;}
  void  SetVolUID(AliGeomManager::ELayerID layerId, Int_t modId);
  void  SetCorrMatrix(Double_t *cov);
  void  SetCorrMatrix(TMatrixDSym& mcov);
  Bool_t SetFromLocalCov(Double_t *lCov);
  Bool_t SetFromLocalCov(TMatrixDSym& lCov);

  //Getters
  const char  *GetSymName()    const {return fVolPath.Data();}
  UShort_t     GetVolUID()     const {return fVolUID;}
  void         GetVolUID(AliGeomManager::ELayerID &layerId, Int_t &modId) const;
  virtual void GetTranslation(Double_t* tr)  const=0;
  virtual Bool_t GetLocalTranslation(Double_t* tr) const;
  virtual Bool_t GetAngles(Double_t* angles) const=0;
  virtual Bool_t GetLocalAngles(Double_t* angles) const;
  virtual Bool_t GetPars(Double_t transl[], Double_t angles[]) const;
  virtual Bool_t GetLocalPars(Double_t transl[], Double_t angles[]) const;
  virtual void GetMatrix(TGeoHMatrix& m) const=0;
  virtual Bool_t GetLocalMatrix(TGeoHMatrix& m) const;
  void  GetCovMatrix(Double_t *cov) const;
  void  GetCovMatrix(TMatrixDSym& mcov) const;
  Bool_t  GetJacobian(TMatrixD& mJ) const;
  Bool_t  GetLocalCovMatrix(Double_t *cov) const;
  Bool_t  GetLocalCovMatrix(TMatrixDSym& lCov) const;

  Bool_t   IsSortable() const {return kTRUE;}
  Int_t         GetLevel() const;
  virtual Int_t Compare(const TObject* obj) const;

  virtual AliAlignObj& Inverse() const=0;

  void  Transform(AliTrackPoint &p, Bool_t copycov=kFALSE) const;
  void  Transform(AliTrackPointArray &array) const;

  void  Print(Option_t *) const;

  static Int_t       LayerSize(Int_t layerId) {return AliGeomManager::LayerSize(layerId);}
  static const char* LayerName(Int_t layerId) {return AliGeomManager::LayerName(layerId);}

  static UShort_t LayerToVolUID(AliGeomManager::ELayerID layerId, Int_t modId) {return AliGeomManager::LayerToVolUID(layerId, modId);}
  static UShort_t LayerToVolUID(Int_t layerId, Int_t modId) {return AliGeomManager::LayerToVolUID(layerId, modId);}
  static AliGeomManager::ELayerID VolUIDToLayer(UShort_t voluid, Int_t &modId) {return AliGeomManager::VolUIDToLayer(voluid, modId);}
  static AliGeomManager::ELayerID VolUIDToLayer(UShort_t voluid) {return AliGeomManager::VolUIDToLayer(voluid);}
  static UShort_t LayerToVolUIDSafe(AliGeomManager::ELayerID layerId, Int_t modId) {return AliGeomManager::LayerToVolUIDSafe(layerId, modId);}
  static UShort_t LayerToVolUIDSafe(Int_t layerId, Int_t modId) {return AliGeomManager::LayerToVolUIDSafe(layerId, modId);}
  static AliGeomManager::ELayerID VolUIDToLayerSafe(UShort_t voluid, Int_t &modId) {return AliGeomManager::VolUIDToLayerSafe(voluid, modId);}
  static AliGeomManager::ELayerID VolUIDToLayerSafe(UShort_t voluid) {return AliGeomManager::VolUIDToLayerSafe(voluid);}

  static const char* SymName(UShort_t voluid) {return AliGeomManager::SymName(voluid);}
  static const char* SymName(AliGeomManager::ELayerID layerId, Int_t modId) {return AliGeomManager::SymName(layerId, modId);}

  Bool_t ApplyToGeometry(Bool_t ovlpcheck=kFALSE);
  static Bool_t   GetFromGeometry(const char *symname, AliAlignObj &alobj) {return AliGeomManager::GetFromGeometry(symname, alobj);}

  static AliAlignObj* GetAlignObj(UShort_t voluid) {return AliGeomManager::GetAlignObj(voluid);}
  static AliAlignObj* GetAlignObj(AliGeomManager::ELayerID layerId, Int_t modId) {return AliGeomManager::GetAlignObj(layerId, modId);}

  static Bool_t   GetOrigGlobalMatrix(const char *symname, TGeoHMatrix &m) {return AliGeomManager::GetOrigGlobalMatrix(symname, m);}

 protected:

  void AnglesToMatrix(const Double_t *angles, Double_t *rot) const;
  Bool_t MatrixToAngles(const Double_t *rot, Double_t *angles) const;

  //Volume identifiers
  TString  fVolPath; // Symbolic volume name; in case could coincide with
      // the volume path inside TGeo geometry (for non-alignable volumes)
  UShort_t fVolUID;  // Unique volume ID

  Double32_t   fDiag[6];  // diagonal elements of the correlation matrix for shifts and rotations (dx,dy,dz,dpsi,dtheta,dphi)
  Double32_t   fODia[15]; // [-1, 1,8] off-diagonal elements (in 8 bit precision) of the correlation matrix
	
  ClassDef(AliAlignObj, 3)
};

#endif
 AliAlignObj.h:1
 AliAlignObj.h:2
 AliAlignObj.h:3
 AliAlignObj.h:4
 AliAlignObj.h:5
 AliAlignObj.h:6
 AliAlignObj.h:7
 AliAlignObj.h:8
 AliAlignObj.h:9
 AliAlignObj.h:10
 AliAlignObj.h:11
 AliAlignObj.h:12
 AliAlignObj.h:13
 AliAlignObj.h:14
 AliAlignObj.h:15
 AliAlignObj.h:16
 AliAlignObj.h:17
 AliAlignObj.h:18
 AliAlignObj.h:19
 AliAlignObj.h:20
 AliAlignObj.h:21
 AliAlignObj.h:22
 AliAlignObj.h:23
 AliAlignObj.h:24
 AliAlignObj.h:25
 AliAlignObj.h:26
 AliAlignObj.h:27
 AliAlignObj.h:28
 AliAlignObj.h:29
 AliAlignObj.h:30
 AliAlignObj.h:31
 AliAlignObj.h:32
 AliAlignObj.h:33
 AliAlignObj.h:34
 AliAlignObj.h:35
 AliAlignObj.h:36
 AliAlignObj.h:37
 AliAlignObj.h:38
 AliAlignObj.h:39
 AliAlignObj.h:40
 AliAlignObj.h:41
 AliAlignObj.h:42
 AliAlignObj.h:43
 AliAlignObj.h:44
 AliAlignObj.h:45
 AliAlignObj.h:46
 AliAlignObj.h:47
 AliAlignObj.h:48
 AliAlignObj.h:49
 AliAlignObj.h:50
 AliAlignObj.h:51
 AliAlignObj.h:52
 AliAlignObj.h:53
 AliAlignObj.h:54
 AliAlignObj.h:55
 AliAlignObj.h:56
 AliAlignObj.h:57
 AliAlignObj.h:58
 AliAlignObj.h:59
 AliAlignObj.h:60
 AliAlignObj.h:61
 AliAlignObj.h:62
 AliAlignObj.h:63
 AliAlignObj.h:64
 AliAlignObj.h:65
 AliAlignObj.h:66
 AliAlignObj.h:67
 AliAlignObj.h:68
 AliAlignObj.h:69
 AliAlignObj.h:70
 AliAlignObj.h:71
 AliAlignObj.h:72
 AliAlignObj.h:73
 AliAlignObj.h:74
 AliAlignObj.h:75
 AliAlignObj.h:76
 AliAlignObj.h:77
 AliAlignObj.h:78
 AliAlignObj.h:79
 AliAlignObj.h:80
 AliAlignObj.h:81
 AliAlignObj.h:82
 AliAlignObj.h:83
 AliAlignObj.h:84
 AliAlignObj.h:85
 AliAlignObj.h:86
 AliAlignObj.h:87
 AliAlignObj.h:88
 AliAlignObj.h:89
 AliAlignObj.h:90
 AliAlignObj.h:91
 AliAlignObj.h:92
 AliAlignObj.h:93
 AliAlignObj.h:94
 AliAlignObj.h:95
 AliAlignObj.h:96
 AliAlignObj.h:97
 AliAlignObj.h:98
 AliAlignObj.h:99
 AliAlignObj.h:100
 AliAlignObj.h:101
 AliAlignObj.h:102
 AliAlignObj.h:103
 AliAlignObj.h:104
 AliAlignObj.h:105
 AliAlignObj.h:106
 AliAlignObj.h:107
 AliAlignObj.h:108
 AliAlignObj.h:109
 AliAlignObj.h:110
 AliAlignObj.h:111
 AliAlignObj.h:112
 AliAlignObj.h:113
 AliAlignObj.h:114
 AliAlignObj.h:115
 AliAlignObj.h:116
 AliAlignObj.h:117
 AliAlignObj.h:118
 AliAlignObj.h:119
 AliAlignObj.h:120
 AliAlignObj.h:121
 AliAlignObj.h:122
 AliAlignObj.h:123
 AliAlignObj.h:124
 AliAlignObj.h:125
 AliAlignObj.h:126
 AliAlignObj.h:127
 AliAlignObj.h:128
 AliAlignObj.h:129
 AliAlignObj.h:130