The precision of AliESDv0::fPointAngle is changed from [-1,1,16] to [-1,1,32]
[u/mrichter/AliRoot.git] / TPC / Rec / 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//-----------------------------------------------------------------
28273e26 20//
81e97e0d 21// Implementation of the TPC seed class
829455ad 22// This class is used by the AliTPCtracker class
81e97e0d 23// Origin: Marian Ivanov, CERN, Marian.Ivanov@cern.ch
24//-----------------------------------------------------------------
25#include "TClonesArray.h"
2efc897f 26#include "TGraphErrors.h"
81e97e0d 27#include "AliTPCseed.h"
3f82c4f2 28#include "AliTPCReconstructor.h"
0a65832b 29#include "AliTPCClusterParam.h"
7cd8ac3f 30#include "AliTPCCalPad.h"
31#include "AliTPCCalROC.h"
37540068 32#include "AliTPCcalibDB.h"
d080e4a4 33#include "AliTPCParam.h"
5731b051 34#include "AliMathBase.h"
3af3fbc4 35#include "AliTPCTransform.h"
36#include "AliSplineFit.h"
37#include "AliCDBManager.h"
108a67db 38#include "AliTPCcalibDButil.h"
7cd8ac3f 39
81e97e0d 40
41ClassImp(AliTPCseed)
42
43
44
32fab534 45AliTPCseed::AliTPCseed():
46 AliTPCtrack(),
47 fEsd(0x0),
2928bdf0 48 fClusterOwner(kFALSE),
32fab534 49 fRow(0),
50 fSector(-1),
51 fRelativeSector(-1),
52 fCurrentSigmaY2(1e10),
53 fCurrentSigmaZ2(1e10),
e0e13b88 54 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
55 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 56 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
57 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
e0e13b88 58 //
32fab534 59 fErrorY2(1e10),
60 fErrorZ2(1e10),
61 fCurrentCluster(0x0),
62 fCurrentClusterIndex1(-1),
63 fInDead(kFALSE),
64 fIsSeeding(kFALSE),
65 fNoCluster(0),
66 fSort(0),
67 fBSigned(kFALSE),
68 fSeedType(0),
69 fSeed1(-1),
70 fSeed2(-1),
71 fMAngular(0),
ddfbc51a 72 fCircular(0),
73 fPoolID(-1)
32fab534 74{
81e97e0d 75 //
5c09947e 76 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 77 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
78 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
32fab534 79 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
80 for (Int_t i=0;i<4;i++) {
81 fDEDX[i] = 0.;
82 fSDEDX[i] = 1e10;
83 fNCDEDX[i] = 0;
9c0db267 84 fNCDEDXInclThres[i] = 0;
32fab534 85 }
9c0db267 86 fDEDX[4] = 0;
32fab534 87 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 88}
32fab534 89
2928bdf0 90AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
32fab534 91 AliTPCtrack(s),
92 fEsd(0x0),
2928bdf0 93 fClusterOwner(clusterOwner),
32fab534 94 fRow(0),
95 fSector(-1),
96 fRelativeSector(-1),
c07cb486 97 fCurrentSigmaY2(-1),
98 fCurrentSigmaZ2(-1),
e0e13b88 99 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
100 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 101 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
102 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 103 fErrorY2(1e10),
104 fErrorZ2(1e10),
105 fCurrentCluster(0x0),
106 fCurrentClusterIndex1(-1),
107 fInDead(kFALSE),
108 fIsSeeding(kFALSE),
109 fNoCluster(0),
110 fSort(0),
111 fBSigned(kFALSE),
112 fSeedType(0),
113 fSeed1(-1),
114 fSeed2(-1),
115 fMAngular(0),
ddfbc51a 116 fCircular(0),
117 fPoolID(-1)
32fab534 118{
81e97e0d 119 //---------------------
120 // dummy copy constructor
121 //-------------------------
2928bdf0 122 for (Int_t i=0;i<160;i++) {
123 fClusterPointer[i]=0;
124 if (fClusterOwner){
125 if (s.fClusterPointer[i])
126 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
127 }else{
128 fClusterPointer[i] = s.fClusterPointer[i];
129 }
130 fTrackPoints[i] = s.fTrackPoints[i];
131 }
81e97e0d 132 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
5c09947e 133 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
134 for (Int_t i=0;i<4;i++) {
135 fDEDX[i] = s.fDEDX[i];
136 fSDEDX[i] = s.fSDEDX[i];
137 fNCDEDX[i] = s.fNCDEDX[i];
9c0db267 138 fNCDEDXInclThres[i] = s.fNCDEDXInclThres[i];
5c09947e 139 }
9c0db267 140 fDEDX[4] = s.fDEDX[4];
5c09947e 141 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
19b00333 142
81e97e0d 143}
5c09947e 144
145
32fab534 146AliTPCseed::AliTPCseed(const AliTPCtrack &t):
147 AliTPCtrack(t),
148 fEsd(0x0),
2928bdf0 149 fClusterOwner(kFALSE),
32fab534 150 fRow(0),
151 fSector(-1),
152 fRelativeSector(-1),
c07cb486 153 fCurrentSigmaY2(-1),
154 fCurrentSigmaZ2(-1),
e0e13b88 155 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
156 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 157 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
158 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 159 fErrorY2(1e10),
160 fErrorZ2(1e10),
161 fCurrentCluster(0x0),
162 fCurrentClusterIndex1(-1),
163 fInDead(kFALSE),
164 fIsSeeding(kFALSE),
165 fNoCluster(0),
166 fSort(0),
167 fBSigned(kFALSE),
168 fSeedType(0),
169 fSeed1(-1),
170 fSeed2(-1),
171 fMAngular(0),
ddfbc51a 172 fCircular(0),
173 fPoolID(-1)
32fab534 174{
81e97e0d 175 //
32fab534 176 // Constructor from AliTPCtrack
177 //
178 fFirstPoint =0;
105b1b81 179 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
81e97e0d 180 for (Int_t i=0;i<160;i++) {
181 fClusterPointer[i] = 0;
182 Int_t index = t.GetClusterIndex(i);
183 if (index>=-1){
184 SetClusterIndex2(i,index);
185 }
186 else{
187 SetClusterIndex2(i,-3);
188 }
189 }
32fab534 190 for (Int_t i=0;i<4;i++) {
191 fDEDX[i] = 0.;
192 fSDEDX[i] = 1e10;
193 fNCDEDX[i] = 0;
9c0db267 194 fNCDEDXInclThres[i] = 0;
32fab534 195 }
9c0db267 196 fDEDX[4] = 0;
32fab534 197 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 198}
199
6c94f330 200AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
201 const Double_t cc[15], Int_t index):
202 AliTPCtrack(xr, alpha, xx, cc, index),
32fab534 203 fEsd(0x0),
2928bdf0 204 fClusterOwner(kFALSE),
32fab534 205 fRow(0),
206 fSector(-1),
207 fRelativeSector(-1),
c07cb486 208 fCurrentSigmaY2(-1),
209 fCurrentSigmaZ2(-1),
e0e13b88 210 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
211 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 212 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
213 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 214 fErrorY2(1e10),
215 fErrorZ2(1e10),
216 fCurrentCluster(0x0),
217 fCurrentClusterIndex1(-1),
218 fInDead(kFALSE),
219 fIsSeeding(kFALSE),
220 fNoCluster(0),
221 fSort(0),
222 fBSigned(kFALSE),
223 fSeedType(0),
224 fSeed1(-1),
225 fSeed2(-1),
226 fMAngular(0),
ddfbc51a 227 fCircular(0),
228 fPoolID(-1)
32fab534 229{
230 //
231 // Constructor
81e97e0d 232 //
32fab534 233 fFirstPoint =0;
5c09947e 234 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 235 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
81e97e0d 236 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
32fab534 237 for (Int_t i=0;i<4;i++) {
238 fDEDX[i] = 0.;
239 fSDEDX[i] = 1e10;
240 fNCDEDX[i] = 0;
9c0db267 241 fNCDEDXInclThres[i] = 0;
32fab534 242 }
9c0db267 243 fDEDX[4] = 0;
32fab534 244 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 245}
246
247AliTPCseed::~AliTPCseed(){
248 //
249 // destructor
81e97e0d 250 fNoCluster =0;
2928bdf0 251 if (fClusterOwner){
252 for (Int_t icluster=0; icluster<160; icluster++){
253 delete fClusterPointer[icluster];
254 }
255 }
bfb57b6c 256
81e97e0d 257}
179c6296 258//_________________________________________________
316c6cd9 259AliTPCseed & AliTPCseed::operator=(const AliTPCseed &param)
179c6296 260{
261 //
316c6cd9 262 // assignment operator
ddfbc51a 263 // don't touch pool ID
179c6296 264 //
316c6cd9 265 if(this!=&param){
266 AliTPCtrack::operator=(param);
267 fEsd =param.fEsd;
316c6cd9 268 fClusterOwner = param.fClusterOwner;
f06a1ff6 269 if (!fClusterOwner) for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i];
396e55e3 270 else for(Int_t i = 0;i<160;++i) {
271 delete fClusterPointer[i];
272 fClusterPointer[i] = new AliTPCclusterMI(*(param.fClusterPointer[i]));
273 }
316c6cd9 274 // leave out fPoint, they are also not copied in the copy ctor...
275 // but deleted in the dtor... strange...
316c6cd9 276 fRow = param.fRow;
277 fSector = param.fSector;
278 fRelativeSector = param.fRelativeSector;
279 fCurrentSigmaY2 = param.fCurrentSigmaY2;
280 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
281 fErrorY2 = param.fErrorY2;
282 fErrorZ2 = param.fErrorZ2;
283 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
284 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
285 fInDead = param.fInDead;
286 fIsSeeding = param.fIsSeeding;
287 fNoCluster = param.fNoCluster;
288 fSort = param.fSort;
289 fBSigned = param.fBSigned;
290 for(Int_t i = 0;i<4;++i){
291 fDEDX[i] = param.fDEDX[i];
292 fSDEDX[i] = param.fSDEDX[i];
293 fNCDEDX[i] = param.fNCDEDX[i];
9c0db267 294 fNCDEDXInclThres[i] = param.fNCDEDXInclThres[i];
316c6cd9 295 }
9c0db267 296 fDEDX[4] = param.fDEDX[4];
316c6cd9 297 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
298
299 fSeedType = param.fSeedType;
300 fSeed1 = param.fSeed1;
301 fSeed2 = param.fSeed2;
302 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
303 fMAngular = param.fMAngular;
304 fCircular = param.fCircular;
305 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
316c6cd9 306 }
179c6296 307 return (*this);
308}
309//____________________________________________________
81e97e0d 310AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
311{
312 //
313 //
314 return &fTrackPoints[i];
315}
316
81e97e0d 317
318
319Double_t AliTPCseed::GetDensityFirst(Int_t n)
320{
321 //
322 //
323 // return cluster for n rows bellow first point
324 Int_t nfoundable = 1;
325 Int_t nfound = 1;
326 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
327 Int_t index = GetClusterIndex2(i);
328 if (index!=-1) nfoundable++;
329 if (index>0) nfound++;
330 }
331 if (nfoundable<n) return 0;
332 return Double_t(nfound)/Double_t(nfoundable);
333
334}
335
336
337void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
338{
339 // get cluster stat. on given region
340 //
341 found = 0;
342 foundable = 0;
343 shared =0;
344 for (Int_t i=first;i<last; i++){
345 Int_t index = GetClusterIndex2(i);
346 if (index!=-1) foundable++;
6d493ea0 347 if (index&0x8000) continue;
81e97e0d 348 if (fClusterPointer[i]) {
349 found++;
350 }
351 else
352 continue;
353
354 if (fClusterPointer[i]->IsUsed(10)) {
355 shared++;
356 continue;
357 }
358 if (!plus2) continue; //take also neighborhoud
359 //
360 if ( (i>0) && fClusterPointer[i-1]){
361 if (fClusterPointer[i-1]->IsUsed(10)) {
362 shared++;
363 continue;
364 }
365 }
366 if ( fClusterPointer[i+1]){
367 if (fClusterPointer[i+1]->IsUsed(10)) {
368 shared++;
369 continue;
370 }
371 }
372
373 }
374 //if (shared>found){
375 //Error("AliTPCseed::GetClusterStatistic","problem\n");
376 //}
377}
378
379
380
381
382
383void AliTPCseed::Reset(Bool_t all)
384{
385 //
386 //
387 SetNumberOfClusters(0);
388 fNFoundable = 0;
389 SetChi2(0);
6c94f330 390 ResetCovariance(10.);
81e97e0d 391 /*
392 if (fTrackPoints){
393 for (Int_t i=0;i<8;i++){
394 delete [] fTrackPoints[i];
395 }
396 delete fTrackPoints;
397 fTrackPoints =0;
398 }
399 */
400
401 if (all){
f06a1ff6 402 for (Int_t i=200;i--;) SetClusterIndex2(i,-3);
403 if (!fClusterOwner) for (Int_t i=160;i--;) fClusterPointer[i]=0;
404 else for (Int_t i=160;i--;) {delete fClusterPointer[i]; fClusterPointer[i]=0;}
81e97e0d 405 }
406
407}
408
409
410void AliTPCseed::Modify(Double_t factor)
411{
412
413 //------------------------------------------------------------------
414 //This function makes a track forget its history :)
415 //------------------------------------------------------------------
416 if (factor<=0) {
6c94f330 417 ResetCovariance(10.);
81e97e0d 418 return;
419 }
6c94f330 420 ResetCovariance(factor);
421
81e97e0d 422 SetNumberOfClusters(0);
423 fNFoundable =0;
424 SetChi2(0);
425 fRemoval = 0;
426 fCurrentSigmaY2 = 0.000005;
427 fCurrentSigmaZ2 = 0.000005;
428 fNoCluster = 0;
429 //fFirstPoint = 160;
430 //fLastPoint = 0;
431}
432
433
434
435
436Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
437{
438 //-----------------------------------------------------------------
439 // This function find proloncation of a track to a reference plane x=xk.
440 // doesn't change internal state of the track
441 //-----------------------------------------------------------------
442
6c94f330 443 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
81e97e0d 444
6c94f330 445 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
81e97e0d 446 return 0;
447 }
448
449 // Double_t y1=fP0, z1=fP1;
60e55aee 450 Double_t c1=GetSnp(), r1=sqrt((1.-c1)*(1.+c1));
451 Double_t c2=c1 + GetC()*dx, r2=sqrt((1.-c2)*(1.+c2));
81e97e0d 452
6c94f330 453 y = GetY();
454 z = GetZ();
81e97e0d 455 //y += dx*(c1+c2)/(r1+r2);
456 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
457
458 Double_t dy = dx*(c1+c2)/(r1+r2);
459 Double_t dz = 0;
460 //
6c94f330 461 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
81e97e0d 462 /*
463 if (TMath::Abs(delta)>0.0001){
464 dz = fP3*TMath::ASin(delta)/fP4;
465 }else{
466 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
467 }
468 */
469 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
6c94f330 470 dz = GetTgl()*TMath::ASin(delta)/GetC();
81e97e0d 471 //
472 y+=dy;
473 z+=dz;
474
475
476 return 1;
477}
478
479
480//_____________________________________________________________________________
af32720d 481Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
81e97e0d 482{
483 //-----------------------------------------------------------------
484 // This function calculates a predicted chi2 increment.
485 //-----------------------------------------------------------------
6c94f330 486 Double_t p[2]={c->GetY(), c->GetZ()};
487 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
9c7b8249 488
489 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
490 if (TMath::Abs(dx)>0){
491 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
492 Float_t dy = dx*ty;
493 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
494 p[0] = c->GetY()-dy;
495 p[1] = c->GetZ()-dz;
496 }
6c94f330 497 return AliExternalTrackParam::GetPredictedChi2(p,cov);
81e97e0d 498}
499
81e97e0d 500//_________________________________________________________________________________________
501
502
503Int_t AliTPCseed::Compare(const TObject *o) const {
504 //-----------------------------------------------------------------
505 // This function compares tracks according to the sector - for given sector according z
506 //-----------------------------------------------------------------
507 AliTPCseed *t=(AliTPCseed*)o;
6c94f330 508
81e97e0d 509 if (fSort == 0){
510 if (t->fRelativeSector>fRelativeSector) return -1;
511 if (t->fRelativeSector<fRelativeSector) return 1;
512 Double_t z2 = t->GetZ();
513 Double_t z1 = GetZ();
514 if (z2>z1) return 1;
515 if (z2<z1) return -1;
516 return 0;
517 }
518 else {
519 Float_t f2 =1;
6c23ffed 520 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
81e97e0d 521 if (t->fBConstrain) f2=1.2;
522
523 Float_t f1 =1;
6c23ffed 524 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
81e97e0d 525
526 if (fBConstrain) f1=1.2;
527
528 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
529 else return +1;
530 }
531}
532
533
534
535
536//_____________________________________________________________________________
70e20dcf 537Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
6c94f330 538{
81e97e0d 539 //-----------------------------------------------------------------
540 // This function associates a cluster with this track.
541 //-----------------------------------------------------------------
81e97e0d 542 Int_t n=GetNumberOfClusters();
70e20dcf 543 Int_t idx=GetClusterIndex(n); // save the current cluster index
544
2d15e7a5 545 AliTPCclusterMI cl(*(AliTPCclusterMI*)c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
546
547 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
548
549 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
550
551 if( parcl ){
552 Int_t padSize = 0; // short pads
553 if (cl.GetDetector() >= 36) {
554 padSize = 1; // medium pads
555 if (cl.GetRow() > 63) padSize = 2; // long pads
556 }
557 Float_t waveCorr = parcl->GetWaveCorrection( padSize, cl.GetZ(), cl.GetMax(),cl.GetPad(), ty );
558 cl.SetY( cl.GetY() - waveCorr );
559 }
560
ca521f6c 561 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
562 if (TMath::Abs(dx)>0){
ca521f6c 563 Float_t dy = dx*ty;
564 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
2d15e7a5 565 cl.SetY(cl.GetY()-dy);
566 cl.SetZ(cl.GetZ()-dz);
567 }
568
ca521f6c 569
70e20dcf 570 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
e0e13b88 571
572 if (fCMeanSigmaY2p30<0){
573 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
c07cb486 574 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
575 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
576 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
e0e13b88 577 }
578 //
579 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
c07cb486 580 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
581 if (fCurrentSigmaY2>0){
582 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
583 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
584 }
e0e13b88 585
81e97e0d 586
70e20dcf 587 SetClusterIndex(n,idx); // restore the current cluster index
6c94f330 588 return kTRUE;
81e97e0d 589}
590
591
592
593//_____________________________________________________________________________
dc5cd41c 594Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t /* onlyused */) {
81e97e0d 595 //-----------------------------------------------------------------
596 // This funtion calculates dE/dX within the "low" and "up" cuts.
597 //-----------------------------------------------------------------
2cadb5d1 598 // CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal)
83afd539 599 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
44a6a09e 600
83afd539 601 Int_t row0 = param->GetNRowLow();
602 Int_t row1 = row0+param->GetNRowUp1();
603 Int_t row2 = row1+param->GetNRowUp2();
44a6a09e 604 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
605 Int_t useTot = 0;
606 if (recoParam) useTot = (recoParam->GetUseTotCharge())? 0:1;
83afd539 607 //
608 //
609 //
2cadb5d1 610 fDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 0);
611 fDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 0);
612 fDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 0);
613 fDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 0);
64bf5ca0 614 fDEDX[4] = CookdEdxAnalytical(low,up,useTot ,row0,row2, 0); // full OROC truncated mean
83afd539 615 //
2cadb5d1 616 fSDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 1);
617 fSDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 1);
618 fSDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 1);
619 fSDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 1);
83afd539 620 //
64bf5ca0 621 fNCDEDX[0] = TMath::Nint(GetTPCClustInfo(2, 1, i1 , i2));
622 fNCDEDX[1] = TMath::Nint(GetTPCClustInfo(2, 1, 0 , row0));
623 fNCDEDX[2] = TMath::Nint(GetTPCClustInfo(2, 1, row0, row1));
624 fNCDEDX[3] = TMath::Nint(GetTPCClustInfo(2, 1, row1, row2));
625 //
626 fNCDEDXInclThres[0] = TMath::Nint(GetTPCClustInfo(2, 2, i1 , i2));
627 fNCDEDXInclThres[1] = TMath::Nint(GetTPCClustInfo(2, 2, 0 , row0));
628 fNCDEDXInclThres[2] = TMath::Nint(GetTPCClustInfo(2, 2, row0, row1));
629 fNCDEDXInclThres[3] = TMath::Nint(GetTPCClustInfo(2, 2, row1, row2));
630 //
83afd539 631 SetdEdx(fDEDX[0]);
632 return fDEDX[0];
81e97e0d 633
ba5e52fb 634// return CookdEdxNorm(low,up,0,i1,i2,1,0,2);
4cc7ba77 635
636
ba5e52fb 637// Float_t amp[200];
638// Float_t angular[200];
639// Float_t weight[200];
640// Int_t index[200];
641// //Int_t nc = 0;
642// Float_t meanlog = 100.;
643
644// Float_t mean[4] = {0,0,0,0};
645// Float_t sigma[4] = {1000,1000,1000,1000};
646// Int_t nc[4] = {0,0,0,0};
647// Float_t norm[4] = {1000,1000,1000,1000};
648// //
649// //
650// fNShared =0;
651
652// Float_t gainGG = 1;
653// if (AliTPCcalibDB::Instance()->GetParameters()){
654// gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
655// }
656
657
658// for (Int_t of =0; of<4; of++){
659// for (Int_t i=of+i1;i<i2;i+=4)
660// {
661// Int_t clindex = fIndex[i];
662// if (clindex<0||clindex&0x8000) continue;
663
664// //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
665// AliTPCTrackerPoint * point = GetTrackPoint(i);
666// //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
667// //AliTPCTrackerPoint * pointp = 0;
668// //if (i<159) pointp = GetTrackPoint(i+1);
669
670// if (point==0) continue;
671// AliTPCclusterMI * cl = fClusterPointer[i];
672// if (cl==0) continue;
673// if (onlyused && (!cl->IsUsed(10))) continue;
674// if (cl->IsUsed(11)) {
675// fNShared++;
676// continue;
677// }
678// Int_t type = cl->GetType();
679// //if (point->fIsShared){
680// // fNShared++;
681// // continue;
682// //}
683// //if (pointm)
684// // if (pointm->fIsShared) continue;
685// //if (pointp)
686// // if (pointp->fIsShared) continue;
687
688// if (type<0) continue;
689// //if (type>10) continue;
690// //if (point->GetErrY()==0) continue;
691// //if (point->GetErrZ()==0) continue;
692
693// //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
694// //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
695// //if ((ddy*ddy+ddz*ddz)>10) continue;
696
697
698// // if (point->GetCPoint().GetMax()<5) continue;
699// if (cl->GetMax()<5) continue;
700// Float_t angley = point->GetAngleY();
701// Float_t anglez = point->GetAngleZ();
702
703// Float_t rsigmay2 = point->GetSigmaY();
704// Float_t rsigmaz2 = point->GetSigmaZ();
705// /*
706// Float_t ns = 1.;
707// if (pointm){
708// rsigmay += pointm->GetTPoint().GetSigmaY();
709// rsigmaz += pointm->GetTPoint().GetSigmaZ();
710// ns+=1.;
711// }
712// if (pointp){
713// rsigmay += pointp->GetTPoint().GetSigmaY();
714// rsigmaz += pointp->GetTPoint().GetSigmaZ();
715// ns+=1.;
716// }
717// rsigmay/=ns;
718// rsigmaz/=ns;
719// */
720
721// Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
722
723// Float_t ampc = 0; // normalization to the number of electrons
724// if (i>64){
725// // ampc = 1.*point->GetCPoint().GetMax();
726// ampc = 1.*cl->GetMax();
727// //ampc = 1.*point->GetCPoint().GetQ();
728// // AliTPCClusterPoint & p = point->GetCPoint();
729// // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
730// // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
731// //Float_t dz =
732// // TMath::Abs( Int_t(iz) - iz + 0.5);
733// //ampc *= 1.15*(1-0.3*dy);
734// //ampc *= 1.15*(1-0.3*dz);
735// // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
736// //ampc *=zfactor;
737// }
738// else{
739// //ampc = 1.0*point->GetCPoint().GetMax();
740// ampc = 1.0*cl->GetMax();
741// //ampc = 1.0*point->GetCPoint().GetQ();
742// //AliTPCClusterPoint & p = point->GetCPoint();
743// // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
744// //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
745// //Float_t dz =
746// // TMath::Abs( Int_t(iz) - iz + 0.5);
747
748// //ampc *= 1.15*(1-0.3*dy);
749// //ampc *= 1.15*(1-0.3*dz);
750// // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
751// //ampc *=zfactor;
752
753// }
754// ampc *= 2.0; // put mean value to channel 50
755// //ampc *= 0.58; // put mean value to channel 50
756// Float_t w = 1.;
757// // if (type>0) w = 1./(type/2.-0.5);
758// // Float_t z = TMath::Abs(cl->GetZ());
759// if (i<64) {
760// ampc /= 0.6;
761// //ampc /= (1+0.0008*z);
762// } else
763// if (i>128){
764// ampc /=1.5;
765// //ampc /= (1+0.0008*z);
766// }else{
767// //ampc /= (1+0.0008*z);
768// }
81e97e0d 769
ba5e52fb 770// if (type<0) { //amp at the border - lower weight
771// // w*= 2.;
81e97e0d 772
ba5e52fb 773// continue;
774// }
775// if (rsigma>1.5) ampc/=1.3; // if big backround
776// amp[nc[of]] = ampc;
777// amp[nc[of]] /=gainGG;
778// angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
779// weight[nc[of]] = w;
780// nc[of]++;
781// }
81e97e0d 782
ba5e52fb 783// TMath::Sort(nc[of],amp,index,kFALSE);
784// Float_t sumamp=0;
785// Float_t sumamp2=0;
786// Float_t sumw=0;
787// //meanlog = amp[index[Int_t(nc[of]*0.33)]];
788// meanlog = 50;
789// for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
790// Float_t ampl = amp[index[i]]/angular[index[i]];
791// ampl = meanlog*TMath::Log(1.+ampl/meanlog);
792// //
793// sumw += weight[index[i]];
794// sumamp += weight[index[i]]*ampl;
795// sumamp2 += weight[index[i]]*ampl*ampl;
796// norm[of] += angular[index[i]]*weight[index[i]];
797// }
798// if (sumw<1){
799// SetdEdx(0);
800// }
801// else {
802// norm[of] /= sumw;
803// mean[of] = sumamp/sumw;
804// sigma[of] = sumamp2/sumw-mean[of]*mean[of];
805// if (sigma[of]>0.1)
806// sigma[of] = TMath::Sqrt(sigma[of]);
807// else
808// sigma[of] = 1000;
81e97e0d 809
ba5e52fb 810// mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
811// //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
812// //mean *=(1-0.1*(norm-1.));
813// }
814// }
815
816// Float_t dedx =0;
817// fSdEdx =0;
818// fMAngular =0;
819// // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
820// // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
81e97e0d 821
822
ba5e52fb 823// // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
824// // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
825
826// Int_t norm2 = 0;
827// Int_t norm3 = 0;
828// for (Int_t i =0;i<4;i++){
829// if (nc[i]>2&&nc[i]<1000){
830// dedx += mean[i] *nc[i];
831// fSdEdx += sigma[i]*(nc[i]-2);
832// fMAngular += norm[i] *nc[i];
833// norm2 += nc[i];
834// norm3 += nc[i]-2;
835// }
836// fDEDX[i] = mean[i];
837// fSDEDX[i] = sigma[i];
838// fNCDEDX[i]= nc[i];
839// }
840
841// if (norm3>0){
842// dedx /=norm2;
843// fSdEdx /=norm3;
844// fMAngular/=norm2;
845// }
846// else{
847// SetdEdx(0);
848// return 0;
849// }
850// // Float_t dedx1 =dedx;
851// /*
852// dedx =0;
853// for (Int_t i =0;i<4;i++){
854// if (nc[i]>2&&nc[i]<1000){
855// mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
856// dedx += mean[i] *nc[i];
857// }
858// fDEDX[i] = mean[i];
859// }
860// dedx /= norm2;
861// */
81e97e0d 862
863
ba5e52fb 864// SetdEdx(dedx);
865// return dedx;
81e97e0d 866}
81e97e0d 867
868void AliTPCseed::CookPID()
869{
870 //
871 // cook PID information according dEdx
872 //
873 Double_t fRange = 10.;
874 Double_t fRes = 0.1;
875 Double_t fMIP = 47.;
876 //
877 Int_t ns=AliPID::kSPECIES;
878 Double_t sumr =0;
879 for (Int_t j=0; j<ns; j++) {
880 Double_t mass=AliPID::ParticleMass(j);
6c94f330 881 Double_t mom=GetP();
81e97e0d 882 Double_t dedx=fdEdx/fMIP;
5731b051 883 Double_t bethe=AliMathBase::BetheBlochAleph(mom/mass);
81e97e0d 884 Double_t sigma=fRes*bethe;
885 if (sigma>0.001){
886 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
887 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
888 sumr+=fTPCr[j];
889 continue;
890 }
891 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
892 sumr+=fTPCr[j];
893 }
894 else{
895 fTPCr[j]=1.;
896 sumr+=fTPCr[j];
897 }
898 }
899 for (Int_t j=0; j<ns; j++) {
900 fTPCr[j]/=sumr; //normalize
901 }
902}
903
6c94f330 904Double_t AliTPCseed::GetYat(Double_t xk) const {
905//-----------------------------------------------------------------
906// This function calculates the Y-coordinate of a track at the plane x=xk.
907//-----------------------------------------------------------------
908 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
60e55aee 909 Double_t c1=GetSnp(), r1=TMath::Sqrt((1.-c1)*(1.+c1));
6c94f330 910 Double_t c2=c1+GetC()*(xk-GetX());
911 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
60e55aee 912 Double_t r2=TMath::Sqrt((1.-c2)*(1.+c2));
6c94f330 913 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
914}
915
0a65832b 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
798017c7 1041 if (type==0 && parcl->QpadTnorm()) corrPadType = (*parcl->QpadTnorm())[ipad];
1042 if (type==1 && parcl->QpadMnorm()) corrPadType = (*parcl->QpadMnorm())[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));
3af3fbc4 1080 //
1081 // do time-dependent correction for pressure and temperature variations
1082 UInt_t runNumber = 1;
1083 Float_t corrTimeGain = 1;
1084 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
e5e80ff9 1085 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1086 if (trans && recoParam->GetUseGainCorrectionTime()>0) {
3af3fbc4 1087 runNumber = trans->GetCurrentRunNumber();
e5e80ff9 1088 //AliTPCcalibDB::Instance()->SetRun(runNumber);
a2c3785e 1089 TObjArray * timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
3af3fbc4 1090 if (timeGainSplines) {
1091 UInt_t time = trans->GetCurrentTimeStamp();
1092 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1093 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1094 if (fitMIP) {
108a67db 1095 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time);/*fitMIP->Eval(time);*/
3af3fbc4 1096 } else {
108a67db 1097 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time);/*fitFPcosmic->Eval(time);*/
3af3fbc4 1098 }
1099 }
1100 }
1101 mean /= corrTimeGain;
1102 rms /= corrTimeGain;
1103 //
83afd539 1104 if (returnVal==1) return rms;
8a92e133 1105 if (returnVal==2) return ncl;
1106 return mean;
1107}
1108
6feb400f 1109Float_t AliTPCseed::CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal, Int_t rowThres, Int_t mode){
8a92e133 1110
1111 //
1112 // calculates dedx using the cluster
1113 // low - up specify trunc mean range - default form 0-0.7
1114 // type - 1 - max charge or 0- total charge in cluster
1115 // //2- max no corr 3- total+ correction
1116 // i1-i2 - the pad-row range used for calculation
1117 //
1118 // posNorm - usage of pos normalization
6feb400f 1119 // returnVal - 0 return mean
1120 // - 1 return RMS
1121 // - 2 return number of clusters
1122 // - 3 ratio
1123 // - 4 mean upper half
1124 // - 5 mean - lower half
1125 // - 6 third moment
1126 // mode - 0 - linear
1127 // - 1 - logatithmic
2efc897f 1128 // rowThres - number of rows before and after given pad row to check for clusters below threshold
8a92e133 1129 //
1130 // normalization parametrization taken from AliTPCClusterParam
1131 //
1132 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1133 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1134 if (!parcl) return 0;
1135 if (!param) return 0;
1136 Int_t row0 = param->GetNRowLow();
1137 Int_t row1 = row0+param->GetNRowUp1();
1138
1139 Float_t amp[160];
1140 Int_t indexes[160];
1141 Int_t ncl=0;
2efc897f 1142 Int_t nclBelowThr = 0; // counts number of clusters below threshold
8a92e133 1143 //
1144 //
1145 Float_t gainGG = 1; // gas gain factor -always enabled
1146 Float_t gainPad = 1; // gain map - used always
1147 Float_t corrPos = 1; // local position correction - if posNorm enabled
8a92e133 1148 //
1149 //
1150 //
1151 if (AliTPCcalibDB::Instance()->GetParameters()){
1152 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
1153 }
649fcc43 1154 //
1155 // extract time-dependent correction for pressure and temperature variations
1156 //
1157 UInt_t runNumber = 1;
1158 Float_t corrTimeGain = 1;
1159 TObjArray * timeGainSplines = 0x0;
1160 TGraphErrors * grPadEqual = 0x0;
7e3e1a9c 1161 TGraphErrors* grChamberGain[3]={0x0,0x0,0x0};
649fcc43 1162 //
1163 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1164 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
6d64657a 1165 //
1166 if (recoParam->GetNeighborRowsDedx() == 0) rowThres = 0;
1167 //
649fcc43 1168 if (trans) {
2efc897f 1169 runNumber = trans->GetCurrentRunNumber();
1170 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1171 timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1172 if (timeGainSplines && recoParam->GetUseGainCorrectionTime()>0) {
1173 UInt_t time = trans->GetCurrentTimeStamp();
1174 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1175 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1176 if (fitMIP) {
1177 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time); /*fitMIP->Eval(time);*/
649fcc43 1178 } else {
2efc897f 1179 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time); /*fitFPcosmic->Eval(time); */
1180 }
649fcc43 1181 //
1182 if (type==1) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQMAX_PADREGIONGAIN_BEAM_ALL");
1183 if (type==0) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQTOT_PADREGIONGAIN_BEAM_ALL");
7e3e1a9c 1184 const char* names[3]={"SHORT","MEDIUM","LONG"};
1185 for (Int_t iPadRegion=0; iPadRegion<3; ++iPadRegion)
1186 grChamberGain[iPadRegion]=(TGraphErrors*)timeGainSplines->FindObject(Form("TGRAPHERRORS_MEAN_CHAMBERGAIN_%s_BEAM_ALL",names[iPadRegion]));
2efc897f 1187 }
7e3e1a9c 1188 }
2efc897f 1189
1190 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
8a92e133 1191 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1192 const Float_t kedgey =3.;
1193 //
1194 //
1195 for (Int_t irow=i1; irow<i2; irow++){
1196 AliTPCclusterMI* cluster = GetClusterPointer(irow);
736a5826 1197 if (!cluster && irow > 1 && irow < 157) {
2efc897f 1198 Bool_t isClBefore = kFALSE;
1199 Bool_t isClAfter = kFALSE;
1200 for(Int_t ithres = 1; ithres <= rowThres; ithres++) {
1201 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1202 if (clusterBefore) isClBefore = kTRUE;
1203 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1204 if (clusterAfter) isClAfter = kTRUE;
1205 }
1206 if (isClBefore && isClAfter) nclBelowThr++;
2efc897f 1207 }
736a5826 1208 if (!cluster) continue;
2efc897f 1209 //
1210 //
8a92e133 1211 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
2efc897f 1212 //
1213 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1214 if (point==0) continue;
1215 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1216 if (rsigmay > kClusterShapeCut) continue;
1217 //
1218 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1219 //
8a92e133 1220 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1221 Int_t ipad= 0;
1222 if (irow>=row0) ipad=1;
1223 if (irow>=row1) ipad=2;
1224 //
1225 //
1226 //
1227 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1228 if (gainMap) {
1229 //
1230 // Get gainPad - pad by pad calibration
1231 //
1232 Float_t factor = 1;
1233 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1234 if (irow < row0) { // IROC
1235 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
1236 } else { // OROC
1237 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
1238 }
2efc897f 1239 if (factor>0.3) gainPad=factor;
8a92e133 1240 }
8a92e133 1241 //
1242 // Do position normalization - relative distance to
1243 // center of pad- time bin
1244
8a92e133 1245 Float_t ty = TMath::Abs(point->GetAngleY());
1246 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1247 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1248 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1249
1250 yres0 *=parcl->GetQnormCorr(ipad, type,0);
1251 zres0 *=parcl->GetQnormCorr(ipad, type,1);
1252 Float_t effLength=parcl->GetQnormCorr(ipad, type,4)*0.5;
1253 Float_t effDiff =(parcl->GetQnormCorr(ipad, type,2)+parcl->GetQnormCorr(ipad, type,3))*0.5;
1254 //
1255 if (type==1) {
1256 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1257 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1258 cluster->GetTimeBin(),ty,tz,yres0,zres0,effLength,effDiff);
1259 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1260 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1261 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1262 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1263 //
1264 }
1265 if (type==0) {
1266 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1267 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1268 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,effLength,effDiff);
1269
1270 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1271 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1272 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1273 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1274 //
1275 }
2efc897f 1276 //
1277 // pad region equalization outside of cluster param
1278 //
1279 Float_t gainEqualPadRegion = 1;
7e3e1a9c 1280 if (grPadEqual && recoParam->GetUseGainCorrectionTime()>0) gainEqualPadRegion = grPadEqual->Eval(ipad);
1281 //
1282 // chamber-by-chamber equalization outside gain map
1283 //
1284 Float_t gainChamber = 1;
1285 if (grChamberGain[ipad] && recoParam->GetUseGainCorrectionTime()>0) gainChamber = grChamberGain[ipad]->Eval(cluster->GetDetector());
8a92e133 1286 //
1287 amp[ncl]=charge;
1288 amp[ncl]/=gainGG;
1289 amp[ncl]/=gainPad;
1290 amp[ncl]/=corrPos;
2efc897f 1291 amp[ncl]/=gainEqualPadRegion;
7e3e1a9c 1292 amp[ncl]/=gainChamber;
8a92e133 1293 //
1294 ncl++;
1295 }
1296
6feb400f 1297 if (type==2) return ncl;
8a92e133 1298 TMath::Sort(ncl,amp, indexes, kFALSE);
2efc897f 1299 //
8a92e133 1300 if (ncl<10) return 0;
2efc897f 1301 //
1302 Double_t * ampWithBelow = new Double_t[ncl + nclBelowThr];
1303 for(Int_t iCl = 0; iCl < ncl + nclBelowThr; iCl++) {
1304 if (iCl < nclBelowThr) {
1305 ampWithBelow[iCl] = amp[indexes[0]];
1306 } else {
1307 ampWithBelow[iCl] = amp[indexes[iCl - nclBelowThr]];
1308 }
1309 }
1310 //printf("DEBUG: %i shit %f", nclBelowThr, amp[indexes[0]]);
1311 //
8a92e133 1312 Float_t suma=0;
1313 Float_t suma2=0;
6feb400f 1314 Float_t suma3=0;
1315 Float_t sumaS=0;
8a92e133 1316 Float_t sumn=0;
6feb400f 1317 // upper,and lower part statistic
1318 Float_t sumL=0, sumL2=0, sumLN=0;
1319 Float_t sumD=0, sumD2=0, sumDN=0;
1320
2efc897f 1321 Int_t icl0=TMath::Nint((ncl + nclBelowThr)*low);
1322 Int_t icl1=TMath::Nint((ncl + nclBelowThr)*up);
6feb400f 1323 Int_t iclm=TMath::Nint((ncl + nclBelowThr)*(low +(up+low)*0.5));
1324 //
8a92e133 1325 for (Int_t icl=icl0; icl<icl1;icl++){
6feb400f 1326 if (ampWithBelow[icl]<0.1) continue;
504dd8df 1327 Double_t camp=ampWithBelow[icl]/corrTimeGain;
1328 if (mode==1) camp= TMath::Log(camp);
6feb400f 1329 if (icl<icl1){
504dd8df 1330 suma+=camp;
1331 suma2+=camp*camp;
1332 suma3+=camp*camp*camp;
1333 sumaS+=TMath::Power(TMath::Abs(camp),1./3.);
6feb400f 1334 sumn++;
1335 }
1336 if (icl>iclm){
504dd8df 1337 sumL+=camp;
1338 sumL2+=camp*camp;
6feb400f 1339 sumLN++;
1340 }
1341 if (icl<=iclm){
504dd8df 1342 sumD+=camp;
1343 sumD2+=camp*camp;
6feb400f 1344 sumDN++;
1345 }
8a92e133 1346 }
0f7547f1 1347 //
1348 Float_t mean = 0;
1349 Float_t meanL = 0;
1350 Float_t meanD = 0; // lower half mean
1351 if (sumn > 1e-30) mean =suma/sumn;
1352 if (sumLN > 1e-30) meanL =sumL/sumLN;
1353 if (sumDN > 1e-30) meanD =(sumD/sumDN);
1354 /*
8a92e133 1355 Float_t mean =suma/sumn;
6feb400f 1356 Float_t meanL = sumL/sumLN;
1357 Float_t meanD =(sumD/sumDN); // lower half mean
0f7547f1 1358 */
28273e26 1359
1360 Float_t rms = 0;
1361 Float_t mean2=0;
1362 Float_t mean3=0;
1363 Float_t meanS=0;
1364
1365 if(sumn>0){
1366 rms = TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
1367 mean2=suma2/sumn;
1368 mean3=suma3/sumn;
1369 meanS=sumaS/sumn;
1370 }
1371
6feb400f 1372 if (mean2>0) mean2=TMath::Power(TMath::Abs(mean2),1./2.);
1373 if (mean3>0) mean3=TMath::Power(TMath::Abs(mean3),1./3.);
1374 if (meanS>0) meanS=TMath::Power(TMath::Abs(meanS),3.);
3af3fbc4 1375 //
6feb400f 1376 if (mode==1) mean=TMath::Exp(mean);
1377 if (mode==1) meanL=TMath::Exp(meanL); // upper truncation
1378 if (mode==1) meanD=TMath::Exp(meanD); // lower truncation
1379 //
1380 delete [] ampWithBelow;
1381
1382
3af3fbc4 1383 //
8a92e133 1384 if (returnVal==1) return rms;
83afd539 1385 if (returnVal==2) return ncl;
6feb400f 1386 if (returnVal==3) return Double_t(nclBelowThr)/Double_t(nclBelowThr+ncl);
1387 if (returnVal==4) return meanL;
1388 if (returnVal==5) return meanD;
1389 if (returnVal==6) return mean2;
1390 if (returnVal==7) return mean3;
1391 if (returnVal==8) return meanS;
83afd539 1392 return mean;
0a65832b 1393}
1394
83afd539 1395
0a65832b 1396
1397
eb02f63a 1398Float_t AliTPCseed::CookShape(Int_t type){
1399 //
1400 //
1401 //
1402 //-----------------------------------------------------------------
1403 // This funtion calculates dE/dX within the "low" and "up" cuts.
1404 //-----------------------------------------------------------------
1405 Float_t means=0;
1406 Float_t meanc=0;
1407 for (Int_t i =0; i<160;i++) {
1408 AliTPCTrackerPoint * point = GetTrackPoint(i);
1409 if (point==0) continue;
1410
1411 AliTPCclusterMI * cl = fClusterPointer[i];
1412 if (cl==0) continue;
1413
1414 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1415 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1416 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1417 if (type==0) means+=rsigma;
1418 if (type==1) means+=rsigmay;
1419 if (type==2) means+=rsigmaz;
1420 meanc++;
1421 }
1422 Float_t mean = (meanc>0)? means/meanc:0;
1423 return mean;
1424}
87e92a27 1425
1426
1427
1428Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1429 //
1430 // Refit the track
1431 // return value - number of used clusters
1432 //
1433 //
1434 const Int_t kMinNcl =10;
1435 AliTPCseed *track=new AliTPCseed(*seed);
1436 Int_t sector=-1;
1437 // reset covariance
1438 //
1439 Double_t covar[15];
1440 for (Int_t i=0;i<15;i++) covar[i]=0;
1441 covar[0]=10.*10.;
1442 covar[2]=10.*10.;
1443 covar[5]=10.*10./(64.*64.);
1444 covar[9]=10.*10./(64.*64.);
1445 covar[14]=1*1;
1446 //
1447
1448 Float_t xmin=1000, xmax=-10000;
1449 Int_t imin=158, imax=0;
1450 for (Int_t i=0;i<160;i++) {
1451 AliTPCclusterMI *c=track->GetClusterPointer(i);
1791d824 1452 if (!c || (track->GetClusterIndex(i) & 0x8000)) continue;
87e92a27 1453 if (sector<0) sector = c->GetDetector();
1454 if (c->GetX()<xmin) xmin=c->GetX();
1455 if (c->GetX()>xmax) xmax=c->GetX();
1456 if (i<imin) imin=i;
1457 if (i>imax) imax=i;
1458 }
1459 if(imax-imin<kMinNcl) {
1460 delete track;
1461 return 0 ;
1462 }
1463 // Not succes to rotate
1464 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1465 delete track;
1466 return 0;
1467 }
1468 //
1469 //
1470 // fit from inner to outer row
1471 //
1472 AliExternalTrackParam paramIn;
1473 AliExternalTrackParam paramOut;
1474 Bool_t isOK=kTRUE;
be34cb88 1475 Int_t ncl=0;
87e92a27 1476 //
1477 //
1478 //
1479 for (Int_t i=imin; i<=imax; i++){
1480 AliTPCclusterMI *c=track->GetClusterPointer(i);
1791d824 1481 if (!c || (track->GetClusterIndex(i) & 0x8000)) continue;
87e92a27 1482 // if (RejectCluster(c,track)) continue;
be34cb88 1483 sector = (c->GetDetector()%18);
1484 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1485 //continue;
1486 }
87e92a27 1487 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1488 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1489 if (!track->PropagateTo(r[0])) {
1490 isOK=kFALSE;
87e92a27 1491 }
1492 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1493 }
1494 if (!isOK) { delete track; return 0;}
1495 track->AddCovariance(covar);
1496 //
1497 //
1498 //
1499 for (Int_t i=imax; i>=imin; i--){
1500 AliTPCclusterMI *c=track->GetClusterPointer(i);
1791d824 1501 if (!c || (track->GetClusterIndex(i) & 0x8000)) continue;
87e92a27 1502 //if (RejectCluster(c,track)) continue;
be34cb88 1503 sector = (c->GetDetector()%18);
1504 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1505 //continue;
1506 }
87e92a27 1507 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1508 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1509 if (!track->PropagateTo(r[0])) {
1510 isOK=kFALSE;
87e92a27 1511 }
1512 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1513 }
be34cb88 1514 //if (!isOK) { delete track; return 0;}
87e92a27 1515 paramIn = *track;
1516 track->AddCovariance(covar);
1517 //
1518 //
1519 for (Int_t i=imin; i<=imax; i++){
1520 AliTPCclusterMI *c=track->GetClusterPointer(i);
1791d824 1521 if (!c || (track->GetClusterIndex(i) & 0x8000)) continue;
be34cb88 1522 sector = (c->GetDetector()%18);
1523 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1524 //continue;
1525 }
1526 ncl++;
87e92a27 1527 //if (RejectCluster(c,track)) continue;
1528 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1529 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1530 if (!track->PropagateTo(r[0])) {
1531 isOK=kFALSE;
87e92a27 1532 }
1533 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1534 }
be34cb88 1535 //if (!isOK) { delete track; return 0;}
87e92a27 1536 paramOut=*track;
87e92a27 1537 //
1538 //
1539 //
1540 if (parin) (*parin)=paramIn;
1541 if (parout) (*parout)=paramOut;
6e23caff 1542 delete track;
be34cb88 1543 return ncl;
87e92a27 1544}
1545
1546
1547
1548Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1549 //
1550 //
1551 //
1552 return kFALSE;
1553}
3247d397 1554
1555
1556
1557
1558
1559
1560void AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1561 Double_t& erry, Double_t &errz)
1562{
1563 //
1564 // Get cluster error at given position
1565 //
1566 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1567 Double_t tany,tanz;
1568 Double_t snp1=param->GetSnp();
60e55aee 1569 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1570 //
1571 Double_t tgl1=param->GetTgl();
60e55aee 1572 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1573 //
1574 Int_t padSize = 0; // short pads
1575 if (cluster->GetDetector() >= 36) {
1576 padSize = 1; // medium pads
1577 if (cluster->GetRow() > 63) padSize = 2; // long pads
1578 }
1579
1580 erry = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
1581 errz = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
1582}
1583
1584
1585void AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1586 Double_t& rmsy, Double_t &rmsz)
1587{
1588 //
1589 // Get cluster error at given position
1590 //
1591 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1592 Double_t tany,tanz;
1593 Double_t snp1=param->GetSnp();
60e55aee 1594 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1595 //
1596 Double_t tgl1=param->GetTgl();
60e55aee 1597 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1598 //
1599 Int_t padSize = 0; // short pads
1600 if (cluster->GetDetector() >= 36) {
1601 padSize = 1; // medium pads
1602 if (cluster->GetRow() > 63) padSize = 2; // long pads
1603 }
1604
1605 rmsy = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
1606 rmsz = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
1607}
ba5e52fb 1608
1609
1610
1611Double_t AliTPCseed::GetQCorrGeom(Float_t ty, Float_t tz){
1612 //Geoetrical
1613 //ty - tangent in local y direction
1614 //tz - tangent
1615 //
1616 Float_t norm=TMath::Sqrt(1+ty*ty+tz*tz);
1617 return norm;
1618}
1619
83afd539 1620Double_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 1621 //
1622 // Q normalization
1623 //
1624 // return value = Q Normalization factor
1625 // Normalization - 1 - shape factor part for full drift
1626 // 1 - electron attachment for 0 drift
1627
1628 // Input parameters:
1629 //
1630 // ipad - 0 short pad
1631 // 1 medium pad
1632 // 2 long pad
1633 //
1634 // type - 0 qmax
1635 // - 1 qtot
1636 //
1637 //z - z position (-250,250 cm)
1638 //ty - tangent in local y direction
1639 //tz - tangent
1640 //
1641
1642 AliTPCClusterParam * paramCl = AliTPCcalibDB::Instance()->GetClusterParam();
1643 AliTPCParam * paramTPC = AliTPCcalibDB::Instance()->GetParameters();
1644
1645 if (!paramCl) return 1;
1646 //
1647 Double_t dr = 250.-TMath::Abs(z);
1648 Double_t sy = paramCl->GetRMS0( 0,ipad, dr, TMath::Abs(ty));
1649 Double_t sy0= paramCl->GetRMS0(0,ipad, 250, 0);
1650 Double_t sz = paramCl->GetRMS0( 1,ipad, dr, TMath::Abs(tz));
1651 Double_t sz0= paramCl->GetRMS0(1,ipad, 250, 0);
1652
1653 Double_t sfactorMax = TMath::Sqrt(sy0*sz0/(sy*sz));
1654
1655
1656 Double_t dt = 1000000*(dr/paramTPC->GetDriftV()); //time in microsecond
1657 Double_t attProb = TMath::Exp(-paramTPC->GetAttCoef()*paramTPC->GetOxyCont()*dt);
1658 //
1659 //
1660 if (type==0) return sfactorMax*attProb;
1661
1662 return attProb;
1663
1664
1665}
1666
64bf5ca0 1667
1668//_______________________________________________________________________
1669Float_t AliTPCseed::GetTPCClustInfo(Int_t nNeighbours, Int_t type, Int_t row0, Int_t row1)
1670{
1671 //
1672 // TPC cluster information
1673 // type 0: get fraction of found/findable clusters with neighbourhood definition
1674 // 1: found clusters
1675 // 2: findable (number of clusters above and below threshold)
1676 //
1677 // definition of findable clusters:
1678 // a cluster is defined as findable if there is another cluster
1679 // within +- nNeighbours pad rows. The idea is to overcome threshold
1680 // effects with a very simple algorithm.
1681 //
1682
1683 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
1684 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1685 const Float_t kedgey =3.;
1686
1687 Float_t ncl = 0;
1688 Float_t nclBelowThr = 0; // counts number of clusters below threshold
1689
1690 for (Int_t irow=row0; irow<row1; irow++){
1691 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1692
1693 if (!cluster && irow > 1 && irow < 157) {
1694 Bool_t isClBefore = kFALSE;
1695 Bool_t isClAfter = kFALSE;
1696 for(Int_t ithres = 1; ithres <= nNeighbours; ithres++) {
1697 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1698 if (clusterBefore) isClBefore = kTRUE;
1699 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1700 if (clusterAfter) isClAfter = kTRUE;
1701 }
1702 if (isClBefore && isClAfter) nclBelowThr++;
1703 }
1704 if (!cluster) continue;
1705 //
1706 //
1707 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
1708 //
1709 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1710 if (point==0) continue;
1711 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1712 if (rsigmay > kClusterShapeCut) continue;
1713 //
1714 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1715 ncl++;
1716 }
1717
1718 if(ncl<10)
1719 return 0;
1720 if(type==0)
1721 if(nclBelowThr+ncl>0)
1722 return ncl/(nclBelowThr+ncl);
1723 if(type==1)
1724 return ncl;
1725 if(type==2)
1726 return ncl+nclBelowThr;
1727 return 0;
1728}
1791d824 1729//_______________________________________________________________________
1730Int_t AliTPCseed::GetNumberOfClustersIndices() {
1731 Int_t ncls = 0;
1732 for (int i=0; i < 160; i++) {
1733 if ((fIndex[i] & 0x8000) == 0)
1734 ncls++;
1735 }
1736 return ncls;
1737}
f06a1ff6 1738
1739//_______________________________________________________________________
1740void AliTPCseed::Clear(Option_t*)
1741{
1742 // formally seed may allocate memory for clusters (althought this should not happen for
1743 // the seeds in the pool). Hence we need this method for fwd. compatibility
1744 if (fClusterOwner) for (int i=160;i--;) {delete fClusterPointer[i]; fClusterPointer[i] = 0;}
1745}
24aea01c 1746
1747TObject* AliTPCseed::Clone(const char* newname) const
1748{
1749 // temporary override TObject::Clone to avoid crashes in reco
1750 AliTPCseed* src = (AliTPCseed*)this;
1751 AliTPCseed* dst = new AliTPCseed(*src,fClusterOwner);
1752 return dst;
1753}