#ifndef ALITOFGEOMETRY_H
#define ALITOFGEOMETRY_H
#include "TGeoMatrix.h"
#include "TObject.h"
class AliTOFGeometry: public TObject{
public:
AliTOFGeometry();
virtual ~AliTOFGeometry();
static Int_t NStripA() { return kNStripA;};
static Int_t NStripB() { return kNStripB;};
static Int_t NStripC() { return kNStripC;};
static Int_t NStrip(Int_t nPlate);
static Int_t NMaxNstrip() { return kMaxNstrip;};
static Int_t NpadX() { return kNpadX;};
static Int_t NpadZ() { return kNpadZ;};
static Int_t NpadXStrip() { return kNpadX*kNpadZ;};
static Int_t NSectors() { return kNSectors;};
static Int_t NPlates() { return kNPlates;};
static Int_t NStripXSector() { return (kNStripA + 2*kNStripB +
2*kNStripC);};
static Int_t NPadXSector() { return (kNStripA + 2*kNStripB +
2*kNStripC)*kNpadX*kNpadZ;};
static Float_t RinTOF() { return fgkxTOF;};
static Float_t Rmin() { return fgkRmin;};
static Float_t Rmax() { return fgkRmax;};
static Float_t XPad() { return fgkXPad;};
static Float_t ZPad() { return fgkZPad;};
static Float_t StripLength() { return fgkStripLength;};
static Float_t DeadTime() { return fgkDeadTime;};
static Float_t MatchingWindow() { return fgkMatchingWindow;};
static Int_t MaxTOFTree() { return kMaxTOFTree;};
static Int_t NDDL() { return kNDDL;};
static Int_t NTRM() { return kNTRM;}
static Int_t NTdc() { return kNTdc;};
static Int_t NChain() { return kNChain;};
static Int_t NCh() { return kNCh;};
static Int_t NPadXTRM() { return kNCh*kNTdc*kNChain;};
static Float_t ZlenA() { return fgkZlenA;};
static Float_t ZlenB() { return fgkZlenB;};
static Float_t ZlenC() { return fgkZlenC;};
static Float_t MaxhZtof() { return fgkMaxhZtof;};
static Float_t SigmaForTail1() { return fgkSigmaForTail1;};
static Float_t SigmaForTail2() { return fgkSigmaForTail2;};
static Double_t GetAlpha() { return 2 * 3.14159265358979323846 / kNSectors; };
static Float_t TdcBinWidth() {return fgkTdcBin;};
static Float_t ToTBinWidth() {return fgkToTBin;};
static Float_t BunchCrossingBinWidth() {return fgkBunchCrossingBin;};
static Float_t SlewTOTMin() {return fgkSlewTOTMin;};
static Float_t SlewTOTMax() {return fgkSlewTOTMax;};
virtual void ImportGeometry();
virtual void SetHoles(Bool_t holes) {fgHoles = holes;};
static Bool_t GetHoles() {return fgHoles;};
static Float_t DistanceToPadPar(Int_t *det, const Float_t * pos, Float_t *dist3d=0);
static Bool_t IsInsideThePadPar(Int_t *det, const Float_t * pos);
static Bool_t IsInsideThePad(TGeoHMatrix *mat, const Float_t * pos, Float_t *dist3d=0);
static void GetVolumePath(const Int_t * ind, Char_t *path );
static void GetVolumePath(Int_t sector, Char_t *path );
static void GetVolumePath(Int_t sector, Int_t plate, Int_t strip, Char_t *path );
static void GetPos(Int_t *det,Float_t *pos);
static void GetPosPar(Int_t *det,Float_t *pos);
static void GetDetID(Float_t *pos,Int_t *det);
static Int_t GetPlate(const Float_t * pos);
static Int_t GetStrip(const Float_t * pos);
static Int_t GetSector(const Float_t * pos);
static Int_t GetPadX(const Float_t * pos);
static Int_t GetPadZ(const Float_t * pos);
static Float_t GetX(const Int_t * det);
static Float_t GetY(const Int_t * det);
static Float_t GetZ(const Int_t * det);
virtual void DetToStripRF(Int_t nPadX, Int_t nPadZ,
Float_t &x, Float_t &z) const;
virtual void DetToSectorRF(Int_t vol[5], Double_t coord[4][3]);
static Float_t GetPadDx(const Float_t * pos);
static Float_t GetPadDy(const Float_t * pos);
static Float_t GetPadDz(const Float_t * pos);
static void Translation(Float_t *xyz, Float_t translationVector[3]);
static void Rotation(Float_t *xyz, Double_t rotationAngles[6]);
static void InverseRotation(Float_t *xyz, Double_t rotationAngles[6]);
static Float_t GetAngles(Int_t iplate, Int_t istrip) {return fgkAngles[iplate][istrip];};
static Float_t GetHeights(Int_t iplate, Int_t istrip) {return fgkHeights[iplate][istrip];};
static Float_t GetDistances(Int_t iplate, Int_t istrip) {return fgkDistances[iplate][istrip];};
static Int_t GetIndex(const Int_t * detId);
static void GetVolumeIndices(Int_t index, Int_t *detId);
static UShort_t GetAliSensVolIndex(Int_t sec, Int_t pla, Int_t str);
static Int_t GetStripNumber(Int_t isector, Int_t iplate, Int_t istrip);
static Int_t GetStripNumberPerSM(Int_t iplate, Int_t istrip);
static void GetStripAndModule(Int_t iStripPerSM, Int_t &iplate, Int_t &istrip);
void PadRF2TrackingRF(Float_t *ctrackPos, Float_t *differenceT);
static Int_t GetTOFsupermodule(Int_t index);
private:
enum {
kNStripA = 15,
kNStripB = 19,
kNStripC = 19,
kNpadX = 48,
kNpadZ = 2,
kNSectors = 18,
kNPlates = 5,
kMaxTOFTree = 5,
kMaxNstrip = 20
};
enum {
kNDDL = 4,
kNTRM = 12,
kNTdc = 15,
kNChain = 2,
kNCh = 8
};
static const Float_t fgkDeadTime;
static const Float_t fgkMatchingWindow;
static const Float_t fgkZlenA;
static const Float_t fgkZlenB;
static const Float_t fgkZlenC;
static const Float_t fgkMaxhZtof;
static const Float_t fgkRmin;
static const Float_t fgkRmax;
static const Float_t fgkxTOF;
static const Float_t fgkStripLength;
static const Float_t fgkXPad;
static const Float_t fgkZPad;
static const Float_t fgkSigmaForTail1;
static const Float_t fgkSigmaForTail2;
static const Float_t fgkPhiSec;
static Bool_t fgHoles;
static const Float_t fgkAngles[kNPlates][kMaxNstrip];
static const Float_t fgkHeights[kNPlates][kMaxNstrip];
static const Float_t fgkDistances[kNPlates][kMaxNstrip];
static const Float_t fgkTdcBin;
static const Float_t fgkToTBin;
static const Float_t fgkBunchCrossingBin;
static const Float_t fgkSlewTOTMin;
static const Float_t fgkSlewTOTMax;
ClassDef(AliTOFGeometry,9)
};
#endif