1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 ///////////////////////////////////////////////////////////////////////////////
19 // Time Projection Chamber //
20 // Comparison macro for reconstructed tracks //
22 // marian.ivanov@cern.ch //
35 #include "AliESDtrack.h"
36 #include "AliTracker.h"
37 #include "AliTPCParam.h"
38 #include "AliTrackReference.h"
39 #include "AliTPCParamSR.h"
40 #include "AliESDfriend.h"
41 #include "AliESDtrack.h"
42 #include "AliTPCseed.h"
43 #include "AliITStrackMI.h"
44 #include "AliTRDtrackV1.h"
45 #include "AliMCInfo.h"
46 #include "AliESDRecInfo.h"
50 ClassImp(AliESDRecInfo)
55 AliTPCParam * GetTPCParam(){
56 AliTPCParamSR * par = new AliTPCParamSR;
64 AliESDRecInfo::AliESDRecInfo():
65 fITSOn(0), // ITS refitted inward
66 fTRDOn(0), // ITS refitted inward
67 fDeltaP(0), //delta of momenta
69 fReconstructed(0), //flag if track was reconstructed
70 fFake(0), // fake track
71 fMultiple(0), // number of reconstructions
72 fTPCOn(0), // TPC refitted inward
73 fBestTOFmatch(0), //best matching between times
74 fESDtrack(0), // esd track
75 fTrackF(0), // friend track
76 fTPCtrack(0), // tpc track
77 fITStrack(0), // its track
78 fTRDtrack(0) // trd track
81 // default constructor
86 AliESDRecInfo::AliESDRecInfo(const AliESDRecInfo& recinfo):
88 fITSOn(0), // ITS refitted inward
89 fTRDOn(0), // ITS refitted inward
90 fDeltaP(0), //delta of momenta
92 fReconstructed(0), //flag if track was reconstructed
93 fFake(0), // fake track
94 fMultiple(0), // number of reconstructions
95 fTPCOn(0), // TPC refitted inward
96 fBestTOFmatch(0), //best matching between times
97 fESDtrack(0), // esd track
98 fTrackF(0), // friend track
99 fTPCtrack(0), // tpc track
100 fITStrack(0), // its track
101 fTRDtrack(0) // trd track
106 memcpy(this,&recinfo, sizeof(recinfo));
107 fESDtrack=0; fTrackF=0; fTPCtrack=0;fITStrack=0;fTRDtrack=0;
108 SetESDtrack(recinfo.GetESDtrack());
112 AliESDRecInfo& AliESDRecInfo::operator=(const AliESDRecInfo& info) {
114 // Assignment operator
116 this->~AliESDRecInfo();
117 new (this) AliESDRecInfo(info);
123 AliESDRecInfo::~AliESDRecInfo()
129 if (fESDtrack) { delete fESDtrack; fESDtrack=0;}
130 if (fTrackF) { delete fTrackF; fTrackF=0;}
131 if (fTPCtrack) { delete fTPCtrack; fTPCtrack=0;}
132 if (fITStrack) { delete fITStrack; fITStrack=0;}
133 if (fTRDtrack) { delete fTRDtrack; fTRDtrack=0;}
139 void AliESDRecInfo::Reset()
147 if (fESDtrack) { delete fESDtrack; fESDtrack=0;}
148 if (fTrackF) { delete fTrackF; fTrackF=0;}
149 if (fTPCtrack) { delete fTPCtrack; fTPCtrack=0;}
150 if (fITStrack) { delete fITStrack; fITStrack=0;}
151 if (fTRDtrack) { delete fTRDtrack; fTRDtrack=0;}
154 void AliESDRecInfo::SetESDtrack(const AliESDtrack *track){
158 if (fESDtrack) delete fESDtrack;
159 fESDtrack = (AliESDtrack*)track->Clone();
160 if (track->GetFriendTrack()){
161 if (fTrackF) delete fTrackF;
162 fTrackF = (AliESDfriendTrack*)track->GetFriendTrack()->Clone();
166 while (fTrackF->GetCalibObject(icalib)){
167 cobject=fTrackF->GetCalibObject(icalib);
168 if (dynamic_cast<AliTPCseed*>(cobject)){
169 if (fTPCtrack) delete fTPCtrack;
170 fTPCtrack = (AliTPCseed*)(dynamic_cast<AliTPCseed*>(cobject))->Clone();
171 } else if (dynamic_cast<AliTRDtrackV1*>(cobject)){
172 if (fTRDtrack) delete fTRDtrack;
173 fTRDtrack = (AliTRDtrackV1*)(dynamic_cast<AliTRDtrackV1*>(cobject))->Clone();
181 void AliESDRecInfo::UpdatePoints(AliESDtrack*track)
185 Int_t iclusters[200];
186 Float_t density[160];
187 for (Int_t i=0;i<160;i++) density[i]=-1.;
191 if (fTPCPoints[0]<fTPCPoints[1]) return;
192 // Int_t nclusters=track->GetTPCclusters(iclusters);
198 for (Int_t i=0;i<160;i++){
199 Int_t last = i-range;
200 if (nall<range) nall++;
202 if (iclusters[last]>0&& (iclusters[last]&0x8000)==0) ngood--;
203 if (iclusters[last]==-1) undeff--;
205 if (iclusters[i]>0&& (iclusters[i]&0x8000)==0) ngood++;
206 if (iclusters[i]==-1) undeff++;
207 if (nall==range &&undeff<range/2) density[i-range/2] = Float_t(ngood)/Float_t(nall-undeff);
211 for (Int_t i=0;i<160;i++){
212 if (density[i]<0) continue;
213 if (density[i]>maxdens){
220 fTPCPoints[3] = maxdens;
221 fTPCPoints[1] = indexmax;
224 for (Int_t i=indexmax;i<160;i++){
225 if (density[i]<0) continue;
226 if (density[i]<maxdens/2.) {
233 for (Int_t i=indexmax;i>0;i--){
234 if (density[i]<0) continue;
235 if (density[i]<maxdens/2.) {
241 // Density at the last 30 padrows
246 for (Int_t i=159;i>0;i--){
247 if (iclusters[i]==-1) continue; //dead zone
249 if (iclusters[i]>0) ngood++;
252 fTPCPoints[4] = Float_t(ngood)/Float_t(nall);
254 if ((track->GetStatus()&AliESDtrack::kITSrefit)>0) fTPCPoints[0]=-1;
261 void AliESDRecInfo::Update(AliMCInfo* info,AliTPCParam * /*par*/, Bool_t reconstructed)
264 //calculates derived variables
266 UpdatePoints(fESDtrack);
267 UpdateStatus(info,reconstructed);
274 void AliESDRecInfo::UpdateStatus(AliMCInfo* info, Bool_t reconstructed){
276 // Interpret bit mask flags
278 for (Int_t i=0;i<4;i++) fStatus[i] =0;
279 fReconstructed = kFALSE;
283 if (reconstructed==kFALSE) return;
285 fLabels[0] = info->fLabel;
286 fLabels[1] = info->fPrimPart;
287 fReconstructed = kTRUE;
288 fTPCOn = ((fESDtrack->GetStatus()&AliESDtrack::kTPCrefit)>0) ? kTRUE : kFALSE;
289 fITSOn = ((fESDtrack->GetStatus()&AliESDtrack::kITSrefit)>0) ? kTRUE : kFALSE;
290 fTRDOn = ((fESDtrack->GetStatus()&AliESDtrack::kTRDrefit)>0) ? kTRUE : kFALSE;
293 if ((fESDtrack->GetStatus()&AliESDtrack::kTPCrefit)>0){
297 if ((fESDtrack->GetStatus()&AliESDtrack::kTPCout)>0){
301 if ((fESDtrack->GetStatus()&AliESDtrack::kTPCin)>0)
306 if ((fESDtrack->GetStatus()&AliESDtrack::kITSout)>0){
310 if ((fESDtrack->GetStatus()&AliESDtrack::kITSrefit)>0){
319 if ((fESDtrack->GetStatus()&AliESDtrack::kTRDrefit)>0){
323 if ((fESDtrack->GetStatus()&AliESDtrack::kTRDout)>0){
327 if ((fESDtrack->GetStatus()&AliESDtrack::kTRDStop)>0){
332 void AliESDRecInfo::UpdateTOF(AliMCInfo* info){
334 // Update TOF related comparison information
337 if (((fESDtrack->GetStatus()&AliESDtrack::kTOFout)>0)){
341 fESDtrack->GetIntegratedTimes(times);
342 for (Int_t i=0;i<5;i++){
343 if ( TMath::Abs(fESDtrack->GetTOFsignal()-times[i]) <TMath::Abs(fBestTOFmatch) ){
344 fBestTOFmatch = fESDtrack->GetTOFsignal()-times[i];
348 fESDtrack->GetTOFLabel(toflabel);
349 Bool_t toffake=kTRUE;
350 Bool_t tofdaughter=kFALSE;
351 for (Int_t i=0;i<3;i++){
352 if (toflabel[i]<0) continue;
353 if (toflabel[i]== TMath::Abs(fESDtrack->GetLabel())) toffake=kFALSE;
354 if (toflabel[i]==info->fParticle.GetDaughter(0) || (toflabel[i]==info->fParticle.GetDaughter(1))) tofdaughter=kTRUE; // decay product of original particle
357 if (toffake) fStatus[3] =3; //total fake
358 if (tofdaughter) fStatus[3]=2; //fake because of decay
366 void AliESDRecInfo::UpdateITS(AliMCInfo* info){
368 // Update ITS related comparison information
370 fITSinP0[0]=info->fParticle.Px();
371 fITSinP0[1]=info->fParticle.Py();
372 fITSinP0[2]=info->fParticle.Pz();
373 fITSinP0[3]=info->fParticle.Pt();
375 fITSinR0[0]=info->fParticle.Vx();
376 fITSinR0[1]=info->fParticle.Vy();
377 fITSinR0[2]=info->fParticle.Vz();
378 fITSinR0[3] = TMath::Sqrt(fITSinR0[0]*fITSinR0[0]+fITSinR0[1]*fITSinR0[1]);
379 fITSinR0[4] = TMath::ATan2(fITSinR0[1],fITSinR0[0]);
382 if (fITSinP0[3]>0.0000001){
383 fITSAngle0[0] = TMath::ATan2(fITSinP0[1],fITSinP0[0]);
384 fITSAngle0[1] = TMath::ATan(fITSinP0[2]/fITSinP0[3]);
389 fESDtrack->GetExternalParameters(x,param);
390 // fESDtrack->GetConstrainedExternalParameters(x,param);
392 fESDtrack->GetExternalCovariance(cov);
393 //fESDtrack->GetConstrainedExternalCovariance(cov);
394 if (TMath::Abs(param[4])<0.0000000001) return;
396 fESDtrack->GetXYZ(fITSinR1);
397 fESDtrack->GetPxPyPz(fITSinP1);
398 fITSinP1[3] = TMath::Sqrt(fITSinP1[0]*fITSinP1[0]+fITSinP1[1]*fITSinP1[1]);
400 fITSinR1[3] = TMath::Sqrt(fITSinR1[0]*fITSinR1[0]+fITSinR1[1]*fITSinR1[1]);
401 fITSinR1[4] = TMath::ATan2(fITSinR1[1],fITSinR1[0]);
404 if (fITSinP1[3]>0.0000001){
405 fITSAngle1[0] = TMath::ATan2(fITSinP1[1],fITSinP1[0]);
406 fITSAngle1[1] = TMath::ATan(fITSinP1[2]/fITSinP1[3]);
410 fITSDelta[0] = (fITSinR0[4]-fITSinR1[4])*fITSinR1[3]; //delta rfi
411 fITSPools[0] = fITSDelta[0]/TMath::Sqrt(cov[0]);
412 fITSDelta[1] = (fITSinR0[2]-fITSinR1[2]); //delta z
413 fITSPools[1] = fITSDelta[1]/TMath::Sqrt(cov[2]);
414 fITSDelta[2] = (fITSAngle0[0]-fITSAngle1[0]);
415 fITSPools[2] = fITSDelta[2]/TMath::Sqrt(cov[5]);
416 fITSDelta[3] = (TMath::Tan(fITSAngle0[1])-TMath::Tan(fITSAngle1[1]));
417 fITSPools[3] = fITSDelta[3]/TMath::Sqrt(cov[9]);
418 fITSDelta[4] = (fITSinP0[3]-fITSinP1[3]);
419 Double_t sign = (param[4]>0) ? 1:-1;
421 fITSPools[4] = sign*(1./fITSinP0[3]-1./fITSinP1[3])/TMath::Sqrt(cov[14]);
425 void AliESDRecInfo::UpdateTPC(AliMCInfo* info){
428 // Update TPC related information
430 AliTrackReference * ref = &(info->fTrackRef);
431 fTPCinR0[0] = info->fTrackRef.X();
432 fTPCinR0[1] = info->fTrackRef.Y();
433 fTPCinR0[2] = info->fTrackRef.Z();
434 fTPCinR0[3] = TMath::Sqrt(fTPCinR0[0]*fTPCinR0[0]+fTPCinR0[1]*fTPCinR0[1]);
435 fTPCinR0[4] = TMath::ATan2(fTPCinR0[1],fTPCinR0[0]);
437 fTPCinP0[0] = ref->Px();
438 fTPCinP0[1] = ref->Py();
439 fTPCinP0[2] = ref->Pz();
440 fTPCinP0[3] = ref->Pt();
441 fTPCinP0[4] = ref->P();
442 fDeltaP = (ref->P()-info->fParticle.P())/info->fParticle.P();
445 if (fTPCinP0[3]>0.0000001){
447 fTPCAngle0[0] = TMath::ATan2(fTPCinP0[1],fTPCinP0[0]);
448 fTPCAngle0[1] = TMath::ATan(fTPCinP0[2]/fTPCinP0[3]);
451 if (fStatus[1]>0 &&info->fNTPCRef>0&&TMath::Abs(fTPCinP0[3])>0.0001){
453 fESDtrack->GetInnerXYZ(fTPCinR1);
454 fTPCinR1[3] = TMath::Sqrt(fTPCinR1[0]*fTPCinR1[0]+fTPCinR1[1]*fTPCinR1[1]);
455 fTPCinR1[4] = TMath::ATan2(fTPCinR1[1],fTPCinR1[0]);
456 fESDtrack->GetInnerPxPyPz(fTPCinP1);
457 fTPCinP1[3] = TMath::Sqrt(fTPCinP1[0]*fTPCinP1[0]+fTPCinP1[1]*fTPCinP1[1]);
458 fTPCinP1[4] = TMath::Sqrt(fTPCinP1[3]*fTPCinP1[3]+fTPCinP1[2]*fTPCinP1[2]);
461 if (fTPCinP1[3]>0.000000000000001){
462 fTPCAngle1[0] = TMath::ATan2(fTPCinP1[1],fTPCinP1[0]);
463 fTPCAngle1[1] = TMath::ATan(fTPCinP1[2]/fTPCinP1[3]);
465 Double_t cov[15], param[5],x, alpha;
466 fESDtrack->GetInnerExternalCovariance(cov);
467 fESDtrack->GetInnerExternalParameters(alpha, x,param);
470 fTPCDelta[0] = (fTPCinR0[4]-fTPCinR1[4])*fTPCinR1[3]; //delta rfi
471 fTPCPools[0] = fTPCDelta[0]/TMath::Sqrt(cov[0]);
472 fTPCDelta[1] = (fTPCinR0[2]-fTPCinR1[2]); //delta z
473 fTPCPools[1] = fTPCDelta[1]/TMath::Sqrt(cov[2]);
474 fTPCDelta[2] = (fTPCAngle0[0]-fTPCAngle1[0]);
475 fTPCPools[2] = fTPCDelta[2]/TMath::Sqrt(cov[5]);
476 fTPCDelta[3] = (TMath::Tan(fTPCAngle0[1])-TMath::Tan(fTPCAngle1[1]));
477 fTPCPools[3] = fTPCDelta[3]/TMath::Sqrt(cov[9]);
478 fTPCDelta[4] = (fTPCinP0[3]-fTPCinP1[3]);
479 Double_t sign = (param[4]>0)? 1.:-1;
481 fTPCPools[4] = sign*(1./fTPCinP0[3]-1./fTPCinP1[3])/TMath::Sqrt(TMath::Abs(cov[14]));