2 //***************************************************************************
3 // This file is property of and copyright by the ALICE HLT Project *
4 // ALICE Experiment at CERN, All rights reserved. *
6 // Primary Authors: Sergey Gorbunov <sergey.gorbunov@kip.uni-heidelberg.de> *
7 // Ivan Kisel <kisel@kip.uni-heidelberg.de> *
8 // for The ALICE HLT Project. *
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 //***************************************************************************
19 #include "AliTPCtrackerCA.h"
22 #include <Riostream.h>
23 #include "AliCluster.h"
24 #include "AliTPCClustersRow.h"
25 #include "AliTPCParam.h"
27 #include "AliRunLoader.h"
30 #include "AliHLTTPCCATracker.h"
31 #include "AliHLTTPCCAGBHit.h"
32 #include "AliHLTTPCCAGBTracker.h"
33 #include "AliHLTTPCCAGBTrack.h"
34 #include "AliHLTTPCCAMCTrack.h"
35 #include "AliHLTTPCCAOutTrack.h"
36 #include "AliHLTTPCCAPerformance.h"
37 #include "AliHLTTPCCAParam.h"
40 #include "AliTPCLoader.h"
42 #include "AliTPCclusterMI.h"
43 #include "AliTPCTransform.h"
44 #include "AliTPCcalibDB.h"
45 #include "AliTPCReconstructor.h"
46 #include "AliTPCtrack.h"
47 #include "AliESDtrack.h"
48 #include "AliESDEvent.h"
51 ClassImp(AliTPCtrackerCA)
53 AliTPCtrackerCA::AliTPCtrackerCA()
54 :AliTracker(),fParam(0), fClusters(0), fNClusters(0), fHLTTracker(0),fHLTPerformance(0),fDoHLTPerformance(0)
56 //* default constructor
59 AliTPCtrackerCA::AliTPCtrackerCA(const AliTPCtrackerCA &):
60 AliTracker(),fParam(0), fClusters(0), fNClusters(0), fHLTTracker(0),fHLTPerformance(0),fDoHLTPerformance(0)
65 AliTPCtrackerCA & AliTPCtrackerCA::operator=(const AliTPCtrackerCA& )
72 AliTPCtrackerCA::~AliTPCtrackerCA()
75 if( fClusters ) delete[] fClusters;
76 if( fHLTTracker ) delete fHLTTracker;
77 if( fHLTPerformance ) delete fHLTPerformance;
80 AliTPCtrackerCA::AliTPCtrackerCA(const AliTPCParam *par):
81 AliTracker(),fParam(par), fClusters(0), fNClusters(0), fHLTTracker(0), fHLTPerformance(0),fDoHLTPerformance(0)
85 DoHLTPerformance() = 0;
87 fHLTTracker = new AliHLTTPCCAGBTracker;
88 fHLTTracker->SetNSlices( fParam->GetNSector()/2 );
90 if( fDoHLTPerformance ){
91 fHLTPerformance = new AliHLTTPCCAPerformance;
92 fHLTPerformance->SetTracker( fHLTTracker );
95 for( int iSlice=0; iSlice<fHLTTracker->NSlices(); iSlice++ ){
97 Double_t bz = AliTracker::GetBz();
99 Double_t inRmin = fParam->GetInnerRadiusLow();
100 //Double_t inRmax = fParam->GetInnerRadiusUp();
101 //Double_t outRmin = fParam->GetOuterRadiusLow();
102 Double_t outRmax = fParam->GetOuterRadiusUp();
103 Double_t plusZmin = 0.0529937;
104 Double_t plusZmax = 249.778;
105 Double_t minusZmin = -249.645;
106 Double_t minusZmax = -0.0799937;
107 Double_t dalpha = 0.349066;
108 Double_t alpha = 0.174533 + dalpha*iSlice;
110 Bool_t zPlus = (iSlice<18 );
111 Double_t zMin = zPlus ?plusZmin :minusZmin;
112 Double_t zMax = zPlus ?plusZmax :minusZmax;
113 //TPCZmin = -249.645, ZMax = 249.778
114 //Double_t rMin = inRmin;
115 //Double_t rMax = outRmax;
117 Double_t padPitch = 0.4;
118 Double_t sigmaZ = 0.228808;
120 Int_t NRows = fParam->GetNRowLow()+fParam->GetNRowUp();
123 for( Int_t irow=0; irow<fParam->GetNRowLow(); irow++){
124 rowX[irow] = fParam->GetPadRowRadiiLow(irow);
126 for( Int_t irow=0; irow<fParam->GetNRowUp(); irow++){
127 rowX[fParam->GetNRowLow()+irow] = fParam->GetPadRowRadiiUp(irow);
129 AliHLTTPCCAParam param;
130 param.Initialize( iSlice, NRows, rowX, alpha, dalpha,
131 inRmin, outRmax, zMin, zMax, padPitch, sigmaZ, bz );
132 param.YErrorCorrection() = .33;//1;
133 param.ZErrorCorrection() = .33;//2;
134 param.MaxTrackMatchDRow() = 5;
135 param.TrackConnectionFactor() = 5.;
136 fHLTTracker->Slices()[iSlice].Initialize( param );
142 Int_t AliTPCtrackerCA::LoadClusters (TTree * tree)
145 if( fClusters ) delete[] fClusters;
147 fHLTTracker->StartEvent();
148 if( fDoHLTPerformance ) fHLTPerformance->StartEvent();
150 if( !fParam ) return 1;
153 if( fDoHLTPerformance ){
154 if( !gAlice ) return 0;
155 AliRunLoader *rl = gAlice->GetRunLoader();
157 rl->LoadKinematics();
158 AliStack *stack = rl->Stack();
159 if( !stack ) return 0 ;
161 fHLTPerformance->SetNMCTracks( stack->GetNtrack() );
163 for( Int_t itr=0; itr<stack->GetNtrack(); itr++ ){
164 TParticle *part = stack->Particle(itr);
165 fHLTPerformance->ReadMCTrack( itr, part );
169 TBranch * br = tree->GetBranch("Segment");
172 AliTPCClustersRow *clrow = new AliTPCClustersRow;
173 clrow->SetClass("AliTPCclusterMI");
175 clrow->GetArray()->ExpandCreateFast(10000);
177 br->SetAddress(&clrow);
180 Int_t NEnt=Int_t(tree->GetEntries());
183 for (Int_t i=0; i<NEnt; i++) {
186 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
187 fNClusters += clrow->GetArray()->GetEntriesFast();
190 fClusters = new AliTPCclusterMI [fNClusters];
191 fHLTTracker->SetNHits( fNClusters );
192 if( fDoHLTPerformance ) fHLTPerformance->SetNHits( fNClusters );
194 for (Int_t i=0; i<NEnt; i++) {
197 fParam->AdjustSectorRow(clrow->GetID(),sec,row);
198 int NClu = clrow->GetArray()->GetEntriesFast();
199 Double_t x = fParam->GetPadRowRadii(sec,row);
200 for (Int_t icl=0; icl<NClu; icl++){
204 AliTPCclusterMI* cluster = (AliTPCclusterMI*)(clrow->GetArray()->At(icl));
205 if( !cluster ) continue;
206 lab0 = cluster->GetLabel(0);
207 lab1 = cluster->GetLabel(1);
208 lab2 = cluster->GetLabel(2);
210 AliTPCTransform *transform = AliTPCcalibDB::Instance()->GetTransform() ;
212 AliFatal("Tranformations not in calibDB");
214 Double_t xx[3]={cluster->GetRow(),cluster->GetPad(),cluster->GetTimeBin()};
215 Int_t id[1]={cluster->GetDetector()};
216 transform->Transform(xx,id,0,1);
217 //if (!AliTPCReconstructor::GetRecoParam()->GetBYMirror()){
218 if (cluster->GetDetector()%36>17){
223 cluster->SetX(xx[0]);
224 cluster->SetY(xx[1]);
225 cluster->SetZ(xx[2]);
227 TGeoHMatrix *mat = fParam->GetClusterMatrix(cluster->GetDetector());
228 Double_t pos[3]= {cluster->GetX(),cluster->GetY(),cluster->GetZ()};
229 Double_t posC[3]={cluster->GetX(),cluster->GetY(),cluster->GetZ()};
230 if (mat) mat->LocalToMaster(pos,posC);
232 // chack Loading of Geo matrices from GeoManager - TEMPORARY FIX
234 cluster->SetX(posC[0]);
235 cluster->SetY(posC[1]);
236 cluster->SetZ(posC[2]);
238 Double_t y = cluster->GetY();
239 Double_t z = cluster->GetZ();
243 row = row + fParam->GetNRowLow();
247 fClusters[index] = *cluster;
248 fHLTTracker->ReadHit( x, y, z,
249 TMath::Sqrt(cluster->GetSigmaY2()), TMath::Sqrt(cluster->GetSigmaZ2()),
251 if( fDoHLTPerformance ) fHLTPerformance->ReadHitLabel(index, lab0, lab1, lab2 );
258 AliCluster * AliTPCtrackerCA::GetCluster(Int_t index) const
260 return &(fClusters[index]);
263 Int_t AliTPCtrackerCA::Clusters2Tracks( AliESDEvent *event )
265 //cout<<"Start of AliTPCtrackerCA"<<endl;
267 fHLTTracker->FindTracks();
268 if( fDoHLTPerformance ) fHLTPerformance->Performance();
272 for( Int_t itr=0; itr<fHLTTracker->NTracks(); itr++ ){
274 AliHLTTPCCAGBTrack &tCA = fHLTTracker->Tracks()[itr];
275 AliHLTTPCCATrackParam &par = tCA.Param();
277 par.GetExtParam( tTPC, tCA.Alpha(), fHLTTracker->Slices()[0].Param().Bz() );
279 tTPC.SetMass(0.13957);
280 int nhits = tCA.NHits();
281 if( nhits>kMaxRow ) nhits = kMaxRow;
282 tTPC.SetNumberOfClusters(nhits);
283 for( Int_t ih=0; ih<nhits; ih++ ){
284 Int_t index = fHLTTracker->TrackHits()[tCA.FirstHitRef()+ih];
285 Int_t ext_index = fHLTTracker->Hits()[index].ID();
286 tTPC.SetClusterIndex(ih, ext_index);
288 CookLabel(&tTPC,0.1);
291 if (tTPC.AliExternalTrackParam::PropagateTo(xTPC,5)) {
292 Double_t y=tTPC.GetY();
293 Double_t ymax=xTPC*TMath::Tan(1.74532920122146606e-01);
295 if (tTPC.Rotate(2*1.74532920122146606e-01)) tTPC.AliExternalTrackParam::PropagateTo(xTPC,5);
296 } else if (y <-ymax) {
297 if (tTPC.Rotate(-2*1.74532920122146606e-01)) tTPC.AliExternalTrackParam::PropagateTo(xTPC,5);
303 tESD.UpdateTrackParams( &(tTPC),AliESDtrack::kTPCin);
304 //tESD.SetStatus( AliESDtrack::kTPCrefit );
305 //tESD.SetTPCPoints(tTPC.GetPoints());
307 event->AddTrack(&tESD);
311 //cout<<"End of AliTPCtrackerCA"<<endl;
316 Int_t AliTPCtrackerCA::RefitInward (AliESDEvent *)
318 //* not implemented yet
322 Int_t AliTPCtrackerCA::PropagateBack(AliESDEvent *)
324 //* not implemented yet