Preparation for the new dEdx algorithm :
[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"
2efc897f 25#include "TGraphErrors.h"
81e97e0d 26#include "AliTPCseed.h"
3f82c4f2 27#include "AliTPCReconstructor.h"
0a65832b 28#include "AliTPCClusterParam.h"
7cd8ac3f 29#include "AliTPCCalPad.h"
30#include "AliTPCCalROC.h"
37540068 31#include "AliTPCcalibDB.h"
d080e4a4 32#include "AliTPCParam.h"
5731b051 33#include "AliMathBase.h"
3af3fbc4 34#include "AliTPCTransform.h"
35#include "AliSplineFit.h"
36#include "AliCDBManager.h"
108a67db 37#include "AliTPCcalibDButil.h"
7cd8ac3f 38
81e97e0d 39
40ClassImp(AliTPCseed)
41
42
43
32fab534 44AliTPCseed::AliTPCseed():
45 AliTPCtrack(),
46 fEsd(0x0),
2928bdf0 47 fClusterOwner(kFALSE),
32fab534 48 fRow(0),
49 fSector(-1),
50 fRelativeSector(-1),
51 fCurrentSigmaY2(1e10),
52 fCurrentSigmaZ2(1e10),
e0e13b88 53 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
54 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 55 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
56 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
e0e13b88 57 //
32fab534 58 fErrorY2(1e10),
59 fErrorZ2(1e10),
60 fCurrentCluster(0x0),
61 fCurrentClusterIndex1(-1),
62 fInDead(kFALSE),
63 fIsSeeding(kFALSE),
64 fNoCluster(0),
65 fSort(0),
66 fBSigned(kFALSE),
67 fSeedType(0),
68 fSeed1(-1),
69 fSeed2(-1),
70 fMAngular(0),
19b00333 71 fCircular(0),
72 fClusterMap(159),
73 fSharedMap(159)
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;
84 }
85 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
bfb57b6c 86 // for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
87 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
88 fClusterMap.ResetAllBits(kFALSE);
89 fSharedMap.ResetAllBits(kFALSE);
90
81e97e0d 91}
32fab534 92
2928bdf0 93AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
32fab534 94 AliTPCtrack(s),
95 fEsd(0x0),
2928bdf0 96 fClusterOwner(clusterOwner),
32fab534 97 fRow(0),
98 fSector(-1),
99 fRelativeSector(-1),
c07cb486 100 fCurrentSigmaY2(-1),
101 fCurrentSigmaZ2(-1),
e0e13b88 102 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
103 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 104 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
105 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 106 fErrorY2(1e10),
107 fErrorZ2(1e10),
108 fCurrentCluster(0x0),
109 fCurrentClusterIndex1(-1),
110 fInDead(kFALSE),
111 fIsSeeding(kFALSE),
112 fNoCluster(0),
113 fSort(0),
114 fBSigned(kFALSE),
115 fSeedType(0),
116 fSeed1(-1),
117 fSeed2(-1),
118 fMAngular(0),
19b00333 119 fCircular(0),
120 fClusterMap(s.fClusterMap),
121 fSharedMap(s.fSharedMap)
32fab534 122{
81e97e0d 123 //---------------------
124 // dummy copy constructor
125 //-------------------------
2928bdf0 126 for (Int_t i=0;i<160;i++) {
127 fClusterPointer[i]=0;
128 if (fClusterOwner){
129 if (s.fClusterPointer[i])
130 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
131 }else{
132 fClusterPointer[i] = s.fClusterPointer[i];
133 }
134 fTrackPoints[i] = s.fTrackPoints[i];
135 }
81e97e0d 136 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
5c09947e 137 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
138 for (Int_t i=0;i<4;i++) {
139 fDEDX[i] = s.fDEDX[i];
140 fSDEDX[i] = s.fSDEDX[i];
141 fNCDEDX[i] = s.fNCDEDX[i];
142 }
143 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
19b00333 144
81e97e0d 145}
5c09947e 146
147
32fab534 148AliTPCseed::AliTPCseed(const AliTPCtrack &t):
149 AliTPCtrack(t),
150 fEsd(0x0),
2928bdf0 151 fClusterOwner(kFALSE),
32fab534 152 fRow(0),
153 fSector(-1),
154 fRelativeSector(-1),
c07cb486 155 fCurrentSigmaY2(-1),
156 fCurrentSigmaZ2(-1),
e0e13b88 157 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
158 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 159 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
160 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 161 fErrorY2(1e10),
162 fErrorZ2(1e10),
163 fCurrentCluster(0x0),
164 fCurrentClusterIndex1(-1),
165 fInDead(kFALSE),
166 fIsSeeding(kFALSE),
167 fNoCluster(0),
168 fSort(0),
169 fBSigned(kFALSE),
170 fSeedType(0),
171 fSeed1(-1),
172 fSeed2(-1),
173 fMAngular(0),
19b00333 174 fCircular(0),
175 fClusterMap(159),
176 fSharedMap(159)
32fab534 177{
81e97e0d 178 //
32fab534 179 // Constructor from AliTPCtrack
180 //
181 fFirstPoint =0;
105b1b81 182 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
81e97e0d 183 for (Int_t i=0;i<160;i++) {
184 fClusterPointer[i] = 0;
185 Int_t index = t.GetClusterIndex(i);
186 if (index>=-1){
187 SetClusterIndex2(i,index);
188 }
189 else{
190 SetClusterIndex2(i,-3);
191 }
192 }
32fab534 193 for (Int_t i=0;i<4;i++) {
194 fDEDX[i] = 0.;
195 fSDEDX[i] = 1e10;
196 fNCDEDX[i] = 0;
197 }
198 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
bfb57b6c 199
200 //for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
201 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
202 fClusterMap.ResetAllBits(kFALSE);
203 fSharedMap.ResetAllBits(kFALSE);
204
81e97e0d 205}
206
6c94f330 207AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
208 const Double_t cc[15], Int_t index):
209 AliTPCtrack(xr, alpha, xx, cc, index),
32fab534 210 fEsd(0x0),
2928bdf0 211 fClusterOwner(kFALSE),
32fab534 212 fRow(0),
213 fSector(-1),
214 fRelativeSector(-1),
c07cb486 215 fCurrentSigmaY2(-1),
216 fCurrentSigmaZ2(-1),
e0e13b88 217 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
218 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 219 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
220 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 221 fErrorY2(1e10),
222 fErrorZ2(1e10),
223 fCurrentCluster(0x0),
224 fCurrentClusterIndex1(-1),
225 fInDead(kFALSE),
226 fIsSeeding(kFALSE),
227 fNoCluster(0),
228 fSort(0),
229 fBSigned(kFALSE),
230 fSeedType(0),
231 fSeed1(-1),
232 fSeed2(-1),
233 fMAngular(0),
19b00333 234 fCircular(0),
235 fClusterMap(159),
236 fSharedMap(159)
32fab534 237{
238 //
239 // Constructor
81e97e0d 240 //
32fab534 241 fFirstPoint =0;
5c09947e 242 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 243 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
81e97e0d 244 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
32fab534 245 for (Int_t i=0;i<4;i++) {
246 fDEDX[i] = 0.;
247 fSDEDX[i] = 1e10;
248 fNCDEDX[i] = 0;
249 }
250 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 251}
252
253AliTPCseed::~AliTPCseed(){
254 //
255 // destructor
81e97e0d 256 fNoCluster =0;
2928bdf0 257 if (fClusterOwner){
258 for (Int_t icluster=0; icluster<160; icluster++){
259 delete fClusterPointer[icluster];
260 }
261 }
bfb57b6c 262
81e97e0d 263}
179c6296 264//_________________________________________________
316c6cd9 265AliTPCseed & AliTPCseed::operator=(const AliTPCseed &param)
179c6296 266{
267 //
316c6cd9 268 // assignment operator
179c6296 269 //
316c6cd9 270 if(this!=&param){
271 AliTPCtrack::operator=(param);
272 fEsd =param.fEsd;
273 for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i]; // this is not allocated by AliTPCSeed
274 fClusterOwner = param.fClusterOwner;
275 // leave out fPoint, they are also not copied in the copy ctor...
276 // but deleted in the dtor... strange...
316c6cd9 277 fRow = param.fRow;
278 fSector = param.fSector;
279 fRelativeSector = param.fRelativeSector;
280 fCurrentSigmaY2 = param.fCurrentSigmaY2;
281 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
282 fErrorY2 = param.fErrorY2;
283 fErrorZ2 = param.fErrorZ2;
284 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
285 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
286 fInDead = param.fInDead;
287 fIsSeeding = param.fIsSeeding;
288 fNoCluster = param.fNoCluster;
289 fSort = param.fSort;
290 fBSigned = param.fBSigned;
291 for(Int_t i = 0;i<4;++i){
292 fDEDX[i] = param.fDEDX[i];
293 fSDEDX[i] = param.fSDEDX[i];
294 fNCDEDX[i] = param.fNCDEDX[i];
295 }
296 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
297
298 fSeedType = param.fSeedType;
299 fSeed1 = param.fSeed1;
300 fSeed2 = param.fSeed2;
301 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
302 fMAngular = param.fMAngular;
303 fCircular = param.fCircular;
304 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
305 fClusterMap = param.fClusterMap;
306 fSharedMap = param.fSharedMap;
307 }
179c6296 308 return (*this);
309}
310//____________________________________________________
81e97e0d 311AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
312{
313 //
314 //
315 return &fTrackPoints[i];
316}
317
81e97e0d 318
319
320Double_t AliTPCseed::GetDensityFirst(Int_t n)
321{
322 //
323 //
324 // return cluster for n rows bellow first point
325 Int_t nfoundable = 1;
326 Int_t nfound = 1;
327 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
328 Int_t index = GetClusterIndex2(i);
329 if (index!=-1) nfoundable++;
330 if (index>0) nfound++;
331 }
332 if (nfoundable<n) return 0;
333 return Double_t(nfound)/Double_t(nfoundable);
334
335}
336
337
338void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
339{
340 // get cluster stat. on given region
341 //
342 found = 0;
343 foundable = 0;
344 shared =0;
345 for (Int_t i=first;i<last; i++){
346 Int_t index = GetClusterIndex2(i);
347 if (index!=-1) foundable++;
6d493ea0 348 if (index&0x8000) continue;
81e97e0d 349 if (fClusterPointer[i]) {
350 found++;
351 }
352 else
353 continue;
354
355 if (fClusterPointer[i]->IsUsed(10)) {
356 shared++;
357 continue;
358 }
359 if (!plus2) continue; //take also neighborhoud
360 //
361 if ( (i>0) && fClusterPointer[i-1]){
362 if (fClusterPointer[i-1]->IsUsed(10)) {
363 shared++;
364 continue;
365 }
366 }
367 if ( fClusterPointer[i+1]){
368 if (fClusterPointer[i+1]->IsUsed(10)) {
369 shared++;
370 continue;
371 }
372 }
373
374 }
375 //if (shared>found){
376 //Error("AliTPCseed::GetClusterStatistic","problem\n");
377 //}
378}
379
380
381
382
383
384void AliTPCseed::Reset(Bool_t all)
385{
386 //
387 //
388 SetNumberOfClusters(0);
389 fNFoundable = 0;
390 SetChi2(0);
6c94f330 391 ResetCovariance(10.);
81e97e0d 392 /*
393 if (fTrackPoints){
394 for (Int_t i=0;i<8;i++){
395 delete [] fTrackPoints[i];
396 }
397 delete fTrackPoints;
398 fTrackPoints =0;
399 }
400 */
401
402 if (all){
403 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
404 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
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
545 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
ca521f6c 546 Float_t dx = ((AliTPCclusterMI*)c)->GetX()-GetX();
547 if (TMath::Abs(dx)>0){
548 Float_t ty = TMath::Tan(TMath::ASin(GetSnp()));
549 Float_t dy = dx*ty;
550 Float_t dz = dx*TMath::Sqrt(1.+ty*ty)*GetTgl();
551 cl.SetY(c->GetY()-dy);
552 cl.SetZ(c->GetZ()-dz);
553 }
554
70e20dcf 555 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
e0e13b88 556
557 if (fCMeanSigmaY2p30<0){
558 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
c07cb486 559 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
560 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
561 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
e0e13b88 562 }
563 //
564 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
c07cb486 565 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
566 if (fCurrentSigmaY2>0){
567 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
568 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
569 }
e0e13b88 570
81e97e0d 571
70e20dcf 572 SetClusterIndex(n,idx); // restore the current cluster index
6c94f330 573 return kTRUE;
81e97e0d 574}
575
576
577
578//_____________________________________________________________________________
dc5cd41c 579Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t /* onlyused */) {
81e97e0d 580 //-----------------------------------------------------------------
581 // This funtion calculates dE/dX within the "low" and "up" cuts.
582 //-----------------------------------------------------------------
2cadb5d1 583 // CookdEdxAnalytical(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, Int_t returnVal)
83afd539 584 AliTPCParam *param = AliTPCcalibDB::Instance()->GetParameters();
44a6a09e 585
83afd539 586 Int_t row0 = param->GetNRowLow();
587 Int_t row1 = row0+param->GetNRowUp1();
588 Int_t row2 = row1+param->GetNRowUp2();
44a6a09e 589 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
590 Int_t useTot = 0;
591 if (recoParam) useTot = (recoParam->GetUseTotCharge())? 0:1;
83afd539 592 //
593 //
594 //
2cadb5d1 595 fDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 0);
596 fDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 0);
597 fDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 0);
598 fDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 0);
83afd539 599 //
2cadb5d1 600 fSDEDX[0] = CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 1);
601 fSDEDX[1] = CookdEdxAnalytical(low,up,useTot ,0 ,row0, 1);
602 fSDEDX[2] = CookdEdxAnalytical(low,up,useTot ,row0,row1, 1);
603 fSDEDX[3] = CookdEdxAnalytical(low,up,useTot ,row1,row2, 1);
83afd539 604 //
2cadb5d1 605 fNCDEDX[0] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,i1 ,i2, 2));
606 fNCDEDX[1] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,0 ,row0, 2));
607 fNCDEDX[2] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,row0,row1, 2));
608 fNCDEDX[3] = TMath::Nint(CookdEdxAnalytical(low,up,useTot ,row1,row2, 2));
81e97e0d 609
83afd539 610 SetdEdx(fDEDX[0]);
611 return fDEDX[0];
81e97e0d 612
ba5e52fb 613// return CookdEdxNorm(low,up,0,i1,i2,1,0,2);
4cc7ba77 614
615
ba5e52fb 616// Float_t amp[200];
617// Float_t angular[200];
618// Float_t weight[200];
619// Int_t index[200];
620// //Int_t nc = 0;
621// Float_t meanlog = 100.;
622
623// Float_t mean[4] = {0,0,0,0};
624// Float_t sigma[4] = {1000,1000,1000,1000};
625// Int_t nc[4] = {0,0,0,0};
626// Float_t norm[4] = {1000,1000,1000,1000};
627// //
628// //
629// fNShared =0;
630
631// Float_t gainGG = 1;
632// if (AliTPCcalibDB::Instance()->GetParameters()){
633// gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000.; //relative gas gain
634// }
635
636
637// for (Int_t of =0; of<4; of++){
638// for (Int_t i=of+i1;i<i2;i+=4)
639// {
640// Int_t clindex = fIndex[i];
641// if (clindex<0||clindex&0x8000) continue;
642
643// //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
644// AliTPCTrackerPoint * point = GetTrackPoint(i);
645// //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
646// //AliTPCTrackerPoint * pointp = 0;
647// //if (i<159) pointp = GetTrackPoint(i+1);
648
649// if (point==0) continue;
650// AliTPCclusterMI * cl = fClusterPointer[i];
651// if (cl==0) continue;
652// if (onlyused && (!cl->IsUsed(10))) continue;
653// if (cl->IsUsed(11)) {
654// fNShared++;
655// continue;
656// }
657// Int_t type = cl->GetType();
658// //if (point->fIsShared){
659// // fNShared++;
660// // continue;
661// //}
662// //if (pointm)
663// // if (pointm->fIsShared) continue;
664// //if (pointp)
665// // if (pointp->fIsShared) continue;
666
667// if (type<0) continue;
668// //if (type>10) continue;
669// //if (point->GetErrY()==0) continue;
670// //if (point->GetErrZ()==0) continue;
671
672// //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
673// //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
674// //if ((ddy*ddy+ddz*ddz)>10) continue;
675
676
677// // if (point->GetCPoint().GetMax()<5) continue;
678// if (cl->GetMax()<5) continue;
679// Float_t angley = point->GetAngleY();
680// Float_t anglez = point->GetAngleZ();
681
682// Float_t rsigmay2 = point->GetSigmaY();
683// Float_t rsigmaz2 = point->GetSigmaZ();
684// /*
685// Float_t ns = 1.;
686// if (pointm){
687// rsigmay += pointm->GetTPoint().GetSigmaY();
688// rsigmaz += pointm->GetTPoint().GetSigmaZ();
689// ns+=1.;
690// }
691// if (pointp){
692// rsigmay += pointp->GetTPoint().GetSigmaY();
693// rsigmaz += pointp->GetTPoint().GetSigmaZ();
694// ns+=1.;
695// }
696// rsigmay/=ns;
697// rsigmaz/=ns;
698// */
699
700// Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
701
702// Float_t ampc = 0; // normalization to the number of electrons
703// if (i>64){
704// // ampc = 1.*point->GetCPoint().GetMax();
705// ampc = 1.*cl->GetMax();
706// //ampc = 1.*point->GetCPoint().GetQ();
707// // AliTPCClusterPoint & p = point->GetCPoint();
708// // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
709// // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
710// //Float_t dz =
711// // TMath::Abs( Int_t(iz) - iz + 0.5);
712// //ampc *= 1.15*(1-0.3*dy);
713// //ampc *= 1.15*(1-0.3*dz);
714// // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
715// //ampc *=zfactor;
716// }
717// else{
718// //ampc = 1.0*point->GetCPoint().GetMax();
719// ampc = 1.0*cl->GetMax();
720// //ampc = 1.0*point->GetCPoint().GetQ();
721// //AliTPCClusterPoint & p = point->GetCPoint();
722// // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
723// //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
724// //Float_t dz =
725// // TMath::Abs( Int_t(iz) - iz + 0.5);
726
727// //ampc *= 1.15*(1-0.3*dy);
728// //ampc *= 1.15*(1-0.3*dz);
729// // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
730// //ampc *=zfactor;
731
732// }
733// ampc *= 2.0; // put mean value to channel 50
734// //ampc *= 0.58; // put mean value to channel 50
735// Float_t w = 1.;
736// // if (type>0) w = 1./(type/2.-0.5);
737// // Float_t z = TMath::Abs(cl->GetZ());
738// if (i<64) {
739// ampc /= 0.6;
740// //ampc /= (1+0.0008*z);
741// } else
742// if (i>128){
743// ampc /=1.5;
744// //ampc /= (1+0.0008*z);
745// }else{
746// //ampc /= (1+0.0008*z);
747// }
81e97e0d 748
ba5e52fb 749// if (type<0) { //amp at the border - lower weight
750// // w*= 2.;
81e97e0d 751
ba5e52fb 752// continue;
753// }
754// if (rsigma>1.5) ampc/=1.3; // if big backround
755// amp[nc[of]] = ampc;
756// amp[nc[of]] /=gainGG;
757// angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
758// weight[nc[of]] = w;
759// nc[of]++;
760// }
81e97e0d 761
ba5e52fb 762// TMath::Sort(nc[of],amp,index,kFALSE);
763// Float_t sumamp=0;
764// Float_t sumamp2=0;
765// Float_t sumw=0;
766// //meanlog = amp[index[Int_t(nc[of]*0.33)]];
767// meanlog = 50;
768// for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
769// Float_t ampl = amp[index[i]]/angular[index[i]];
770// ampl = meanlog*TMath::Log(1.+ampl/meanlog);
771// //
772// sumw += weight[index[i]];
773// sumamp += weight[index[i]]*ampl;
774// sumamp2 += weight[index[i]]*ampl*ampl;
775// norm[of] += angular[index[i]]*weight[index[i]];
776// }
777// if (sumw<1){
778// SetdEdx(0);
779// }
780// else {
781// norm[of] /= sumw;
782// mean[of] = sumamp/sumw;
783// sigma[of] = sumamp2/sumw-mean[of]*mean[of];
784// if (sigma[of]>0.1)
785// sigma[of] = TMath::Sqrt(sigma[of]);
786// else
787// sigma[of] = 1000;
81e97e0d 788
ba5e52fb 789// mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
790// //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
791// //mean *=(1-0.1*(norm-1.));
792// }
793// }
794
795// Float_t dedx =0;
796// fSdEdx =0;
797// fMAngular =0;
798// // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
799// // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
81e97e0d 800
801
ba5e52fb 802// // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
803// // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
804
805// Int_t norm2 = 0;
806// Int_t norm3 = 0;
807// for (Int_t i =0;i<4;i++){
808// if (nc[i]>2&&nc[i]<1000){
809// dedx += mean[i] *nc[i];
810// fSdEdx += sigma[i]*(nc[i]-2);
811// fMAngular += norm[i] *nc[i];
812// norm2 += nc[i];
813// norm3 += nc[i]-2;
814// }
815// fDEDX[i] = mean[i];
816// fSDEDX[i] = sigma[i];
817// fNCDEDX[i]= nc[i];
818// }
819
820// if (norm3>0){
821// dedx /=norm2;
822// fSdEdx /=norm3;
823// fMAngular/=norm2;
824// }
825// else{
826// SetdEdx(0);
827// return 0;
828// }
829// // Float_t dedx1 =dedx;
830// /*
831// dedx =0;
832// for (Int_t i =0;i<4;i++){
833// if (nc[i]>2&&nc[i]<1000){
834// mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
835// dedx += mean[i] *nc[i];
836// }
837// fDEDX[i] = mean[i];
838// }
839// dedx /= norm2;
840// */
81e97e0d 841
842
ba5e52fb 843// SetdEdx(dedx);
844// return dedx;
81e97e0d 845}
81e97e0d 846
847void AliTPCseed::CookPID()
848{
849 //
850 // cook PID information according dEdx
851 //
852 Double_t fRange = 10.;
853 Double_t fRes = 0.1;
854 Double_t fMIP = 47.;
855 //
856 Int_t ns=AliPID::kSPECIES;
857 Double_t sumr =0;
858 for (Int_t j=0; j<ns; j++) {
859 Double_t mass=AliPID::ParticleMass(j);
6c94f330 860 Double_t mom=GetP();
81e97e0d 861 Double_t dedx=fdEdx/fMIP;
5731b051 862 Double_t bethe=AliMathBase::BetheBlochAleph(mom/mass);
81e97e0d 863 Double_t sigma=fRes*bethe;
864 if (sigma>0.001){
865 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
866 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
867 sumr+=fTPCr[j];
868 continue;
869 }
870 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
871 sumr+=fTPCr[j];
872 }
873 else{
874 fTPCr[j]=1.;
875 sumr+=fTPCr[j];
876 }
877 }
878 for (Int_t j=0; j<ns; j++) {
879 fTPCr[j]/=sumr; //normalize
880 }
881}
882
6c94f330 883Double_t AliTPCseed::GetYat(Double_t xk) const {
884//-----------------------------------------------------------------
885// This function calculates the Y-coordinate of a track at the plane x=xk.
886//-----------------------------------------------------------------
887 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
60e55aee 888 Double_t c1=GetSnp(), r1=TMath::Sqrt((1.-c1)*(1.+c1));
6c94f330 889 Double_t c2=c1+GetC()*(xk-GetX());
890 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
60e55aee 891 Double_t r2=TMath::Sqrt((1.-c2)*(1.+c2));
6c94f330 892 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
893}
894
19b00333 895void AliTPCseed::SetClusterMapBit(int ibit, Bool_t state)
896{
897 fClusterMap[ibit] = state;
898}
899Bool_t AliTPCseed::GetClusterMapBit(int ibit)
900{
901 return fClusterMap[ibit];
902}
903void AliTPCseed::SetSharedMapBit(int ibit, Bool_t state)
904{
905 fSharedMap[ibit] = state;
906}
907Bool_t AliTPCseed::GetSharedMapBit(int ibit)
908{
909 return fSharedMap[ibit];
910}
eb02f63a 911
912
0a65832b 913
914
915
8a92e133 916Float_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 917
918 //
919 // calculates dedx using the cluster
920 // low - up specify trunc mean range - default form 0-0.7
8076baa0 921 // type - 1 - max charge or 0- total charge in cluster
922 // //2- max no corr 3- total+ correction
0a65832b 923 // i1-i2 - the pad-row range used for calculation
ba5e52fb 924 // shapeNorm - kTRUE -taken from OCDB
925 //
926 // posNorm - usage of pos normalization
83afd539 927 // padNorm - pad type normalization
928 // returnVal - 0 return mean
929 // - 1 return RMS
930 // - 2 return number of clusters
931 //
0a65832b 932 // normalization parametrization taken from AliTPCClusterParam
933 //
ba5e52fb 934 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
935 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
936 if (!parcl) return 0;
937 if (!param) return 0;
83afd539 938 Int_t row0 = param->GetNRowLow();
939 Int_t row1 = row0+param->GetNRowUp1();
940
0a65832b 941 Float_t amp[160];
942 Int_t indexes[160];
943 Int_t ncl=0;
944 //
945 //
ba5e52fb 946 Float_t gainGG = 1; // gas gain factor -always enabled
947 Float_t gainPad = 1; // gain map - used always
83afd539 948 Float_t corrShape = 1; // correction due angular effect, diffusion and electron attachment
ba5e52fb 949 Float_t corrPos = 1; // local position correction - if posNorm enabled
950 Float_t corrPadType = 1; // pad type correction - if padNorm enabled
951 Float_t corrNorm = 1; // normalization factor - set Q to channel 50
952 //
953 //
954 //
4cc7ba77 955 if (AliTPCcalibDB::Instance()->GetParameters()){
ba5e52fb 956 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
4cc7ba77 957 }
958
0a65832b 959 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
4cc7ba77 960 const Float_t kedgey =3.;
0a65832b 961 //
7cd8ac3f 962 //
0a65832b 963 for (Int_t irow=i1; irow<i2; irow++){
964 AliTPCclusterMI* cluster = GetClusterPointer(irow);
965 if (!cluster) continue;
966 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
8076baa0 967 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
ba5e52fb 968 Int_t ipad= 0;
83afd539 969 if (irow>=row0) ipad=1;
970 if (irow>=row1) ipad=2;
ba5e52fb 971 //
972 //
973 //
974 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
975 if (gainMap) {
976 //
977 // Get gainPad - pad by pad calibration
978 //
d6920632 979 Float_t factor = 1;
980 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
83afd539 981 if (irow < row0) { // IROC
ba5e52fb 982 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
d6920632 983 } else { // OROC
83afd539 984 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
d6920632 985 }
ba5e52fb 986 if (factor>0.5) gainPad=factor;
7cd8ac3f 987 }
ba5e52fb 988 //
989 //do position and angular normalization
990 //
991 if (shapeNorm){
992 if (type<=1){
993 //
994 AliTPCTrackerPoint * point = GetTrackPoint(irow);
995 Float_t ty = TMath::Abs(point->GetAngleY());
83afd539 996 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
ba5e52fb 997
998 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
999 corrShape = parcl->Qnorm(ipad,type,dr,ty,tz);
1000 }
0a65832b 1001 }
ba5e52fb 1002
8a92e133 1003 if (posNorm>0){
8e1dcdda 1004 //
ba5e52fb 1005 // Do position normalization - relative distance to
1006 // center of pad- time bin
1007 // Work in progress
022a2383 1008 // corrPos = parcl->QnormPos(ipad,type, cluster->GetPad(),
1009 // cluster->GetTimeBin(), cluster->GetZ(),
1010 // cluster->GetSigmaY2(),cluster->GetSigmaZ2(),
1011 // cluster->GetMax(),cluster->GetQ());
8a92e133 1012 // scaled response function
1013 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1014 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1015 //
1016
022a2383 1017 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1018 Float_t ty = TMath::Abs(point->GetAngleY());
1019 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1020
1021 if (type==1) corrPos =
1022 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
8a92e133 1023 cluster->GetTimeBin(),ty,tz,yres0,zres0,0.4);
022a2383 1024 if (type==0) corrPos =
1025 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
8a92e133 1026 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,0.4);
1027 if (posNorm==3){
1028 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1029 Double_t signtgl = (cluster->GetZ()*point->GetAngleZ()>0)? 1:-1;
1030 Double_t p2 = TMath::Abs(TMath::Sin(TMath::ATan(ty)));
1031 Float_t corrHis = parcl->QnormHis(ipad,type,dr,p2,TMath::Abs(point->GetAngleZ())*signtgl);
1032 if (corrHis>0) corrPos*=corrHis;
1033 }
1034
8e1dcdda 1035 }
1036
ba5e52fb 1037 if (padNorm==1){
1038 //taken from OCDB
798017c7 1039 if (type==0 && parcl->QpadTnorm()) corrPadType = (*parcl->QpadTnorm())[ipad];
1040 if (type==1 && parcl->QpadMnorm()) corrPadType = (*parcl->QpadMnorm())[ipad];
022a2383 1041
2fc9608f 1042 }
ba5e52fb 1043 if (padNorm==2){
1044 corrPadType =param->GetPadPitchLength(cluster->GetDetector(),cluster->GetRow());
1045 //use hardwired - temp fix
1046 if (type==0) corrNorm=3.;
1047 if (type==1) corrNorm=1.;
1048 }
1049 //
1050 amp[ncl]=charge;
1051 amp[ncl]/=gainGG;
1052 amp[ncl]/=gainPad;
1053 amp[ncl]/=corrShape;
1054 amp[ncl]/=corrPadType;
1055 amp[ncl]/=corrPos;
1056 amp[ncl]/=corrNorm;
1057 //
0a65832b 1058 ncl++;
1059 }
8076baa0 1060
0a65832b 1061 if (type>3) return ncl;
1062 TMath::Sort(ncl,amp, indexes, kFALSE);
1063
8076baa0 1064 if (ncl<10) return 0;
0a65832b 1065
1066 Float_t suma=0;
83afd539 1067 Float_t suma2=0;
0a65832b 1068 Float_t sumn=0;
1069 Int_t icl0=TMath::Nint(ncl*low);
1070 Int_t icl1=TMath::Nint(ncl*up);
1071 for (Int_t icl=icl0; icl<icl1;icl++){
1072 suma+=amp[indexes[icl]];
83afd539 1073 suma2+=amp[indexes[icl]]*amp[indexes[icl]];
0a65832b 1074 sumn++;
1075 }
83afd539 1076 Float_t mean =suma/sumn;
1077 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
3af3fbc4 1078 //
1079 // do time-dependent correction for pressure and temperature variations
1080 UInt_t runNumber = 1;
1081 Float_t corrTimeGain = 1;
1082 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
e5e80ff9 1083 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
1084 if (trans && recoParam->GetUseGainCorrectionTime()>0) {
3af3fbc4 1085 runNumber = trans->GetCurrentRunNumber();
e5e80ff9 1086 //AliTPCcalibDB::Instance()->SetRun(runNumber);
a2c3785e 1087 TObjArray * timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
3af3fbc4 1088 if (timeGainSplines) {
1089 UInt_t time = trans->GetCurrentTimeStamp();
1090 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1091 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1092 if (fitMIP) {
108a67db 1093 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time);/*fitMIP->Eval(time);*/
3af3fbc4 1094 } else {
108a67db 1095 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time);/*fitFPcosmic->Eval(time);*/
3af3fbc4 1096 }
1097 }
1098 }
1099 mean /= corrTimeGain;
1100 rms /= corrTimeGain;
1101 //
83afd539 1102 if (returnVal==1) return rms;
8a92e133 1103 if (returnVal==2) return ncl;
1104 return mean;
1105}
1106
6feb400f 1107Float_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 1108
1109 //
1110 // calculates dedx using the cluster
1111 // low - up specify trunc mean range - default form 0-0.7
1112 // type - 1 - max charge or 0- total charge in cluster
1113 // //2- max no corr 3- total+ correction
1114 // i1-i2 - the pad-row range used for calculation
1115 //
1116 // posNorm - usage of pos normalization
6feb400f 1117 // returnVal - 0 return mean
1118 // - 1 return RMS
1119 // - 2 return number of clusters
1120 // - 3 ratio
1121 // - 4 mean upper half
1122 // - 5 mean - lower half
1123 // - 6 third moment
1124 // mode - 0 - linear
1125 // - 1 - logatithmic
2efc897f 1126 // rowThres - number of rows before and after given pad row to check for clusters below threshold
8a92e133 1127 //
1128 // normalization parametrization taken from AliTPCClusterParam
1129 //
1130 AliTPCClusterParam * parcl = AliTPCcalibDB::Instance()->GetClusterParam();
1131 AliTPCParam * param = AliTPCcalibDB::Instance()->GetParameters();
1132 if (!parcl) return 0;
1133 if (!param) return 0;
1134 Int_t row0 = param->GetNRowLow();
1135 Int_t row1 = row0+param->GetNRowUp1();
1136
1137 Float_t amp[160];
1138 Int_t indexes[160];
1139 Int_t ncl=0;
2efc897f 1140 Int_t nclBelowThr = 0; // counts number of clusters below threshold
8a92e133 1141 //
1142 //
1143 Float_t gainGG = 1; // gas gain factor -always enabled
1144 Float_t gainPad = 1; // gain map - used always
1145 Float_t corrPos = 1; // local position correction - if posNorm enabled
8a92e133 1146 //
1147 //
1148 //
1149 if (AliTPCcalibDB::Instance()->GetParameters()){
1150 gainGG= AliTPCcalibDB::Instance()->GetParameters()->GetGasGain()/20000; //relative gas gain
1151 }
649fcc43 1152 //
1153 // extract time-dependent correction for pressure and temperature variations
1154 //
1155 UInt_t runNumber = 1;
1156 Float_t corrTimeGain = 1;
1157 TObjArray * timeGainSplines = 0x0;
1158 TGraphErrors * grPadEqual = 0x0;
1159 //
1160 AliTPCTransform * trans = AliTPCcalibDB::Instance()->GetTransform();
1161 const AliTPCRecoParam * recoParam = AliTPCcalibDB::Instance()->GetTransform()->GetCurrentRecoParam();
6d64657a 1162 //
1163 if (recoParam->GetNeighborRowsDedx() == 0) rowThres = 0;
1164 //
649fcc43 1165 if (trans) {
2efc897f 1166 runNumber = trans->GetCurrentRunNumber();
1167 //AliTPCcalibDB::Instance()->SetRun(runNumber);
1168 timeGainSplines = AliTPCcalibDB::Instance()->GetTimeGainSplinesRun(runNumber);
1169 if (timeGainSplines && recoParam->GetUseGainCorrectionTime()>0) {
1170 UInt_t time = trans->GetCurrentTimeStamp();
1171 AliSplineFit * fitMIP = (AliSplineFit *) timeGainSplines->At(0);
1172 AliSplineFit * fitFPcosmic = (AliSplineFit *) timeGainSplines->At(1);
1173 if (fitMIP) {
1174 corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitMIP, time); /*fitMIP->Eval(time);*/
649fcc43 1175 } else {
2efc897f 1176 if (fitFPcosmic) corrTimeGain = AliTPCcalibDButil::EvalGraphConst(fitFPcosmic, time); /*fitFPcosmic->Eval(time); */
1177 }
649fcc43 1178 //
1179 if (type==1) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQMAX_PADREGIONGAIN_BEAM_ALL");
1180 if (type==0) grPadEqual = (TGraphErrors * ) timeGainSplines->FindObject("TGRAPHERRORS_MEANQTOT_PADREGIONGAIN_BEAM_ALL");
2efc897f 1181 }
649fcc43 1182 }
2efc897f 1183
1184 const Float_t kClusterShapeCut = 1.5; // IMPPRTANT TO DO: move value to AliTPCRecoParam
8a92e133 1185 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1186 const Float_t kedgey =3.;
1187 //
1188 //
1189 for (Int_t irow=i1; irow<i2; irow++){
1190 AliTPCclusterMI* cluster = GetClusterPointer(irow);
736a5826 1191 if (!cluster && irow > 1 && irow < 157) {
2efc897f 1192 Bool_t isClBefore = kFALSE;
1193 Bool_t isClAfter = kFALSE;
1194 for(Int_t ithres = 1; ithres <= rowThres; ithres++) {
1195 AliTPCclusterMI * clusterBefore = GetClusterPointer(irow - ithres);
1196 if (clusterBefore) isClBefore = kTRUE;
1197 AliTPCclusterMI * clusterAfter = GetClusterPointer(irow + ithres);
1198 if (clusterAfter) isClAfter = kTRUE;
1199 }
1200 if (isClBefore && isClAfter) nclBelowThr++;
2efc897f 1201 }
736a5826 1202 if (!cluster) continue;
2efc897f 1203 //
1204 //
8a92e133 1205 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
2efc897f 1206 //
1207 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1208 if (point==0) continue;
1209 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1210 if (rsigmay > kClusterShapeCut) continue;
1211 //
1212 if (cluster->IsUsed(11)) continue; // remove shared clusters for PbPb
1213 //
8a92e133 1214 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
1215 Int_t ipad= 0;
1216 if (irow>=row0) ipad=1;
1217 if (irow>=row1) ipad=2;
1218 //
1219 //
1220 //
1221 AliTPCCalPad * gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
1222 if (gainMap) {
1223 //
1224 // Get gainPad - pad by pad calibration
1225 //
1226 Float_t factor = 1;
1227 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1228 if (irow < row0) { // IROC
1229 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()));
1230 } else { // OROC
1231 factor = roc->GetValue(irow - row0, TMath::Nint(cluster->GetPad()));
1232 }
2efc897f 1233 if (factor>0.3) gainPad=factor;
8a92e133 1234 }
8a92e133 1235 //
1236 // Do position normalization - relative distance to
1237 // center of pad- time bin
1238
8a92e133 1239 Float_t ty = TMath::Abs(point->GetAngleY());
1240 Float_t tz = TMath::Abs(point->GetAngleZ()*TMath::Sqrt(1+ty*ty));
1241 Float_t yres0 = parcl->GetRMS0(0,ipad,0,0)/param->GetPadPitchWidth(cluster->GetDetector());
1242 Float_t zres0 = parcl->GetRMS0(1,ipad,0,0)/param->GetZWidth();
1243
1244 yres0 *=parcl->GetQnormCorr(ipad, type,0);
1245 zres0 *=parcl->GetQnormCorr(ipad, type,1);
1246 Float_t effLength=parcl->GetQnormCorr(ipad, type,4)*0.5;
1247 Float_t effDiff =(parcl->GetQnormCorr(ipad, type,2)+parcl->GetQnormCorr(ipad, type,3))*0.5;
1248 //
1249 if (type==1) {
1250 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1251 parcl->QmaxCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1252 cluster->GetTimeBin(),ty,tz,yres0,zres0,effLength,effDiff);
1253 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1254 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1255 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1256 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1257 //
1258 }
1259 if (type==0) {
1260 corrPos = parcl->GetQnormCorr(ipad, type,5)*
1261 parcl->QtotCorrection(cluster->GetDetector(), cluster->GetRow(),cluster->GetPad(),
1262 cluster->GetTimeBin(),ty,tz,yres0,zres0,cluster->GetQ(),2.5,effLength,effDiff);
1263
1264 Float_t drm = 0.5-TMath::Abs(cluster->GetZ()/250.);
1265 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,0)*drm);
1266 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,1)*ty*ty);
1267 corrPos*=(1+parcl->GetQnormCorr(ipad, type+2,2)*tz*tz);
1268 //
1269 }
2efc897f 1270 //
1271 // pad region equalization outside of cluster param
1272 //
1273 Float_t gainEqualPadRegion = 1;
649fcc43 1274 if (grPadEqual) gainEqualPadRegion = grPadEqual->Eval(ipad);
8a92e133 1275 //
1276 amp[ncl]=charge;
1277 amp[ncl]/=gainGG;
1278 amp[ncl]/=gainPad;
1279 amp[ncl]/=corrPos;
2efc897f 1280 amp[ncl]/=gainEqualPadRegion;
8a92e133 1281 //
1282 ncl++;
1283 }
1284
6feb400f 1285 if (type==2) return ncl;
8a92e133 1286 TMath::Sort(ncl,amp, indexes, kFALSE);
2efc897f 1287 //
8a92e133 1288 if (ncl<10) return 0;
2efc897f 1289 //
1290 Double_t * ampWithBelow = new Double_t[ncl + nclBelowThr];
1291 for(Int_t iCl = 0; iCl < ncl + nclBelowThr; iCl++) {
1292 if (iCl < nclBelowThr) {
1293 ampWithBelow[iCl] = amp[indexes[0]];
1294 } else {
1295 ampWithBelow[iCl] = amp[indexes[iCl - nclBelowThr]];
1296 }
1297 }
1298 //printf("DEBUG: %i shit %f", nclBelowThr, amp[indexes[0]]);
1299 //
8a92e133 1300 Float_t suma=0;
1301 Float_t suma2=0;
6feb400f 1302 Float_t suma3=0;
1303 Float_t sumaS=0;
8a92e133 1304 Float_t sumn=0;
6feb400f 1305 // upper,and lower part statistic
1306 Float_t sumL=0, sumL2=0, sumLN=0;
1307 Float_t sumD=0, sumD2=0, sumDN=0;
1308
2efc897f 1309 Int_t icl0=TMath::Nint((ncl + nclBelowThr)*low);
1310 Int_t icl1=TMath::Nint((ncl + nclBelowThr)*up);
6feb400f 1311 Int_t iclm=TMath::Nint((ncl + nclBelowThr)*(low +(up+low)*0.5));
1312 //
8a92e133 1313 for (Int_t icl=icl0; icl<icl1;icl++){
6feb400f 1314 if (ampWithBelow[icl]<0.1) continue;
1315 Double_t amp=ampWithBelow[icl]/corrTimeGain;
1316 if (mode==1) amp= TMath::Log(amp);
1317 if (icl<icl1){
1318 suma+=amp;
1319 suma2+=amp*amp;
1320 suma3+=amp*amp*amp;
1321 sumaS+=TMath::Power(TMath::Abs(amp),1./3.);
1322 sumn++;
1323 }
1324 if (icl>iclm){
1325 sumL+=amp;
1326 sumL2+=amp*amp;
1327 sumLN++;
1328 }
1329 if (icl<=iclm){
1330 sumD+=amp;
1331 sumD2+=amp*amp;
1332 sumDN++;
1333 }
8a92e133 1334 }
1335 Float_t mean =suma/sumn;
6feb400f 1336 Float_t meanL = sumL/sumLN;
1337 Float_t meanD =(sumD/sumDN); // lower half mean
8a92e133 1338 Float_t rms =TMath::Sqrt(TMath::Abs(suma2/sumn-mean*mean));
6feb400f 1339 Float_t mean2=suma2/sumn;
1340 Float_t mean3=suma3/sumn;
1341 Float_t meanS=sumaS/sumn;
1342 if (mean2>0) mean2=TMath::Power(TMath::Abs(mean2),1./2.);
1343 if (mean3>0) mean3=TMath::Power(TMath::Abs(mean3),1./3.);
1344 if (meanS>0) meanS=TMath::Power(TMath::Abs(meanS),3.);
3af3fbc4 1345 //
6feb400f 1346 if (mode==1) mean=TMath::Exp(mean);
1347 if (mode==1) meanL=TMath::Exp(meanL); // upper truncation
1348 if (mode==1) meanD=TMath::Exp(meanD); // lower truncation
1349 //
1350 delete [] ampWithBelow;
1351
1352
3af3fbc4 1353 //
8a92e133 1354 if (returnVal==1) return rms;
83afd539 1355 if (returnVal==2) return ncl;
6feb400f 1356 if (returnVal==3) return Double_t(nclBelowThr)/Double_t(nclBelowThr+ncl);
1357 if (returnVal==4) return meanL;
1358 if (returnVal==5) return meanD;
1359 if (returnVal==6) return mean2;
1360 if (returnVal==7) return mean3;
1361 if (returnVal==8) return meanS;
83afd539 1362 return mean;
0a65832b 1363}
1364
83afd539 1365
0a65832b 1366
1367
eb02f63a 1368Float_t AliTPCseed::CookShape(Int_t type){
1369 //
1370 //
1371 //
1372 //-----------------------------------------------------------------
1373 // This funtion calculates dE/dX within the "low" and "up" cuts.
1374 //-----------------------------------------------------------------
1375 Float_t means=0;
1376 Float_t meanc=0;
1377 for (Int_t i =0; i<160;i++) {
1378 AliTPCTrackerPoint * point = GetTrackPoint(i);
1379 if (point==0) continue;
1380
1381 AliTPCclusterMI * cl = fClusterPointer[i];
1382 if (cl==0) continue;
1383
1384 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1385 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1386 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1387 if (type==0) means+=rsigma;
1388 if (type==1) means+=rsigmay;
1389 if (type==2) means+=rsigmaz;
1390 meanc++;
1391 }
1392 Float_t mean = (meanc>0)? means/meanc:0;
1393 return mean;
1394}
87e92a27 1395
1396
1397
1398Int_t AliTPCseed::RefitTrack(AliTPCseed *seed, AliExternalTrackParam * parin, AliExternalTrackParam * parout){
1399 //
1400 // Refit the track
1401 // return value - number of used clusters
1402 //
1403 //
1404 const Int_t kMinNcl =10;
1405 AliTPCseed *track=new AliTPCseed(*seed);
1406 Int_t sector=-1;
1407 // reset covariance
1408 //
1409 Double_t covar[15];
1410 for (Int_t i=0;i<15;i++) covar[i]=0;
1411 covar[0]=10.*10.;
1412 covar[2]=10.*10.;
1413 covar[5]=10.*10./(64.*64.);
1414 covar[9]=10.*10./(64.*64.);
1415 covar[14]=1*1;
1416 //
1417
1418 Float_t xmin=1000, xmax=-10000;
1419 Int_t imin=158, imax=0;
1420 for (Int_t i=0;i<160;i++) {
1421 AliTPCclusterMI *c=track->GetClusterPointer(i);
1422 if (!c) continue;
1423 if (sector<0) sector = c->GetDetector();
1424 if (c->GetX()<xmin) xmin=c->GetX();
1425 if (c->GetX()>xmax) xmax=c->GetX();
1426 if (i<imin) imin=i;
1427 if (i>imax) imax=i;
1428 }
1429 if(imax-imin<kMinNcl) {
1430 delete track;
1431 return 0 ;
1432 }
1433 // Not succes to rotate
1434 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1435 delete track;
1436 return 0;
1437 }
1438 //
1439 //
1440 // fit from inner to outer row
1441 //
1442 AliExternalTrackParam paramIn;
1443 AliExternalTrackParam paramOut;
1444 Bool_t isOK=kTRUE;
be34cb88 1445 Int_t ncl=0;
87e92a27 1446 //
1447 //
1448 //
1449 for (Int_t i=imin; i<=imax; i++){
1450 AliTPCclusterMI *c=track->GetClusterPointer(i);
1451 if (!c) continue;
1452 // if (RejectCluster(c,track)) continue;
be34cb88 1453 sector = (c->GetDetector()%18);
1454 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1455 //continue;
1456 }
87e92a27 1457 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1458 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1459 if (!track->PropagateTo(r[0])) {
1460 isOK=kFALSE;
87e92a27 1461 }
1462 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1463 }
1464 if (!isOK) { delete track; return 0;}
1465 track->AddCovariance(covar);
1466 //
1467 //
1468 //
1469 for (Int_t i=imax; i>=imin; i--){
1470 AliTPCclusterMI *c=track->GetClusterPointer(i);
1471 if (!c) continue;
1472 //if (RejectCluster(c,track)) continue;
be34cb88 1473 sector = (c->GetDetector()%18);
1474 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1475 //continue;
1476 }
87e92a27 1477 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1478 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1479 if (!track->PropagateTo(r[0])) {
1480 isOK=kFALSE;
87e92a27 1481 }
1482 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1483 }
be34cb88 1484 //if (!isOK) { delete track; return 0;}
87e92a27 1485 paramIn = *track;
1486 track->AddCovariance(covar);
1487 //
1488 //
1489 for (Int_t i=imin; i<=imax; i++){
1490 AliTPCclusterMI *c=track->GetClusterPointer(i);
1491 if (!c) continue;
be34cb88 1492 sector = (c->GetDetector()%18);
1493 if (!track->Rotate(TMath::DegToRad()*(sector%18*20.+10.)-track->GetAlpha())) {
1494 //continue;
1495 }
1496 ncl++;
87e92a27 1497 //if (RejectCluster(c,track)) continue;
1498 Double_t r[3]={c->GetX(),c->GetY(),c->GetZ()};
1499 Double_t cov[3]={0.01,0.,0.01}; //TODO: correct error parametrisation
1500 if (!track->PropagateTo(r[0])) {
1501 isOK=kFALSE;
87e92a27 1502 }
1503 if ( !((static_cast<AliExternalTrackParam*>(track)->Update(&r[1],cov)))) isOK=kFALSE;
1504 }
be34cb88 1505 //if (!isOK) { delete track; return 0;}
87e92a27 1506 paramOut=*track;
87e92a27 1507 //
1508 //
1509 //
1510 if (parin) (*parin)=paramIn;
1511 if (parout) (*parout)=paramOut;
6e23caff 1512 delete track;
be34cb88 1513 return ncl;
87e92a27 1514}
1515
1516
1517
1518Bool_t AliTPCseed::RefitTrack(AliTPCseed* /*seed*/, Bool_t /*out*/){
1519 //
1520 //
1521 //
1522 return kFALSE;
1523}
3247d397 1524
1525
1526
1527
1528
1529
1530void AliTPCseed::GetError(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1531 Double_t& erry, Double_t &errz)
1532{
1533 //
1534 // Get cluster error at given position
1535 //
1536 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1537 Double_t tany,tanz;
1538 Double_t snp1=param->GetSnp();
60e55aee 1539 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1540 //
1541 Double_t tgl1=param->GetTgl();
60e55aee 1542 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1543 //
1544 Int_t padSize = 0; // short pads
1545 if (cluster->GetDetector() >= 36) {
1546 padSize = 1; // medium pads
1547 if (cluster->GetRow() > 63) padSize = 2; // long pads
1548 }
1549
1550 erry = clusterParam->GetError0Par( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany) );
1551 errz = clusterParam->GetError0Par( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) );
1552}
1553
1554
1555void AliTPCseed::GetShape(AliTPCclusterMI* cluster, AliExternalTrackParam * param,
1556 Double_t& rmsy, Double_t &rmsz)
1557{
1558 //
1559 // Get cluster error at given position
1560 //
1561 AliTPCClusterParam *clusterParam = AliTPCcalibDB::Instance()->GetClusterParam();
1562 Double_t tany,tanz;
1563 Double_t snp1=param->GetSnp();
60e55aee 1564 tany=snp1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1565 //
1566 Double_t tgl1=param->GetTgl();
60e55aee 1567 tanz=tgl1/TMath::Sqrt((1.-snp1)*(1.+snp1));
3247d397 1568 //
1569 Int_t padSize = 0; // short pads
1570 if (cluster->GetDetector() >= 36) {
1571 padSize = 1; // medium pads
1572 if (cluster->GetRow() > 63) padSize = 2; // long pads
1573 }
1574
1575 rmsy = clusterParam->GetRMSQ( 0, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tany), TMath::Abs(cluster->GetMax()) );
1576 rmsz = clusterParam->GetRMSQ( 1, padSize, (250.0 - TMath::Abs(cluster->GetZ())), TMath::Abs(tanz) ,TMath::Abs(cluster->GetMax()));
1577}
ba5e52fb 1578
1579
1580
1581Double_t AliTPCseed::GetQCorrGeom(Float_t ty, Float_t tz){
1582 //Geoetrical
1583 //ty - tangent in local y direction
1584 //tz - tangent
1585 //
1586 Float_t norm=TMath::Sqrt(1+ty*ty+tz*tz);
1587 return norm;
1588}
1589
83afd539 1590Double_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 1591 //
1592 // Q normalization
1593 //
1594 // return value = Q Normalization factor
1595 // Normalization - 1 - shape factor part for full drift
1596 // 1 - electron attachment for 0 drift
1597
1598 // Input parameters:
1599 //
1600 // ipad - 0 short pad
1601 // 1 medium pad
1602 // 2 long pad
1603 //
1604 // type - 0 qmax
1605 // - 1 qtot
1606 //
1607 //z - z position (-250,250 cm)
1608 //ty - tangent in local y direction
1609 //tz - tangent
1610 //
1611
1612 AliTPCClusterParam * paramCl = AliTPCcalibDB::Instance()->GetClusterParam();
1613 AliTPCParam * paramTPC = AliTPCcalibDB::Instance()->GetParameters();
1614
1615 if (!paramCl) return 1;
1616 //
1617 Double_t dr = 250.-TMath::Abs(z);
1618 Double_t sy = paramCl->GetRMS0( 0,ipad, dr, TMath::Abs(ty));
1619 Double_t sy0= paramCl->GetRMS0(0,ipad, 250, 0);
1620 Double_t sz = paramCl->GetRMS0( 1,ipad, dr, TMath::Abs(tz));
1621 Double_t sz0= paramCl->GetRMS0(1,ipad, 250, 0);
1622
1623 Double_t sfactorMax = TMath::Sqrt(sy0*sz0/(sy*sz));
1624
1625
1626 Double_t dt = 1000000*(dr/paramTPC->GetDriftV()); //time in microsecond
1627 Double_t attProb = TMath::Exp(-paramTPC->GetAttCoef()*paramTPC->GetOxyCont()*dt);
1628 //
1629 //
1630 if (type==0) return sfactorMax*attProb;
1631
1632 return attProb;
1633
1634
1635}
1636