]> git.uio.no Git - u/mrichter/AliRoot.git/blame - HLT/TPCLib/transform/AliHLTTPCFastTransform.cxx
bug fix in initialisation of fast cluster transformation
[u/mrichter/AliRoot.git] / HLT / TPCLib / transform / AliHLTTPCFastTransform.cxx
CommitLineData
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
32using namespace std;
33
34ClassImp(AliHLTTPCFastTransform); //ROOT macro for the implementation of ROOT specific class methods
35
9eb867b1 36AliHLTTPCFastTransform AliHLTTPCFastTransform::fgInstance;
dc9f7928 37
38
dc9f7928 39AliHLTTPCFastTransform::AliHLTTPCFastTransform()
40:
41 fOrigTransform(0),
42 fLastTimeStamp(-1),
43 fLastTimeBin(600),
44 fTimeBorder1(100),
45 fTimeBorder2(500)
46{
47 // see header file for class documentation
48 // or
49 // refer to README to build package
50 // or
51 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
52 for( Int_t i=0; i<72; i++)
53 for( Int_t j=0; j<100; j++ ) fRows[i][j] = 0;
dc9f7928 54}
55
56AliHLTTPCFastTransform::~AliHLTTPCFastTransform()
57{
58 // see header file for class documentation
59 for( Int_t i=0; i<72; i++)
60 for( Int_t j=0; j<100; j++ ) delete fRows[i][j];
dc9f7928 61}
62
63
64Int_t AliHLTTPCFastTransform::Init( AliTPCTransform *transform, Int_t TimeStamp )
65{
66 // Initialisation
9eb867b1 67
dc9f7928 68 if( !transform ){
69 AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance();
70 if(!pCalib ) return 1;
71 transform = pCalib->GetTransform();
72 }
73
74 if( fOrigTransform != transform ){
75 fOrigTransform = transform;
76 fLastTimeStamp = -1;
77 }
78
79 SetCurrentTimeStamp( TimeStamp );
5a0a183a 80
81 // at the moment initialise all the rows
82
83 AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance();
84 if(!pCalib ) return 1;
85 AliTPCParam *par = pCalib->GetParameters();
86 if( !par ) return 1;
87
88 for( int iSector=0; iSector<par->GetNSector(); iSector++ ){
9eb867b1 89 for( int iRow=0; iRow<par->GetNRow(iSector); iRow++){
5a0a183a 90 InitRow( iSector, iRow );
91 }
92 }
93
dc9f7928 94 return 0;
95}
96
97
98void AliHLTTPCFastTransform::SetCurrentTimeStamp( Int_t TimeStamp )
99{
100 // Set the current time stamp
dbff40a1 101
102 if( !fOrigTransform ) Init(NULL,TimeStamp);
103 if( !fOrigTransform ) return;
104
dc9f7928 105 if( fLastTimeStamp>=0 && TMath::Abs(fLastTimeStamp - TimeStamp ) <60 ) return;
106
dbff40a1 107
dc9f7928 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
9eb867b1 138 for( Int_t i=0; i<72; i++ ){
dc9f7928 139 for( Int_t j=0; j<100; j++ ) if( fRows[i][j] ) InitRow(i,j);
9eb867b1 140 }
dc9f7928 141}
142
143Int_t AliHLTTPCFastTransform::InitRow( Int_t iSector, Int_t iRow )
144{
145 // see header file for class documentation
146
147 if( iSector<0 || iSector>=72 || iRow<0 || iRow>=100 || !fOrigTransform) return 1;
148
149 AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance();
150 if(!pCalib ) return 1;
151
152 AliTPCParam *par = pCalib->GetParameters();
153 if( !par ) return 1;
154
155 Int_t nPads = par->GetNPads(iSector,iRow);
156
157 if( !fRows[iSector][iRow] ){
158 fRows[iSector][iRow] = new AliHLTTPCFastTransform::AliRowTransform;
159 }
160
161 fRows[iSector][iRow]->fSpline[0].Init( 0.5, nPads-1+0.5, 15, 0, fTimeBorder1, 5);
162 fRows[iSector][iRow]->fSpline[1].Init( 0.5, nPads-1+0.5, 15, fTimeBorder1, fTimeBorder2, 10);
163 fRows[iSector][iRow]->fSpline[2].Init( 0.5, nPads-1+0.5, 15, fTimeBorder2, fLastTimeBin, 5);
164
165 for( Int_t i=0; i<3; i++){
166 Int_t is[]={iSector};
167 for( Int_t j=0; j<fRows[iSector][iRow]->fSpline[i].GetNPoints(); j++){
168 Float_t pad, time;
169 fRows[iSector][iRow]->fSpline[i].GetAB(j,pad,time);
170 Double_t xx[]={iRow,pad,time};
171 fOrigTransform->Transform(xx,is,0,1);
172 fRows[iSector][iRow]->fSpline[i].Fill(j,xx);
173 }
10801676 174 fRows[iSector][iRow]->fSpline[i].Consolidate();
dc9f7928 175 }
176 return 0;
177}
178
179
180
181Int_t AliHLTTPCFastTransform::GetRowSize( Int_t iSec, Int_t iRow ) const
182{
183 // see header file for class documentation
184 Int_t s = sizeof(AliHLTTPCFastTransform::AliRowTransform);
185 if( fRows[iSec][iRow] ) for( Int_t i=0; i<3; i++) s+=fRows[iSec][iRow]->fSpline[i].GetMapSize();
186 return s;
187}
188
189Int_t AliHLTTPCFastTransform::GetSize() const
190{
191 // see header file for class documentation
192 Int_t s = sizeof(AliHLTTPCFastTransform);
193 for( Int_t i=0; i<72; i++ )
194 for( Int_t j=0; j<100; j++ ) if( fRows[i][j] ){
195 s+= sizeof(AliHLTTPCFastTransform::AliRowTransform);
926a15a0 196 for( Int_t k=0; k<3; k++) fRows[i][j]->fSpline[k].GetMapSize();
dc9f7928 197 }
198 return s;
199}