Added function to update FXS logbooks' time_processed field
[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"
7cd8ac3f 31
32
81e97e0d 33
34ClassImp(AliTPCseed)
35
36
37
32fab534 38AliTPCseed::AliTPCseed():
39 AliTPCtrack(),
40 fEsd(0x0),
2928bdf0 41 fClusterOwner(kFALSE),
32fab534 42 fRow(0),
43 fSector(-1),
44 fRelativeSector(-1),
45 fCurrentSigmaY2(1e10),
46 fCurrentSigmaZ2(1e10),
e0e13b88 47 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
48 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 49 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
50 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
e0e13b88 51 //
32fab534 52 fErrorY2(1e10),
53 fErrorZ2(1e10),
54 fCurrentCluster(0x0),
55 fCurrentClusterIndex1(-1),
56 fInDead(kFALSE),
57 fIsSeeding(kFALSE),
58 fNoCluster(0),
59 fSort(0),
60 fBSigned(kFALSE),
61 fSeedType(0),
62 fSeed1(-1),
63 fSeed2(-1),
64 fMAngular(0),
19b00333 65 fCircular(0),
66 fClusterMap(159),
67 fSharedMap(159)
32fab534 68{
81e97e0d 69 //
5c09947e 70 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 71 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
72 for (Int_t i=0;i<3;i++) fKinkIndexes[i]=0;
32fab534 73 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=0.2;
74 for (Int_t i=0;i<4;i++) {
75 fDEDX[i] = 0.;
76 fSDEDX[i] = 1e10;
77 fNCDEDX[i] = 0;
78 }
79 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
bfb57b6c 80 // for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
81 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
82 fClusterMap.ResetAllBits(kFALSE);
83 fSharedMap.ResetAllBits(kFALSE);
84
81e97e0d 85}
32fab534 86
2928bdf0 87AliTPCseed::AliTPCseed(const AliTPCseed &s, Bool_t clusterOwner):
32fab534 88 AliTPCtrack(s),
89 fEsd(0x0),
2928bdf0 90 fClusterOwner(clusterOwner),
32fab534 91 fRow(0),
92 fSector(-1),
93 fRelativeSector(-1),
c07cb486 94 fCurrentSigmaY2(-1),
95 fCurrentSigmaZ2(-1),
e0e13b88 96 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
97 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 98 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
99 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 100 fErrorY2(1e10),
101 fErrorZ2(1e10),
102 fCurrentCluster(0x0),
103 fCurrentClusterIndex1(-1),
104 fInDead(kFALSE),
105 fIsSeeding(kFALSE),
106 fNoCluster(0),
107 fSort(0),
108 fBSigned(kFALSE),
109 fSeedType(0),
110 fSeed1(-1),
111 fSeed2(-1),
112 fMAngular(0),
19b00333 113 fCircular(0),
114 fClusterMap(s.fClusterMap),
115 fSharedMap(s.fSharedMap)
32fab534 116{
81e97e0d 117 //---------------------
118 // dummy copy constructor
119 //-------------------------
2928bdf0 120 for (Int_t i=0;i<160;i++) {
121 fClusterPointer[i]=0;
122 if (fClusterOwner){
123 if (s.fClusterPointer[i])
124 fClusterPointer[i] = new AliTPCclusterMI(*(s.fClusterPointer[i]));
125 }else{
126 fClusterPointer[i] = s.fClusterPointer[i];
127 }
128 fTrackPoints[i] = s.fTrackPoints[i];
129 }
81e97e0d 130 for (Int_t i=0;i<160;i++) fIndex[i] = s.fIndex[i];
5c09947e 131 for (Int_t i=0;i<AliPID::kSPECIES;i++) fTPCr[i]=s.fTPCr[i];
132 for (Int_t i=0;i<4;i++) {
133 fDEDX[i] = s.fDEDX[i];
134 fSDEDX[i] = s.fSDEDX[i];
135 fNCDEDX[i] = s.fNCDEDX[i];
136 }
137 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = s.fOverlapLabels[i];
19b00333 138
81e97e0d 139}
5c09947e 140
141
32fab534 142AliTPCseed::AliTPCseed(const AliTPCtrack &t):
143 AliTPCtrack(t),
144 fEsd(0x0),
2928bdf0 145 fClusterOwner(kFALSE),
32fab534 146 fRow(0),
147 fSector(-1),
148 fRelativeSector(-1),
c07cb486 149 fCurrentSigmaY2(-1),
150 fCurrentSigmaZ2(-1),
e0e13b88 151 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
152 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 153 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
154 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 155 fErrorY2(1e10),
156 fErrorZ2(1e10),
157 fCurrentCluster(0x0),
158 fCurrentClusterIndex1(-1),
159 fInDead(kFALSE),
160 fIsSeeding(kFALSE),
161 fNoCluster(0),
162 fSort(0),
163 fBSigned(kFALSE),
164 fSeedType(0),
165 fSeed1(-1),
166 fSeed2(-1),
167 fMAngular(0),
19b00333 168 fCircular(0),
169 fClusterMap(159),
170 fSharedMap(159)
32fab534 171{
81e97e0d 172 //
32fab534 173 // Constructor from AliTPCtrack
174 //
175 fFirstPoint =0;
105b1b81 176 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
81e97e0d 177 for (Int_t i=0;i<160;i++) {
178 fClusterPointer[i] = 0;
179 Int_t index = t.GetClusterIndex(i);
180 if (index>=-1){
181 SetClusterIndex2(i,index);
182 }
183 else{
184 SetClusterIndex2(i,-3);
185 }
186 }
32fab534 187 for (Int_t i=0;i<4;i++) {
188 fDEDX[i] = 0.;
189 fSDEDX[i] = 1e10;
190 fNCDEDX[i] = 0;
191 }
192 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
bfb57b6c 193
194 //for (Int_t i=0;i<160;i++) fClusterMap[i]=kFALSE;
195 //for (Int_t i=0;i<160;i++) fSharedMap[i]=kFALSE;
196 fClusterMap.ResetAllBits(kFALSE);
197 fSharedMap.ResetAllBits(kFALSE);
198
81e97e0d 199}
200
6c94f330 201AliTPCseed::AliTPCseed(Double_t xr, Double_t alpha, const Double_t xx[5],
202 const Double_t cc[15], Int_t index):
203 AliTPCtrack(xr, alpha, xx, cc, index),
32fab534 204 fEsd(0x0),
2928bdf0 205 fClusterOwner(kFALSE),
32fab534 206 fRow(0),
207 fSector(-1),
208 fRelativeSector(-1),
c07cb486 209 fCurrentSigmaY2(-1),
210 fCurrentSigmaZ2(-1),
e0e13b88 211 fCMeanSigmaY2p30(-1.), //! current mean sigma Y2 - mean30%
212 fCMeanSigmaZ2p30(-1.), //! current mean sigma Z2 - mean30%
c07cb486 213 fCMeanSigmaY2p30R(-1.), //! current mean sigma Y2 - mean2%
214 fCMeanSigmaZ2p30R(-1.), //! current mean sigma Z2 - mean2%
32fab534 215 fErrorY2(1e10),
216 fErrorZ2(1e10),
217 fCurrentCluster(0x0),
218 fCurrentClusterIndex1(-1),
219 fInDead(kFALSE),
220 fIsSeeding(kFALSE),
221 fNoCluster(0),
222 fSort(0),
223 fBSigned(kFALSE),
224 fSeedType(0),
225 fSeed1(-1),
226 fSeed2(-1),
227 fMAngular(0),
19b00333 228 fCircular(0),
229 fClusterMap(159),
230 fSharedMap(159)
32fab534 231{
232 //
233 // Constructor
81e97e0d 234 //
32fab534 235 fFirstPoint =0;
5c09947e 236 for (Int_t i=0;i<160;i++) SetClusterIndex2(i,-3);
81e97e0d 237 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
81e97e0d 238 for (Int_t i=0;i<5;i++) fTPCr[i]=0.2;
32fab534 239 for (Int_t i=0;i<4;i++) {
240 fDEDX[i] = 0.;
241 fSDEDX[i] = 1e10;
242 fNCDEDX[i] = 0;
243 }
244 for (Int_t i=0;i<12;i++) fOverlapLabels[i] = -1;
81e97e0d 245}
246
247AliTPCseed::~AliTPCseed(){
248 //
249 // destructor
81e97e0d 250 fNoCluster =0;
2928bdf0 251 if (fClusterOwner){
252 for (Int_t icluster=0; icluster<160; icluster++){
253 delete fClusterPointer[icluster];
254 }
255 }
bfb57b6c 256
81e97e0d 257}
179c6296 258//_________________________________________________
316c6cd9 259AliTPCseed & AliTPCseed::operator=(const AliTPCseed &param)
179c6296 260{
261 //
316c6cd9 262 // assignment operator
179c6296 263 //
316c6cd9 264 if(this!=&param){
265 AliTPCtrack::operator=(param);
266 fEsd =param.fEsd;
267 for(Int_t i = 0;i<160;++i)fClusterPointer[i] = param.fClusterPointer[i]; // this is not allocated by AliTPCSeed
268 fClusterOwner = param.fClusterOwner;
269 // leave out fPoint, they are also not copied in the copy ctor...
270 // but deleted in the dtor... strange...
316c6cd9 271 fRow = param.fRow;
272 fSector = param.fSector;
273 fRelativeSector = param.fRelativeSector;
274 fCurrentSigmaY2 = param.fCurrentSigmaY2;
275 fCurrentSigmaZ2 = param.fCurrentSigmaZ2;
276 fErrorY2 = param.fErrorY2;
277 fErrorZ2 = param.fErrorZ2;
278 fCurrentCluster = param.fCurrentCluster; // this is not allocated by AliTPCSeed
279 fCurrentClusterIndex1 = param.fCurrentClusterIndex1;
280 fInDead = param.fInDead;
281 fIsSeeding = param.fIsSeeding;
282 fNoCluster = param.fNoCluster;
283 fSort = param.fSort;
284 fBSigned = param.fBSigned;
285 for(Int_t i = 0;i<4;++i){
286 fDEDX[i] = param.fDEDX[i];
287 fSDEDX[i] = param.fSDEDX[i];
288 fNCDEDX[i] = param.fNCDEDX[i];
289 }
290 for(Int_t i = 0;i<AliPID::kSPECIES;++i)fTPCr[i] = param.fTPCr[i];
291
292 fSeedType = param.fSeedType;
293 fSeed1 = param.fSeed1;
294 fSeed2 = param.fSeed2;
295 for(Int_t i = 0;i<12;++i)fOverlapLabels[i] = param.fOverlapLabels[i];
296 fMAngular = param.fMAngular;
297 fCircular = param.fCircular;
298 for(int i = 0;i<160;++i)fTrackPoints[i] = param.fTrackPoints[i];
299 fClusterMap = param.fClusterMap;
300 fSharedMap = param.fSharedMap;
301 }
179c6296 302 return (*this);
303}
304//____________________________________________________
81e97e0d 305AliTPCTrackerPoint * AliTPCseed::GetTrackPoint(Int_t i)
306{
307 //
308 //
309 return &fTrackPoints[i];
310}
311
81e97e0d 312
313
314Double_t AliTPCseed::GetDensityFirst(Int_t n)
315{
316 //
317 //
318 // return cluster for n rows bellow first point
319 Int_t nfoundable = 1;
320 Int_t nfound = 1;
321 for (Int_t i=fLastPoint-1;i>0&&nfoundable<n; i--){
322 Int_t index = GetClusterIndex2(i);
323 if (index!=-1) nfoundable++;
324 if (index>0) nfound++;
325 }
326 if (nfoundable<n) return 0;
327 return Double_t(nfound)/Double_t(nfoundable);
328
329}
330
331
332void AliTPCseed::GetClusterStatistic(Int_t first, Int_t last, Int_t &found, Int_t &foundable, Int_t &shared, Bool_t plus2)
333{
334 // get cluster stat. on given region
335 //
336 found = 0;
337 foundable = 0;
338 shared =0;
339 for (Int_t i=first;i<last; i++){
340 Int_t index = GetClusterIndex2(i);
341 if (index!=-1) foundable++;
6d493ea0 342 if (index&0x8000) continue;
81e97e0d 343 if (fClusterPointer[i]) {
344 found++;
345 }
346 else
347 continue;
348
349 if (fClusterPointer[i]->IsUsed(10)) {
350 shared++;
351 continue;
352 }
353 if (!plus2) continue; //take also neighborhoud
354 //
355 if ( (i>0) && fClusterPointer[i-1]){
356 if (fClusterPointer[i-1]->IsUsed(10)) {
357 shared++;
358 continue;
359 }
360 }
361 if ( fClusterPointer[i+1]){
362 if (fClusterPointer[i+1]->IsUsed(10)) {
363 shared++;
364 continue;
365 }
366 }
367
368 }
369 //if (shared>found){
370 //Error("AliTPCseed::GetClusterStatistic","problem\n");
371 //}
372}
373
374
375
376
377
378void AliTPCseed::Reset(Bool_t all)
379{
380 //
381 //
382 SetNumberOfClusters(0);
383 fNFoundable = 0;
384 SetChi2(0);
6c94f330 385 ResetCovariance(10.);
81e97e0d 386 /*
387 if (fTrackPoints){
388 for (Int_t i=0;i<8;i++){
389 delete [] fTrackPoints[i];
390 }
391 delete fTrackPoints;
392 fTrackPoints =0;
393 }
394 */
395
396 if (all){
397 for (Int_t i=0;i<200;i++) SetClusterIndex2(i,-3);
398 for (Int_t i=0;i<160;i++) fClusterPointer[i]=0;
399 }
400
401}
402
403
404void AliTPCseed::Modify(Double_t factor)
405{
406
407 //------------------------------------------------------------------
408 //This function makes a track forget its history :)
409 //------------------------------------------------------------------
410 if (factor<=0) {
6c94f330 411 ResetCovariance(10.);
81e97e0d 412 return;
413 }
6c94f330 414 ResetCovariance(factor);
415
81e97e0d 416 SetNumberOfClusters(0);
417 fNFoundable =0;
418 SetChi2(0);
419 fRemoval = 0;
420 fCurrentSigmaY2 = 0.000005;
421 fCurrentSigmaZ2 = 0.000005;
422 fNoCluster = 0;
423 //fFirstPoint = 160;
424 //fLastPoint = 0;
425}
426
427
428
429
430Int_t AliTPCseed::GetProlongation(Double_t xk, Double_t &y, Double_t & z) const
431{
432 //-----------------------------------------------------------------
433 // This function find proloncation of a track to a reference plane x=xk.
434 // doesn't change internal state of the track
435 //-----------------------------------------------------------------
436
6c94f330 437 Double_t x1=GetX(), x2=x1+(xk-x1), dx=x2-x1;
81e97e0d 438
6c94f330 439 if (TMath::Abs(GetSnp()+GetC()*dx) >= AliTPCReconstructor::GetMaxSnpTrack()) {
81e97e0d 440 return 0;
441 }
442
443 // Double_t y1=fP0, z1=fP1;
6c94f330 444 Double_t c1=GetSnp(), r1=sqrt(1.- c1*c1);
445 Double_t c2=c1 + GetC()*dx, r2=sqrt(1.- c2*c2);
81e97e0d 446
6c94f330 447 y = GetY();
448 z = GetZ();
81e97e0d 449 //y += dx*(c1+c2)/(r1+r2);
450 //z += dx*(c1+c2)/(c1*r2 + c2*r1)*fP3;
451
452 Double_t dy = dx*(c1+c2)/(r1+r2);
453 Double_t dz = 0;
454 //
6c94f330 455 Double_t delta = GetC()*dx*(c1+c2)/(c1*r2 + c2*r1);
81e97e0d 456 /*
457 if (TMath::Abs(delta)>0.0001){
458 dz = fP3*TMath::ASin(delta)/fP4;
459 }else{
460 dz = dx*fP3*(c1+c2)/(c1*r2 + c2*r1);
461 }
462 */
463 // dz = fP3*AliTPCFastMath::FastAsin(delta)/fP4;
6c94f330 464 dz = GetTgl()*TMath::ASin(delta)/GetC();
81e97e0d 465 //
466 y+=dy;
467 z+=dz;
468
469
470 return 1;
471}
472
473
474//_____________________________________________________________________________
af32720d 475Double_t AliTPCseed::GetPredictedChi2(const AliCluster *c) const
81e97e0d 476{
477 //-----------------------------------------------------------------
478 // This function calculates a predicted chi2 increment.
479 //-----------------------------------------------------------------
6c94f330 480 Double_t p[2]={c->GetY(), c->GetZ()};
481 Double_t cov[3]={fErrorY2, 0., fErrorZ2};
482 return AliExternalTrackParam::GetPredictedChi2(p,cov);
81e97e0d 483}
484
81e97e0d 485//_________________________________________________________________________________________
486
487
488Int_t AliTPCseed::Compare(const TObject *o) const {
489 //-----------------------------------------------------------------
490 // This function compares tracks according to the sector - for given sector according z
491 //-----------------------------------------------------------------
492 AliTPCseed *t=(AliTPCseed*)o;
6c94f330 493
81e97e0d 494 if (fSort == 0){
495 if (t->fRelativeSector>fRelativeSector) return -1;
496 if (t->fRelativeSector<fRelativeSector) return 1;
497 Double_t z2 = t->GetZ();
498 Double_t z1 = GetZ();
499 if (z2>z1) return 1;
500 if (z2<z1) return -1;
501 return 0;
502 }
503 else {
504 Float_t f2 =1;
6c23ffed 505 f2 = 1-20*TMath::Sqrt(t->GetSigma1Pt2())/(t->OneOverPt()+0.0066);
81e97e0d 506 if (t->fBConstrain) f2=1.2;
507
508 Float_t f1 =1;
6c23ffed 509 f1 = 1-20*TMath::Sqrt(GetSigma1Pt2())/(OneOverPt()+0.0066);
81e97e0d 510
511 if (fBConstrain) f1=1.2;
512
513 if (t->GetNumberOfClusters()*f2 <GetNumberOfClusters()*f1) return -1;
514 else return +1;
515 }
516}
517
518
519
520
521//_____________________________________________________________________________
70e20dcf 522Bool_t AliTPCseed::Update(const AliCluster *c, Double_t chisq, Int_t index)
6c94f330 523{
81e97e0d 524 //-----------------------------------------------------------------
525 // This function associates a cluster with this track.
526 //-----------------------------------------------------------------
81e97e0d 527 Int_t n=GetNumberOfClusters();
70e20dcf 528 Int_t idx=GetClusterIndex(n); // save the current cluster index
529
530 AliCluster cl(*c); cl.SetSigmaY2(fErrorY2); cl.SetSigmaZ2(fErrorZ2);
531 if (!AliTPCtrack::Update(&cl,chisq,index)) return kFALSE;
e0e13b88 532
533 if (fCMeanSigmaY2p30<0){
534 fCMeanSigmaY2p30= c->GetSigmaY2(); //! current mean sigma Y2 - mean30%
c07cb486 535 fCMeanSigmaZ2p30= c->GetSigmaZ2(); //! current mean sigma Z2 - mean30%
536 fCMeanSigmaY2p30R = 1; //! current mean sigma Y2 - mean5%
537 fCMeanSigmaZ2p30R = 1; //! current mean sigma Z2 - mean5%
e0e13b88 538 }
539 //
540 fCMeanSigmaY2p30= 0.70*fCMeanSigmaY2p30 +0.30*c->GetSigmaY2();
c07cb486 541 fCMeanSigmaZ2p30= 0.70*fCMeanSigmaZ2p30 +0.30*c->GetSigmaZ2();
542 if (fCurrentSigmaY2>0){
543 fCMeanSigmaY2p30R = 0.7*fCMeanSigmaY2p30R +0.3*c->GetSigmaY2()/fCurrentSigmaY2;
544 fCMeanSigmaZ2p30R = 0.7*fCMeanSigmaZ2p30R +0.3*c->GetSigmaZ2()/fCurrentSigmaZ2;
545 }
e0e13b88 546
81e97e0d 547
70e20dcf 548 SetClusterIndex(n,idx); // restore the current cluster index
6c94f330 549 return kTRUE;
81e97e0d 550}
551
552
553
554//_____________________________________________________________________________
105b1b81 555Float_t AliTPCseed::CookdEdx(Double_t low, Double_t up,Int_t i1, Int_t i2, Bool_t onlyused) {
81e97e0d 556 //-----------------------------------------------------------------
557 // This funtion calculates dE/dX within the "low" and "up" cuts.
558 //-----------------------------------------------------------------
559
560 Float_t amp[200];
561 Float_t angular[200];
562 Float_t weight[200];
563 Int_t index[200];
564 //Int_t nc = 0;
81e97e0d 565 Float_t meanlog = 100.;
566
567 Float_t mean[4] = {0,0,0,0};
568 Float_t sigma[4] = {1000,1000,1000,1000};
569 Int_t nc[4] = {0,0,0,0};
570 Float_t norm[4] = {1000,1000,1000,1000};
571 //
572 //
573 fNShared =0;
574
575 for (Int_t of =0; of<4; of++){
576 for (Int_t i=of+i1;i<i2;i+=4)
577 {
578 Int_t index = fIndex[i];
579 if (index<0||index&0x8000) continue;
580
581 //AliTPCTrackPoint * point = (AliTPCTrackPoint *) arr.At(i);
582 AliTPCTrackerPoint * point = GetTrackPoint(i);
583 //AliTPCTrackerPoint * pointm = GetTrackPoint(i-1);
584 //AliTPCTrackerPoint * pointp = 0;
585 //if (i<159) pointp = GetTrackPoint(i+1);
586
587 if (point==0) continue;
588 AliTPCclusterMI * cl = fClusterPointer[i];
589 if (cl==0) continue;
590 if (onlyused && (!cl->IsUsed(10))) continue;
591 if (cl->IsUsed(11)) {
592 fNShared++;
593 continue;
594 }
595 Int_t type = cl->GetType();
596 //if (point->fIsShared){
597 // fNShared++;
598 // continue;
599 //}
600 //if (pointm)
601 // if (pointm->fIsShared) continue;
602 //if (pointp)
603 // if (pointp->fIsShared) continue;
604
605 if (type<0) continue;
606 //if (type>10) continue;
607 //if (point->GetErrY()==0) continue;
608 //if (point->GetErrZ()==0) continue;
609
610 //Float_t ddy = (point->GetY()-cl->GetY())/point->GetErrY();
611 //Float_t ddz = (point->GetZ()-cl->GetZ())/point->GetErrZ();
612 //if ((ddy*ddy+ddz*ddz)>10) continue;
613
614
615 // if (point->GetCPoint().GetMax()<5) continue;
616 if (cl->GetMax()<5) continue;
617 Float_t angley = point->GetAngleY();
618 Float_t anglez = point->GetAngleZ();
619
620 Float_t rsigmay2 = point->GetSigmaY();
621 Float_t rsigmaz2 = point->GetSigmaZ();
622 /*
623 Float_t ns = 1.;
624 if (pointm){
625 rsigmay += pointm->GetTPoint().GetSigmaY();
626 rsigmaz += pointm->GetTPoint().GetSigmaZ();
627 ns+=1.;
628 }
629 if (pointp){
630 rsigmay += pointp->GetTPoint().GetSigmaY();
631 rsigmaz += pointp->GetTPoint().GetSigmaZ();
632 ns+=1.;
633 }
634 rsigmay/=ns;
635 rsigmaz/=ns;
636 */
637
638 Float_t rsigma = TMath::Sqrt(rsigmay2*rsigmaz2);
639
640 Float_t ampc = 0; // normalization to the number of electrons
641 if (i>64){
642 // ampc = 1.*point->GetCPoint().GetMax();
643 ampc = 1.*cl->GetMax();
644 //ampc = 1.*point->GetCPoint().GetQ();
645 // AliTPCClusterPoint & p = point->GetCPoint();
646 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.6)) - TMath::Abs(p.GetY()/0.6)+0.5);
647 // Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
648 //Float_t dz =
649 // TMath::Abs( Int_t(iz) - iz + 0.5);
650 //ampc *= 1.15*(1-0.3*dy);
651 //ampc *= 1.15*(1-0.3*dz);
652 // Float_t zfactor = (AliTPCReconstructor::GetCtgRange()-0.0004*TMath::Abs(point->GetCPoint().GetZ()));
653 //ampc *=zfactor;
654 }
655 else{
656 //ampc = 1.0*point->GetCPoint().GetMax();
657 ampc = 1.0*cl->GetMax();
658 //ampc = 1.0*point->GetCPoint().GetQ();
659 //AliTPCClusterPoint & p = point->GetCPoint();
660 // Float_t dy = TMath::Abs(Int_t( TMath::Abs(p.GetY()/0.4)) - TMath::Abs(p.GetY()/0.4)+0.5);
661 //Float_t iz = (250.0-TMath::Abs(p.GetZ())+0.11)/0.566;
662 //Float_t dz =
663 // TMath::Abs( Int_t(iz) - iz + 0.5);
664
665 //ampc *= 1.15*(1-0.3*dy);
666 //ampc *= 1.15*(1-0.3*dz);
667 // Float_t zfactor = (1.02-0.000*TMath::Abs(point->GetCPoint().GetZ()));
668 //ampc *=zfactor;
669
670 }
671 ampc *= 2.0; // put mean value to channel 50
672 //ampc *= 0.58; // put mean value to channel 50
673 Float_t w = 1.;
674 // if (type>0) w = 1./(type/2.-0.5);
675 // Float_t z = TMath::Abs(cl->GetZ());
676 if (i<64) {
677 ampc /= 0.6;
678 //ampc /= (1+0.0008*z);
679 } else
680 if (i>128){
681 ampc /=1.5;
682 //ampc /= (1+0.0008*z);
683 }else{
684 //ampc /= (1+0.0008*z);
685 }
686
687 if (type<0) { //amp at the border - lower weight
688 // w*= 2.;
689
690 continue;
691 }
692 if (rsigma>1.5) ampc/=1.3; // if big backround
693 amp[nc[of]] = ampc;
694 angular[nc[of]] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
695 weight[nc[of]] = w;
696 nc[of]++;
697 }
698
699 TMath::Sort(nc[of],amp,index,kFALSE);
700 Float_t sumamp=0;
701 Float_t sumamp2=0;
702 Float_t sumw=0;
703 //meanlog = amp[index[Int_t(nc[of]*0.33)]];
704 meanlog = 50;
705 for (Int_t i=int(nc[of]*low+0.5);i<int(nc[of]*up+0.5);i++){
706 Float_t ampl = amp[index[i]]/angular[index[i]];
707 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
708 //
709 sumw += weight[index[i]];
710 sumamp += weight[index[i]]*ampl;
711 sumamp2 += weight[index[i]]*ampl*ampl;
712 norm[of] += angular[index[i]]*weight[index[i]];
713 }
714 if (sumw<1){
715 SetdEdx(0);
716 }
717 else {
718 norm[of] /= sumw;
719 mean[of] = sumamp/sumw;
720 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
721 if (sigma[of]>0.1)
722 sigma[of] = TMath::Sqrt(sigma[of]);
723 else
724 sigma[of] = 1000;
725
726 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
727 //mean *=(1-0.02*(sigma/(mean*0.17)-1.));
728 //mean *=(1-0.1*(norm-1.));
729 }
730 }
731
732 Float_t dedx =0;
733 fSdEdx =0;
734 fMAngular =0;
735 // mean[0]*= (1-0.05*(sigma[0]/(0.01+mean[1]*0.18)-1));
736 // mean[1]*= (1-0.05*(sigma[1]/(0.01+mean[0]*0.18)-1));
737
738
739 // dedx = (mean[0]* TMath::Sqrt((1.+nc[0]))+ mean[1]* TMath::Sqrt((1.+nc[1])) )/
740 // ( TMath::Sqrt((1.+nc[0]))+TMath::Sqrt((1.+nc[1])));
741
742 Int_t norm2 = 0;
743 Int_t norm3 = 0;
744 for (Int_t i =0;i<4;i++){
745 if (nc[i]>2&&nc[i]<1000){
746 dedx += mean[i] *nc[i];
747 fSdEdx += sigma[i]*(nc[i]-2);
748 fMAngular += norm[i] *nc[i];
749 norm2 += nc[i];
750 norm3 += nc[i]-2;
751 }
752 fDEDX[i] = mean[i];
753 fSDEDX[i] = sigma[i];
754 fNCDEDX[i]= nc[i];
755 }
756
757 if (norm3>0){
758 dedx /=norm2;
759 fSdEdx /=norm3;
760 fMAngular/=norm2;
761 }
762 else{
763 SetdEdx(0);
105b1b81 764 return 0;
81e97e0d 765 }
766 // Float_t dedx1 =dedx;
767 /*
768 dedx =0;
769 for (Int_t i =0;i<4;i++){
770 if (nc[i]>2&&nc[i]<1000){
771 mean[i] = mean[i]*(1-0.12*(sigma[i]/(fSdEdx)-1.));
772 dedx += mean[i] *nc[i];
773 }
774 fDEDX[i] = mean[i];
775 }
776 dedx /= norm2;
777 */
778
779
780 SetdEdx(dedx);
a2d457f2 781 return dedx;
81e97e0d 782}
783Double_t AliTPCseed::Bethe(Double_t bg){
784 //
785 // This is the Bethe-Bloch function normalised to 1 at the minimum
786 //
787 Double_t bg2=bg*bg;
788 Double_t bethe;
789 if (bg<3.5e1)
790 bethe=(1.+ bg2)/bg2*(log(5940*bg2) - bg2/(1.+ bg2));
791 else // Density effect ( approximately :)
792 bethe=1.15*(1.+ bg2)/bg2*(log(3.5*5940*bg) - bg2/(1.+ bg2));
793 return bethe/11.091;
794}
795
796void AliTPCseed::CookPID()
797{
798 //
799 // cook PID information according dEdx
800 //
801 Double_t fRange = 10.;
802 Double_t fRes = 0.1;
803 Double_t fMIP = 47.;
804 //
805 Int_t ns=AliPID::kSPECIES;
806 Double_t sumr =0;
807 for (Int_t j=0; j<ns; j++) {
808 Double_t mass=AliPID::ParticleMass(j);
6c94f330 809 Double_t mom=GetP();
81e97e0d 810 Double_t dedx=fdEdx/fMIP;
811 Double_t bethe=Bethe(mom/mass);
812 Double_t sigma=fRes*bethe;
813 if (sigma>0.001){
814 if (TMath::Abs(dedx-bethe) > fRange*sigma) {
815 fTPCr[j]=TMath::Exp(-0.5*fRange*fRange)/sigma;
816 sumr+=fTPCr[j];
817 continue;
818 }
819 fTPCr[j]=TMath::Exp(-0.5*(dedx-bethe)*(dedx-bethe)/(sigma*sigma))/sigma;
820 sumr+=fTPCr[j];
821 }
822 else{
823 fTPCr[j]=1.;
824 sumr+=fTPCr[j];
825 }
826 }
827 for (Int_t j=0; j<ns; j++) {
828 fTPCr[j]/=sumr; //normalize
829 }
830}
831
832/*
833void AliTPCseed::CookdEdx2(Double_t low, Double_t up) {
834 //-----------------------------------------------------------------
835 // This funtion calculates dE/dX within the "low" and "up" cuts.
836 //-----------------------------------------------------------------
837
838 Float_t amp[200];
839 Float_t angular[200];
840 Float_t weight[200];
841 Int_t index[200];
842 Bool_t inlimit[200];
843 for (Int_t i=0;i<200;i++) inlimit[i]=kFALSE;
844 for (Int_t i=0;i<200;i++) amp[i]=10000;
845 for (Int_t i=0;i<200;i++) angular[i]= 1;;
846
847
848 //
849 Float_t meanlog = 100.;
850 Int_t indexde[4]={0,64,128,160};
851
852 Float_t amean =0;
853 Float_t asigma =0;
854 Float_t anc =0;
855 Float_t anorm =0;
856
857 Float_t mean[4] = {0,0,0,0};
858 Float_t sigma[4] = {1000,1000,1000,1000};
859 Int_t nc[4] = {0,0,0,0};
860 Float_t norm[4] = {1000,1000,1000,1000};
861 //
862 //
863 fNShared =0;
864
865 // for (Int_t of =0; of<3; of++){
866 // for (Int_t i=indexde[of];i<indexde[of+1];i++)
867 for (Int_t i =0; i<160;i++)
868 {
869 AliTPCTrackPoint * point = GetTrackPoint(i);
870 if (point==0) continue;
871 if (point->fIsShared){
872 fNShared++;
873 continue;
874 }
875 Int_t type = point->GetCPoint().GetType();
876 if (type<0) continue;
877 if (point->GetCPoint().GetMax()<5) continue;
878 Float_t angley = point->GetTPoint().GetAngleY();
879 Float_t anglez = point->GetTPoint().GetAngleZ();
880 Float_t rsigmay = point->GetCPoint().GetSigmaY();
881 Float_t rsigmaz = point->GetCPoint().GetSigmaZ();
882 Float_t rsigma = TMath::Sqrt(rsigmay*rsigmaz);
883
884 Float_t ampc = 0; // normalization to the number of electrons
885 if (i>64){
886 ampc = point->GetCPoint().GetMax();
887 }
888 else{
889 ampc = point->GetCPoint().GetMax();
890 }
891 ampc *= 2.0; // put mean value to channel 50
892 // ampc *= 0.565; // put mean value to channel 50
893
894 Float_t w = 1.;
895 Float_t z = TMath::Abs(point->GetCPoint().GetZ());
896 if (i<64) {
897 ampc /= 0.63;
898 } else
899 if (i>128){
900 ampc /=1.51;
901 }
902 if (type<0) { //amp at the border - lower weight
903 continue;
904 }
905 if (rsigma>1.5) ampc/=1.3; // if big backround
906 angular[i] = TMath::Sqrt(1.+angley*angley+anglez*anglez);
907 amp[i] = ampc/angular[i];
908 weight[i] = w;
909 anc++;
910 }
911
912 TMath::Sort(159,amp,index,kFALSE);
913 for (Int_t i=int(anc*low+0.5);i<int(anc*up+0.5);i++){
914 inlimit[index[i]] = kTRUE; // take all clusters
915 }
916
917 // meanlog = amp[index[Int_t(anc*0.3)]];
918 meanlog =10000.;
919 for (Int_t of =0; of<3; of++){
920 Float_t sumamp=0;
921 Float_t sumamp2=0;
922 Float_t sumw=0;
923 for (Int_t i=indexde[of];i<indexde[of+1];i++)
924 {
925 if (inlimit[i]==kFALSE) continue;
926 Float_t ampl = amp[i];
927 ///angular[i];
928 ampl = meanlog*TMath::Log(1.+ampl/meanlog);
929 //
930 sumw += weight[i];
931 sumamp += weight[i]*ampl;
932 sumamp2 += weight[i]*ampl*ampl;
933 norm[of] += angular[i]*weight[i];
934 nc[of]++;
935 }
936 if (sumw<1){
937 SetdEdx(0);
938 }
939 else {
940 norm[of] /= sumw;
941 mean[of] = sumamp/sumw;
942 sigma[of] = sumamp2/sumw-mean[of]*mean[of];
943 if (sigma[of]>0.1)
944 sigma[of] = TMath::Sqrt(sigma[of]);
945 else
946 sigma[of] = 1000;
947 mean[of] = (TMath::Exp(mean[of]/meanlog)-1)*meanlog;
948 }
949 }
950
951 Float_t dedx =0;
952 fSdEdx =0;
953 fMAngular =0;
954 //
955 Int_t norm2 = 0;
956 Int_t norm3 = 0;
957 Float_t www[3] = {12.,14.,17.};
958 //Float_t www[3] = {1.,1.,1.};
959
960 for (Int_t i =0;i<3;i++){
961 if (nc[i]>2&&nc[i]<1000){
962 dedx += mean[i] *nc[i]*www[i]/sigma[i];
963 fSdEdx += sigma[i]*(nc[i]-2)*www[i]/sigma[i];
964 fMAngular += norm[i] *nc[i];
965 norm2 += nc[i]*www[i]/sigma[i];
966 norm3 += (nc[i]-2)*www[i]/sigma[i];
967 }
968 fDEDX[i] = mean[i];
969 fSDEDX[i] = sigma[i];
970 fNCDEDX[i]= nc[i];
971 }
972
973 if (norm3>0){
974 dedx /=norm2;
975 fSdEdx /=norm3;
976 fMAngular/=norm2;
977 }
978 else{
979 SetdEdx(0);
980 return;
981 }
982 // Float_t dedx1 =dedx;
983
984 dedx =0;
985 Float_t norm4 = 0;
986 for (Int_t i =0;i<3;i++){
987 if (nc[i]>2&&nc[i]<1000&&sigma[i]>3){
988 //mean[i] = mean[i]*(1+0.08*(sigma[i]/(fSdEdx)-1.));
989 dedx += mean[i] *(nc[i])/(sigma[i]);
990 norm4 += (nc[i])/(sigma[i]);
991 }
992 fDEDX[i] = mean[i];
993 }
994 if (norm4>0) dedx /= norm4;
995
996
997
998 SetdEdx(dedx);
999
1000 //mi deDX
1001
1002}
1003*/
6c94f330 1004Double_t AliTPCseed::GetYat(Double_t xk) const {
1005//-----------------------------------------------------------------
1006// This function calculates the Y-coordinate of a track at the plane x=xk.
1007//-----------------------------------------------------------------
1008 if (TMath::Abs(GetSnp())>AliTPCReconstructor::GetMaxSnpTrack()) return 0.; //patch 01 jan 06
1009 Double_t c1=GetSnp(), r1=TMath::Sqrt(1.- c1*c1);
1010 Double_t c2=c1+GetC()*(xk-GetX());
1011 if (TMath::Abs(c2)>AliTPCReconstructor::GetMaxSnpTrack()) return 0;
1012 Double_t r2=TMath::Sqrt(1.- c2*c2);
1013 return GetY() + (xk-GetX())*(c1+c2)/(r1+r2);
1014}
1015
19b00333 1016void AliTPCseed::SetClusterMapBit(int ibit, Bool_t state)
1017{
1018 fClusterMap[ibit] = state;
1019}
1020Bool_t AliTPCseed::GetClusterMapBit(int ibit)
1021{
1022 return fClusterMap[ibit];
1023}
1024void AliTPCseed::SetSharedMapBit(int ibit, Bool_t state)
1025{
1026 fSharedMap[ibit] = state;
1027}
1028Bool_t AliTPCseed::GetSharedMapBit(int ibit)
1029{
1030 return fSharedMap[ibit];
1031}
eb02f63a 1032
1033
0a65832b 1034
1035
1036
2fc9608f 1037Float_t AliTPCseed::CookdEdxNorm(Double_t low, Double_t up, Int_t type, Int_t i1, Int_t i2, AliTPCCalPad * gainMap, Bool_t posNorm, Bool_t padNorm){
0a65832b 1038
1039 //
1040 // calculates dedx using the cluster
1041 // low - up specify trunc mean range - default form 0-0.7
8076baa0 1042 // type - 1 - max charge or 0- total charge in cluster
1043 // //2- max no corr 3- total+ correction
0a65832b 1044 // i1-i2 - the pad-row range used for calculation
1045 //
1046 // normalization parametrization taken from AliTPCClusterParam
1047 //
1048 AliTPCClusterParam * parcl = AliTPCClusterParam::Instance();
8e1dcdda 1049 if (!parcl) parcl = AliTPCcalibDB::Instance()->GetClusterParam();
0a65832b 1050 if (!parcl) return 0;
1051 Float_t amp[160];
1052 Int_t indexes[160];
1053 Int_t ncl=0;
1054 //
1055 //
1056 const Float_t ktany = TMath::Tan(TMath::DegToRad()*10);
1057 const Float_t kedgey =4.;
1058 //
7cd8ac3f 1059 //
0a65832b 1060 for (Int_t irow=i1; irow<i2; irow++){
1061 AliTPCclusterMI* cluster = GetClusterPointer(irow);
1062 if (!cluster) continue;
1063 if (TMath::Abs(cluster->GetY())>cluster->GetX()*ktany-kedgey) continue; // edge cluster
8076baa0 1064 Float_t charge= (type%2)? cluster->GetMax():cluster->GetQ();
37540068 1065 if (!gainMap) gainMap = AliTPCcalibDB::Instance()->GetDedxGainFactor();
d6920632 1066 if (gainMap) {
1067 Float_t factor = 1;
1068 AliTPCCalROC * roc = gainMap->GetCalROC(cluster->GetDetector());
1069 if (irow < 63) { // IROC
1070 factor = roc->GetValue(irow, TMath::Nint(cluster->GetPad()))*1.55;
1071 } else { // OROC
1072 factor = roc->GetValue(irow - 63, TMath::Nint(cluster->GetPad()));
1073 }
1074 if (factor>0.5) charge/=factor;
7cd8ac3f 1075 }
d6920632 1076
0a65832b 1077 //do normalization
1078 Float_t corr=1;
8076baa0 1079 Int_t ipad= 0;
1080 if (irow>62) ipad=1;
1081 if (irow>127) ipad=2;
0a65832b 1082 if (type<=1){
0a65832b 1083 //
1084 AliTPCTrackerPoint * point = GetTrackPoint(irow);
1085 Float_t ty = TMath::Abs(point->GetAngleY());
1086 Float_t tz = TMath::Abs(point->GetAngleZ());
1087
1088 Float_t dr = (250.-TMath::Abs(cluster->GetZ()))/250.;
1089 corr = parcl->Qnorm(ipad,type,dr,ty,tz);
1090 }
1091 amp[ncl]=charge/corr;
8e1dcdda 1092 if (posNorm){
1093 //
1094 //
1095 //
1096 corr = parcl->QnormPos(ipad,type, cluster->GetPad(),cluster->GetTimeBin(), cluster->GetZ(),
1097 cluster->GetSigmaY2(),cluster->GetSigmaZ2(),cluster->GetMax(),cluster->GetQ());
1098 amp[ncl]/=corr;
1099 }
1100
1101
8076baa0 1102 amp[ncl] *= 2.0; // put mean value to channel 50
2fc9608f 1103 if (padNorm){
1104 corr=1;
1105 if (type==0 && parcl->fQpadTnorm) corr = (*parcl->fQpadTnorm)[ipad];
1106 if (type==1 && parcl->fQpadTnorm) corr = (*parcl->fQpadMnorm)[ipad];
1107 amp[ncl]/=corr;
1108 }
1109
1110 // if (ipad==0) {
1111// amp[ncl] /= 0.65; // this we will take form OCDB
1112// } else
1113// if (ipad==2){
1114// amp[ncl] /=1.57;
1115// }else{
1116// }
0a65832b 1117 ncl++;
1118 }
8076baa0 1119
0a65832b 1120 if (type>3) return ncl;
1121 TMath::Sort(ncl,amp, indexes, kFALSE);
1122
8076baa0 1123 if (ncl<10) return 0;
0a65832b 1124
1125 Float_t suma=0;
1126 Float_t sumn=0;
1127 Int_t icl0=TMath::Nint(ncl*low);
1128 Int_t icl1=TMath::Nint(ncl*up);
1129 for (Int_t icl=icl0; icl<icl1;icl++){
1130 suma+=amp[indexes[icl]];
1131 sumn++;
1132 }
1133 return suma/sumn;
1134
1135}
1136
1137Double_t AliTPCseed::BetheMass(Double_t mass){
1138 //
1139 // return bethe-bloch
1140 //
1141 Float_t bg= P()/mass;
1142 const Double_t kp1=0.76176e-1;
1143 const Double_t kp2=10.632;
1144 const Double_t kp3=0.13279e-4;
1145 const Double_t kp4=1.8631;
1146 const Double_t kp5=1.9479;
1147
1148 Double_t dbg = (Double_t) bg;
1149
1150 Double_t beta = dbg/TMath::Sqrt(1.+dbg*dbg);
1151
1152 Double_t aa = TMath::Power(beta,kp4);
1153 Double_t bb = TMath::Power(1./dbg,kp5);
1154
1155 bb=TMath::Log(kp3+bb);
1156
1157 return ((Float_t)((kp2-aa-bb)*kp1/aa));
1158}
1159
1160
eb02f63a 1161Float_t AliTPCseed::CookShape(Int_t type){
1162 //
1163 //
1164 //
1165 //-----------------------------------------------------------------
1166 // This funtion calculates dE/dX within the "low" and "up" cuts.
1167 //-----------------------------------------------------------------
1168 Float_t means=0;
1169 Float_t meanc=0;
1170 for (Int_t i =0; i<160;i++) {
1171 AliTPCTrackerPoint * point = GetTrackPoint(i);
1172 if (point==0) continue;
1173
1174 AliTPCclusterMI * cl = fClusterPointer[i];
1175 if (cl==0) continue;
1176
1177 Float_t rsigmay = TMath::Sqrt(point->GetSigmaY());
1178 Float_t rsigmaz = TMath::Sqrt(point->GetSigmaZ());
1179 Float_t rsigma = (rsigmay+rsigmaz)*0.5;
1180 if (type==0) means+=rsigma;
1181 if (type==1) means+=rsigmay;
1182 if (type==2) means+=rsigmaz;
1183 meanc++;
1184 }
1185 Float_t mean = (meanc>0)? means/meanc:0;
1186 return mean;
1187}