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
79 fTracks(0) // array of tracks with the same label
82 // default constructor
87 AliESDRecInfo::AliESDRecInfo(const AliESDRecInfo& recinfo):
89 fITSOn(0), // ITS refitted inward
90 fTRDOn(0), // ITS refitted inward
91 fDeltaP(0), //delta of momenta
93 fReconstructed(0), //flag if track was reconstructed
94 fFake(0), // fake track
95 fMultiple(0), // number of reconstructions
96 fTPCOn(0), // TPC refitted inward
97 fBestTOFmatch(0), //best matching between times
98 fESDtrack(0), // esd track
99 fTrackF(0), // friend track
100 fTPCtrack(0), // tpc track
101 fITStrack(0), // its track
102 fTRDtrack(0), // trd track
103 fTracks(0) // array of tracks with the same label
108 memcpy(this,&recinfo, sizeof(recinfo));
109 fESDtrack=0; fTrackF=0; fTPCtrack=0;fITStrack=0;fTRDtrack=0;
111 SetESDtrack(recinfo.GetESDtrack());
115 AliESDRecInfo& AliESDRecInfo::operator=(const AliESDRecInfo& info) {
117 // Assignment operator
119 this->~AliESDRecInfo();
120 new (this) AliESDRecInfo(info);
126 AliESDRecInfo::~AliESDRecInfo()
132 if (fESDtrack) { delete fESDtrack; fESDtrack=0;}
133 if (fTrackF) { fTrackF=0;}
134 if (fTPCtrack) { delete fTPCtrack; fTPCtrack=0;}
135 if (fITStrack) { delete fITStrack; fITStrack=0;}
136 if (fTRDtrack) { delete fTRDtrack; fTRDtrack=0;}
138 delete fTracks; fTracks=0;
144 void AliESDRecInfo::Reset()
152 if (fESDtrack) { delete fESDtrack; fESDtrack=0;}
153 if (fTrackF) { fTrackF=0;}
154 if (fTPCtrack) { delete fTPCtrack; fTPCtrack=0;}
155 if (fITStrack) { delete fITStrack; fITStrack=0;}
156 if (fTRDtrack) { delete fTRDtrack; fTRDtrack=0;}
157 if (fTracks) { delete fTracks; fTracks=0;}
160 void AliESDRecInfo::SetESDtrack(const AliESDtrack *track){
165 if (fESDtrack) delete fESDtrack;
166 fESDtrack = (AliESDtrack*)track->Clone();
167 //AliESDfriendTrack *friendTrack=fESDfriend->GetTrack(fESDtrack->GetID());
170 if (track->GetFriendTrack()){
171 fTrackF = (AliESDfriendTrack*)track->GetFriendTrack();
175 while (fTrackF->GetCalibObject(icalib)){
176 cobject=fTrackF->GetCalibObject(icalib);
177 if (dynamic_cast<AliTPCseed*>(cobject)){
178 if (fTPCtrack) delete fTPCtrack;
179 fTPCtrack = (AliTPCseed*)(dynamic_cast<AliTPCseed*>(cobject))->Clone();
180 } else if (dynamic_cast<AliTRDtrackV1*>(cobject)){
181 if (fTRDtrack) delete fTRDtrack;
182 fTRDtrack = (AliTRDtrackV1*)(dynamic_cast<AliTRDtrackV1*>(cobject))->Clone();
187 if (!fTPCtrack) fTPCtrack = new AliTPCseed; // add dummy track
192 void AliESDRecInfo::AddESDtrack(const AliESDtrack *track, AliMCInfo* info){
196 AliESDtrack *nctrack = (AliESDtrack*) track;
200 Update(info,0,kTRUE);
203 if (!fTracks) fTracks = new TClonesArray("AliESDtrack",10);
204 Int_t ntracks = fTracks->GetEntriesFast();
205 new ((*fTracks)[ntracks]) AliESDtrack(*track);
206 if (nctrack->GetKinkIndex(0)>0) return;
210 if (!nctrack->IsOn(AliESDtrack::kTPCrefit) && fStatus[1]==2) return;
211 if (!nctrack->IsOn(AliESDtrack::kITSin) && fStatus[0]>0) return;
212 if ( nctrack->GetParameter()[4]*info->GetCharge()<0) return; //returning track
214 Float_t dtheta = TMath::ATan(nctrack->GetTgl())-info->GetParticle().Theta()-TMath::Pi()-2;
215 if (TMath::Abs(dtheta)>0.1) return;
218 Update(info,0,kTRUE);
223 void AliESDRecInfo::UpdatePoints(AliESDtrack*track)
227 Int_t iclusters[200];
228 Float_t density[160];
229 for (Int_t i=0;i<160;i++) density[i]=-1.;
233 if (fTPCPoints[0]<fTPCPoints[1]) return;
234 /*Int_t nclusters=*/track->GetTPCclusters(iclusters);
240 for (Int_t i=0;i<160;i++){
241 Int_t last = i-range;
242 if (nall<range) nall++;
244 if (iclusters[last]>0&& (iclusters[last]&0x8000)==0) ngood--;
245 if (iclusters[last]==-1) undeff--;
247 if (iclusters[i]>0&& (iclusters[i]&0x8000)==0) ngood++;
248 if (iclusters[i]==-1) undeff++;
249 if (nall==range &&undeff<range/2) density[i-range/2] = Float_t(ngood)/Float_t(nall-undeff);
253 for (Int_t i=0;i<160;i++){
254 if (density[i]<0) continue;
255 if (density[i]>maxdens){
262 fTPCPoints[3] = maxdens;
263 fTPCPoints[1] = indexmax;
266 for (Int_t i=indexmax;i<160;i++){
267 if (density[i]<0) continue;
268 if (density[i]<maxdens/2.) {
275 for (Int_t i=indexmax;i>0;i--){
276 if (density[i]<0) continue;
277 if (density[i]<maxdens/2.) {
283 // Density at the last 30 padrows
288 for (Int_t i=159;i>0;i--){
289 if (iclusters[i]==-1) continue; //dead zone
291 if (iclusters[i]>0) ngood++;
294 fTPCPoints[4] = Float_t(ngood)/Float_t(nall);
296 if ((track->GetStatus()&AliESDtrack::kITSrefit)>0) fTPCPoints[0]=-1;
303 void AliESDRecInfo::Update(AliMCInfo* info,AliTPCParam * /*par*/, Bool_t reconstructed)
306 //calculates derived variables
308 UpdatePoints(fESDtrack);
309 UpdateStatus(info,reconstructed);
316 void AliESDRecInfo::UpdateStatus(AliMCInfo* info, Bool_t reconstructed){
318 // Interpret bit mask flags
320 for (Int_t i=0;i<4;i++) fStatus[i] =0;
321 fReconstructed = kFALSE;
325 if (reconstructed==kFALSE) return;
327 fLabels[0] = info->fLabel;
328 fLabels[1] = info->fPrimPart;
329 fReconstructed = kTRUE;
330 fTPCOn = ((fESDtrack->GetStatus()&AliESDtrack::kTPCrefit)>0) ? kTRUE : kFALSE;
331 fITSOn = ((fESDtrack->GetStatus()&AliESDtrack::kITSrefit)>0) ? kTRUE : kFALSE;
332 fTRDOn = ((fESDtrack->GetStatus()&AliESDtrack::kTRDrefit)>0) ? kTRUE : kFALSE;
335 if ((fESDtrack->GetStatus()&AliESDtrack::kTPCrefit)>0){
339 if ((fESDtrack->GetStatus()&AliESDtrack::kTPCout)>0){
343 if ((fESDtrack->GetStatus()&AliESDtrack::kTPCin)>0)
348 if ((fESDtrack->GetStatus()&AliESDtrack::kITSout)>0){
352 if ((fESDtrack->GetStatus()&AliESDtrack::kITSrefit)>0){
361 if ((fESDtrack->GetStatus()&AliESDtrack::kTRDrefit)>0){
365 if ((fESDtrack->GetStatus()&AliESDtrack::kTRDout)>0){
369 if ((fESDtrack->GetStatus()&AliESDtrack::kTRDStop)>0){
374 void AliESDRecInfo::UpdateTOF(AliMCInfo* info){
376 // Update TOF related comparison information
379 if (((fESDtrack->GetStatus()&AliESDtrack::kTOFout)>0)){
383 fESDtrack->GetIntegratedTimes(times);
384 for (Int_t i=0;i<5;i++){
385 if ( TMath::Abs(fESDtrack->GetTOFsignal()-times[i]) <TMath::Abs(fBestTOFmatch) ){
386 fBestTOFmatch = fESDtrack->GetTOFsignal()-times[i];
390 fESDtrack->GetTOFLabel(toflabel);
391 Bool_t toffake=kTRUE;
392 Bool_t tofdaughter=kFALSE;
393 for (Int_t i=0;i<3;i++){
394 if (toflabel[i]<0) continue;
395 if (toflabel[i]== TMath::Abs(fESDtrack->GetLabel())) toffake=kFALSE;
396 if (toflabel[i]==info->fParticle.GetDaughter(0) || (toflabel[i]==info->fParticle.GetDaughter(1))) tofdaughter=kTRUE; // decay product of original particle
399 if (toffake) fStatus[3] =3; //total fake
400 if (tofdaughter) fStatus[3]=2; //fake because of decay
408 void AliESDRecInfo::UpdateITS(AliMCInfo* info){
410 // Update ITS related comparison information
412 fITSinP0[0]=info->fParticle.Px();
413 fITSinP0[1]=info->fParticle.Py();
414 fITSinP0[2]=info->fParticle.Pz();
415 fITSinP0[3]=info->fParticle.Pt();
417 fITSinR0[0]=info->fParticle.Vx();
418 fITSinR0[1]=info->fParticle.Vy();
419 fITSinR0[2]=info->fParticle.Vz();
420 fITSinR0[3] = TMath::Sqrt(fITSinR0[0]*fITSinR0[0]+fITSinR0[1]*fITSinR0[1]);
421 fITSinR0[4] = TMath::ATan2(fITSinR0[1],fITSinR0[0]);
424 if (fITSinP0[3]>0.0000001){
425 fITSAngle0[0] = TMath::ATan2(fITSinP0[1],fITSinP0[0]);
426 fITSAngle0[1] = TMath::ATan(fITSinP0[2]/fITSinP0[3]);
431 fESDtrack->GetExternalParameters(x,param);
432 // fESDtrack->GetConstrainedExternalParameters(x,param);
434 fESDtrack->GetExternalCovariance(cov);
435 //fESDtrack->GetConstrainedExternalCovariance(cov);
436 if (TMath::Abs(param[4])<0.0000000001) return;
438 fESDtrack->GetXYZ(fITSinR1);
439 fESDtrack->GetPxPyPz(fITSinP1);
440 fITSinP1[3] = TMath::Sqrt(fITSinP1[0]*fITSinP1[0]+fITSinP1[1]*fITSinP1[1]);
442 fITSinR1[3] = TMath::Sqrt(fITSinR1[0]*fITSinR1[0]+fITSinR1[1]*fITSinR1[1]);
443 fITSinR1[4] = TMath::ATan2(fITSinR1[1],fITSinR1[0]);
446 if (fITSinP1[3]>0.0000001){
447 fITSAngle1[0] = TMath::ATan2(fITSinP1[1],fITSinP1[0]);
448 fITSAngle1[1] = TMath::ATan(fITSinP1[2]/fITSinP1[3]);
452 fITSDelta[0] = (fITSinR0[4]-fITSinR1[4])*fITSinR1[3]; //delta rfi
453 fITSPools[0] = fITSDelta[0]/TMath::Sqrt(cov[0]);
454 fITSDelta[1] = (fITSinR0[2]-fITSinR1[2]); //delta z
455 fITSPools[1] = fITSDelta[1]/TMath::Sqrt(cov[2]);
456 fITSDelta[2] = (fITSAngle0[0]-fITSAngle1[0]);
457 fITSPools[2] = fITSDelta[2]/TMath::Sqrt(cov[5]);
458 fITSDelta[3] = (TMath::Tan(fITSAngle0[1])-TMath::Tan(fITSAngle1[1]));
459 fITSPools[3] = fITSDelta[3]/TMath::Sqrt(cov[9]);
460 fITSDelta[4] = (fITSinP0[3]-fITSinP1[3]);
461 Double_t sign = (param[4]>0) ? 1:-1;
463 fITSPools[4] = sign*(1./fITSinP0[3]-1./fITSinP1[3])/TMath::Sqrt(cov[14]);
467 void AliESDRecInfo::UpdateTPC(AliMCInfo* info){
470 // Update TPC related information
472 AliTrackReference * ref = &(info->fTrackRef);
473 fTPCinR0[0] = info->fTrackRef.X();
474 fTPCinR0[1] = info->fTrackRef.Y();
475 fTPCinR0[2] = info->fTrackRef.Z();
476 fTPCinR0[3] = TMath::Sqrt(fTPCinR0[0]*fTPCinR0[0]+fTPCinR0[1]*fTPCinR0[1]);
477 fTPCinR0[4] = TMath::ATan2(fTPCinR0[1],fTPCinR0[0]);
479 fTPCinP0[0] = ref->Px();
480 fTPCinP0[1] = ref->Py();
481 fTPCinP0[2] = ref->Pz();
482 fTPCinP0[3] = ref->Pt();
483 fTPCinP0[4] = ref->P();
484 fDeltaP = (ref->P()-info->fParticle.P())/info->fParticle.P();
487 if (fTPCinP0[3]>0.0000001){
489 fTPCAngle0[0] = TMath::ATan2(fTPCinP0[1],fTPCinP0[0]);
490 fTPCAngle0[1] = TMath::ATan(fTPCinP0[2]/fTPCinP0[3]);
493 if (fStatus[1]>0 &&info->fNTPCRef>0&&TMath::Abs(fTPCinP0[3])>0.0001){
495 fESDtrack->GetInnerXYZ(fTPCinR1);
496 fTPCinR1[3] = TMath::Sqrt(fTPCinR1[0]*fTPCinR1[0]+fTPCinR1[1]*fTPCinR1[1]);
497 fTPCinR1[4] = TMath::ATan2(fTPCinR1[1],fTPCinR1[0]);
498 fESDtrack->GetInnerPxPyPz(fTPCinP1);
499 fTPCinP1[3] = TMath::Sqrt(fTPCinP1[0]*fTPCinP1[0]+fTPCinP1[1]*fTPCinP1[1]);
500 fTPCinP1[4] = TMath::Sqrt(fTPCinP1[3]*fTPCinP1[3]+fTPCinP1[2]*fTPCinP1[2]);
503 if (fTPCinP1[3]>0.000000000000001){
504 fTPCAngle1[0] = TMath::ATan2(fTPCinP1[1],fTPCinP1[0]);
505 fTPCAngle1[1] = TMath::ATan(fTPCinP1[2]/fTPCinP1[3]);
507 Double_t cov[15], param[5],x, alpha;
508 fESDtrack->GetInnerExternalCovariance(cov);
509 fESDtrack->GetInnerExternalParameters(alpha, x,param);
512 fTPCDelta[0] = (fTPCinR0[4]-fTPCinR1[4])*fTPCinR1[3]; //delta rfi
513 fTPCPools[0] = fTPCDelta[0]/TMath::Sqrt(cov[0]);
514 fTPCDelta[1] = (fTPCinR0[2]-fTPCinR1[2]); //delta z
515 fTPCPools[1] = fTPCDelta[1]/TMath::Sqrt(cov[2]);
516 fTPCDelta[2] = (fTPCAngle0[0]-fTPCAngle1[0]);
517 fTPCPools[2] = fTPCDelta[2]/TMath::Sqrt(cov[5]);
518 fTPCDelta[3] = (TMath::Tan(fTPCAngle0[1])-TMath::Tan(fTPCAngle1[1]));
519 fTPCPools[3] = fTPCDelta[3]/TMath::Sqrt(cov[9]);
520 fTPCDelta[4] = (fTPCinP0[3]-fTPCinP1[3]);
521 Double_t sign = (param[4]>0)? 1.:-1;
523 fTPCPools[4] = sign*(1./fTPCinP0[3]-1./fTPCinP1[3])/TMath::Sqrt(TMath::Abs(cov[14]));