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