Line data Source code
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 AliHLTTPCFastTransformObject;
25 :
26 : class AliTPCTransform;
27 :
28 : /**
29 : * @class AliHLTTPCFastTransform
30 : *
31 : * The class transforms internal TPC coordinates (pad,time) to XYZ.
32 : *
33 : * @ingroup alihlt_tpc_components
34 : */
35 :
36 :
37 :
38 : class AliHLTTPCFastTransform{
39 :
40 : public:
41 :
42 : /** standard constructor */
43 : AliHLTTPCFastTransform();
44 : /** destructor */
45 : virtual ~AliHLTTPCFastTransform();
46 :
47 : /** initialization */
48 : Int_t Init( AliTPCTransform *transform=0, Long_t TimeStamp=-1 );
49 :
50 : /** initialization */
51 : Int_t ReadFromObject( const AliHLTTPCFastTransformObject &obj );
52 :
53 : /** initialization */
54 : Int_t WriteToObject( AliHLTTPCFastTransformObject &obj );
55 :
56 : /** initialization */
57 0 : Bool_t IsInitialised() const { return fInitialisationMode != -1; }
58 :
59 : /** deinitialization */
60 : void DeInit();
61 :
62 : /** set the time stamp */
63 : Int_t SetCurrentTimeStamp( Long_t TimeStamp );
64 :
65 : /** Returns the current time stamp */
66 0 : Long_t GetCurrentTimeStamp() const { return fLastTimeStamp; }
67 :
68 : /** Transformation: calibration + alignment */
69 : Int_t Transform( Int_t Sector, Int_t Row, Float_t Pad, Float_t Time, Float_t XYZ[] );
70 :
71 : /** Transformation: calibration + alignment in double*/
72 : Int_t Transform( Int_t Sector, Int_t Row, Float_t Pad, Float_t Time, Double_t XYZ[] );
73 :
74 : /** Alignment */
75 : Int_t Alignment( Int_t iSec, Float_t XYZ[] );
76 :
77 : /** Alignment in double */
78 : Int_t Alignment( Int_t iSec, Double_t XYZ[] );
79 :
80 : /** Reverse alignment */
81 : Int_t ReverseAlignment( Int_t iSec, Float_t XYZ[] );
82 :
83 : /** Reverse alignment in double */
84 : Int_t ReverseAlignment( Int_t iSec, Double_t XYZ[] );
85 :
86 : /** Error string */
87 0 : const char* GetLastError() const { return fError.Data(); }
88 :
89 : /** total size of the object*/
90 : Int_t GetSize() const ;
91 :
92 : /** size of a particular row*/
93 : Int_t GetRowSize( Int_t iSec, Int_t iRow ) const;
94 :
95 : /** last calibrated time bin */
96 0 : Int_t GetLastTimeBin() const { return fLastTimeBin; }
97 :
98 : /** Print */
99 : void Print(const char* option=0) const;
100 :
101 0 : static Int_t Version() { return 0; }
102 :
103 0 : Int_t MinInitSec() {return fMinInitSec;}
104 0 : Int_t MaxInitSec() {return fMaxInitSec;}
105 0 : void SetInitSec(Int_t min, Int_t max) {fMinInitSec = min;fMaxInitSec = max;if (min < 0) min = 0;if (max > fkNSec) max = fkNSec;}
106 :
107 : private:
108 :
109 : /** copy constructor prohibited */
110 : AliHLTTPCFastTransform(const AliHLTTPCFastTransform&);
111 : /** assignment operator prohibited */
112 : AliHLTTPCFastTransform& operator=(const AliHLTTPCFastTransform&);
113 :
114 :
115 : /** Initialisation of splines for a particular row */
116 : Int_t InitRow( Int_t iSector, Int_t iRow );
117 :
118 : /** Reverse rotation of matrix mA */
119 : bool CalcAdjugateRotation(const Float_t *mA, Float_t *mB, bool bCheck=0);
120 :
121 0 : struct AliRowTransform{
122 : AliHLTTPCSpline2D3D fSpline[3];
123 : };
124 :
125 : /** Set error string */
126 : Int_t Error(Int_t code, const char *msg);
127 :
128 : static const Int_t fkNSec = 72; //! transient
129 : static const Int_t fkNRows = 100; //! transient
130 :
131 : Int_t fMinInitSec; //Min sector for parallel initialization
132 : Int_t fMaxInitSec; //Max sector for parallel initialization
133 :
134 : TString fError; // error string
135 : Int_t fInitialisationMode; // 0 == is initialised from pre-calculated OCDB object (online, no re-calculation in time) or 1== from TPC calib
136 : AliTPCTransform * fOrigTransform; //! transient
137 : Long_t fLastTimeStamp; // last time stamp
138 : Int_t fLastTimeBin; // last calibrated time bin
139 : Float_t fTimeBorder1; //! transient
140 : Float_t fTimeBorder2; //! transient
141 : Float_t *fAlignment; // alignment matrices translation,rotation,reverse rotation
142 :
143 : AliHLTTPCFastTransform::AliRowTransform *fRows[fkNSec][fkNRows]; //! transient
144 :
145 6 : ClassDef(AliHLTTPCFastTransform,0)
146 : };
147 :
148 : inline Int_t AliHLTTPCFastTransform::Transform( Int_t iSec, Int_t iRow, Float_t Pad, Float_t Time, Float_t XYZ[] ){
149 0 : if( fLastTimeStamp<0 || iSec<0 || iSec>=fkNSec || iRow<0 || iRow>=fkNRows || !fRows[iSec][iRow] ) return -1;
150 0 : Int_t iTime = ( Time>=fTimeBorder2 ) ?2 :( ( Time>fTimeBorder1 ) ?1 :0 );
151 0 : fRows[iSec][iRow]->fSpline[iTime].GetValue(Pad, Time, XYZ);
152 0 : if( fAlignment ) Alignment( iSec, XYZ );
153 : return 0;
154 0 : }
155 :
156 : inline Int_t AliHLTTPCFastTransform::Transform( Int_t iSec, Int_t iRow, Float_t Pad, Float_t Time, Double_t XYZ[] ){
157 0 : if( fLastTimeStamp<0 || iSec<0 || iSec>=fkNSec || iRow<0 || iRow>=fkNRows || !fRows[iSec][iRow] ) return -1;
158 0 : Int_t iTime = ( Time>=fTimeBorder2 ) ?2 :( ( Time>fTimeBorder1 ) ?1 :0 );
159 0 : fRows[iSec][iRow]->fSpline[iTime].GetValue(Pad, Time, XYZ);
160 0 : if( fAlignment ) Alignment( iSec, XYZ );
161 : return 0;
162 0 : }
163 :
164 : inline Int_t AliHLTTPCFastTransform::Alignment( Int_t iSec, Float_t XYZ[] ){
165 0 : if( iSec<0 || iSec>=fkNSec ) return Error(-1, Form("AliHLTTPCFastTransform::Alignment: wrong sector %d", iSec));
166 0 : if( !fAlignment ) return 0;
167 0 : Float_t x=XYZ[0], y = XYZ[1], z = XYZ[2], *t = fAlignment + iSec*21, *r = t+3;
168 0 : XYZ[0] = t[0] + x*r[0] + y*r[1] + z*r[2];
169 0 : XYZ[1] = t[1] + x*r[3] + y*r[4] + z*r[5];
170 0 : XYZ[2] = t[2] + x*r[6] + y*r[7] + z*r[8];
171 : return 0;
172 0 : }
173 :
174 : inline Int_t AliHLTTPCFastTransform::Alignment( Int_t iSec, Double_t XYZ[] ){
175 0 : if( iSec<0 || iSec>=fkNSec ) return Error(-1, Form("AliHLTTPCFastTransform::Alignment: wrong sector %d", iSec));
176 0 : if( !fAlignment ) return 0;
177 0 : Float_t x=XYZ[0], y = XYZ[1], z = XYZ[2], *t = fAlignment + iSec*21, *r = t+3;
178 0 : XYZ[0] = t[0] + x*r[0] + y*r[1] + z*r[2];
179 0 : XYZ[1] = t[1] + x*r[3] + y*r[4] + z*r[5];
180 0 : XYZ[2] = t[2] + x*r[6] + y*r[7] + z*r[8];
181 : return 0;
182 0 : }
183 :
184 : inline Int_t AliHLTTPCFastTransform::ReverseAlignment( Int_t iSec, Float_t XYZ[] ){
185 0 : if( iSec<0 || iSec>=fkNSec ) return Error(-1, Form("AliHLTTPCFastTransform::ReverseAlignment: wrong sector %d", iSec));
186 0 : if( !fAlignment ) return 0;
187 0 : Float_t *t = fAlignment + iSec*21, *r = t+12, x=XYZ[0] - t[0], y = XYZ[1]-t[1], z = XYZ[2]-t[2];
188 0 : XYZ[0] = x*r[0] + y*r[1] + z*r[2];
189 0 : XYZ[1] = x*r[3] + y*r[4] + z*r[5];
190 0 : XYZ[2] = x*r[6] + y*r[7] + z*r[8];
191 : return 0;
192 0 : }
193 :
194 : inline Int_t AliHLTTPCFastTransform::ReverseAlignment( Int_t iSec, Double_t XYZ[] ){
195 0 : if( iSec<0 || iSec>=fkNSec ) return Error(-1, Form("AliHLTTPCFastTransform::ReverseAlignment: wrong sector %d", iSec));
196 0 : if( !fAlignment ) return 0;
197 0 : Float_t *t = fAlignment + iSec*21, *r = t+12, x=XYZ[0] - t[0], y = XYZ[1]-t[1], z = XYZ[2]-t[2];
198 0 : XYZ[0] = x*r[0] + y*r[1] + z*r[2];
199 0 : XYZ[1] = x*r[3] + y*r[4] + z*r[5];
200 0 : XYZ[2] = x*r[6] + y*r[7] + z*r[8];
201 : return 0;
202 0 : }
203 :
204 : inline Int_t AliHLTTPCFastTransform::Error(Int_t code, const char *msg)
205 : {
206 0 : fError = msg;
207 0 : return code;
208 : }
209 :
210 : #endif
|