]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/TPCLib/AliHLTTPCClusterTransformation.cxx
debug output removed
[u/mrichter/AliRoot.git] / HLT / TPCLib / AliHLTTPCClusterTransformation.cxx
1 // $Id: AliHLTTPCClusterTransformation.cxx 41244 2010-05-14 08:13:35Z kkanaki $
2
3 //**************************************************************************
4 //* This file is property of and copyright by the ALICE HLT Project        *
5 //* ALICE Experiment at CERN, All rights reserved.                         *
6 //*                                                                        *
7 //* Primary Authors: Kalliopi Kanaki <Kalliopi.Kanaki@ift.uib.no>          *
8 //*                  for The ALICE HLT Project.                            *
9 //*                                                                        *
10 //* Permission to use, copy, modify and distribute this software and its   *
11 //* documentation strictly for non-commercial purposes is hereby granted   *
12 //* without fee, provided that the above copyright notice appears in all   *
13 //* copies and that both the copyright notice and this permission notice   *
14 //* appear in the supporting documentation. The authors make no claims     *
15 //* about the suitability of this software for any purpose. It is          *
16 //* provided "as is" without express or implied warranty.                  *
17 //**************************************************************************
18
19 /** @file   AliHLTTPCClusterTransformation.cxx
20     @author Kalliopi Kanaki, Sergey Gorbubnov
21     @date   
22     @brief 
23 */
24
25
26 #include "AliHLTTPCClusterTransformation.h"
27 #include "AliHLTTPCTransform.h"
28
29 #include "AliTPCcalibDB.h"
30 #include "AliTPCTransform.h"
31 #include "AliTPCParam.h"
32 #include "AliTPCRecoParam.h"
33 #include "AliGeomManager.h"
34 //#include "Riostream.h"
35
36 ClassImp(AliHLTTPCClusterTransformation) //ROOT macro for the implementation of ROOT specific class methods
37
38 AliHLTTPCClusterTransformation::AliHLTTPCClusterTransformation()
39 :
40   fOfflineTransform(NULL),
41   fOfflineTPCParam( NULL ),
42   fLastSector(-1)
43 {
44   // see header file for class documentation
45   // or
46   // refer to README to build package
47   // or
48   // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt  
49   fAliT[0] = 0.;
50   fAliT[1] = 0.;
51   fAliT[2] = 0.;
52   for( int i=0; i<9; i++ ) fAliR[i] = 0;
53   fAliR[0] = 1.;
54   fAliR[4] = 1.;
55   fAliR[8] = 1.;
56 }
57
58 AliHLTTPCClusterTransformation::AliHLTTPCClusterTransformation(const AliHLTTPCClusterTransformation&)
59 :
60   fOfflineTransform(NULL),
61   fOfflineTPCParam( NULL ),
62   fLastSector(-1)
63 {
64   // copy constructor prohibited
65   fAliT[0] = 0.;
66   fAliT[1] = 0.;
67   fAliT[2] = 0.;
68   for( int i=0; i<9; i++ ) fAliR[i] = 0;
69   fAliR[0] = 1.;
70   fAliR[4] = 1.;
71   fAliR[8] = 1.;
72 }
73
74 AliHLTTPCClusterTransformation& AliHLTTPCClusterTransformation::operator=(const AliHLTTPCClusterTransformation&)
75 {
76   // assignment operator prohibited
77   return *this;
78 }
79
80 AliHLTTPCClusterTransformation::~AliHLTTPCClusterTransformation() 
81
82   // see header file for class documentation
83   //delete fOfflineTransform;
84 }
85
86
87 int  AliHLTTPCClusterTransformation::Init( double FieldBz, UInt_t TimeStamp )
88 {
89   // Initialisation
90
91   //delete fOfflineTransform;
92   fOfflineTransform = 0;
93   fOfflineTPCParam = 0;
94
95   AliTPCcalibDB* pCalib=AliTPCcalibDB::Instance();
96
97   if(!pCalib ) return -1;
98
99   pCalib->SetExBField(FieldBz);
100   
101   if(!AliGeomManager::GetGeometry()){
102      AliGeomManager::LoadGeometry();
103   }
104
105   if( !pCalib->GetTransform() ) return -2; 
106
107   //fOfflineTransform = new AliTPCTransform (*pCalib->GetTransform());
108   fOfflineTransform = pCalib->GetTransform();
109   fOfflineTransform->SetCurrentRecoParam( AliTPCRecoParam::GetHLTParam() );
110   fOfflineTransform->SetCurrentTimeStamp( TimeStamp );
111   fOfflineTPCParam = pCalib->GetParameters(); 
112   if( !fOfflineTPCParam ) return -3;
113
114   fOfflineTPCParam->Update();
115   fOfflineTPCParam->ReadGeoMatrices();  
116
117   fLastSector = -1;
118
119   fAliT[0] = 0.;
120   fAliT[1] = 0.;
121   fAliT[2] = 0.;
122   for( int i=0; i<9; i++ ) fAliR[i] = 0;
123   fAliR[0] = 1.;
124   fAliR[4] = 1.;
125   fAliR[8] = 1.;
126
127   return 0;
128 }
129
130
131 void AliHLTTPCClusterTransformation::SetCurrentTimeStamp( UInt_t TimeStamp )
132 {
133   // Set the current time stamp
134   if( fOfflineTransform ) fOfflineTransform->SetCurrentTimeStamp( TimeStamp );
135 }
136
137
138 int  AliHLTTPCClusterTransformation::Transform( int Slice, int Row, float Pad, float Time, float XYZ[] )
139 {
140   // Convert row, pad, time to X Y Z
141            
142   Int_t sector=-99, thisrow=-99;
143   AliHLTTPCTransform::Slice2Sector( Slice, Row, sector, thisrow);
144
145   if( !fOfflineTransform ){                
146     AliHLTTPCTransform::Raw2Local( XYZ, sector, thisrow, Pad, Time); 
147     if(Slice>17) XYZ[1]= - XYZ[1];         
148     return 0;
149   }
150
151   Int_t iSector[1]= {sector};   
152   Double_t x[3] = { thisrow, Pad, Time }; 
153   fOfflineTransform->Transform(x,iSector,0,1);
154           
155   if( sector!= fLastSector ){
156     if( fOfflineTPCParam && sector<fOfflineTPCParam->GetNSector() ){
157       TGeoHMatrix  *alignment = fOfflineTPCParam->GetClusterMatrix( sector );
158       if ( alignment ){
159         const Double_t *tr = alignment->GetTranslation();
160         const Double_t *rot = alignment->GetRotationMatrix();
161         if( tr && rot ){
162           for( int i=0; i<3; i++ ) fAliT[i] = tr[i];
163           for( int i=0; i<9; i++ ) fAliR[i] = rot[i];
164         }
165       }
166     } else {
167       fAliT[0] = 0.;
168       fAliT[1] = 0.;
169       fAliT[2] = 0.;
170       for( int i=0; i<9; i++ ) fAliR[i] = 0;
171       fAliR[0] = 1.;
172       fAliR[4] = 1.;
173       fAliR[8] = 1.;
174     }
175     fLastSector = sector;
176   }
177   // alignment->LocalToMaster( x, y);
178
179   XYZ[0] = fAliT[0] + x[0]*fAliR[0] + x[1]*fAliR[1] + x[2]*fAliR[2];
180   XYZ[1] = fAliT[1] + x[0]*fAliR[3] + x[1]*fAliR[4] + x[2]*fAliR[5];
181   XYZ[2] = fAliT[2] + x[0]*fAliR[6] + x[1]*fAliR[7] + x[2]*fAliR[8];
182
183   return 0; 
184 }