]>
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 ); | |
97 | return 0; | |
98 | } | |
99 | ||
100 | ||
101 | void AliHLTTPCFastTransform::SetCurrentTimeStamp( Int_t TimeStamp ) | |
102 | { | |
103 | // Set the current time stamp | |
104 | if( fLastTimeStamp>=0 && TMath::Abs(fLastTimeStamp - TimeStamp ) <60 ) return; | |
105 | ||
106 | if( !fOrigTransform ) return; | |
107 | ||
108 | if( TimeStamp>=0 ){ | |
109 | fOrigTransform->SetCurrentTimeStamp( TimeStamp ); | |
110 | fLastTimeStamp = TimeStamp; | |
111 | } else fLastTimeStamp = fOrigTransform->GetCurrentTimeStamp(); | |
112 | ||
113 | ||
114 | AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance(); | |
115 | if(!pCalib ) return ; | |
116 | ||
117 | AliTPCParam *par = pCalib->GetParameters(); | |
118 | if( !par ) return ; | |
119 | ||
120 | // find last calibrated time bin | |
121 | ||
122 | Int_t nTimeBins = par->GetMaxTBin(); | |
123 | Int_t is[]={0}; | |
124 | bool sign = 0; | |
125 | for( fLastTimeBin=0; fLastTimeBin<nTimeBins; fLastTimeBin++){ | |
126 | Double_t xx[]={0,0,fLastTimeBin}; | |
127 | fOrigTransform->Transform(xx,is,0,1); | |
128 | bool s = (xx[2]>=0); | |
129 | if( fLastTimeBin==0 ) sign = s; | |
130 | else if( sign!=s ){ | |
131 | fLastTimeBin--; | |
132 | break; | |
133 | } | |
134 | } | |
135 | fTimeBorder1 = 60; | |
136 | fTimeBorder2 = fLastTimeBin - 100; | |
137 | ||
138 | for( Int_t i=0; i<72; i++ ) | |
139 | for( Int_t j=0; j<100; j++ ) if( fRows[i][j] ) InitRow(i,j); | |
140 | } | |
141 | ||
142 | Int_t AliHLTTPCFastTransform::InitRow( Int_t iSector, Int_t iRow ) | |
143 | { | |
144 | // see header file for class documentation | |
145 | ||
146 | if( iSector<0 || iSector>=72 || iRow<0 || iRow>=100 || !fOrigTransform) return 1; | |
147 | ||
148 | AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance(); | |
149 | if(!pCalib ) return 1; | |
150 | ||
151 | AliTPCParam *par = pCalib->GetParameters(); | |
152 | if( !par ) return 1; | |
153 | ||
154 | Int_t nPads = par->GetNPads(iSector,iRow); | |
155 | ||
156 | if( !fRows[iSector][iRow] ){ | |
157 | fRows[iSector][iRow] = new AliHLTTPCFastTransform::AliRowTransform; | |
158 | } | |
159 | ||
160 | fRows[iSector][iRow]->fSpline[0].Init( 0.5, nPads-1+0.5, 15, 0, fTimeBorder1, 5); | |
161 | fRows[iSector][iRow]->fSpline[1].Init( 0.5, nPads-1+0.5, 15, fTimeBorder1, fTimeBorder2, 10); | |
162 | fRows[iSector][iRow]->fSpline[2].Init( 0.5, nPads-1+0.5, 15, fTimeBorder2, fLastTimeBin, 5); | |
163 | ||
164 | for( Int_t i=0; i<3; i++){ | |
165 | Int_t is[]={iSector}; | |
166 | for( Int_t j=0; j<fRows[iSector][iRow]->fSpline[i].GetNPoints(); j++){ | |
167 | Float_t pad, time; | |
168 | fRows[iSector][iRow]->fSpline[i].GetAB(j,pad,time); | |
169 | Double_t xx[]={iRow,pad,time}; | |
170 | fOrigTransform->Transform(xx,is,0,1); | |
171 | fRows[iSector][iRow]->fSpline[i].Fill(j,xx); | |
172 | } | |
173 | } | |
174 | return 0; | |
175 | } | |
176 | ||
177 | ||
178 | ||
179 | Int_t AliHLTTPCFastTransform::GetRowSize( Int_t iSec, Int_t iRow ) const | |
180 | { | |
181 | // see header file for class documentation | |
182 | Int_t s = sizeof(AliHLTTPCFastTransform::AliRowTransform); | |
183 | if( fRows[iSec][iRow] ) for( Int_t i=0; i<3; i++) s+=fRows[iSec][iRow]->fSpline[i].GetMapSize(); | |
184 | return s; | |
185 | } | |
186 | ||
187 | Int_t AliHLTTPCFastTransform::GetSize() const | |
188 | { | |
189 | // see header file for class documentation | |
190 | Int_t s = sizeof(AliHLTTPCFastTransform); | |
191 | for( Int_t i=0; i<72; i++ ) | |
192 | for( Int_t j=0; j<100; j++ ) if( fRows[i][j] ){ | |
193 | s+= sizeof(AliHLTTPCFastTransform::AliRowTransform); | |
926a15a0 | 194 | for( Int_t k=0; k<3; k++) fRows[i][j]->fSpline[k].GetMapSize(); |
dc9f7928 | 195 | } |
196 | return s; | |
197 | } |