]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/transform/AliHLTTPCFastTransform.h
Removing annoying prints
[u/mrichter/AliRoot.git] / HLT / TPCLib / transform / AliHLTTPCFastTransform.h
1 #ifndef ALIHLTTPCFASTTRANSFORM_H
2 #define ALIHLTTPCFASTTRANSFORM_H
3
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                               *
7
8 /** @file   AliHLTTPCFastTransform.h
9     @author Sergey Gorbunov
10     @date   
11     @brief
12 */
13
14 // see below for class documentation
15 // or
16 // refer to README to build package
17 // or
18 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
19
20 #include "Rtypes.h"
21 #include "TString.h"
22 #include "AliHLTTPCSpline2D3D.h"
23
24 class AliTPCTransform;
25
26 /**
27  * @class AliHLTTPCFastTransform
28  *
29  * The class transforms internal TPC coordinates (pad,time) to XYZ. 
30  * 
31  * @ingroup alihlt_tpc_components
32  */
33
34
35
36 class AliHLTTPCFastTransform{
37     
38  public:
39
40   /** standard constructor */    
41   AliHLTTPCFastTransform();           
42   /** destructor */
43   virtual ~AliHLTTPCFastTransform();
44   
45   /** initialization */
46   Int_t  Init( AliTPCTransform *transform=0, Long_t TimeStamp=-1 );
47  
48   /** initialization */
49   Bool_t IsInitialised() const { return fOrigTransform!=NULL; }
50   
51   /** deinitialization */
52   void  DeInit();
53
54   /** set the time stamp */
55   Int_t SetCurrentTimeStamp( Long_t TimeStamp );
56
57   /** Returns the current time stamp  */
58   Long_t GetCurrentTimeStamp() const { return fLastTimeStamp; }
59
60   /** Transformation: calibration + alignment */
61   Int_t  Transform( Int_t Sector, Int_t Row, Float_t Pad, Float_t Time, Float_t XYZ[] );
62
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[] );
65
66   /** Alignment */
67   Int_t Alignment( Int_t iSec, Float_t XYZ[] );
68   
69   /** Alignment in double */
70   Int_t Alignment( Int_t iSec, Double_t XYZ[] ); 
71
72   /** Reverse alignment */
73   Int_t ReverseAlignment( Int_t iSec, Float_t XYZ[] );
74
75   /** Reverse alignment in double */
76   Int_t ReverseAlignment( Int_t iSec, Double_t XYZ[] );
77
78   /** Error string */
79   const char* GetLastError() const { return fError.Data(); }
80
81   /** total size of the object*/
82   Int_t GetSize() const ;
83   
84   /** size of a particular row*/
85   Int_t GetRowSize( Int_t iSec, Int_t iRow ) const;
86
87   /** last calibrated time bin */
88   Int_t GetLastTimeBin() const { return fLastTimeBin; }
89
90   /** Print */
91   void Print(const char* option=0) const;
92
93  private:
94
95   /** copy constructor prohibited */
96   AliHLTTPCFastTransform(const AliHLTTPCFastTransform&);
97   /** assignment operator prohibited */
98   AliHLTTPCFastTransform& operator=(const AliHLTTPCFastTransform&);
99   
100
101  /** Initialisation of splines for a particular row */
102   Int_t InitRow( Int_t iSector, Int_t iRow );
103
104   /** Reverse rotation of matrix mA */
105   bool CalcAdjugateRotation(const Float_t *mA, Float_t *mB, bool bCheck=0);
106   
107   struct AliRowTransform{
108     AliHLTTPCSpline2D3D fSpline[3];
109   };
110  
111   /** Set error string */
112   Int_t Error(Int_t code, const char *msg);
113
114   static const Int_t fkNSec = 72; //! transient
115   static const Int_t fkNRows = 100; //! transient
116
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
124
125   AliHLTTPCFastTransform::AliRowTransform *fRows[fkNSec][fkNRows]; //! transient
126
127   ClassDef(AliHLTTPCFastTransform,0)
128 };
129
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 );
135   return 0; 
136 }
137
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 );
143   return 0; 
144 }
145
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];
153   return 0;
154 }
155
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];
163   return 0;
164 }
165
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];
173   return 0;
174 }
175
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];
183   return 0;
184 }
185
186 inline Int_t AliHLTTPCFastTransform::Error(Int_t code, const char *msg)
187 {
188   fError = msg;
189   return code;
190 }
191
192 #endif