Another round of fixes in order to use the event specie in the QA. The procedure...
[u/mrichter/AliRoot.git] / TPC / AliTPCseed.cxx
CommitLineData
81e97e0d 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16
17
18
19//-----------------------------------------------------------------
20// Implementation of the TPC seed class
21// This class is used by the AliTPCtrackerMI class
22// Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
23//-----------------------------------------------------------------
24#include "TClonesArray.h"
25#include "AliTPCseed.h"
3f82c4f2 26#include "AliTPCReconstructor.h"
0a65832b 27#include "AliTPCClusterParam.h"
7cd8ac3f 28#include "AliTPCCalPad.h"
29#include "AliTPCCalROC.h"
37540068 30#include "AliTPCcalibDB.h"
d080e4a4 31#include "AliTPCParam.h"
7cd8ac3f 32
33
81e97e0d 34
35ClassImp(AliTPCseed)
36
37
38
32fab534 39AliTPCseed::AliTPCseed():
40 AliTPCtrack(),
41 fEsd(0x0),
2928bdf0 42 fClusterOwner(kFALSE),
32fab534 43 fRow(0),
44 fSector(-1),
45 fRelativeSector(-1),
46 fCurrentSigmaY2(1e10),
47 fCurrentSigmaZ2(1e10),
e0e13b88 48 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
49 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 50 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
51 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
e0e13b88 52 //
32fab534 53 fErrorY2(1e10),
54 fErrorZ2(1e10),
55 fCurrentCluster(0x0),
56 fCurrentClusterIndex1(-1),
57 fInDead(kFALSE),
58 fIsSeeding(kFALSE),
59 fNoCluster(0),
60 fSort(0),
61 fBSigned(kFALSE),
62 fSeedType(0),
63 fSeed1(-1),
64 fSeed2(-1),
65 fMAngular(0),
19b00333 66 fCircular(0),
67 fClusterMap(159),
68 fSharedMap(159)
32fab534 69{
81e97e0d 70 //
5c09947e 71 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 72 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
73 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
32fab534 74 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
75 for (Int_t i=0;i<4;i++) {
76 fDEDX[i] = 0.;
77 fSDEDX[i] = 1e10;
78 fNCDEDX[i] = 0;
79 }
80 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
bfb57b6c 81 // for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
82 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
83 fClusterMap.ResetAllBits(kFALSE);
84 fSharedMap.ResetAllBits(kFALSE);
85
81e97e0d 86}
32fab534 87
2928bdf0 88AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
32fab534 89 AliTPCtrack(s),
90 fEsd(0x0),
2928bdf0 91 fClusterOwner(clusterOwner),
32fab534 92 fRow(0),
93 fSector(-1),
94 fRelativeSector(-1),
c07cb486 95 fCurrentSigmaY2(-1),
96 fCurrentSigmaZ2(-1),
e0e13b88 97 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
98 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 99 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
100 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 101 fErrorY2(1e10),
102 fErrorZ2(1e10),
103 fCurrentCluster(0x0),
104 fCurrentClusterIndex1(-1),
105 fInDead(kFALSE),
106 fIsSeeding(kFALSE),
107 fNoCluster(0),
108 fSort(0),
109 fBSigned(kFALSE),
110 fSeedType(0),
111 fSeed1(-1),
112 fSeed2(-1),
113 fMAngular(0),
19b00333 114 fCircular(0),
115 fClusterMap(s.fClusterMap),
116 fSharedMap(s.fSharedMap)
32fab534 117{
81e97e0d 118 //---------------------
119 // dummy copy constructor
120 //-------------------------
2928bdf0 121 for (Int_t i=0;i<160;i++) {
122 fClusterPointer[i]=0;
123 if (fClusterOwner){
124 if (s.fClusterPointer[i])
125 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
126 }else{
127 fClusterPointer[i] = s.fClusterPointer[i];
128 }
129 fTrackPoints[i] = s.fTrackPoints[i];
130 }
81e97e0d 131 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
5c09947e 132 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
133 for (Int_t i=0;i<4;i++) {
134 fDEDX[i] = s.fDEDX[i];
135 fSDEDX[i] = s.fSDEDX[i];
136 fNCDEDX[i] = s.fNCDEDX[i];
137 }
138 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
19b00333 139
81e97e0d 140}
5c09947e 141
142
32fab534 143AliTPCseed::AliTPCseed(const AliTPCtrack &t):
144 AliTPCtrack(t),
145 fEsd(0x0),
2928bdf0 146 fClusterOwner(kFALSE),
32fab534 147 fRow(0),
148 fSector(-1),
149 fRelativeSector(-1),
c07cb486 150 fCurrentSigmaY2(-1),
151 fCurrentSigmaZ2(-1),
e0e13b88 152 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
153 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 154 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
155 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 156 fErrorY2(1e10),
157 fErrorZ2(1e10),
158 fCurrentCluster(0x0),
159 fCurrentClusterIndex1(-1),
160 fInDead(kFALSE),
161 fIsSeeding(kFALSE),
162 fNoCluster(0),
163 fSort(0),
164 fBSigned(kFALSE),
165 fSeedType(0),
166 fSeed1(-1),
167 fSeed2(-1),
168 fMAngular(0),
19b00333 169 fCircular(0),
170 fClusterMap(159),
171 fSharedMap(159)
32fab534 172{
81e97e0d 173 //
32fab534 174 // Constructor from AliTPCtrack
175 //
176 fFirstPoint =0;
105b1b81 177 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
81e97e0d 178 for (Int_t i=0;i<160;i++) {
179 fClusterPointer[i] = 0;
180 Int_t index = t.GetClusterIndex(i);
181 if (index>=-1){
182 SetClusterIndex2(i,index);
183 }
184 else{
185 SetClusterIndex2(i,-3);
186 }
187 }
32fab534 188 for (Int_t i=0;i<4;i++) {
189 fDEDX[i] = 0.;
190 fSDEDX[i] = 1e10;
191 fNCDEDX[i] = 0;
192 }
193 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
bfb57b6c 194
195 //for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
196 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
197 fClusterMap.ResetAllBits(kFALSE);
198 fSharedMap.ResetAllBits(kFALSE);
199
81e97e0d 200}
201
6c94f330 202AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
203 const Double_t cc[15], Int_t index):
204 AliTPCtrack(xr, alpha, xx, cc, index),
32fab534 205 fEsd(0x0),
2928bdf0 206 fClusterOwner(kFALSE),
32fab534 207 fRow(0),
208 fSector(-1),
209 fRelativeSector(-1),
c07cb486 210 fCurrentSigmaY2(-1),
211 fCurrentSigmaZ2(-1),
e0e13b88 212 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
213 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 214 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
215 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 216 fErrorY2(1e10),
217 fErrorZ2(1e10),
218 fCurrentCluster(0x0),
219 fCurrentClusterIndex1(-1),
220 fInDead(kFALSE),
221 fIsSeeding(kFALSE),
222 fNoCluster(0),
223 fSort(0),
224 fBSigned(kFALSE),
225 fSeedType(0),
226 fSeed1(-1),
227 fSeed2(-1),
228 fMAngular(0),
19b00333 229 fCircular(0),
230 fClusterMap(159),
231 fSharedMap(159)
32fab534 232{
233 //
234 // Constructor
81e97e0d 235 //
32fab534 236 fFirstPoint =0;
5c09947e 237 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 238 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
81e97e0d 239 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
32fab534 240 for (Int_t i=0;i<4;i++) {
241 fDEDX[i] = 0.;
242 fSDEDX[i] = 1e10;
243 fNCDEDX[i] = 0;
244 }
245 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 246}
247
248AliTPCseed::~AliTPCseed(){
249 //
250 // destructor
81e97e0d 251 fNoCluster =0;
2928bdf0 252 if (fClusterOwner){
253 for (Int_t icluster=0; icluster<160; icluster++){
254 delete fClusterPointer[icluster];
255 }
256 }
bfb57b6c 257
81e97e0d 258}
179c6296 259//_________________________________________________
316c6cd9 260AliTPCseed & AliTPCseed::operator=(const AliTPCseed &param)
179c6296 261{
262 //
316c6cd9 263 // assignment operator
179c6296 264 //
316c6cd9 265 if(this!=&param){
266 AliTPCtrack::operator=(param);
267 fEsd =param.fEsd;
268 for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i]; // this is not allocated by AliTPCSeed
269 fClusterOwner = param.fClusterOwner;
270 // leave out fPoint, they are also not copied in the copy ctor...
271 // but deleted in the dtor... strange...
316c6cd9 272 fRow = param.fRow;
273 fSector = param.fSector;
274 fRelativeSector = param.fRelativeSector;
275 fCurrentSigmaY2 = param.fCurrentSigmaY2;
276 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
277 fErrorY2 = param.fErrorY2;
278 fErrorZ2 = param.fErrorZ2;
279 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
280 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
281 fInDead = param.fInDead;
282 fIsSeeding = param.fIsSeeding;
283 fNoCluster = param.fNoCluster;
284 fSort = param.fSort;
285 fBSigned = param.fBSigned;
286 for(Int_t i = 0;i<4;++i){
287 fDEDX[i] = param.fDEDX[i];
288 fSDEDX[i] = param.fSDEDX[i];
289 fNCDEDX[i] = param.fNCDEDX[i];
290 }
291 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
292
293 fSeedType = param.fSeedType;
294 fSeed1 = param.fSeed1;
295 fSeed2 = param.fSeed2;
296 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
297 fMAngular = param.fMAngular;
298 fCircular = param.fCircular;
299 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
300 fClusterMap = param.fClusterMap;
301 fSharedMap = param.fSharedMap;
302 }
179c6296 303 return (*this);
304}
305//____________________________________________________
81e97e0d 306AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
307{
308 //
309 //
310 return &fTrackPoints[i];
311}
312
81e97e0d 313
314
315Double_t AliTPCseed::GetDensityFirst(Int_t n)
316{
317 //
318 //
319 // return cluster for n rows bellow first point
320 Int_t nfoundable = 1;
321 Int_t nfound = 1;
322 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
323 Int_t index = GetClusterIndex2(i);
324 if (index!=-1) nfoundable++;
325 if (index>0) nfound++;
326 }
327 if (nfoundable<n) return 0;
328 return Double_t(nfound)/Double_t(nfoundable);
329
330}
331
332
333void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
334{
335 // get cluster stat. on given region
336 //
337 found = 0;
338 foundable = 0;
339 shared =0;
340 for (Int_t i=first;i<last; i++){
341 Int_t index = GetClusterIndex2(i);
342 if (index!=-1) foundable++;
6d493ea0 343 if (index&0x8000) continue;
81e97e0d 344 if (fClusterPointer[i]) {
345 found++;
346 }
347 else
348 continue;
349
350 if (fClusterPointer[i]->IsUsed(10)) {
351 shared++;
352 continue;
353 }
354 if (!plus2) continue; //take also neighborhoud
355 //
356 if ( (i>0) && fClusterPointer[i-1]){
357 if (fClusterPointer[i-1]->IsUsed(10)) {
358 shared++;
359 continue;
360 }
361 }
362 if ( fClusterPointer[i+1]){
363 if (fClusterPointer[i+1]->IsUsed(10)) {
364 shared++;
365 continue;
366 }
367 }
368
369 }
370 //if (shared>found){
371 //Error("AliTPCseed::GetClusterStatistic","problem\n");
372 //}
373}
374
375
376
377
378
379void AliTPCseed::Reset(Bool_t all)
380{
381 //
382 //
383 SetNumberOfClusters(0);
384 fNFoundable = 0;
385 SetChi2(0);
6c94f330 386 ResetCovariance(10.);
81e97e0d 387 /*
388 if (fTrackPoints){
389 for (Int_t i=0;i<8;i++){
390 delete [] fTrackPoints[i];
391 }
392 delete fTrackPoints;
393 fTrackPoints =0;
394 }
395 */
396
397 if (all){
398 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
399 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
400 }
401
402}
403
404
405void AliTPCseed::Modify(Double_t factor)
406{
407
408 //------------------------------------------------------------------
409 //This function makes a track forget its history :)
410 //------------------------------------------------------------------
411 if (factor<=0) {
6c94f330 412 ResetCovariance(10.);
81e97e0d 413 return;
414 }
6c94f330 415 ResetCovariance(factor);
416
81e97e0d 417 SetNumberOfClusters(0);
418 fNFoundable =0;
419 SetChi2(0);
420 fRemoval = 0;
421 fCurrentSigmaY2 = 0.000005;
422 fCurrentSigmaZ2 = 0.000005;
423 fNoCluster = 0;
424 //fFirstPoint = 160;
425 //fLastPoint = 0;
426}
427
428
429
430
431Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
432{
433 //-----------------------------------------------------------------
434 // This function find proloncation of a track to a reference plane x=xk.
435 // doesn't change internal state of the track
436 //-----------------------------------------------------------------
437
6c94f330 438 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
81e97e0d 439
6c94f330 440 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
81e97e0d 441 return 0;
442 }
443
444 // Double_t y1=fP0, z1=fP1;
60e55aee 445 Double_t c1=GetSnp(), r1=sqrt((1.-c1)*(1.+c1));
446 Double_t c2=c1 + GetC()*dx, r2=sqrt((1.-c2)*(1.+c2));
81e97e0d 447
6c94f330 448 y = GetY();
449 z = GetZ();
81e97e0d 450 //y += dx*(c1+c2)/(r1+r2);
451 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
452
453 Double_t dy = dx*(c1+c2)/(r1+r2);
454 Double_t dz = 0;
455 //
6c94f330 456 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
81e97e0d 457 /*
458 if (TMath::Abs(delta)>0.0001){
459 dz = fP3*TMath::ASin(delta)/fP4;
460 }else{
461 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
462 }
463 */
464 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
6c94f330 465 dz = GetTgl()*TMath::ASin(delta)/GetC();
81e97e0d 466 //
467 y+=dy;
468 z+=dz;
469
470
471 return 1;
472}
473
474
475//_____________________________________________________________________________
af32720d 476Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
81e97e0d 477{
478 //-----------------------------------------------------------------
479 // This function calculates a predicted chi2 increment.
480 //-----------------------------------------------------------------
6c94f330 481 Double_t p[2]={c->GetY(), c->GetZ()};
482 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
9c7b8249 483
484 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
485 if (TMath::Abs(dx)>0){
486 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
487 Float_t dy = dx*ty;
488 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
489 p[0] = c->GetY()-dy;
490 p[1] = c->GetZ()-dz;
491 }
6c94f330 492 return AliExternalTrackParam::GetPredictedChi2(p,cov);
81e97e0d 493}
494
81e97e0d 495//_________________________________________________________________________________________
496
497
498Int_t AliTPCseed::Compare(const TObject *o) const {
499 //-----------------------------------------------------------------
500 // This function compares tracks according to the sector - for given sector according z
501 //-----------------------------------------------------------------
502 AliTPCseed *t=(AliTPCseed*)o;
6c94f330 503
81e97e0d 504 if (fSort == 0){
505 if (t->fRelativeSector>fRelativeSector) return -1;
506 if (t->fRelativeSector<fRelativeSector) return 1;
507 Double_t z2 = t->GetZ();
508 Double_t z1 = GetZ();
509 if (z2>z1) return 1;
510 if (z2<z1) return -1;
511 return 0;
512 }
513 else {
514 Float_t f2 =1;
6c23ffed 515 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
81e97e0d 516 if (t->fBConstrain) f2=1.2;
517
518 Float_t f1 =1;
6c23ffed 519 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
81e97e0d 520
521 if (fBConstrain) f1=1.2;
522
523 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
524 else return +1;
525 }
526}
527
528
529
530
531//_____________________________________________________________________________
70e20dcf 532Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
6c94f330 533{
81e97e0d 534 //-----------------------------------------------------------------
535 // This function associates a cluster with this track.
536 //-----------------------------------------------------------------
81e97e0d 537 Int_t n=GetNumberOfClusters();
70e20dcf 538 Int_t idx=GetClusterIndex(n); // save the current cluster index
539
540 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
ca521f6c 541 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
542 if (TMath::Abs(dx)>0){
543 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
544 Float_t dy = dx*ty;
545 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
546 cl.SetY(c->GetY()-dy);
547 cl.SetZ(c->GetZ()-dz);
548 }
549
70e20dcf 550 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
e0e13b88 551
552 if (fCMeanSigmaY2p30<0){
553 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
c07cb486 554 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
555 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
556 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
e0e13b88 557 }
558 //
559 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
c07cb486 560 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
561 if (fCurrentSigmaY2>0){
562 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
563 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
564 }
e0e13b88 565
81e97e0d 566
70e20dcf 567 SetClusterIndex(n,idx); // restore the current cluster index
6c94f330 568 return kTRUE;
81e97e0d 569}
570
571
572
573//_____________________________________________________________________________
dc5cd41c 574Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t /* onlyused */) {
81e97e0d 575 //-----------------------------------------------------------------
576 // This funtion calculates dE/dX within the "low" and "up" cuts.
577 //-----------------------------------------------------------------
83afd539 578 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
579 Int_t row0 = param->GetNRowLow();
580 Int_t row1 = row0+param->GetNRowUp1();
581 Int_t row2 = row1+param->GetNRowUp2();
582 //
583 //
584 //
585 fDEDX[0] = CookdEdxNorm(low,up,0 ,i1 ,i2, kTRUE,kFALSE,2,0);
586 fDEDX[1] = CookdEdxNorm(low,up,0 ,0 ,row0,kTRUE,kFALSE,2,0);
587 fDEDX[2] = CookdEdxNorm(low,up,0 ,row0,row1,kTRUE,kFALSE,2,0);
588 fDEDX[3] = CookdEdxNorm(low,up,0 ,row1,row2,kTRUE,kFALSE,2,0);
589 //
590 fSDEDX[0] = CookdEdxNorm(low,up,0 ,i1 ,i2, kTRUE,kFALSE,2,1);
591 fSDEDX[1] = CookdEdxNorm(low,up,0 ,0 ,row0,kTRUE,kFALSE,2,1);
592 fSDEDX[2] = CookdEdxNorm(low,up,0 ,row0,row1,kTRUE,kFALSE,2,1);
593 fSDEDX[3] = CookdEdxNorm(low,up,0 ,row1,row2,kTRUE,kFALSE,2,1);
594 //
595 fNCDEDX[0] = TMath::Nint(CookdEdxNorm(low,up,0 ,i1 ,i2, kTRUE,kFALSE,2,2));
596 fNCDEDX[1] = TMath::Nint(CookdEdxNorm(low,up,0 ,0 ,row0,kTRUE,kFALSE,2,2));
597 fNCDEDX[2] = TMath::Nint(CookdEdxNorm(low,up,0 ,row0,row1,kTRUE,kFALSE,2,2));
598 fNCDEDX[3] = TMath::Nint(CookdEdxNorm(low,up,0 ,row1,row2,kTRUE,kFALSE,2,2));
81e97e0d 599
83afd539 600 SetdEdx(fDEDX[0]);
601 return fDEDX[0];
81e97e0d 602
ba5e52fb 603// return CookdEdxNorm(low,up,0,i1,i2,1,0,2);
4cc7ba77 604
605
ba5e52fb 606// Float_t amp[200];
607// Float_t angular[200];
608// Float_t weight[200];
609// Int_t index[200];
610// //Int_t nc = 0;
611// Float_t meanlog = 100.;
612
613// Float_t mean[4] = {0,0,0,0};
614// Float_t sigma[4] = {1000,1000,1000,1000};
615// Int_t nc[4] = {0,0,0,0};
616// Float_t norm[4] = {1000,1000,1000,1000};
617// //
618// //
619// fNShared =0;
620
621// Float_t gainGG = 1;
622// if (AliTPCcalibDB::Instance()->GetParameters()){
623// gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
624// }
625
626
627// for (Int_t of =0; of<4; of++){
628// for (Int_t i=of+i1;i<i2;i+=4)
629// {
630// Int_t clindex = fIndex[i];
631// if (clindex<0||clindex&0x8000) continue;
632
633// //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
634// AliTPCTrackerPoint * point = GetTrackPoint(i);
635// //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
636// //AliTPCTrackerPoint * pointp = 0;
637// //if (i<159) pointp = GetTrackPoint(i+1);
638
639// if (point==0) continue;
640// AliTPCclusterMI * cl = fClusterPointer[i];
641// if (cl==0) continue;
642// if (onlyused && (!cl->IsUsed(10))) continue;
643// if (cl->IsUsed(11)) {
644// fNShared++;
645// continue;
646// }
647// Int_t type = cl->GetType();
648// //if (point->fIsShared){
649// // fNShared++;
650// // continue;
651// //}
652// //if (pointm)
653// // if (pointm->fIsShared) continue;
654// //if (pointp)
655// // if (pointp->fIsShared) continue;
656
657// if (type<0) continue;
658// //if (type>10) continue;
659// //if (point->GetErrY()==0) continue;
660// //if (point->GetErrZ()==0) continue;
661
662// //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
663// //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
664// //if ((ddy*ddy+ddz*ddz)>10) continue;
665
666
667// // if (point->GetCPoint().GetMax()<5) continue;
668// if (cl->GetMax()<5) continue;
669// Float_t angley = point->GetAngleY();
670// Float_t anglez = point->GetAngleZ();
671
672// Float_t rsigmay2 = point->GetSigmaY();
673// Float_t rsigmaz2 = point->GetSigmaZ();
674// /*
675// Float_t ns = 1.;
676// if (pointm){
677// rsigmay += pointm->GetTPoint().GetSigmaY();
678// rsigmaz += pointm->GetTPoint().GetSigmaZ();
679// ns+=1.;
680// }
681// if (pointp){
682// rsigmay += pointp->GetTPoint().GetSigmaY();
683// rsigmaz += pointp->GetTPoint().GetSigmaZ();
684// ns+=1.;
685// }
686// rsigmay/=ns;
687// rsigmaz/=ns;
688// */
689
690// Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
691
692// Float_t ampc = 0; // normalization to the number of electrons
693// if (i>64){
694// // ampc = 1.*point->GetCPoint().GetMax();
695// ampc = 1.*cl->GetMax();
696// //ampc = 1.*point->GetCPoint().GetQ();
697// // AliTPCClusterPoint & p = point->GetCPoint();
698// // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
699// // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
700// //Float_t dz =
701// // TMath::Abs( Int_t(iz) - iz + 0.5);
702// //ampc *= 1.15*(1-0.3*dy);
703// //ampc *= 1.15*(1-0.3*dz);
704// // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
705// //ampc *=zfactor;
706// }
707// else{
708// //ampc = 1.0*point->GetCPoint().GetMax();
709// ampc = 1.0*cl->GetMax();
710// //ampc = 1.0*point->GetCPoint().GetQ();
711// //AliTPCClusterPoint & p = point->GetCPoint();
712// // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
713// //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
714// //Float_t dz =
715// // TMath::Abs( Int_t(iz) - iz + 0.5);
716
717// //ampc *= 1.15*(1-0.3*dy);
718// //ampc *= 1.15*(1-0.3*dz);
719// // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
720// //ampc *=zfactor;
721
722// }
723// ampc *= 2.0; // put mean value to channel 50
724// //ampc *= 0.58; // put mean value to channel 50
725// Float_t w = 1.;
726// // if (type>0) w = 1./(type/2.-0.5);
727// // Float_t z = TMath::Abs(cl->GetZ());
728// if (i<64) {
729// ampc /= 0.6;
730// //ampc /= (1+0.0008*z);
731// } else
732// if (i>128){
733// ampc /=1.5;
734// //ampc /= (1+0.0008*z);
735// }else{
736// //ampc /= (1+0.0008*z);
737// }
81e97e0d 738
ba5e52fb 739// if (type<0) { //amp at the border - lower weight
740// // w*= 2.;
81e97e0d 741
ba5e52fb 742// continue;
743// }
744// if (rsigma>1.5) ampc/=1.3; // if big backround
745// amp[nc[of]] = ampc;
746// amp[nc[of]] /=gainGG;
747// angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
748// weight[nc[of]] = w;
749// nc[of]++;
750// }
81e97e0d 751
ba5e52fb 752// TMath::Sort(nc[of],amp,index,kFALSE);
753// Float_t sumamp=0;
754// Float_t sumamp2=0;
755// Float_t sumw=0;
756// //meanlog = amp[index[Int_t(nc[of]*0.33)]];
757// meanlog = 50;
758// for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
759// Float_t ampl = amp[index[i]]/angular[index[i]];
760// ampl = meanlog*TMath::Log(1.+ampl/meanlog);
761// //
762// sumw += weight[index[i]];
763// sumamp += weight[index[i]]*ampl;
764// sumamp2 += weight[index[i]]*ampl*ampl;
765// norm[of] += angular[index[i]]*weight[index[i]];
766// }
767// if (sumw<1){
768// SetdEdx(0);
769// }
770// else {
771// norm[of] /= sumw;
772// mean[of] = sumamp/sumw;
773// sigma[of] = sumamp2/sumw-mean[of]*mean[of];
774// if (sigma[of]>0.1)
775// sigma[of] = TMath::Sqrt(sigma[of]);
776// else
777// sigma[of] = 1000;
81e97e0d 778
ba5e52fb 779// mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
780// //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
781// //mean *=(1-0.1*(norm-1.));
782// }
783// }
784
785// Float_t dedx =0;
786// fSdEdx =0;
787// fMAngular =0;
788// // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
789// // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
81e97e0d 790
791
ba5e52fb 792// // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
793// // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
794
795// Int_t norm2 = 0;
796// Int_t norm3 = 0;
797// for (Int_t i =0;i<4;i++){
798// if (nc[i]>2&&nc[i]<1000){
799// dedx += mean[i] *nc[i];
800// fSdEdx += sigma[i]*(nc[i]-2);
801// fMAngular += norm[i] *nc[i];
802// norm2 += nc[i];
803// norm3 += nc[i]-2;
804// }
805// fDEDX[i] = mean[i];
806// fSDEDX[i] = sigma[i];
807// fNCDEDX[i]= nc[i];
808// }
809
810// if (norm3>0){
811// dedx /=norm2;
812// fSdEdx /=norm3;
813// fMAngular/=norm2;
814// }
815// else{
816// SetdEdx(0);
817// return 0;
818// }
819// // Float_t dedx1 =dedx;
820// /*
821// dedx =0;
822// for (Int_t i =0;i<4;i++){
823// if (nc[i]>2&&nc[i]<1000){
824// mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
825// dedx += mean[i] *nc[i];
826// }
827// fDEDX[i] = mean[i];
828// }
829// dedx /= norm2;
830// */
81e97e0d 831
832
ba5e52fb 833// SetdEdx(dedx);
834// return dedx;
81e97e0d 835}
836Double_t AliTPCseed::Bethe(Double_t bg){
837 //
838 // This is the Bethe-Bloch function normalised to 1 at the minimum
839 //
840 Double_t bg2=bg*bg;
841 Double_t bethe;
842 if (bg<3.5e1)
843 bethe=(1.+ bg2)/bg2*(log(5940*bg2) - bg2/(1.+ bg2));
844 else // Density effect ( approximately :)
845 bethe=1.15*(1.+ bg2)/bg2*(log(3.5*5940*bg) - bg2/(1.+ bg2));
846 return bethe/11.091;
847}
848
849void AliTPCseed::CookPID()
850{
851 //
852 // cook PID information according dEdx
853 //
854 Double_t fRange = 10.;
855 Double_t fRes = 0.1;
856 Double_t fMIP = 47.;
857 //
858 Int_t ns=AliPID::kSPECIES;
859 Double_t sumr =0;
860 for (Int_t j=0; j<ns; j++) {
861 Double_t mass=AliPID::ParticleMass(j);
6c94f330 862 Double_t mom=GetP();
81e97e0d 863 Double_t dedx=fdEdx/fMIP;
864 Double_t bethe=Bethe(mom/mass);
865 Double_t sigma=fRes*bethe;
866 if (sigma>0.001){
867 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
868 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
869 sumr+=fTPCr[j];
870 continue;
871 }
872 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
873 sumr+=fTPCr[j];
874 }
875 else{
876 fTPCr[j]=1.;
877 sumr+=fTPCr[j];
878 }
879 }
880 for (Int_t j=0; j<ns; j++) {
881 fTPCr[j]/=sumr; //normalize
882 }
883}
884
6c94f330 885Double_t AliTPCseed::GetYat(Double_t xk) const {
886//-----------------------------------------------------------------
887// This function calculates the Y-coordinate of a track at the plane x=xk.
888//-----------------------------------------------------------------
889 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
60e55aee 890 Double_t c1=GetSnp(), r1=TMath::Sqrt((1.-c1)*(1.+c1));
6c94f330 891 Double_t c2=c1+GetC()*(xk-GetX());
892 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
60e55aee 893 Double_t r2=TMath::Sqrt((1.-c2)*(1.+c2));
6c94f330 894 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
895}
896
19b00333 897void AliTPCseed::SetClusterMapBit(int ibit, Bool_t state)
898{
899 fClusterMap[ibit] = state;
900}
901Bool_t AliTPCseed::GetClusterMapBit(int ibit)
902{
903 return fClusterMap[ibit];
904}
905void AliTPCseed::SetSharedMapBit(int ibit, Bool_t state)
906{
907 fSharedMap[ibit] = state;
908}
909Bool_t AliTPCseed::GetSharedMapBit(int ibit)
910{
911 return fSharedMap[ibit];
912}
eb02f63a 913
914
0a65832b 915
916
917
8a92e133 918Float_t AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Bool_t shapeNorm,Int_t posNorm, Int_t padNorm, Int_t returnVal){
0a65832b 919
920 //
921 // calculates dedx using the cluster
922 // low - up specify trunc mean range - default form 0-0.7
8076baa0 923 // type - 1 - max charge or 0- total charge in cluster
924 // //2- max no corr 3- total+ correction
0a65832b 925 // i1-i2 - the pad-row range used for calculation
ba5e52fb 926 // shapeNorm - kTRUE -taken from OCDB
927 //
928 // posNorm - usage of pos normalization
83afd539 929 // padNorm - pad type normalization
930 // returnVal - 0 return mean
931 // - 1 return RMS
932 // - 2 return number of clusters
933 //
0a65832b 934 // normalization parametrization taken from AliTPCClusterParam
935 //
ba5e52fb 936 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
937 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
938 if (!parcl) return 0;
939 if (!param) return 0;
83afd539 940 Int_t row0 = param->GetNRowLow();
941 Int_t row1 = row0+param->GetNRowUp1();
942
0a65832b 943 Float_t amp[160];
944 Int_t indexes[160];
945 Int_t ncl=0;
946 //
947 //
ba5e52fb 948 Float_t gainGG = 1; // gas gain factor -always enabled
949 Float_t gainPad = 1; // gain map - used always
83afd539 950 Float_t corrShape = 1; // correction due angular effect, diffusion and electron attachment
ba5e52fb 951 Float_t corrPos = 1; // local position correction - if posNorm enabled
952 Float_t corrPadType = 1; // pad type correction - if padNorm enabled
953 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
954 //
955 //
956 //
4cc7ba77 957 if (AliTPCcalibDB::Instance()->GetParameters()){
ba5e52fb 958 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
4cc7ba77 959 }
960
0a65832b 961 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
4cc7ba77 962 const Float_t kedgey =3.;
0a65832b 963 //
7cd8ac3f 964 //
0a65832b 965 for (Int_t irow=i1; irow<i2; irow++){
966 AliTPCclusterMI* cluster = GetClusterPointer(irow);
967 if (!cluster) continue;
968 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
8076baa0 969 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
ba5e52fb 970 Int_t ipad= 0;
83afd539 971 if (irow>=row0) ipad=1;
972 if (irow>=row1) ipad=2;
ba5e52fb 973 //
974 //
975 //
976 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
977 if (gainMap) {
978 //
979 // Get gainPad - pad by pad calibration
980 //
d6920632 981 Float_t factor = 1;
982 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
83afd539 983 if (irow < row0) { // IROC
ba5e52fb 984 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
d6920632 985 } else { // OROC
83afd539 986 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
d6920632 987 }
ba5e52fb 988 if (factor>0.5) gainPad=factor;
7cd8ac3f 989 }
ba5e52fb 990 //
991 //do position and angular normalization
992 //
993 if (shapeNorm){
994 if (type<=1){
995 //
996 AliTPCTrackerPoint * point = GetTrackPoint(irow);
997 Float_t ty = TMath::Abs(point->GetAngleY());
83afd539 998 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
ba5e52fb 999
1000 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1001 corrShape = parcl->Qnorm(ipad,type,dr,ty,tz);
1002 }
0a65832b 1003 }
ba5e52fb 1004
8a92e133 1005 if (posNorm>0){
8e1dcdda 1006 //
ba5e52fb 1007 // Do position normalization - relative distance to
1008 // center of pad- time bin
1009 // Work in progress
022a2383 1010 // corrPos = parcl->QnormPos(ipad,type, cluster->GetPad(),
1011 // cluster->GetTimeBin(), cluster->GetZ(),
1012 // cluster->GetSigmaY2(),cluster->GetSigmaZ2(),
1013 // cluster->GetMax(),cluster->GetQ());
8a92e133 1014 // scaled response function
1015 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1016 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1017 //
1018
022a2383 1019 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1020 Float_t ty = TMath::Abs(point->GetAngleY());
1021 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1022
1023 if (type==1) corrPos =
1024 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
8a92e133 1025 cluster->GetTimeBin(),ty,tz,yres0,zres0,0.4);
022a2383 1026 if (type==0) corrPos =
1027 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
8a92e133 1028 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,0.4);
1029 if (posNorm==3){
1030 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1031 Double_t signtgl = (cluster->GetZ()*point->GetAngleZ()>0)? 1:-1;
1032 Double_t p2 = TMath::Abs(TMath::Sin(TMath::ATan(ty)));
1033 Float_t corrHis = parcl->QnormHis(ipad,type,dr,p2,TMath::Abs(point->GetAngleZ())*signtgl);
1034 if (corrHis>0) corrPos*=corrHis;
1035 }
1036
8e1dcdda 1037 }
1038
ba5e52fb 1039 if (padNorm==1){
1040 //taken from OCDB
1041 if (type==0 && parcl->fQpadTnorm) corrPadType = (*parcl->fQpadTnorm)[ipad];
1042 if (type==1 && parcl->fQpadTnorm) corrPadType = (*parcl->fQpadMnorm)[ipad];
022a2383 1043
2fc9608f 1044 }
ba5e52fb 1045 if (padNorm==2){
1046 corrPadType =param->GetPadPitchLength(cluster->GetDetector(),cluster->GetRow());
1047 //use hardwired - temp fix
1048 if (type==0) corrNorm=3.;
1049 if (type==1) corrNorm=1.;
1050 }
1051 //
1052 amp[ncl]=charge;
1053 amp[ncl]/=gainGG;
1054 amp[ncl]/=gainPad;
1055 amp[ncl]/=corrShape;
1056 amp[ncl]/=corrPadType;
1057 amp[ncl]/=corrPos;
1058 amp[ncl]/=corrNorm;
1059 //
0a65832b 1060 ncl++;
1061 }
8076baa0 1062
0a65832b 1063 if (type>3) return ncl;
1064 TMath::Sort(ncl,amp, indexes, kFALSE);
1065
8076baa0 1066 if (ncl<10) return 0;
0a65832b 1067
1068 Float_t suma=0;
83afd539 1069 Float_t suma2=0;
0a65832b 1070 Float_t sumn=0;
1071 Int_t icl0=TMath::Nint(ncl*low);
1072 Int_t icl1=TMath::Nint(ncl*up);
1073 for (Int_t icl=icl0; icl<icl1;icl++){
1074 suma+=amp[indexes[icl]];
83afd539 1075 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
0a65832b 1076 sumn++;
1077 }
83afd539 1078 Float_t mean =suma/sumn;
1079 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1080 if (returnVal==1) return rms;
8a92e133 1081 if (returnVal==2) return ncl;
1082 return mean;
1083}
1084
1085Float_t AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal){
1086
1087 //
1088 // calculates dedx using the cluster
1089 // low - up specify trunc mean range - default form 0-0.7
1090 // type - 1 - max charge or 0- total charge in cluster
1091 // //2- max no corr 3- total+ correction
1092 // i1-i2 - the pad-row range used for calculation
1093 //
1094 // posNorm - usage of pos normalization
1095 // returnVal - 0 return mean
1096 // - 1 return RMS
1097 // - 2 return number of clusters
1098 //
1099 // normalization parametrization taken from AliTPCClusterParam
1100 //
1101 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1102 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1103 if (!parcl) return 0;
1104 if (!param) return 0;
1105 Int_t row0 = param->GetNRowLow();
1106 Int_t row1 = row0+param->GetNRowUp1();
1107
1108 Float_t amp[160];
1109 Int_t indexes[160];
1110 Int_t ncl=0;
1111 //
1112 //
1113 Float_t gainGG = 1; // gas gain factor -always enabled
1114 Float_t gainPad = 1; // gain map - used always
1115 Float_t corrPos = 1; // local position correction - if posNorm enabled
1116 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
1117 //
1118 //
1119 //
1120 if (AliTPCcalibDB::Instance()->GetParameters()){
1121 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
1122 }
1123
1124 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1125 const Float_t kedgey =3.;
1126 //
1127 //
1128 for (Int_t irow=i1; irow<i2; irow++){
1129 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1130 if (!cluster) continue;
1131 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1132 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1133 Int_t ipad= 0;
1134 if (irow>=row0) ipad=1;
1135 if (irow>=row1) ipad=2;
1136 //
1137 //
1138 //
1139 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1140 if (gainMap) {
1141 //
1142 // Get gainPad - pad by pad calibration
1143 //
1144 Float_t factor = 1;
1145 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1146 if (irow < row0) { // IROC
1147 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
1148 } else { // OROC
1149 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
1150 }
1151 if (factor>0.5) gainPad=factor;
1152 }
1153
1154 //
1155 // Do position normalization - relative distance to
1156 // center of pad- time bin
1157
1158 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1159 Float_t ty = TMath::Abs(point->GetAngleY());
1160 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1161 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1162 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1163
1164 yres0 *=parcl->GetQnormCorr(ipad, type,0);
1165 zres0 *=parcl->GetQnormCorr(ipad, type,1);
1166 Float_t effLength=parcl->GetQnormCorr(ipad, type,4)*0.5;
1167 Float_t effDiff =(parcl->GetQnormCorr(ipad, type,2)+parcl->GetQnormCorr(ipad, type,3))*0.5;
1168 //
1169 if (type==1) {
1170 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1171 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1172 cluster->GetTimeBin(),ty,tz,yres0,zres0,effLength,effDiff);
1173 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1174 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1175 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1176 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1177 //
1178 }
1179 if (type==0) {
1180 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1181 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1182 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,effLength,effDiff);
1183
1184 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1185 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1186 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1187 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1188 //
1189 }
1190
1191 //
1192 amp[ncl]=charge;
1193 amp[ncl]/=gainGG;
1194 amp[ncl]/=gainPad;
1195 amp[ncl]/=corrPos;
1196 //
1197 ncl++;
1198 }
1199
1200 if (type>3) return ncl;
1201 TMath::Sort(ncl,amp, indexes, kFALSE);
1202
1203 if (ncl<10) return 0;
1204
1205 Float_t suma=0;
1206 Float_t suma2=0;
1207 Float_t sumn=0;
1208 Int_t icl0=TMath::Nint(ncl*low);
1209 Int_t icl1=TMath::Nint(ncl*up);
1210 for (Int_t icl=icl0; icl<icl1;icl++){
1211 suma+=amp[indexes[icl]];
1212 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
1213 sumn++;
1214 }
1215 Float_t mean =suma/sumn;
1216 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1217 if (returnVal==1) return rms;
83afd539 1218 if (returnVal==2) return ncl;
1219 return mean;
0a65832b 1220}
1221
83afd539 1222
0a65832b 1223Double_t AliTPCseed::BetheMass(Double_t mass){
1224 //
1225 // return bethe-bloch
1226 //
1227 Float_t bg= P()/mass;
1228 const Double_t kp1=0.76176e-1;
1229 const Double_t kp2=10.632;
1230 const Double_t kp3=0.13279e-4;
1231 const Double_t kp4=1.8631;
1232 const Double_t kp5=1.9479;
1233
1234 Double_t dbg = (Double_t) bg;
1235
1236 Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
1237
1238 Double_t aa = TMath::Power(beta,kp4);
1239 Double_t bb = TMath::Power(1./dbg,kp5);
1240
1241 bb=TMath::Log(kp3+bb);
1242
1243 return ((Float_t)((kp2-aa-bb)*kp1/aa));
1244}
1245
1246
eb02f63a 1247Float_t AliTPCseed::CookShape(Int_t type){
1248 //
1249 //
1250 //
1251 //-----------------------------------------------------------------
1252 // This funtion calculates dE/dX within the "low" and "up" cuts.
1253 //-----------------------------------------------------------------
1254 Float_t means=0;
1255 Float_t meanc=0;
1256 for (Int_t i =0; i<160;i++) {
1257 AliTPCTrackerPoint * point = GetTrackPoint(i);
1258 if (point==0) continue;
1259
1260 AliTPCclusterMI * cl = fClusterPointer[i];
1261 if (cl==0) continue;
1262
1263 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1264 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1265 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1266 if (type==0) means+=rsigma;
1267 if (type==1) means+=rsigmay;
1268 if (type==2) means+=rsigmaz;
1269 meanc++;
1270 }
1271 Float_t mean = (meanc>0)? means/meanc:0;
1272 return mean;
1273}
87e92a27 1274
1275
1276
1277Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1278 //
1279 // Refit the track
1280 // return value - number of used clusters
1281 //
1282 //
1283 const Int_t kMinNcl =10;
1284 AliTPCseed *track=new AliTPCseed(*seed);
1285 Int_t sector=-1;
1286 // reset covariance
1287 //
1288 Double_t covar[15];
1289 for (Int_t i=0;i<15;i++) covar[i]=0;
1290 covar[0]=10.*10.;
1291 covar[2]=10.*10.;
1292 covar[5]=10.*10./(64.*64.);
1293 covar[9]=10.*10./(64.*64.);
1294 covar[14]=1*1;
1295 //
1296
1297 Float_t xmin=1000, xmax=-10000;
1298 Int_t imin=158, imax=0;
1299 for (Int_t i=0;i<160;i++) {
1300 AliTPCclusterMI *c=track->GetClusterPointer(i);
1301 if (!c) continue;
1302 if (sector<0) sector = c->GetDetector();
1303 if (c->GetX()<xmin) xmin=c->GetX();
1304 if (c->GetX()>xmax) xmax=c->GetX();
1305 if (i<imin) imin=i;
1306 if (i>imax) imax=i;
1307 }
1308 if(imax-imin<kMinNcl) {
1309 delete track;
1310 return 0 ;
1311 }
1312 // Not succes to rotate
1313 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1314 delete track;
1315 return 0;
1316 }
1317 //
1318 //
1319 // fit from inner to outer row
1320 //
1321 AliExternalTrackParam paramIn;
1322 AliExternalTrackParam paramOut;
1323 Bool_t isOK=kTRUE;
be34cb88 1324 Int_t ncl=0;
87e92a27 1325 //
1326 //
1327 //
1328 for (Int_t i=imin; i<=imax; i++){
1329 AliTPCclusterMI *c=track->GetClusterPointer(i);
1330 if (!c) continue;
1331 // if (RejectCluster(c,track)) continue;
be34cb88 1332 sector = (c->GetDetector()%18);
1333 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1334 //continue;
1335 }
87e92a27 1336 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1337 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1338 if (!track->PropagateTo(r[0])) {
1339 isOK=kFALSE;
87e92a27 1340 }
1341 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1342 }
1343 if (!isOK) { delete track; return 0;}
1344 track->AddCovariance(covar);
1345 //
1346 //
1347 //
1348 for (Int_t i=imax; i>=imin; i--){
1349 AliTPCclusterMI *c=track->GetClusterPointer(i);
1350 if (!c) continue;
1351 //if (RejectCluster(c,track)) continue;
be34cb88 1352 sector = (c->GetDetector()%18);
1353 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1354 //continue;
1355 }
87e92a27 1356 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1357 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1358 if (!track->PropagateTo(r[0])) {
1359 isOK=kFALSE;
87e92a27 1360 }
1361 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1362 }
be34cb88 1363 //if (!isOK) { delete track; return 0;}
87e92a27 1364 paramIn = *track;
1365 track->AddCovariance(covar);
1366 //
1367 //
1368 for (Int_t i=imin; i<=imax; i++){
1369 AliTPCclusterMI *c=track->GetClusterPointer(i);
1370 if (!c) continue;
be34cb88 1371 sector = (c->GetDetector()%18);
1372 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1373 //continue;
1374 }
1375 ncl++;
87e92a27 1376 //if (RejectCluster(c,track)) continue;
1377 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1378 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1379 if (!track->PropagateTo(r[0])) {
1380 isOK=kFALSE;
87e92a27 1381 }
1382 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1383 }
be34cb88 1384 //if (!isOK) { delete track; return 0;}
87e92a27 1385 paramOut=*track;
87e92a27 1386 //
1387 //
1388 //
1389 if (parin) (*parin)=paramIn;
1390 if (parout) (*parout)=paramOut;
be34cb88 1391 return ncl;
87e92a27 1392}
1393
1394
1395
1396Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1397 //
1398 //
1399 //
1400 return kFALSE;
1401}
3247d397 1402
1403
1404
1405
1406
1407
1408void AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1409 Double_t& erry, Double_t &errz)
1410{
1411 //
1412 // Get cluster error at given position
1413 //
1414 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1415 Double_t tany,tanz;
1416 Double_t snp1=param->GetSnp();
60e55aee 1417 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1418 //
1419 Double_t tgl1=param->GetTgl();
60e55aee 1420 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1421 //
1422 Int_t padSize = 0; // short pads
1423 if (cluster->GetDetector() >= 36) {
1424 padSize = 1; // medium pads
1425 if (cluster->GetRow() > 63) padSize = 2; // long pads
1426 }
1427
1428 erry = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
1429 errz = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
1430}
1431
1432
1433void AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1434 Double_t& rmsy, Double_t &rmsz)
1435{
1436 //
1437 // Get cluster error at given position
1438 //
1439 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1440 Double_t tany,tanz;
1441 Double_t snp1=param->GetSnp();
60e55aee 1442 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1443 //
1444 Double_t tgl1=param->GetTgl();
60e55aee 1445 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1446 //
1447 Int_t padSize = 0; // short pads
1448 if (cluster->GetDetector() >= 36) {
1449 padSize = 1; // medium pads
1450 if (cluster->GetRow() > 63) padSize = 2; // long pads
1451 }
1452
1453 rmsy = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
1454 rmsz = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
1455}
ba5e52fb 1456
1457
1458
1459Double_t AliTPCseed::GetQCorrGeom(Float_t ty, Float_t tz){
1460 //Geoetrical
1461 //ty - tangent in local y direction
1462 //tz - tangent
1463 //
1464 Float_t norm=TMath::Sqrt(1+ty*ty+tz*tz);
1465 return norm;
1466}
1467
83afd539 1468Double_t AliTPCseed::GetQCorrShape(Int_t ipad, Int_t type,Float_t z, Float_t ty, Float_t tz, Float_t /*q*/, Float_t /*thr*/){
ba5e52fb 1469 //
1470 // Q normalization
1471 //
1472 // return value = Q Normalization factor
1473 // Normalization - 1 - shape factor part for full drift
1474 // 1 - electron attachment for 0 drift
1475
1476 // Input parameters:
1477 //
1478 // ipad - 0 short pad
1479 // 1 medium pad
1480 // 2 long pad
1481 //
1482 // type - 0 qmax
1483 // - 1 qtot
1484 //
1485 //z - z position (-250,250 cm)
1486 //ty - tangent in local y direction
1487 //tz - tangent
1488 //
1489
1490 AliTPCClusterParam * paramCl = AliTPCcalibDB::Instance()->GetClusterParam();
1491 AliTPCParam * paramTPC = AliTPCcalibDB::Instance()->GetParameters();
1492
1493 if (!paramCl) return 1;
1494 //
1495 Double_t dr = 250.-TMath::Abs(z);
1496 Double_t sy = paramCl->GetRMS0( 0,ipad, dr, TMath::Abs(ty));
1497 Double_t sy0= paramCl->GetRMS0(0,ipad, 250, 0);
1498 Double_t sz = paramCl->GetRMS0( 1,ipad, dr, TMath::Abs(tz));
1499 Double_t sz0= paramCl->GetRMS0(1,ipad, 250, 0);
1500
1501 Double_t sfactorMax = TMath::Sqrt(sy0*sz0/(sy*sz));
1502
1503
1504 Double_t dt = 1000000*(dr/paramTPC->GetDriftV()); //time in microsecond
1505 Double_t attProb = TMath::Exp(-paramTPC->GetAttCoef()*paramTPC->GetOxyCont()*dt);
1506 //
1507 //
1508 if (type==0) return sfactorMax*attProb;
1509
1510 return attProb;
1511
1512
1513}
1514