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