]>
Commit | Line | Data |
---|---|---|
dc9f7928 | 1 | //************************************************************************** |
2 | //* This file is property of and copyright by the ALICE HLT Project * | |
3 | //* ALICE Experiment at CERN, All rights reserved. * | |
4 | //* * | |
5 | //* Primary Authors: Sergey Gorbunov <sergey.gorbunov@cern.ch> * | |
6 | //* for The ALICE HLT Project. * | |
7 | //* * | |
8 | //* Permission to use, copy, modify and distribute this software and its * | |
9 | //* documentation strictly for non-commercial purposes is hereby granted * | |
10 | //* without fee, provided that the above copyright notice appears in all * | |
11 | //* copies and that both the copyright notice and this permission notice * | |
12 | //* appear in the supporting documentation. The authors make no claims * | |
13 | //* about the suitability of this software for any purpose. It is * | |
14 | //* provided "as is" without express or implied warranty. * | |
15 | //************************************************************************** | |
16 | ||
17 | /** @file AliHLTTPCFastTransform.cxx | |
18 | @author Sergey Gorbubnov | |
19 | @date | |
20 | @brief | |
21 | */ | |
22 | ||
23 | ||
24 | #include "AliHLTTPCFastTransform.h" | |
25 | #include "AliTPCTransform.h" | |
26 | #include "AliTPCParam.h" | |
27 | #include "AliTPCcalibDB.h" | |
28 | ||
29 | #include <iostream> | |
30 | #include <iomanip> | |
31 | ||
32 | using namespace std; | |
33 | ||
34 | ClassImp(AliHLTTPCFastTransform); //ROOT macro for the implementation of ROOT specific class methods | |
35 | ||
36 | AliHLTTPCFastTransform* AliHLTTPCFastTransform::fgInstance = 0; | |
37 | ||
38 | ||
39 | void AliHLTTPCFastTransform::Terminate() | |
40 | { | |
41 | // | |
42 | // Singleton implementation | |
43 | // Deletes the instance of this class and sets the terminated flag, instances cannot be requested anymore | |
44 | // This function can be called several times. | |
45 | // | |
46 | ||
47 | if( fgInstance ){ | |
48 | delete fgInstance; | |
49 | fgInstance = 0; | |
50 | } | |
51 | } | |
52 | ||
53 | AliHLTTPCFastTransform::AliHLTTPCFastTransform() | |
54 | : | |
55 | fOrigTransform(0), | |
56 | fLastTimeStamp(-1), | |
57 | fLastTimeBin(600), | |
58 | fTimeBorder1(100), | |
59 | fTimeBorder2(500) | |
60 | { | |
61 | // see header file for class documentation | |
62 | // or | |
63 | // refer to README to build package | |
64 | // or | |
65 | // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt | |
66 | for( Int_t i=0; i<72; i++) | |
67 | for( Int_t j=0; j<100; j++ ) fRows[i][j] = 0; | |
68 | Init(); | |
69 | } | |
70 | ||
71 | AliHLTTPCFastTransform::~AliHLTTPCFastTransform() | |
72 | { | |
73 | // see header file for class documentation | |
74 | for( Int_t i=0; i<72; i++) | |
75 | for( Int_t j=0; j<100; j++ ) delete fRows[i][j]; | |
76 | ||
77 | if( fgInstance == this ) fgInstance = 0; | |
78 | } | |
79 | ||
80 | ||
81 | Int_t AliHLTTPCFastTransform::Init( AliTPCTransform *transform, Int_t TimeStamp ) | |
82 | { | |
83 | // Initialisation | |
84 | ||
85 | if( !transform ){ | |
86 | AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance(); | |
87 | if(!pCalib ) return 1; | |
88 | transform = pCalib->GetTransform(); | |
89 | } | |
90 | ||
91 | if( fOrigTransform != transform ){ | |
92 | fOrigTransform = transform; | |
93 | fLastTimeStamp = -1; | |
94 | } | |
95 | ||
96 | SetCurrentTimeStamp( TimeStamp ); | |
5a0a183a | 97 | |
98 | // at the moment initialise all the rows | |
99 | ||
100 | AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance(); | |
101 | if(!pCalib ) return 1; | |
102 | AliTPCParam *par = pCalib->GetParameters(); | |
103 | if( !par ) return 1; | |
104 | ||
105 | for( int iSector=0; iSector<par->GetNSector(); iSector++ ){ | |
106 | for( int iRow=0; iRow<par->GetNRow(iSector); iRow++){ | |
107 | InitRow( iSector, iRow ); | |
108 | } | |
109 | } | |
110 | ||
dc9f7928 | 111 | return 0; |
112 | } | |
113 | ||
114 | ||
115 | void AliHLTTPCFastTransform::SetCurrentTimeStamp( Int_t TimeStamp ) | |
116 | { | |
117 | // Set the current time stamp | |
118 | if( fLastTimeStamp>=0 && TMath::Abs(fLastTimeStamp - TimeStamp ) <60 ) return; | |
119 | ||
120 | if( !fOrigTransform ) return; | |
121 | ||
122 | if( TimeStamp>=0 ){ | |
123 | fOrigTransform->SetCurrentTimeStamp( TimeStamp ); | |
124 | fLastTimeStamp = TimeStamp; | |
125 | } else fLastTimeStamp = fOrigTransform->GetCurrentTimeStamp(); | |
126 | ||
127 | ||
128 | AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance(); | |
129 | if(!pCalib ) return ; | |
130 | ||
131 | AliTPCParam *par = pCalib->GetParameters(); | |
132 | if( !par ) return ; | |
133 | ||
134 | // find last calibrated time bin | |
135 | ||
136 | Int_t nTimeBins = par->GetMaxTBin(); | |
137 | Int_t is[]={0}; | |
138 | bool sign = 0; | |
139 | for( fLastTimeBin=0; fLastTimeBin<nTimeBins; fLastTimeBin++){ | |
140 | Double_t xx[]={0,0,fLastTimeBin}; | |
141 | fOrigTransform->Transform(xx,is,0,1); | |
142 | bool s = (xx[2]>=0); | |
143 | if( fLastTimeBin==0 ) sign = s; | |
144 | else if( sign!=s ){ | |
145 | fLastTimeBin--; | |
146 | break; | |
147 | } | |
148 | } | |
149 | fTimeBorder1 = 60; | |
150 | fTimeBorder2 = fLastTimeBin - 100; | |
151 | ||
152 | for( Int_t i=0; i<72; i++ ) | |
153 | for( Int_t j=0; j<100; j++ ) if( fRows[i][j] ) InitRow(i,j); | |
154 | } | |
155 | ||
156 | Int_t AliHLTTPCFastTransform::InitRow( Int_t iSector, Int_t iRow ) | |
157 | { | |
158 | // see header file for class documentation | |
159 | ||
160 | if( iSector<0 || iSector>=72 || iRow<0 || iRow>=100 || !fOrigTransform) return 1; | |
161 | ||
162 | AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance(); | |
163 | if(!pCalib ) return 1; | |
164 | ||
165 | AliTPCParam *par = pCalib->GetParameters(); | |
166 | if( !par ) return 1; | |
167 | ||
168 | Int_t nPads = par->GetNPads(iSector,iRow); | |
169 | ||
170 | if( !fRows[iSector][iRow] ){ | |
171 | fRows[iSector][iRow] = new AliHLTTPCFastTransform::AliRowTransform; | |
172 | } | |
173 | ||
174 | fRows[iSector][iRow]->fSpline[0].Init( 0.5, nPads-1+0.5, 15, 0, fTimeBorder1, 5); | |
175 | fRows[iSector][iRow]->fSpline[1].Init( 0.5, nPads-1+0.5, 15, fTimeBorder1, fTimeBorder2, 10); | |
176 | fRows[iSector][iRow]->fSpline[2].Init( 0.5, nPads-1+0.5, 15, fTimeBorder2, fLastTimeBin, 5); | |
177 | ||
178 | for( Int_t i=0; i<3; i++){ | |
179 | Int_t is[]={iSector}; | |
180 | for( Int_t j=0; j<fRows[iSector][iRow]->fSpline[i].GetNPoints(); j++){ | |
181 | Float_t pad, time; | |
182 | fRows[iSector][iRow]->fSpline[i].GetAB(j,pad,time); | |
183 | Double_t xx[]={iRow,pad,time}; | |
184 | fOrigTransform->Transform(xx,is,0,1); | |
185 | fRows[iSector][iRow]->fSpline[i].Fill(j,xx); | |
186 | } | |
10801676 | 187 | fRows[iSector][iRow]->fSpline[i].Consolidate(); |
dc9f7928 | 188 | } |
189 | return 0; | |
190 | } | |
191 | ||
192 | ||
193 | ||
194 | Int_t AliHLTTPCFastTransform::GetRowSize( Int_t iSec, Int_t iRow ) const | |
195 | { | |
196 | // see header file for class documentation | |
197 | Int_t s = sizeof(AliHLTTPCFastTransform::AliRowTransform); | |
198 | if( fRows[iSec][iRow] ) for( Int_t i=0; i<3; i++) s+=fRows[iSec][iRow]->fSpline[i].GetMapSize(); | |
199 | return s; | |
200 | } | |
201 | ||
202 | Int_t AliHLTTPCFastTransform::GetSize() const | |
203 | { | |
204 | // see header file for class documentation | |
205 | Int_t s = sizeof(AliHLTTPCFastTransform); | |
206 | for( Int_t i=0; i<72; i++ ) | |
207 | for( Int_t j=0; j<100; j++ ) if( fRows[i][j] ){ | |
208 | s+= sizeof(AliHLTTPCFastTransform::AliRowTransform); | |
926a15a0 | 209 | for( Int_t k=0; k<3; k++) fRows[i][j]->fSpline[k].GetMapSize(); |
dc9f7928 | 210 | } |
211 | return s; | |
212 | } |