1 #ifndef ALIHLTTPCFASTTRANSFORM_H
2 #define ALIHLTTPCFASTTRANSFORM_H
4 //* This file is property of and copyright by the ALICE HLT Project *
5 //* ALICE Experiment at CERN, All rights reserved. *
6 //* See cxx source for full Copyright notice *
8 /** @file AliHLTTPCFastTransform.h
9 @author Sergey Gorbunov
14 // see below for class documentation
16 // refer to README to build package
18 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
22 #include "AliHLTTPCSpline2D3D.h"
24 class AliTPCTransform;
27 * @class AliHLTTPCFastTransform
29 * The class transforms internal TPC coordinates (pad,time) to XYZ.
31 * @ingroup alihlt_tpc_components
36 class AliHLTTPCFastTransform{
40 /** standard constructor */
41 AliHLTTPCFastTransform();
43 virtual ~AliHLTTPCFastTransform();
46 Int_t Init( AliTPCTransform *transform=0, Long_t TimeStamp=-1 );
49 Bool_t IsInitialised() const { return fOrigTransform!=NULL; }
51 /** deinitialization */
54 /** set the time stamp */
55 Int_t SetCurrentTimeStamp( Long_t TimeStamp );
57 /** Returns the current time stamp */
58 Long_t GetCurrentTimeStamp() const { return fLastTimeStamp; }
60 /** Transformation: calibration + alignment */
61 Int_t Transform( Int_t Sector, Int_t Row, Float_t Pad, Float_t Time, Float_t XYZ[] );
63 /** Transformation: calibration + alignment in double*/
64 Int_t Transform( Int_t Sector, Int_t Row, Float_t Pad, Float_t Time, Double_t XYZ[] );
67 Int_t Alignment( Int_t iSec, Float_t XYZ[] );
69 /** Alignment in double */
70 Int_t Alignment( Int_t iSec, Double_t XYZ[] );
72 /** Reverse alignment */
73 Int_t ReverseAlignment( Int_t iSec, Float_t XYZ[] );
75 /** Reverse alignment in double */
76 Int_t ReverseAlignment( Int_t iSec, Double_t XYZ[] );
79 const char* GetLastError() const { return fError.Data(); }
81 /** total size of the object*/
82 Int_t GetSize() const ;
84 /** size of a particular row*/
85 Int_t GetRowSize( Int_t iSec, Int_t iRow ) const;
87 /** last calibrated time bin */
88 Int_t GetLastTimeBin() const { return fLastTimeBin; }
91 void Print(const char* option=0) const;
95 /** copy constructor prohibited */
96 AliHLTTPCFastTransform(const AliHLTTPCFastTransform&);
97 /** assignment operator prohibited */
98 AliHLTTPCFastTransform& operator=(const AliHLTTPCFastTransform&);
101 /** Initialisation of splines for a particular row */
102 Int_t InitRow( Int_t iSector, Int_t iRow );
104 /** Reverse rotation of matrix mA */
105 bool CalcAdjugateRotation(const Float_t *mA, Float_t *mB, bool bCheck=0);
107 struct AliRowTransform{
108 AliHLTTPCSpline2D3D fSpline[3];
111 /** Set error string */
112 Int_t Error(Int_t code, const char *msg);
114 static const Int_t fkNSec = 72; //! transient
115 static const Int_t fkNRows = 100; //! transient
117 TString fError; // error string
118 AliTPCTransform * fOrigTransform; //! transient
119 Long_t fLastTimeStamp; // last time stamp
120 Int_t fLastTimeBin; // last calibrated time bin
121 Float_t fTimeBorder1; //! transient
122 Float_t fTimeBorder2; //! transient
123 Float_t *fAlignment; // alignment matrices translation,rotation,reverse rotation
125 AliHLTTPCFastTransform::AliRowTransform *fRows[fkNSec][fkNRows]; //! transient
127 ClassDef(AliHLTTPCFastTransform,0)
130 inline Int_t AliHLTTPCFastTransform::Transform( Int_t iSec, Int_t iRow, Float_t Pad, Float_t Time, Float_t XYZ[] ){
131 if( fLastTimeStamp<0 || iSec<0 || iSec>=fkNSec || iRow<0 || iRow>=fkNRows || !fRows[iSec][iRow] ) return -1;
132 Int_t iTime = ( Time>=fTimeBorder2 ) ?2 :( ( Time>fTimeBorder1 ) ?1 :0 );
133 fRows[iSec][iRow]->fSpline[iTime].GetValue(Pad, Time, XYZ);
134 if( fAlignment ) Alignment( iSec, XYZ );
138 inline Int_t AliHLTTPCFastTransform::Transform( Int_t iSec, Int_t iRow, Float_t Pad, Float_t Time, Double_t XYZ[] ){
139 if( fLastTimeStamp<0 || iSec<0 || iSec>=fkNSec || iRow<0 || iRow>=fkNRows || !fRows[iSec][iRow] ) return -1;
140 Int_t iTime = ( Time>=fTimeBorder2 ) ?2 :( ( Time>fTimeBorder1 ) ?1 :0 );
141 fRows[iSec][iRow]->fSpline[iTime].GetValue(Pad, Time, XYZ);
142 if( fAlignment ) Alignment( iSec, XYZ );
146 inline Int_t AliHLTTPCFastTransform::Alignment( Int_t iSec, Float_t XYZ[] ){
147 if( iSec<0 || iSec>=fkNSec ) return Error(-1, Form("AliHLTTPCFastTransform::Alignment: wrong sector %d", iSec));
148 if( !fAlignment ) return 0;
149 Float_t x=XYZ[0], y = XYZ[1], z = XYZ[2], *t = fAlignment + iSec*21, *r = t+3;
150 XYZ[0] = t[0] + x*r[0] + y*r[1] + z*r[2];
151 XYZ[1] = t[1] + x*r[3] + y*r[4] + z*r[5];
152 XYZ[2] = t[2] + x*r[6] + y*r[7] + z*r[8];
156 inline Int_t AliHLTTPCFastTransform::Alignment( Int_t iSec, Double_t XYZ[] ){
157 if( iSec<0 || iSec>=fkNSec ) return Error(-1, Form("AliHLTTPCFastTransform::Alignment: wrong sector %d", iSec));
158 if( !fAlignment ) return 0;
159 Float_t x=XYZ[0], y = XYZ[1], z = XYZ[2], *t = fAlignment + iSec*21, *r = t+3;
160 XYZ[0] = t[0] + x*r[0] + y*r[1] + z*r[2];
161 XYZ[1] = t[1] + x*r[3] + y*r[4] + z*r[5];
162 XYZ[2] = t[2] + x*r[6] + y*r[7] + z*r[8];
166 inline Int_t AliHLTTPCFastTransform::ReverseAlignment( Int_t iSec, Float_t XYZ[] ){
167 if( iSec<0 || iSec>=fkNSec ) return Error(-1, Form("AliHLTTPCFastTransform::ReverseAlignment: wrong sector %d", iSec));
168 if( !fAlignment ) return 0;
169 Float_t *t = fAlignment + iSec*21, *r = t+12, x=XYZ[0] - t[0], y = XYZ[1]-t[1], z = XYZ[2]-t[2];
170 XYZ[0] = x*r[0] + y*r[1] + z*r[2];
171 XYZ[1] = x*r[3] + y*r[4] + z*r[5];
172 XYZ[2] = x*r[6] + y*r[7] + z*r[8];
176 inline Int_t AliHLTTPCFastTransform::ReverseAlignment( Int_t iSec, Double_t XYZ[] ){
177 if( iSec<0 || iSec>=fkNSec ) return Error(-1, Form("AliHLTTPCFastTransform::ReverseAlignment: wrong sector %d", iSec));
178 if( !fAlignment ) return 0;
179 Float_t *t = fAlignment + iSec*21, *r = t+12, x=XYZ[0] - t[0], y = XYZ[1]-t[1], z = XYZ[2]-t[2];
180 XYZ[0] = x*r[0] + y*r[1] + z*r[2];
181 XYZ[1] = x*r[3] + y*r[4] + z*r[5];
182 XYZ[2] = x*r[6] + y*r[7] + z*r[8];
186 inline Int_t AliHLTTPCFastTransform::Error(Int_t code, const char *msg)