]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/AliESDRecInfo.cxx
Clear() replaced by Delete() for TClonesArray
[u/mrichter/AliRoot.git] / PWG1 / AliESDRecInfo.cxx
CommitLineData
6fc428f0 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// Time Projection Chamber //
5b662585 20// Comparison macro for reconstructed tracks //
6fc428f0 21// responsible:
22// marian.ivanov@cern.ch //
23//
24//
25
26
27
28
29
6fc428f0 30//ROOT includes
31#include "Rtypes.h"
32//
33//ALIROOT includes
34//
35#include "AliESDtrack.h"
5b662585 36#include "AliTracker.h"
6fc428f0 37#include "AliTPCParam.h"
38#include "AliTrackReference.h"
39#include "AliTPCParamSR.h"
6fc428f0 40#include "AliESDfriend.h"
41#include "AliESDtrack.h"
42#include "AliTPCseed.h"
43#include "AliITStrackMI.h"
44#include "AliTRDtrack.h"
76472f75 45#include "AliMCInfo.h"
6fc428f0 46#include "AliESDRecInfo.h"
47
48
49
50ClassImp(AliESDRecInfo)
51
52
53
54
55AliTPCParam * GetTPCParam(){
56 AliTPCParamSR * par = new AliTPCParamSR;
57 par->Update();
58 return par;
59}
60
61
62
63
64AliESDRecInfo::AliESDRecInfo():
65 fITSOn(0), // ITS refitted inward
66 fTRDOn(0), // ITS refitted inward
67 fDeltaP(0), //delta of momenta
68 fSign(0), // sign
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
a1e6aa99 78 fTRDtrack(0) // trd track
6fc428f0 79{
80 //
81 // default constructor
82 //
83}
84
85
86AliESDRecInfo::AliESDRecInfo(const AliESDRecInfo& recinfo):
cd875161 87 TObject(),
88 fITSOn(0), // ITS refitted inward
89 fTRDOn(0), // ITS refitted inward
90 fDeltaP(0), //delta of momenta
91 fSign(0), // sign
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
a1e6aa99 101 fTRDtrack(0) // trd track
6fc428f0 102{
103 //
104 //
105 //
106 memcpy(this,&recinfo, sizeof(recinfo));
107 fESDtrack=0; fTrackF=0; fTPCtrack=0;fITStrack=0;fTRDtrack=0;
108 SetESDtrack(recinfo.GetESDtrack());
109}
110
111
cd875161 112AliESDRecInfo& AliESDRecInfo::operator=(const AliESDRecInfo& info) {
113 //
114 // Assignment operator
115 //
a1e6aa99 116 this->~AliESDRecInfo();
cd875161 117 new (this) AliESDRecInfo(info);
118 return *this;
119}
120
121
122
6fc428f0 123AliESDRecInfo::~AliESDRecInfo()
124
125{
126 //
127 // destructor
128 //
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;}
134
135}
136
137
138
139void AliESDRecInfo::Reset()
140{
141 //
142 // reset info
143 //
144 fMultiple =0;
145 fFake =0;
146 fReconstructed=0;
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;}
152}
153
154void AliESDRecInfo::SetESDtrack(const AliESDtrack *track){
155 //
156 //
157 //
158 if (fESDtrack) delete fESDtrack;
159 fESDtrack = (AliESDtrack*)track->Clone();
160 if (0 &&track->GetFriendTrack()){
161 if (fTrackF) delete fTrackF;
162 fTrackF = (AliESDfriendTrack*)track->GetFriendTrack()->Clone();
163 if (fTrackF->GetCalibObject(0)){
164 if (fTPCtrack) delete fTPCtrack;
165 fTPCtrack = (AliTPCseed*)fTrackF->GetCalibObject(0)->Clone();
166 }
167 }
168
169}
170
171void AliESDRecInfo::UpdatePoints(AliESDtrack*track)
172{
173 //
174 //
175 Int_t iclusters[200];
176 Float_t density[160];
177 for (Int_t i=0;i<160;i++) density[i]=-1.;
178 fTPCPoints[0]= 160;
179 fTPCPoints[1] = -1;
180 //
181 if (fTPCPoints[0]<fTPCPoints[1]) return;
182 // Int_t nclusters=track->GetTPCclusters(iclusters);
183
184 Int_t ngood=0;
185 Int_t undeff=0;
186 Int_t nall =0;
187 Int_t range=20;
188 for (Int_t i=0;i<160;i++){
189 Int_t last = i-range;
190 if (nall<range) nall++;
191 if (last>=0){
192 if (iclusters[last]>0&& (iclusters[last]&0x8000)==0) ngood--;
193 if (iclusters[last]==-1) undeff--;
194 }
195 if (iclusters[i]>0&& (iclusters[i]&0x8000)==0) ngood++;
196 if (iclusters[i]==-1) undeff++;
197 if (nall==range &&undeff<range/2) density[i-range/2] = Float_t(ngood)/Float_t(nall-undeff);
198 }
199 Float_t maxdens=0;
200 Int_t indexmax =0;
201 for (Int_t i=0;i<160;i++){
202 if (density[i]<0) continue;
203 if (density[i]>maxdens){
204 maxdens=density[i];
205 indexmax=i;
206 }
207 }
208 //
209 //max dens point
210 fTPCPoints[3] = maxdens;
211 fTPCPoints[1] = indexmax;
212 //
213 // last point
214 for (Int_t i=indexmax;i<160;i++){
215 if (density[i]<0) continue;
216 if (density[i]<maxdens/2.) {
217 break;
218 }
219 fTPCPoints[2]=i;
220 }
221 //
222 // first point
223 for (Int_t i=indexmax;i>0;i--){
224 if (density[i]<0) continue;
225 if (density[i]<maxdens/2.) {
226 break;
227 }
228 fTPCPoints[0]=i;
229 }
230 //
231 // Density at the last 30 padrows
232 //
233 //
234 nall = 0;
235 ngood = 0;
236 for (Int_t i=159;i>0;i--){
237 if (iclusters[i]==-1) continue; //dead zone
238 nall++;
239 if (iclusters[i]>0) ngood++;
240 if (nall>20) break;
241 }
242 fTPCPoints[4] = Float_t(ngood)/Float_t(nall);
243 //
244 if ((track->GetStatus()&AliESDtrack::kITSrefit)>0) fTPCPoints[0]=-1;
245
246
247}
248
249//
250//
251void AliESDRecInfo::Update(AliMCInfo* info,AliTPCParam * /*par*/, Bool_t reconstructed)
252{
6fc428f0 253 //
254 //calculates derived variables
255 //
6fc428f0 256 UpdatePoints(fESDtrack);
5b662585 257 UpdateStatus(info,reconstructed);
258 UpdateITS(info);
259 UpdateTPC(info);
260 UpdateTOF(info);
261}
262
263
264void AliESDRecInfo::UpdateStatus(AliMCInfo* info, Bool_t reconstructed){
6fc428f0 265 //
5b662585 266 // Interpret bit mask flags
6fc428f0 267 //
268 for (Int_t i=0;i<4;i++) fStatus[i] =0;
269 fReconstructed = kFALSE;
270 fTPCOn = kFALSE;
271 fITSOn = kFALSE;
272 fTRDOn = kFALSE;
273 if (reconstructed==kFALSE) return;
274
275 fLabels[0] = info->fLabel;
276 fLabels[1] = info->fPrimPart;
277 fReconstructed = kTRUE;
278 fTPCOn = ((fESDtrack->GetStatus()&AliESDtrack::kTPCrefit)>0) ? kTRUE : kFALSE;
279 fITSOn = ((fESDtrack->GetStatus()&AliESDtrack::kITSrefit)>0) ? kTRUE : kFALSE;
280 fTRDOn = ((fESDtrack->GetStatus()&AliESDtrack::kTRDrefit)>0) ? kTRUE : kFALSE;
281 //
282 //
283 if ((fESDtrack->GetStatus()&AliESDtrack::kTPCrefit)>0){
284 fStatus[1] =3;
285 }
286 else{
287 if ((fESDtrack->GetStatus()&AliESDtrack::kTPCout)>0){
288 fStatus[1] =2;
289 }
290 else{
291 if ((fESDtrack->GetStatus()&AliESDtrack::kTPCin)>0)
292 fStatus[1]=1;
293 }
294 }
295 //
296 if ((fESDtrack->GetStatus()&AliESDtrack::kITSout)>0){
297 fStatus[0] =2;
298 }
299 else{
300 if ((fESDtrack->GetStatus()&AliESDtrack::kITSrefit)>0){
301 fStatus[0] =1;
302 }
303 else{
304 fStatus[0]=0;
305 }
306 }
6fc428f0 307 //
308 //
309 if ((fESDtrack->GetStatus()&AliESDtrack::kTRDrefit)>0){
310 fStatus[2] =2;
311 }
312 else{
313 if ((fESDtrack->GetStatus()&AliESDtrack::kTRDout)>0){
314 fStatus[2] =1;
315 }
316 }
317 if ((fESDtrack->GetStatus()&AliESDtrack::kTRDStop)>0){
318 fStatus[2] =10;
5b662585 319 }
320}
6fc428f0 321
5b662585 322void AliESDRecInfo::UpdateTOF(AliMCInfo* info){
6fc428f0 323 //
5b662585 324 // Update TOF related comparison information
325 //
326 fBestTOFmatch=1000;
6fc428f0 327 if (((fESDtrack->GetStatus()&AliESDtrack::kTOFout)>0)){
328 //
329 // best tof match
330 Double_t times[5];
331 fESDtrack->GetIntegratedTimes(times);
332 for (Int_t i=0;i<5;i++){
333 if ( TMath::Abs(fESDtrack->GetTOFsignal()-times[i]) <TMath::Abs(fBestTOFmatch) ){
334 fBestTOFmatch = fESDtrack->GetTOFsignal()-times[i];
335 }
336 }
337 Int_t toflabel[3];
338 fESDtrack->GetTOFLabel(toflabel);
339 Bool_t toffake=kTRUE;
340 Bool_t tofdaughter=kFALSE;
341 for (Int_t i=0;i<3;i++){
342 if (toflabel[i]<0) continue;
343 if (toflabel[i]== TMath::Abs(fESDtrack->GetLabel())) toffake=kFALSE;
344 if (toflabel[i]==info->fParticle.GetDaughter(0) || (toflabel[i]==info->fParticle.GetDaughter(1))) tofdaughter=kTRUE; // decay product of original particle
345 fStatus[3]=1;
346 }
347 if (toffake) fStatus[3] =3; //total fake
348 if (tofdaughter) fStatus[3]=2; //fake because of decay
349 }else{
350 fStatus[3]=0;
351 }
5b662585 352}
6fc428f0 353
354
5b662585 355
356void AliESDRecInfo::UpdateITS(AliMCInfo* info){
357 //
358 // Update ITS related comparison information
359 //
360 fITSinP0[0]=info->fParticle.Px();
361 fITSinP0[1]=info->fParticle.Py();
362 fITSinP0[2]=info->fParticle.Pz();
363 fITSinP0[3]=info->fParticle.Pt();
364 //
365 fITSinR0[0]=info->fParticle.Vx();
366 fITSinR0[1]=info->fParticle.Vy();
367 fITSinR0[2]=info->fParticle.Vz();
368 fITSinR0[3] = TMath::Sqrt(fITSinR0[0]*fITSinR0[0]+fITSinR0[1]*fITSinR0[1]);
369 fITSinR0[4] = TMath::ATan2(fITSinR0[1],fITSinR0[0]);
370 //
371 //
372 if (fITSinP0[3]>0.0000001){
373 fITSAngle0[0] = TMath::ATan2(fITSinP0[1],fITSinP0[0]);
374 fITSAngle0[1] = TMath::ATan(fITSinP0[2]/fITSinP0[3]);
6fc428f0 375 }
376 if (fITSOn){
377 // ITS
378 Double_t param[5],x;
379 fESDtrack->GetExternalParameters(x,param);
380 // fESDtrack->GetConstrainedExternalParameters(x,param);
381 Double_t cov[15];
382 fESDtrack->GetExternalCovariance(cov);
383 //fESDtrack->GetConstrainedExternalCovariance(cov);
384 if (TMath::Abs(param[4])<0.0000000001) return;
5b662585 385
6fc428f0 386 fESDtrack->GetXYZ(fITSinR1);
387 fESDtrack->GetPxPyPz(fITSinP1);
388 fITSinP1[3] = TMath::Sqrt(fITSinP1[0]*fITSinP1[0]+fITSinP1[1]*fITSinP1[1]);
389 //
390 fITSinR1[3] = TMath::Sqrt(fITSinR1[0]*fITSinR1[0]+fITSinR1[1]*fITSinR1[1]);
391 fITSinR1[4] = TMath::ATan2(fITSinR1[1],fITSinR1[0]);
392 //
393 //
394 if (fITSinP1[3]>0.0000001){
395 fITSAngle1[0] = TMath::ATan2(fITSinP1[1],fITSinP1[0]);
396 fITSAngle1[1] = TMath::ATan(fITSinP1[2]/fITSinP1[3]);
397 }
398 //
399 //
400 fITSDelta[0] = (fITSinR0[4]-fITSinR1[4])*fITSinR1[3]; //delta rfi
401 fITSPools[0] = fITSDelta[0]/TMath::Sqrt(cov[0]);
402 fITSDelta[1] = (fITSinR0[2]-fITSinR1[2]); //delta z
403 fITSPools[1] = fITSDelta[1]/TMath::Sqrt(cov[2]);
404 fITSDelta[2] = (fITSAngle0[0]-fITSAngle1[0]);
405 fITSPools[2] = fITSDelta[2]/TMath::Sqrt(cov[5]);
406 fITSDelta[3] = (TMath::Tan(fITSAngle0[1])-TMath::Tan(fITSAngle1[1]));
407 fITSPools[3] = fITSDelta[3]/TMath::Sqrt(cov[9]);
408 fITSDelta[4] = (fITSinP0[3]-fITSinP1[3]);
409 Double_t sign = (param[4]>0) ? 1:-1;
410 fSign = sign;
5b662585 411 fITSPools[4] = sign*(1./fITSinP0[3]-1./fITSinP1[3])/TMath::Sqrt(cov[14]);
6fc428f0 412 }
6fc428f0 413}
414
5b662585 415void AliESDRecInfo::UpdateTPC(AliMCInfo* info){
416 //
417 //
418 // Update TPC related information
419 //
420 AliTrackReference * ref = &(info->fTrackRef);
421 fTPCinR0[0] = info->fTrackRef.X();
422 fTPCinR0[1] = info->fTrackRef.Y();
423 fTPCinR0[2] = info->fTrackRef.Z();
424 fTPCinR0[3] = TMath::Sqrt(fTPCinR0[0]*fTPCinR0[0]+fTPCinR0[1]*fTPCinR0[1]);
425 fTPCinR0[4] = TMath::ATan2(fTPCinR0[1],fTPCinR0[0]);
426 //
427 fTPCinP0[0] = ref->Px();
428 fTPCinP0[1] = ref->Py();
429 fTPCinP0[2] = ref->Pz();
430 fTPCinP0[3] = ref->Pt();
431 fTPCinP0[4] = ref->P();
432 fDeltaP = (ref->P()-info->fParticle.P())/info->fParticle.P();
433 //
434 //
435 if (fTPCinP0[3]>0.0000001){
436 //
437 fTPCAngle0[0] = TMath::ATan2(fTPCinP0[1],fTPCinP0[0]);
438 fTPCAngle0[1] = TMath::ATan(fTPCinP0[2]/fTPCinP0[3]);
439 }
440 //
441 if (fStatus[1]>0 &&info->fNTPCRef>0&&TMath::Abs(fTPCinP0[3])>0.0001){
442 //TPC
443 fESDtrack->GetInnerXYZ(fTPCinR1);
444 fTPCinR1[3] = TMath::Sqrt(fTPCinR1[0]*fTPCinR1[0]+fTPCinR1[1]*fTPCinR1[1]);
445 fTPCinR1[4] = TMath::ATan2(fTPCinR1[1],fTPCinR1[0]);
446 fESDtrack->GetInnerPxPyPz(fTPCinP1);
447 fTPCinP1[3] = TMath::Sqrt(fTPCinP1[0]*fTPCinP1[0]+fTPCinP1[1]*fTPCinP1[1]);
448 fTPCinP1[4] = TMath::Sqrt(fTPCinP1[3]*fTPCinP1[3]+fTPCinP1[2]*fTPCinP1[2]);
449 //
450 //
451 if (fTPCinP1[3]>0.000000000000001){
452 fTPCAngle1[0] = TMath::ATan2(fTPCinP1[1],fTPCinP1[0]);
453 fTPCAngle1[1] = TMath::ATan(fTPCinP1[2]/fTPCinP1[3]);
454 }
455 Double_t cov[15], param[5],x, alpha;
456 fESDtrack->GetInnerExternalCovariance(cov);
457 fESDtrack->GetInnerExternalParameters(alpha, x,param);
458 if (x<50) return ;
459 //
460 fTPCDelta[0] = (fTPCinR0[4]-fTPCinR1[4])*fTPCinR1[3]; //delta rfi
461 fTPCPools[0] = fTPCDelta[0]/TMath::Sqrt(cov[0]);
462 fTPCDelta[1] = (fTPCinR0[2]-fTPCinR1[2]); //delta z
463 fTPCPools[1] = fTPCDelta[1]/TMath::Sqrt(cov[2]);
464 fTPCDelta[2] = (fTPCAngle0[0]-fTPCAngle1[0]);
465 fTPCPools[2] = fTPCDelta[2]/TMath::Sqrt(cov[5]);
466 fTPCDelta[3] = (TMath::Tan(fTPCAngle0[1])-TMath::Tan(fTPCAngle1[1]));
467 fTPCPools[3] = fTPCDelta[3]/TMath::Sqrt(cov[9]);
468 fTPCDelta[4] = (fTPCinP0[3]-fTPCinP1[3]);
469 Double_t sign = (param[4]>0)? 1.:-1;
470 fSign =sign;
471 fTPCPools[4] = sign*(1./fTPCinP0[3]-1./fTPCinP1[3])/TMath::Sqrt(TMath::Abs(cov[14]));
472 }
5b662585 473}
474
475
476
477
6fc428f0 478