]>
Commit | Line | Data |
---|---|---|
4c039060 | 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 | ||
f531a546 | 16 | // $Id$ |
4c039060 | 17 | |
959fbac5 | 18 | /////////////////////////////////////////////////////////////////////////// |
19 | // Class AliTrack | |
20 | // Handling of the attributes of a reconstructed particle track. | |
21 | // | |
22 | // Coding example : | |
23 | // ---------------- | |
24 | // | |
25 | // Float_t a[4]={195.,1.2,-0.04,8.5}; | |
26 | // Ali4Vector pmu; | |
27 | // pmu.SetVector(a,"car"); | |
28 | // AliTrack t1; | |
29 | // t1.Set4Momentum(pmu); | |
30 | // | |
31 | // Float_t b[3]={1.2,-0.04,8.5}; | |
32 | // Ali3Vector p; | |
33 | // p.SetVector(b,"car"); | |
34 | // AliTrack t2; | |
35 | // t2.Set3Momentum(p); | |
36 | // t2.SetCharge(0); | |
37 | // t2.SetMass(1.115); | |
38 | // | |
84bb7c66 | 39 | // t1.Data(); |
40 | // t2.Data(); | |
959fbac5 | 41 | // |
42 | // Float_t pi=acos(-1.); | |
43 | // Float_t thcms=0.2*pi; // decay theta angle in cms | |
44 | // Float_t phicms=pi/4.; // decay theta angle in cms | |
45 | // Float_t m1=0.938; | |
46 | // Float_t m2=0.140; | |
47 | // t2.Decay(m1,m2,thcms,phicms); // Track t2 decay : Lambda -> proton + pion | |
48 | // | |
49 | // t2.List(); | |
50 | // | |
51 | // Int_t ndec=t2.GetNdecay(); | |
52 | // AliTrack* d1=t2.GetDecayTrack(1); // Access to decay track number 1 | |
53 | // AliTrack* d2=t2.GetDecayTrack(2); // Access to decay track number 2 | |
54 | // | |
55 | // AliSignal s1,s2,s3,s4; | |
56 | // | |
57 | // .... // Code (e.g. detector readout) to fill AliSignal data | |
58 | // | |
59 | // AliTrack trec; // Track which will be reconstructed from signals | |
60 | // trec.AddSignal(s1); | |
61 | // trec.AddSignal(s3); | |
62 | // trec.AddSignal(s4); | |
63 | // | |
64 | // Ali3Vector P; | |
65 | // Float_t Q,M; | |
66 | // | |
67 | // ... // Code which accesses signals from trec and reconstructs | |
68 | // 3-momentum P, charge Q, mass M etc... | |
69 | // | |
70 | // trec.Set3Momentum(P); | |
71 | // trec.SetCharge(Q); | |
72 | // trec.SetMass(M); | |
73 | // | |
74 | // Float_t r1[3]={1.6,-3.8,25.7}; | |
75 | // Float_t er1[3]={0.2,0.5,1.8}; | |
76 | // Float_t r2[3]={8.6,23.8,-6.7}; | |
77 | // Float_t er2[3]={0.93,1.78,0.8}; | |
78 | // AliPosition begin,end; | |
79 | // begin.SetPosition(r1,"car"); | |
80 | // begin.SetPositionErrors(er1,"car"); | |
81 | // end.SetPosition(r2,"car"); | |
82 | // end.SetPositionErrors(er2,"car"); | |
83 | // trec.SetBeginPoint(begin); | |
84 | // trec.SetEndPoint(end); | |
85 | // | |
86 | // Note : All quantities are in GeV, GeV/c or GeV/c**2 | |
87 | // | |
88 | //--- Author: Nick van Eijndhoven 10-jul-1997 UU-SAP Utrecht | |
f531a546 | 89 | //- Modified: NvE $Date$ UU-SAP Utrecht |
959fbac5 | 90 | /////////////////////////////////////////////////////////////////////////// |
91 | ||
d88f97cc | 92 | #include "AliTrack.h" |
c72198f1 | 93 | #include "Riostream.h" |
d88f97cc | 94 | |
95 | ClassImp(AliTrack) // Class implementation to enable ROOT I/O | |
96 | ||
5f25234b | 97 | AliTrack::AliTrack() : TNamed(),Ali4Vector() |
d88f97cc | 98 | { |
99 | // Default constructor | |
100 | // All variables initialised to 0 | |
6516b62d | 101 | Init(); |
102 | Reset(); | |
103 | } | |
104 | /////////////////////////////////////////////////////////////////////////// | |
105 | void AliTrack::Init() | |
106 | { | |
107 | // Initialisation of pointers etc... | |
d88f97cc | 108 | fDecays=0; |
959fbac5 | 109 | fSignals=0; |
5f25234b | 110 | fHypotheses=0; |
c72198f1 | 111 | fBegin=0; |
112 | fEnd=0; | |
c5555bc0 | 113 | fRef=0; |
c72198f1 | 114 | fImpactXY=0; |
115 | fImpactXZ=0; | |
116 | fImpactYZ=0; | |
117 | fClosest=0; | |
1fbffa23 | 118 | fParent=0; |
ea0b5b7f | 119 | fFit=0; |
a7dc0627 | 120 | fTstamp=0; |
d88f97cc | 121 | } |
122 | /////////////////////////////////////////////////////////////////////////// | |
123 | AliTrack::~AliTrack() | |
124 | { | |
5f25234b | 125 | // Destructor to delete memory allocated for decay tracks array. |
d0120ca2 | 126 | // This destructor automatically cleares all references to this AliTrack |
127 | // from all the related AliSignal objects. | |
5f25234b | 128 | Int_t nsig=GetNsignals(); |
129 | for (Int_t i=1; i<=nsig; i++) | |
130 | { | |
131 | AliSignal* s=GetSignal(i); | |
d0120ca2 | 132 | if (s) s->RemoveTrack(*this,0); |
5f25234b | 133 | } |
134 | ||
d88f97cc | 135 | if (fDecays) |
136 | { | |
d88f97cc | 137 | delete fDecays; |
138 | fDecays=0; | |
139 | } | |
959fbac5 | 140 | if (fSignals) |
141 | { | |
959fbac5 | 142 | delete fSignals; |
143 | fSignals=0; | |
144 | } | |
5f25234b | 145 | if (fHypotheses) |
c72198f1 | 146 | { |
5f25234b | 147 | delete fHypotheses; |
148 | fHypotheses=0; | |
c72198f1 | 149 | } |
150 | if (fBegin) | |
151 | { | |
152 | delete fBegin; | |
153 | fBegin=0; | |
154 | } | |
155 | if (fEnd) | |
156 | { | |
157 | delete fEnd; | |
158 | fEnd=0; | |
159 | } | |
c5555bc0 | 160 | if (fRef) |
161 | { | |
162 | delete fRef; | |
163 | fRef=0; | |
164 | } | |
c72198f1 | 165 | if (fImpactXY) |
166 | { | |
167 | delete fImpactXY; | |
168 | fImpactXY=0; | |
169 | } | |
170 | if (fImpactXZ) | |
171 | { | |
172 | delete fImpactXZ; | |
173 | fImpactXZ=0; | |
174 | } | |
175 | if (fImpactYZ) | |
176 | { | |
177 | delete fImpactYZ; | |
178 | fImpactYZ=0; | |
179 | } | |
180 | if (fClosest) | |
181 | { | |
182 | delete fClosest; | |
183 | fClosest=0; | |
184 | } | |
ea0b5b7f | 185 | if (fFit) |
186 | { | |
187 | delete fFit; | |
188 | fFit=0; | |
189 | } | |
a7dc0627 | 190 | if (fTstamp) |
191 | { | |
192 | delete fTstamp; | |
193 | fTstamp=0; | |
194 | } | |
d88f97cc | 195 | } |
196 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 197 | AliTrack::AliTrack(const AliTrack& t) : TNamed(t),Ali4Vector(t) |
6516b62d | 198 | { |
199 | // Copy constructor | |
200 | Init(); | |
201 | ||
c72198f1 | 202 | fQ=t.fQ; |
5f25234b | 203 | fProb=t.fProb; |
c72198f1 | 204 | if (t.fBegin) fBegin=new AliPositionObj(*(t.fBegin)); |
205 | if (t.fEnd) fEnd=new AliPositionObj(*(t.fEnd)); | |
c5555bc0 | 206 | if (t.fRef) fRef=new AliPositionObj(*(t.fRef)); |
c72198f1 | 207 | if (t.fImpactXY) fImpactXY=new AliPositionObj(*(t.fImpactXY)); |
208 | if (t.fImpactXZ) fImpactXZ=new AliPositionObj(*(t.fImpactXZ)); | |
209 | if (t.fImpactYZ) fImpactYZ=new AliPositionObj(*(t.fImpactYZ)); | |
210 | if (t.fClosest) fClosest=new AliPositionObj(*(t.fClosest)); | |
ea0b5b7f | 211 | if (t.fFit) fFit=t.fFit->Clone(); |
a7dc0627 | 212 | if (t.fTstamp) fTstamp=new AliTimestamp(*(t.fTstamp)); |
c72198f1 | 213 | fUserId=t.fUserId; |
214 | fChi2=t.fChi2; | |
215 | fNdf=t.fNdf; | |
216 | fCode=t.fCode; | |
1fbffa23 | 217 | fParent=t.fParent; |
c72198f1 | 218 | |
5f25234b | 219 | Int_t ndec=t.GetNdecay(); |
220 | if (ndec) | |
6516b62d | 221 | { |
5f25234b | 222 | fDecays=new TObjArray(ndec); |
6516b62d | 223 | fDecays->SetOwner(); |
5f25234b | 224 | for (Int_t it=1; it<=ndec; it++) |
6516b62d | 225 | { |
c72198f1 | 226 | AliTrack* tx=t.GetDecayTrack(it); |
6516b62d | 227 | fDecays->Add(new AliTrack(*tx)); |
228 | } | |
229 | } | |
230 | ||
5f25234b | 231 | Int_t nsig=t.GetNsignals(); |
232 | if (nsig) | |
6516b62d | 233 | { |
5f25234b | 234 | fSignals=new TObjArray(nsig); |
235 | for (Int_t is=1; is<=nsig; is++) | |
6516b62d | 236 | { |
c72198f1 | 237 | AliSignal* sx=t.GetSignal(is); |
6516b62d | 238 | fSignals->Add(sx); |
239 | } | |
240 | } | |
5f25234b | 241 | |
242 | Int_t nhyp=t.GetNhypotheses(); | |
243 | if (nhyp) | |
244 | { | |
245 | fHypotheses=new TObjArray(nhyp); | |
246 | fHypotheses->SetOwner(); | |
247 | for (Int_t ih=1; ih<=nhyp; ih++) | |
248 | { | |
249 | AliTrack* tx=t.GetTrackHypothesis(ih); | |
250 | fHypotheses->Add(new AliTrack(*tx)); | |
251 | } | |
252 | } | |
6516b62d | 253 | } |
254 | /////////////////////////////////////////////////////////////////////////// | |
d88f97cc | 255 | void AliTrack::Reset() |
256 | { | |
35044448 | 257 | // Reset all variables to 0 and delete all auto-generated decay tracks. |
d88f97cc | 258 | fQ=0; |
2693cb4e | 259 | fChi2=0; |
260 | fNdf=0; | |
43bfa5be | 261 | fUserId=0; |
fdbea0ce | 262 | fCode=0; |
5f25234b | 263 | fProb=0; |
d88f97cc | 264 | Double_t a[4]={0,0,0,0}; |
265 | SetVector(a,"sph"); | |
1fbffa23 | 266 | fParent=0; |
d88f97cc | 267 | if (fDecays) |
268 | { | |
d88f97cc | 269 | delete fDecays; |
270 | fDecays=0; | |
271 | } | |
959fbac5 | 272 | if (fSignals) |
273 | { | |
959fbac5 | 274 | delete fSignals; |
275 | fSignals=0; | |
276 | } | |
5f25234b | 277 | if (fHypotheses) |
f531a546 | 278 | { |
5f25234b | 279 | delete fHypotheses; |
280 | fHypotheses=0; | |
f531a546 | 281 | } |
c72198f1 | 282 | if (fBegin) |
283 | { | |
284 | delete fBegin; | |
285 | fBegin=0; | |
286 | } | |
287 | if (fEnd) | |
288 | { | |
289 | delete fEnd; | |
290 | fEnd=0; | |
291 | } | |
c5555bc0 | 292 | if (fRef) |
293 | { | |
294 | delete fRef; | |
295 | fRef=0; | |
296 | } | |
c72198f1 | 297 | if (fImpactXY) |
298 | { | |
299 | delete fImpactXY; | |
300 | fImpactXY=0; | |
301 | } | |
302 | if (fImpactXZ) | |
303 | { | |
304 | delete fImpactXZ; | |
305 | fImpactXZ=0; | |
306 | } | |
307 | if (fImpactYZ) | |
308 | { | |
309 | delete fImpactYZ; | |
310 | fImpactYZ=0; | |
311 | } | |
312 | if (fClosest) | |
313 | { | |
314 | delete fClosest; | |
315 | fClosest=0; | |
316 | } | |
ea0b5b7f | 317 | if (fFit) |
318 | { | |
319 | delete fFit; | |
320 | fFit=0; | |
321 | } | |
a7dc0627 | 322 | if (fTstamp) |
323 | { | |
324 | delete fTstamp; | |
325 | fTstamp=0; | |
326 | } | |
d88f97cc | 327 | } |
328 | /////////////////////////////////////////////////////////////////////////// | |
329 | void AliTrack::Set3Momentum(Ali3Vector& p) | |
330 | { | |
261c0caf | 331 | // Set the track parameters according to the 3-momentum p. |
332 | // In case the mass was not yet set, the energy is set to correspond to m=0. | |
959fbac5 | 333 | Set3Vector(p); |
261c0caf | 334 | Double_t inv=GetInvariant(); |
335 | if (inv<0) SetMass(0.); | |
d88f97cc | 336 | } |
337 | /////////////////////////////////////////////////////////////////////////// | |
338 | void AliTrack::Set4Momentum(Ali4Vector& p) | |
339 | { | |
340 | // Set the track parameters according to the 4-momentum p | |
341 | Double_t E=p.GetScalar(); | |
959fbac5 | 342 | Double_t dE=p.GetResultError(); |
d88f97cc | 343 | Ali3Vector pv=p.Get3Vector(); |
344 | SetVector(E,pv); | |
959fbac5 | 345 | SetScalarError(dE); |
d88f97cc | 346 | } |
347 | /////////////////////////////////////////////////////////////////////////// | |
959fbac5 | 348 | void AliTrack::SetMass(Double_t m,Double_t dm) |
d88f97cc | 349 | { |
350 | // Set the particle mass | |
959fbac5 | 351 | // The default value for the error dm is 0. |
352 | Double_t inv=pow(m,2); | |
353 | Double_t dinv=fabs(2.*m*dm); | |
354 | SetInvariant(inv,dinv); | |
d88f97cc | 355 | } |
356 | /////////////////////////////////////////////////////////////////////////// | |
357 | void AliTrack::SetCharge(Float_t q) | |
358 | { | |
359 | // Set the particle charge | |
360 | fQ=q; | |
361 | } | |
362 | /////////////////////////////////////////////////////////////////////////// | |
1f241680 | 363 | void AliTrack::Data(TString f,TString u) |
d88f97cc | 364 | { |
365 | // Provide track information within the coordinate frame f | |
1f241680 | 366 | // |
367 | // The string argument "u" allows to choose between different angular units | |
368 | // in case e.g. a spherical frame is selected. | |
369 | // u = "rad" : angles provided in radians | |
370 | // "deg" : angles provided in degrees | |
371 | // | |
372 | // The defaults are f="car" and u="rad". | |
373 | ||
959fbac5 | 374 | Double_t m=GetMass(); |
375 | Double_t dm=GetResultError(); | |
5f25234b | 376 | const char* name=GetName(); |
377 | const char* title=GetTitle(); | |
378 | ||
379 | cout << " *" << ClassName() << "::Data*"; | |
ea0b5b7f | 380 | if (strlen(name)) cout << " Name : " << name; |
381 | if (strlen(title)) cout << " Title : " << title; | |
5f25234b | 382 | cout << endl; |
a7dc0627 | 383 | if (fTstamp) fTstamp->Date(1); |
5f25234b | 384 | cout << " Id : " << fUserId << " Code : " << fCode |
385 | << " m : " << m << " dm : " << dm << " Charge : " << fQ | |
386 | << " p : " << GetMomentum() << endl; | |
387 | cout << " Nhypotheses : " << GetNhypotheses() << " Ndecay-tracks : " << GetNdecay() | |
388 | << " Nsignals : " << GetNsignals() << endl; | |
ea0b5b7f | 389 | if (fParent) |
390 | { | |
391 | cout << " Parent track Id : " << fParent->GetId() << " Code : " << fParent->GetParticleCode() | |
392 | << " m : " << fParent->GetMass() << " Q : " << fParent->GetCharge() | |
393 | << " p : " << fParent->GetMomentum(); | |
394 | const char* pname=fParent->GetName(); | |
395 | const char* ptitle=fParent->GetTitle(); | |
396 | if (strlen(pname)) cout << " Name : " << pname; | |
397 | if (strlen(ptitle)) cout << " Title : " << ptitle; | |
398 | cout << endl; | |
399 | } | |
400 | if (fFit) | |
401 | { | |
402 | cout << " Fit details present in object of class " << fFit->ClassName() << endl; | |
403 | if (fFit->InheritsFrom("AliSignal")) ((AliSignal*)fFit)->List(-1); | |
404 | } | |
1f241680 | 405 | Ali4Vector::Data(f,u); |
d88f97cc | 406 | } |
407 | /////////////////////////////////////////////////////////////////////////// | |
1f241680 | 408 | void AliTrack::List(TString f,TString u) |
d88f97cc | 409 | { |
410 | // Provide current track and decay level 1 information within coordinate frame f | |
1f241680 | 411 | // |
412 | // The string argument "u" allows to choose between different angular units | |
413 | // in case e.g. a spherical frame is selected. | |
414 | // u = "rad" : angles provided in radians | |
415 | // "deg" : angles provided in degrees | |
416 | // | |
417 | // The defaults are f="car" and u="rad". | |
d88f97cc | 418 | |
1f241680 | 419 | Data(f,u); // Information of the current track |
e51b7d1a | 420 | if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); } |
421 | if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); } | |
422 | if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); } | |
d88f97cc | 423 | |
424 | // Decay products of this track | |
425 | AliTrack* td; | |
5f25234b | 426 | for (Int_t id=1; id<=GetNdecay(); id++) |
d88f97cc | 427 | { |
428 | td=GetDecayTrack(id); | |
429 | if (td) | |
430 | { | |
431 | cout << " ---Level 1 sec. track no. " << id << endl; | |
1f241680 | 432 | td->Data(f,u); |
d88f97cc | 433 | } |
434 | else | |
435 | { | |
5f25234b | 436 | cout << " *AliTrack::List* Error : Empty decay track slot." << endl; |
d88f97cc | 437 | } |
438 | } | |
439 | } | |
440 | /////////////////////////////////////////////////////////////////////////// | |
1f241680 | 441 | void AliTrack::ListAll(TString f,TString u) |
d88f97cc | 442 | { |
443 | // Provide complete track and decay information within the coordinate frame f | |
1f241680 | 444 | // |
445 | // The string argument "u" allows to choose between different angular units | |
446 | // in case e.g. a spherical frame is selected. | |
447 | // u = "rad" : angles provided in radians | |
448 | // "deg" : angles provided in degrees | |
449 | // | |
450 | // The defaults are f="car" and u="rad". | |
d88f97cc | 451 | |
1f241680 | 452 | Data(f,u); // Information of the current track |
e51b7d1a | 453 | if (fBegin) { cout << " Begin-point :"; fBegin->Data(f,u); } |
454 | if (fEnd) { cout << " End-point :"; fEnd->Data(f,u); } | |
455 | if (fRef) { cout << " Ref-point :"; fRef->Data(f,u); } | |
5f25234b | 456 | |
457 | Int_t nhyp=GetNhypotheses(); | |
458 | if (nhyp) | |
459 | { | |
460 | cout << " List of the " << nhyp << " track hypotheses : " << endl; | |
461 | for (Int_t ih=1; ih<=nhyp; ih++) | |
462 | { | |
463 | AliTrack* tx=GetTrackHypothesis(ih); | |
1f241680 | 464 | if (tx) tx->Data(f,u); |
5f25234b | 465 | } |
466 | } | |
467 | ||
468 | Int_t nsig=GetNsignals(); | |
469 | if (nsig) | |
959fbac5 | 470 | { |
d0a8ef71 | 471 | cout << " List of the corresponding slots for the " << nsig |
472 | << " related signals : " << endl; | |
473 | AliPosition r; | |
474 | Int_t nrefs,jslot; | |
475 | TArrayI slotarr; | |
5f25234b | 476 | for (Int_t is=1; is<=nsig; is++) |
477 | { | |
478 | AliSignal* sx=GetSignal(is); | |
d0a8ef71 | 479 | if (sx) |
480 | { | |
481 | nrefs=sx->GetIndices(this,slotarr,0); | |
482 | for (Int_t jref=0; jref<nrefs; jref++) | |
483 | { | |
484 | jslot=slotarr.At(jref); | |
485 | sx->List(jslot); | |
486 | } | |
487 | r=sx->GetPosition(); | |
488 | cout << " Position"; | |
1f241680 | 489 | r.Data(f,u); |
d0a8ef71 | 490 | } |
5f25234b | 491 | } |
959fbac5 | 492 | } |
d88f97cc | 493 | |
494 | AliTrack* t=this; | |
1f241680 | 495 | Dumps(t,1,f,u); // Information of all decay products |
d88f97cc | 496 | } |
497 | ////////////////////////////////////////////////////////////////////////// | |
1f241680 | 498 | void AliTrack::Dumps(AliTrack* t,Int_t n,TString f,TString u) |
d88f97cc | 499 | { |
500 | // Recursively provide the info of all decay levels of this track | |
501 | AliTrack* td; | |
502 | for (Int_t id=1; id<=t->GetNdecay(); id++) | |
503 | { | |
504 | td=t->GetDecayTrack(id); | |
505 | if (td) | |
506 | { | |
507 | cout << " ---Level " << n << " sec. track no. " << id << endl; | |
1f241680 | 508 | td->Data(f,u); |
5f25234b | 509 | |
510 | Int_t nhyp=td->GetNhypotheses(); | |
511 | if (nhyp) | |
512 | { | |
513 | cout << " List of the " << nhyp << " track hypotheses : " << endl; | |
514 | for (Int_t ih=1; ih<=nhyp; ih++) | |
515 | { | |
516 | AliTrack* tx=td->GetTrackHypothesis(ih); | |
1f241680 | 517 | if (tx) tx->Data(f,u); |
5f25234b | 518 | } |
519 | } | |
520 | ||
521 | Int_t nsig=td->GetNsignals(); | |
522 | if (nsig) | |
959fbac5 | 523 | { |
5f25234b | 524 | cout << " List of the " << nsig << " related signals : " << endl; |
525 | for (Int_t is=1; is<=nsig; is++) | |
526 | { | |
527 | AliSignal* sx=td->GetSignal(is); | |
1f241680 | 528 | if (sx) sx->Data(f,u); |
5f25234b | 529 | } |
959fbac5 | 530 | } |
d88f97cc | 531 | |
532 | // Go for next decay level of this decay track recursively | |
1f241680 | 533 | Dumps(td,n+1,f,u); |
d88f97cc | 534 | } |
535 | else | |
536 | { | |
5f25234b | 537 | cout << " *AliTrack::Dumps* Error : Empty decay track slot." << endl; |
d88f97cc | 538 | } |
539 | } | |
540 | } | |
541 | ////////////////////////////////////////////////////////////////////////// | |
542 | Double_t AliTrack::GetMomentum() | |
543 | { | |
959fbac5 | 544 | // Provide the value of the track 3-momentum. |
545 | // The error can be obtained by invoking GetResultError() after | |
546 | // invokation of GetMomentum(). | |
959fbac5 | 547 | Double_t norm=fV.GetNorm(); |
d071d629 | 548 | fDresult=fV.GetResultError(); |
959fbac5 | 549 | return norm; |
d88f97cc | 550 | } |
551 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 552 | Ali3Vector AliTrack::Get3Momentum() const |
d88f97cc | 553 | { |
554 | // Provide the track 3-momentum | |
555 | return (Ali3Vector)Get3Vector(); | |
556 | } | |
557 | /////////////////////////////////////////////////////////////////////////// | |
558 | Double_t AliTrack::GetMass() | |
559 | { | |
959fbac5 | 560 | // Provide the particle mass. |
561 | // The error can be obtained by invoking GetResultError() after | |
562 | // invokation of GetMass(). | |
563 | Double_t inv=GetInvariant(); | |
564 | Double_t dinv=GetResultError(); | |
565 | Double_t dm=0; | |
566 | if (inv >= 0) | |
567 | { | |
568 | Double_t m=sqrt(inv); | |
569 | if (m) dm=dinv/(2.*m); | |
570 | fDresult=dm; | |
571 | return m; | |
572 | } | |
573 | else | |
574 | { | |
575 | cout << "*AliTrack::GetMass* Unphysical situation m**2 = " << inv << endl; | |
576 | cout << " Value 0 will be returned." << endl; | |
577 | fDresult=dm; | |
578 | return 0; | |
579 | } | |
d88f97cc | 580 | } |
581 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 582 | Float_t AliTrack::GetCharge() const |
d88f97cc | 583 | { |
584 | // Provide the particle charge | |
585 | return fQ; | |
586 | } | |
587 | /////////////////////////////////////////////////////////////////////////// | |
588 | Double_t AliTrack::GetEnergy() | |
589 | { | |
959fbac5 | 590 | // Provide the particle's energy. |
591 | // The error can be obtained by invoking GetResultError() after | |
592 | // invokation of GetEnergy(). | |
593 | Double_t E=GetScalar(); | |
594 | if (E>0) | |
595 | { | |
596 | return E; | |
597 | } | |
598 | else | |
599 | { | |
600 | cout << "*AliTrack::GetEnergy* Unphysical situation E = " << E << endl; | |
601 | cout << " Value 0 will be returned." << endl; | |
602 | return 0; | |
603 | } | |
d88f97cc | 604 | } |
605 | /////////////////////////////////////////////////////////////////////////// | |
606 | void AliTrack::Decay(Double_t m1,Double_t m2,Double_t thcms,Double_t phicms) | |
607 | { | |
608 | // Perform 2-body decay of current track | |
609 | // m1 : mass of decay product 1 | |
610 | // m2 : mass of decay product 2 | |
611 | // thcms : cms theta decay angle (in rad.) of m1 | |
612 | // phicms : cms phi decay angle (in rad.) of m1 | |
613 | ||
959fbac5 | 614 | Double_t M=GetMass(); |
d88f97cc | 615 | |
616 | // Compute the 4-momenta of the decay products in the cms | |
617 | // Note : p2=p1=pnorm for a 2-body decay | |
959fbac5 | 618 | Double_t e1=0; |
619 | if (M) e1=((M*M)+(m1*m1)-(m2*m2))/(2.*M); | |
620 | Double_t e2=0; | |
621 | if (M) e2=((M*M)+(m2*m2)-(m1*m1))/(2.*M); | |
d88f97cc | 622 | Double_t pnorm=(e1*e1)-(m1*m1); |
623 | if (pnorm>0.) | |
624 | { | |
625 | pnorm=sqrt(pnorm); | |
626 | } | |
627 | else | |
628 | { | |
629 | pnorm=0; | |
630 | } | |
631 | ||
632 | Double_t a[3]; | |
633 | a[0]=pnorm; | |
634 | a[1]=thcms; | |
635 | a[2]=phicms; | |
636 | Ali3Vector p; | |
637 | p.SetVector(a,"sph"); | |
638 | ||
639 | Ali4Vector pprim1; | |
640 | pprim1.SetVector(e1,p); | |
959fbac5 | 641 | pprim1.SetInvariant(m1*m1); |
d88f97cc | 642 | |
643 | Ali4Vector pprim2; | |
644 | p*=-1; | |
645 | pprim2.SetVector(e2,p); | |
959fbac5 | 646 | pprim2.SetInvariant(m2*m2); |
d88f97cc | 647 | |
648 | // Determine boost parameters from the parent particle | |
959fbac5 | 649 | Double_t E=GetEnergy(); |
d88f97cc | 650 | p=Get3Vector(); |
651 | Ali4Vector pmu; | |
652 | pmu.SetVector(E,p); | |
653 | ||
654 | AliBoost q; | |
655 | q.Set4Momentum(pmu); | |
656 | ||
657 | Ali4Vector p1=q.Inverse(pprim1); // Boost decay product 1 | |
658 | Ali4Vector p2=q.Inverse(pprim2); // Boost decay product 2 | |
659 | ||
660 | // Enter the boosted data into the decay tracks array | |
661 | if (fDecays) | |
662 | { | |
d88f97cc | 663 | delete fDecays; |
6516b62d | 664 | fDecays=0; |
d88f97cc | 665 | } |
5f25234b | 666 | fDecays=new TObjArray(2); |
6516b62d | 667 | fDecays->SetOwner(); |
d88f97cc | 668 | |
669 | fDecays->Add(new AliTrack); | |
670 | ((AliTrack*)fDecays->At(0))->Set4Momentum(p1); | |
959fbac5 | 671 | ((AliTrack*)fDecays->At(0))->SetMass(m1); |
d88f97cc | 672 | fDecays->Add(new AliTrack); |
673 | ((AliTrack*)fDecays->At(1))->Set4Momentum(p2); | |
d88f97cc | 674 | ((AliTrack*)fDecays->At(1))->SetMass(m2); |
675 | } | |
676 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 677 | Int_t AliTrack::GetNdecay() const |
d88f97cc | 678 | { |
679 | // Provide the number of decay produced tracks | |
5f25234b | 680 | Int_t ndec=0; |
681 | if (fDecays) ndec=fDecays->GetEntries(); | |
682 | return ndec; | |
d88f97cc | 683 | } |
684 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 685 | AliTrack* AliTrack::GetDecayTrack(Int_t j) const |
d88f97cc | 686 | { |
687 | // Provide decay produced track number j | |
688 | // Note : j=1 denotes the first decay track | |
6516b62d | 689 | if (!fDecays) |
d88f97cc | 690 | { |
6516b62d | 691 | cout << " *AliTrack::GetDecayTrack* No tracks present." << endl; |
692 | return 0; | |
d88f97cc | 693 | } |
694 | else | |
695 | { | |
5f25234b | 696 | if ((j >= 1) && (j <= GetNdecay())) |
6516b62d | 697 | { |
698 | return (AliTrack*)fDecays->At(j-1); | |
699 | } | |
700 | else | |
701 | { | |
702 | cout << " *AliTrack* decay track number : " << j << " out of range." | |
5f25234b | 703 | << " Ndec = " << GetNdecay() << endl; |
6516b62d | 704 | return 0; |
705 | } | |
d88f97cc | 706 | } |
707 | } | |
708 | /////////////////////////////////////////////////////////////////////////// | |
5f25234b | 709 | void AliTrack::RemoveDecays() |
710 | { | |
711 | // Remove all decay tracks from this track. | |
712 | if (fDecays) | |
713 | { | |
714 | delete fDecays; | |
715 | fDecays=0; | |
716 | } | |
717 | } | |
718 | /////////////////////////////////////////////////////////////////////////// | |
d0120ca2 | 719 | void AliTrack::AddSignal(AliSignal& s,Int_t mode) |
959fbac5 | 720 | { |
721 | // Relate an AliSignal object to this track. | |
d0120ca2 | 722 | // |
723 | // mode = 0 : Only the reference to the specified signal is stored in | |
724 | // the current track, without storing the (backward) reference | |
725 | // to this track into the AliSignal structure. | |
726 | // 1 : The (backward) reference to the current track is also automatically | |
727 | // stored into the AliSignal (or derived) object specified in the | |
728 | // input argument. | |
729 | // | |
730 | // The default is mode=0. | |
731 | ||
5f25234b | 732 | if (!fSignals) fSignals=new TObjArray(1); |
733 | ||
734 | // Check if this signal is already stored for this track | |
735 | Int_t nsig=GetNsignals(); | |
736 | for (Int_t i=0; i<nsig; i++) | |
737 | { | |
738 | if (&s==fSignals->At(i)) return; | |
739 | } | |
740 | ||
959fbac5 | 741 | fSignals->Add(&s); |
d0120ca2 | 742 | if (mode==1) s.AddTrack(*this,0); |
959fbac5 | 743 | } |
744 | /////////////////////////////////////////////////////////////////////////// | |
d0120ca2 | 745 | void AliTrack::RemoveSignal(AliSignal& s,Int_t mode) |
959fbac5 | 746 | { |
5f25234b | 747 | // Remove related AliSignal object from this track. |
d0120ca2 | 748 | // |
749 | // mode = 0 : Only the reference to the specified signal is removed from | |
750 | // the current track, without removing the (backward) reference(s) | |
751 | // to this track from the AliSignal structure. | |
752 | // 1 : The (backward) reference(s) to the current track are also automatically | |
753 | // removed from the AliSignal (or derived) object specified in the | |
754 | // input argument. | |
755 | // | |
756 | // The default is mode=1. | |
757 | ||
959fbac5 | 758 | if (fSignals) |
759 | { | |
760 | AliSignal* test=(AliSignal*)fSignals->Remove(&s); | |
5f25234b | 761 | if (test) fSignals->Compress(); |
762 | } | |
d0120ca2 | 763 | if (mode==1) s.RemoveTrack(*this,0); |
5f25234b | 764 | } |
765 | /////////////////////////////////////////////////////////////////////////// | |
d0120ca2 | 766 | void AliTrack::RemoveSignals(Int_t mode) |
5f25234b | 767 | { |
768 | // Remove all related AliSignal objects from this track. | |
d0120ca2 | 769 | // |
770 | // mode = 0 : All signal references are removed from the current track, | |
771 | // without removing the (backward) references to this track from | |
772 | // the corresponding AliSignal objects. | |
773 | // 1 : The (backward) references to the current track are also automatically | |
774 | // removed from the corresponding AliSignal (or derived) objects. | |
775 | // | |
776 | // The default is mode=1. | |
777 | ||
778 | if (!fSignals) return; | |
779 | ||
780 | Int_t ns=GetNsignals(); | |
781 | for (Int_t i=0; i<ns; i++) | |
5f25234b | 782 | { |
d0120ca2 | 783 | AliSignal* sx=(AliSignal*)fSignals->At(i); |
784 | if (sx && mode==1) sx->RemoveTrack(*this,0); | |
959fbac5 | 785 | } |
d0120ca2 | 786 | |
787 | delete fSignals; | |
788 | fSignals=0; | |
959fbac5 | 789 | } |
790 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 791 | Int_t AliTrack::GetNsignals() const |
959fbac5 | 792 | { |
793 | // Provide the number of related AliSignals. | |
5f25234b | 794 | Int_t nsig=0; |
795 | if (fSignals) nsig=fSignals->GetEntries(); | |
796 | return nsig; | |
959fbac5 | 797 | } |
798 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 799 | AliSignal* AliTrack::GetSignal(Int_t j) const |
959fbac5 | 800 | { |
801 | // Provide the related AliSignal number j. | |
802 | // Note : j=1 denotes the first signal. | |
6516b62d | 803 | if (!fSignals) |
959fbac5 | 804 | { |
6516b62d | 805 | cout << " *AliTrack::GetSignal* No signals present." << endl; |
806 | return 0; | |
959fbac5 | 807 | } |
808 | else | |
809 | { | |
5f25234b | 810 | if ((j >= 1) && (j <= GetNsignals())) |
6516b62d | 811 | { |
812 | return (AliSignal*)fSignals->At(j-1); | |
813 | } | |
814 | else | |
815 | { | |
816 | cout << " *AliTrack* signal number : " << j << " out of range." | |
5f25234b | 817 | << " Nsig = " << GetNsignals() << endl; |
6516b62d | 818 | return 0; |
819 | } | |
959fbac5 | 820 | } |
821 | } | |
822 | /////////////////////////////////////////////////////////////////////////// | |
5f25234b | 823 | void AliTrack::AddTrackHypothesis(AliTrack& t) |
959fbac5 | 824 | { |
5f25234b | 825 | // Relate a track hypothesis to this track. |
826 | // Note : a private copy of the input track will be made via the Clone() | |
827 | // facility. | |
828 | if (!fHypotheses) | |
c72198f1 | 829 | { |
5f25234b | 830 | fHypotheses=new TObjArray(1); |
831 | fHypotheses->SetOwner(); | |
c72198f1 | 832 | } |
5f25234b | 833 | fHypotheses->Add(t.Clone()); |
959fbac5 | 834 | } |
835 | /////////////////////////////////////////////////////////////////////////// | |
5f25234b | 836 | void AliTrack::AddTrackHypothesis(Double_t prob,Double_t m,Double_t dm) |
959fbac5 | 837 | { |
5f25234b | 838 | // Add a track hypothesis by explicitly setting the mass and probability. |
839 | // This will affect e.g. the hypothesis track's energy, since the momentum | |
840 | // and all other attributes will be copied from the current track. | |
841 | // | |
842 | // Input arguments : | |
843 | // ----------------- | |
844 | // prob=probalility m=mass value dm=error on the mass value. | |
845 | // The default value for the mass error dm is 0. | |
846 | ||
847 | AliTrack t(*this); | |
848 | t.RemoveDecays(); | |
849 | t.RemoveTrackHypotheses(); | |
850 | t.RemoveSignals(); | |
851 | t.SetTitle("Mass hypothesis"); | |
852 | t.SetMass(m,dm); | |
853 | t.SetProb(prob); | |
854 | AddTrackHypothesis(t); | |
959fbac5 | 855 | } |
856 | /////////////////////////////////////////////////////////////////////////// | |
5f25234b | 857 | void AliTrack::RemoveTrackHypothesis(AliTrack& t) |
959fbac5 | 858 | { |
5f25234b | 859 | // Remove the specified track hypothesis from this track. |
860 | if (fHypotheses) | |
c72198f1 | 861 | { |
5f25234b | 862 | AliTrack* test=(AliTrack*)fHypotheses->Remove(&t); |
863 | if (test) fHypotheses->Compress(); | |
c72198f1 | 864 | } |
959fbac5 | 865 | } |
866 | /////////////////////////////////////////////////////////////////////////// | |
5f25234b | 867 | void AliTrack::RemoveTrackHypotheses() |
959fbac5 | 868 | { |
5f25234b | 869 | // Remove all track hypotheses from this track. |
870 | if (fHypotheses) | |
871 | { | |
872 | delete fHypotheses; | |
873 | fHypotheses=0; | |
874 | } | |
f531a546 | 875 | } |
876 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 877 | Int_t AliTrack::GetNhypotheses() const |
f531a546 | 878 | { |
5f25234b | 879 | // Provide the number of track hypotheses. |
880 | Int_t nhyp=0; | |
881 | if (fHypotheses) nhyp=fHypotheses->GetEntries(); | |
882 | return nhyp; | |
f531a546 | 883 | } |
884 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 885 | AliTrack* AliTrack::GetTrackHypothesis(Int_t j) const |
f531a546 | 886 | { |
5f25234b | 887 | // Provide the j-th track hypothesis. |
888 | // Note : j=1 denotes the first hypothesis. | |
f531a546 | 889 | // Default : j=0 ==> Hypothesis with highest probability. |
f531a546 | 890 | |
5f25234b | 891 | if (!fHypotheses) return 0; |
892 | ||
893 | Int_t nhyp=GetNhypotheses(); | |
f531a546 | 894 | |
895 | // Check validity of index j | |
5f25234b | 896 | if (j<0 || j>nhyp) |
f531a546 | 897 | { |
5f25234b | 898 | cout << " *AliTrack* hypothesis number : " << j << " out of range." |
899 | << " Nhyp = " << nhyp << endl; | |
900 | return 0; | |
901 | } | |
f531a546 | 902 | |
5f25234b | 903 | AliTrack* t=0; |
904 | ||
905 | if (j==0) // Provide track hypothesis with highest probability | |
f531a546 | 906 | { |
5f25234b | 907 | Float_t prob=0; |
908 | t=(AliTrack*)fHypotheses->At(0); | |
909 | if (t) prob=t->GetProb(); | |
910 | Float_t probx=0; | |
911 | for (Int_t ih=1; ih<nhyp; ih++) | |
f531a546 | 912 | { |
5f25234b | 913 | AliTrack* tx=(AliTrack*)fHypotheses->At(ih); |
914 | if (tx) | |
f531a546 | 915 | { |
5f25234b | 916 | probx=tx->GetProb(); |
917 | if (probx > prob) t=tx; | |
f531a546 | 918 | } |
919 | } | |
5f25234b | 920 | return t; |
921 | } | |
922 | else // Provide requested j-th track hypothesis | |
923 | { | |
924 | return (AliTrack*)fHypotheses->At(j-1); | |
f531a546 | 925 | } |
f531a546 | 926 | } |
927 | /////////////////////////////////////////////////////////////////////////// | |
5f25234b | 928 | void AliTrack::SetBeginPoint(AliPosition& p) |
f531a546 | 929 | { |
5f25234b | 930 | // Store the position of the track begin-point. |
f4d1f676 | 931 | if (fBegin) delete fBegin; |
932 | fBegin=new AliPositionObj(p); | |
f531a546 | 933 | } |
934 | /////////////////////////////////////////////////////////////////////////// | |
5f25234b | 935 | AliPosition* AliTrack::GetBeginPoint() |
f531a546 | 936 | { |
5f25234b | 937 | // Provide the position of the track begin-point. |
938 | return fBegin; | |
939 | } | |
940 | /////////////////////////////////////////////////////////////////////////// | |
941 | void AliTrack::SetEndPoint(AliPosition& p) | |
942 | { | |
943 | // Store the position of the track end-point. | |
f4d1f676 | 944 | if (fEnd) delete fEnd; |
945 | fEnd=new AliPositionObj(p); | |
f531a546 | 946 | } |
947 | /////////////////////////////////////////////////////////////////////////// | |
5f25234b | 948 | AliPosition* AliTrack::GetEndPoint() |
949 | { | |
950 | // Provide the position of the track end-point. | |
951 | return fEnd; | |
952 | } | |
953 | /////////////////////////////////////////////////////////////////////////// | |
c5555bc0 | 954 | void AliTrack::SetReferencePoint(AliPosition& p) |
955 | { | |
956 | // Store the position of the track reference-point. | |
957 | // The reference-point is the point on the track in which the | |
958 | // 3-momentum vector components have been defined. | |
959 | // This reference point is the preferable point to start track extrapolations | |
960 | // etc... which are sensitive to the components of the 3-momentum vector. | |
f4d1f676 | 961 | if (fRef) delete fRef; |
962 | fRef=new AliPositionObj(p); | |
c5555bc0 | 963 | } |
964 | /////////////////////////////////////////////////////////////////////////// | |
965 | AliPosition* AliTrack::GetReferencePoint() | |
966 | { | |
967 | // Provide the position of the track reference-point. | |
968 | // The reference-point is the point on the track in which the | |
969 | // 3-momentum vector components have been defined. | |
970 | // This reference point is the preferable point to start track extrapolations | |
971 | // etc... which are sensitive to the components of the 3-momentum vector. | |
972 | return fRef; | |
973 | } | |
974 | /////////////////////////////////////////////////////////////////////////// | |
5f25234b | 975 | void AliTrack::SetMass() |
f531a546 | 976 | { |
5f25234b | 977 | // Set the mass and error to the value of the hypothesis with highest prob. |
f531a546 | 978 | |
5f25234b | 979 | Double_t m=0,dm=0; |
980 | ||
981 | // Select mass hypothesis with highest probability | |
982 | AliTrack* t=GetTrackHypothesis(0); | |
983 | if (t) | |
f531a546 | 984 | { |
5f25234b | 985 | m=t->GetMass(); |
986 | dm=t->GetResultError(); | |
987 | SetMass(m,dm); | |
f531a546 | 988 | } |
989 | else | |
990 | { | |
5f25234b | 991 | cout << " *AliTrack::SetMass()* No hypothesis present => No action." << endl; |
f531a546 | 992 | } |
993 | } | |
994 | /////////////////////////////////////////////////////////////////////////// | |
d071d629 | 995 | Double_t AliTrack::GetPt() |
996 | { | |
997 | // Provide trans. momentum value w.r.t. z-axis. | |
998 | // The error on the value can be obtained by GetResultError() | |
999 | // after invokation of GetPt(). | |
1000 | Ali3Vector v; | |
1001 | v=GetVecTrans(); | |
1002 | Double_t norm=v.GetNorm(); | |
1003 | fDresult=v.GetResultError(); | |
1004 | ||
1005 | return norm; | |
1006 | } | |
1007 | /////////////////////////////////////////////////////////////////////////// | |
1008 | Double_t AliTrack::GetPl() | |
1009 | { | |
1010 | // Provide long. momentum value w.r.t. z-axis. | |
8adaf597 | 1011 | // Note : the returned value can also be negative. |
d071d629 | 1012 | // The error on the value can be obtained by GetResultError() |
1013 | // after invokation of GetPl(). | |
1014 | Ali3Vector v; | |
1015 | v=GetVecLong(); | |
8adaf597 | 1016 | |
1017 | Double_t pl=v.GetNorm(); | |
d071d629 | 1018 | fDresult=v.GetResultError(); |
1019 | ||
8adaf597 | 1020 | Double_t a[3]; |
1021 | v.GetVector(a,"sph"); | |
1022 | if (cos(a[1])<0) pl=-pl; | |
1023 | ||
1024 | return pl; | |
d071d629 | 1025 | } |
1026 | /////////////////////////////////////////////////////////////////////////// | |
1027 | Double_t AliTrack::GetEt() | |
1028 | { | |
1029 | // Provide trans. energy value w.r.t. z-axis. | |
1030 | // The error on the value can be obtained by GetResultError() | |
1031 | // after invokation of GetEt(). | |
1032 | Double_t et=GetScaTrans(); | |
1033 | ||
1034 | return et; | |
1035 | } | |
1036 | /////////////////////////////////////////////////////////////////////////// | |
1037 | Double_t AliTrack::GetEl() | |
1038 | { | |
1039 | // Provide long. energy value w.r.t. z-axis. | |
8adaf597 | 1040 | // Note : the returned value can also be negative. |
d071d629 | 1041 | // The error on the value can be obtained by GetResultError() |
1042 | // after invokation of GetEl(). | |
1043 | Double_t el=GetScaLong(); | |
1044 | ||
1045 | return el; | |
1046 | } | |
1047 | /////////////////////////////////////////////////////////////////////////// | |
1048 | Double_t AliTrack::GetMt() | |
1049 | { | |
1050 | // Provide transverse mass value w.r.t. z-axis. | |
1051 | // The error on the value can be obtained by GetResultError() | |
1052 | // after invokation of GetMt(). | |
1053 | Double_t pt=GetPt(); | |
1054 | Double_t dpt=GetResultError(); | |
1055 | Double_t m=GetMass(); | |
1056 | Double_t dm=GetResultError(); | |
1057 | ||
1058 | Double_t mt=sqrt(pt*pt+m*m); | |
1059 | Double_t dmt2=0; | |
1060 | if (mt) dmt2=(pow((pt*dpt),2)+pow((m*dm),2))/(mt*mt); | |
1061 | ||
1062 | fDresult=sqrt(dmt2); | |
1063 | return mt; | |
1064 | } | |
1065 | /////////////////////////////////////////////////////////////////////////// | |
8adaf597 | 1066 | Double_t AliTrack::GetRapidity() |
1067 | { | |
1068 | // Provide rapidity value w.r.t. z-axis. | |
1069 | // The error on the value can be obtained by GetResultError() | |
1070 | // after invokation of GetRapidity(). | |
1071 | // Note : Also GetPseudoRapidity() is available since this class is | |
1072 | // derived from Ali4Vector. | |
1073 | Double_t e=GetEnergy(); | |
1074 | Double_t de=GetResultError(); | |
1075 | Double_t pl=GetPl(); | |
1076 | Double_t dpl=GetResultError(); | |
1077 | Double_t sum=e+pl; | |
1078 | Double_t dif=e-pl; | |
1079 | ||
1080 | Double_t y=9999,dy2=0; | |
1081 | if (sum && dif) y=0.5*log(sum/dif); | |
1082 | ||
1083 | if (sum*dif) dy2=(1./(sum*dif))*(pow((pl*de),2)+pow((e*dpl),2)); | |
1084 | ||
1085 | fDresult=sqrt(dy2); | |
1086 | return y; | |
1087 | } | |
1088 | /////////////////////////////////////////////////////////////////////////// | |
c72198f1 | 1089 | void AliTrack::SetImpactPoint(AliPosition& p,TString q) |
43bfa5be | 1090 | { |
1091 | // Store the position of the impact-point in the plane "q=0". | |
1092 | // Here q denotes one of the axes X, Y or Z. | |
1093 | // Note : The character to denote the axis may be entered in lower or | |
1094 | // in uppercase. | |
1095 | Int_t axis=0; | |
1096 | if (q=="x" || q=="X") axis=1; | |
1097 | if (q=="y" || q=="Y") axis=2; | |
1098 | if (q=="z" || q=="Z") axis=3; | |
1099 | ||
1100 | switch (axis) | |
1101 | { | |
1102 | case 1: // Impact-point in the plane X=0 | |
f4d1f676 | 1103 | if (fImpactYZ) delete fImpactYZ; |
1104 | fImpactYZ=new AliPositionObj(p); | |
43bfa5be | 1105 | break; |
1106 | ||
1107 | case 2: // Impact-point in the plane Y=0 | |
f4d1f676 | 1108 | if (fImpactXZ) delete fImpactXZ; |
1109 | fImpactXZ=new AliPositionObj(p); | |
43bfa5be | 1110 | break; |
1111 | ||
1112 | case 3: // Impact-point in the plane Z=0 | |
f4d1f676 | 1113 | if (fImpactXY) delete fImpactXY; |
1114 | fImpactXY=new AliPositionObj(p); | |
43bfa5be | 1115 | break; |
1116 | ||
1117 | default: // Unsupported axis | |
1118 | cout << "*AliTrack::SetImpactPoint* Unsupported axis : " << q << endl | |
1119 | << " Possible axes are 'X', 'Y' and 'Z'." << endl; | |
1120 | break; | |
1121 | } | |
1122 | } | |
1123 | /////////////////////////////////////////////////////////////////////////// | |
c72198f1 | 1124 | AliPosition* AliTrack::GetImpactPoint(TString q) |
43bfa5be | 1125 | { |
1126 | // Provide the position of the impact-point in the plane "q=0". | |
1127 | // Here q denotes one of the axes X, Y or Z. | |
1128 | // Note : The character to denote the axis may be entered in lower or | |
1129 | // in uppercase. | |
43bfa5be | 1130 | Int_t axis=0; |
1131 | if (q=="x" || q=="X") axis=1; | |
1132 | if (q=="y" || q=="Y") axis=2; | |
1133 | if (q=="z" || q=="Z") axis=3; | |
1134 | ||
1135 | switch (axis) | |
1136 | { | |
1137 | case 1: // Impact-point in the plane X=0 | |
1138 | return fImpactYZ; | |
1139 | ||
1140 | case 2: // Impact-point in the plane Y=0 | |
1141 | return fImpactXZ; | |
1142 | ||
1143 | case 3: // Impact-point in the plane Z=0 | |
1144 | return fImpactXY; | |
1145 | ||
1146 | default: // Unsupported axis | |
1147 | cout << "*AliTrack::GetImpactPoint* Unsupported axis : " << q << endl | |
1148 | << " Possible axes are 'X', 'Y' and 'Z'." << endl; | |
c72198f1 | 1149 | return 0; |
43bfa5be | 1150 | } |
1151 | } | |
1152 | /////////////////////////////////////////////////////////////////////////// | |
1153 | void AliTrack::SetId(Int_t id) | |
1154 | { | |
fdbea0ce | 1155 | // Set a user defined unique identifier for this track. |
43bfa5be | 1156 | fUserId=id; |
1157 | } | |
1158 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1159 | Int_t AliTrack::GetId() const |
43bfa5be | 1160 | { |
fdbea0ce | 1161 | // Provide the user defined unique identifier of this track. |
43bfa5be | 1162 | return fUserId; |
1163 | } | |
1164 | /////////////////////////////////////////////////////////////////////////// | |
c72198f1 | 1165 | void AliTrack::SetClosestPoint(AliPosition& p) |
43bfa5be | 1166 | { |
1167 | // Set position p as the point of closest approach w.r.t. some reference | |
f4d1f676 | 1168 | if (fClosest) delete fClosest; |
1169 | fClosest=new AliPositionObj(p); | |
43bfa5be | 1170 | } |
1171 | /////////////////////////////////////////////////////////////////////////// | |
c72198f1 | 1172 | AliPosition* AliTrack::GetClosestPoint() |
43bfa5be | 1173 | { |
1174 | // Provide the point of closest approach w.r.t. some reference | |
1175 | return fClosest; | |
1176 | } | |
1177 | /////////////////////////////////////////////////////////////////////////// | |
2693cb4e | 1178 | void AliTrack::SetChi2(Float_t chi2) |
1179 | { | |
1180 | // Set the chi-squared value of the track fit. | |
1181 | if (chi2<0) | |
1182 | { | |
1183 | cout << " *AliTrack::SetChi2* Invalid chi2 value : " << chi2 << endl; | |
1184 | } | |
1185 | else | |
1186 | { | |
1187 | fChi2=chi2; | |
1188 | } | |
1189 | } | |
1190 | /////////////////////////////////////////////////////////////////////////// | |
1191 | void AliTrack::SetNdf(Int_t ndf) | |
1192 | { | |
1193 | // Set the number of degrees of freedom for the track fit. | |
1194 | if (ndf<0) | |
1195 | { | |
1196 | cout << " *AliTrack::SetNdf* Invalid ndf value : " << ndf << endl; | |
1197 | } | |
1198 | else | |
1199 | { | |
1200 | fNdf=ndf; | |
1201 | } | |
1202 | } | |
1203 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1204 | Float_t AliTrack::GetChi2() const |
2693cb4e | 1205 | { |
1206 | // Provide the chi-squared value of the track fit. | |
1207 | return fChi2; | |
1208 | } | |
1209 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1210 | Int_t AliTrack::GetNdf() const |
2693cb4e | 1211 | { |
1212 | // Provide the number of degrees of freedom for the track fit. | |
1213 | return fNdf; | |
1214 | } | |
1215 | /////////////////////////////////////////////////////////////////////////// | |
fdbea0ce | 1216 | void AliTrack::SetParticleCode(Int_t code) |
1217 | { | |
1218 | // Set the user defined particle id code (e.g. the PDF convention). | |
1219 | fCode=code; | |
1220 | } | |
1221 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1222 | Int_t AliTrack::GetParticleCode() const |
fdbea0ce | 1223 | { |
1224 | // Provide the user defined particle id code. | |
1225 | return fCode; | |
1226 | } | |
1227 | /////////////////////////////////////////////////////////////////////////// | |
1fbffa23 | 1228 | void AliTrack::SetParentTrack(AliTrack* t) |
1229 | { | |
1230 | // Set pointer to the parent track. | |
1231 | fParent=t; | |
1232 | } | |
1233 | /////////////////////////////////////////////////////////////////////////// | |
1234 | AliTrack* AliTrack::GetParentTrack() | |
1235 | { | |
1236 | // Provide pointer to the parent track. | |
1237 | return fParent; | |
1238 | } | |
1239 | /////////////////////////////////////////////////////////////////////////// | |
5f25234b | 1240 | void AliTrack::SetProb(Double_t prob) |
1241 | { | |
1242 | // Set hypothesis probability for this track. | |
1243 | fProb=prob; | |
1244 | } | |
1245 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1246 | Float_t AliTrack::GetProb() const |
5f25234b | 1247 | { |
1248 | // Provide the hypothesis probability for this track. | |
1249 | return fProb; | |
1250 | } | |
1251 | /////////////////////////////////////////////////////////////////////////// | |
ea0b5b7f | 1252 | void AliTrack::SetFitDetails(TObject* obj) |
1253 | { | |
1254 | // Enter the object containing the fit details. | |
1255 | // In case an object to hold fit details was already present, this | |
1256 | // will be deleted first before the new one is stored. | |
1257 | // This means that SetFitDetails(0) can be used to just remove the | |
1258 | // existing object with the fit details. | |
1259 | // All objects derived from TObject can be entered in this way. | |
1260 | // Obvious candidates for objects containing detailed fit information | |
1261 | // are functions (e.g. TF1) and histograms (e.g. TH1F). | |
1262 | // However, using an AliDevice object provides a very versatile facility | |
1263 | // to store the parameters of various fit procedures. | |
1264 | // In such a case the AliDevice can be used to provide the various fit | |
1265 | // definitions and the corresponding fit parameters can be entered as | |
1266 | // separate AliSignal objects which are stored as hits to the AliDevice. | |
1267 | // In addition various functions and histograms can be linked to the | |
1268 | // various AliSignal instances | |
1269 | // The latter procedure is based on the original idea of Adam Bouchta. | |
1270 | // | |
1271 | // Note : The entered object is owned by this AliTrack instance. | |
1272 | // As such, a private copy of obj will be stored using the Clone() | |
1273 | // memberfunction. | |
1274 | // In case the entered object contains pointers to other objects, | |
1275 | // the user has to provide the appropriate Clone() memberfunction | |
1276 | // for the class to which the entered object belongs. | |
1277 | // An example can be seen from AliTrack::Clone(). | |
1278 | // | |
1279 | if (fFit) | |
1280 | { | |
1281 | delete fFit; | |
1282 | fFit=0; | |
1283 | } | |
1284 | ||
1285 | if (obj) fFit=obj->Clone(); | |
1286 | } | |
1287 | /////////////////////////////////////////////////////////////////////////// | |
1288 | TObject* AliTrack::GetFitDetails() | |
1289 | { | |
1290 | // Provide the pointer to the object containing the fit details. | |
1291 | return fFit; | |
1292 | } | |
1293 | /////////////////////////////////////////////////////////////////////////// | |
a7dc0627 | 1294 | void AliTrack::SetTimestamp(AliTimestamp& t) |
1295 | { | |
1296 | // Store the timestamp for this track. | |
1297 | if (fTstamp) delete fTstamp; | |
1298 | fTstamp=new AliTimestamp(t); | |
1299 | } | |
1300 | /////////////////////////////////////////////////////////////////////////// | |
1301 | AliTimestamp* AliTrack::GetTimestamp() | |
1302 | { | |
1303 | // Provide the timestamp of this track. | |
1304 | return fTstamp; | |
1305 | } | |
1306 | /////////////////////////////////////////////////////////////////////////// | |
1307 | void AliTrack::RemoveTimestamp() | |
1308 | { | |
1309 | // Remove the timestamp from this track. | |
1310 | if (fTstamp) | |
1311 | { | |
1312 | delete fTstamp; | |
1313 | fTstamp=0; | |
1314 | } | |
1315 | } | |
1316 | /////////////////////////////////////////////////////////////////////////// | |
1c96d8dc | 1317 | Double_t AliTrack::GetDistance(AliPosition* p) |
1318 | { | |
1319 | // Provide distance of the current track to the position p. | |
1320 | // The error on the result can be obtained as usual by invoking | |
1321 | // GetResultError() afterwards. | |
1322 | // | |
1323 | // The distance will be provided in the unit scale of the AliPosition p. | |
1324 | // As such it is possible to obtain a correctly computed distance even in case | |
1325 | // the track parameters have a different unit scale. | |
1326 | // However, it is recommended to work always with one single unit scale. | |
1327 | // | |
1328 | // Note : In case of incomplete information, a distance value of -1 is | |
1329 | // returned. | |
1330 | ||
1331 | Double_t dist=-1.; | |
1332 | fDresult=0.; | |
1333 | ||
1334 | if (!p) return dist; | |
1335 | ||
1336 | // Obtain a defined position on this track | |
1337 | AliPosition* rx=fRef; | |
1338 | if (!rx) rx=fBegin; | |
1339 | if (!rx) rx=fEnd; | |
1340 | ||
1341 | if (!rx) return dist; | |
1342 | ||
9427ac75 | 1343 | Ali3Vector p1=Get3Momentum(); |
1344 | ||
1345 | if (p1.GetNorm() <= 0.) return dist; | |
1346 | ||
1c96d8dc | 1347 | Ali3Vector r0=(Ali3Vector)(*rx); |
1348 | ||
1349 | Float_t tscale=rx->GetUnitScale(); | |
1350 | Float_t pscale=p->GetUnitScale(); | |
1351 | if ((tscale/pscale > 1.1) || (pscale/tscale > 1.1)) r0=r0*(tscale/pscale); | |
1352 | ||
1353 | // Obtain the direction unit vector of this track | |
1354 | Double_t vec[3]; | |
1355 | Double_t err[3]; | |
1c96d8dc | 1356 | p1.GetVector(vec,"sph"); |
1357 | p1.GetErrors(err,"sph"); | |
1358 | vec[0]=1.; | |
1359 | err[0]=0.; | |
1360 | p1.SetVector(vec,"sph"); | |
1361 | p1.SetErrors(err,"sph"); | |
1362 | ||
1363 | Ali3Vector q=(Ali3Vector)(*p); | |
1364 | Ali3Vector r=q-r0; | |
1365 | Ali3Vector d=r.Cross(p1); | |
1366 | dist=d.GetNorm(); | |
1367 | fDresult=d.GetResultError(); | |
1368 | return dist; | |
1369 | } | |
1370 | /////////////////////////////////////////////////////////////////////////// | |
9427ac75 | 1371 | Double_t AliTrack::GetDistance(AliTrack* t) |
1372 | { | |
1373 | // Provide distance of the current track to the track t. | |
1374 | // The error on the result can be obtained as usual by invoking | |
1375 | // GetResultError() afterwards. | |
1376 | // | |
1377 | // The distance will be provided in the unit scale of the current track. | |
1378 | // As such it is possible to obtain a correctly computed distance even in case | |
1379 | // the track parameters have a different unit scale. | |
1380 | // This implies that in such cases the results of t1.GetDistance(t2) and | |
1381 | // t2.GetDistance(t1) will be numerically different. | |
1382 | // However, it is recommended to work always with one single unit scale. | |
1383 | // | |
1384 | // Note : In case of incomplete information, a distance value of -1 is | |
1385 | // returned. | |
1386 | ||
1387 | Double_t dist=-1.; | |
1388 | fDresult=0.; | |
1389 | ||
1390 | if (!t) return dist; | |
1391 | ||
1392 | // Obtain a defined position on this track | |
1393 | AliPosition* rx=fRef; | |
1394 | if (!rx) rx=fBegin; | |
1395 | if (!rx) rx=fEnd; | |
1396 | ||
1397 | if (!rx) return dist; | |
1398 | ||
1399 | // Obtain a defined position on track t | |
1400 | AliPosition* ry=t->GetReferencePoint(); | |
1401 | if (!ry) ry=t->GetBeginPoint(); | |
1402 | if (!ry) ry=t->GetEndPoint(); | |
1403 | ||
1404 | if (!ry) return dist; | |
1405 | ||
1406 | Ali3Vector p1=Get3Momentum(); | |
1407 | Ali3Vector p2=t->Get3Momentum(); | |
1408 | ||
1409 | if (p1.GetNorm() <= 0. || p2.GetNorm() <= 0.) return dist; | |
1410 | ||
1411 | // The vector normal to both track directions | |
1412 | Ali3Vector n=p1.Cross(p2); | |
1413 | ||
1414 | if (n.GetNorm() > 1.e-10) | |
1415 | { | |
1416 | // Normalise n to a unit vector | |
1417 | Double_t vec[3]; | |
1418 | Double_t err[3]; | |
1419 | n.GetVector(vec,"sph"); | |
1420 | n.GetErrors(err,"sph"); | |
1421 | vec[0]=1.; | |
1422 | err[0]=0.; | |
1423 | n.SetVector(vec,"sph"); | |
1424 | n.SetErrors(err,"sph"); | |
1425 | Ali3Vector r1=(Ali3Vector)(*rx); | |
1426 | Ali3Vector r2=(Ali3Vector)(*ry); | |
1427 | // Correct components of r2 in case of different unit scales | |
1428 | Float_t scale=rx->GetUnitScale(); | |
1429 | Float_t tscale=ry->GetUnitScale(); | |
1430 | if ((tscale/scale > 1.1) || (scale/tscale > 1.1)) r2=r2*(tscale/scale); | |
1431 | Ali3Vector r=r1-r2; | |
1432 | dist=fabs(r.Dot(n)); | |
1433 | fDresult=r.GetResultError(); | |
1434 | } | |
1435 | else // Parallel tracks | |
1436 | { | |
1437 | dist=t->GetDistance(rx); | |
1438 | fDresult=t->GetResultError(); | |
1439 | } | |
1440 | return dist; | |
1441 | } | |
1442 | /////////////////////////////////////////////////////////////////////////// | |
261c0caf | 1443 | TObject* AliTrack::Clone(const char* name) const |
5f25234b | 1444 | { |
1445 | // Make a deep copy of the current object and provide the pointer to the copy. | |
1446 | // This memberfunction enables automatic creation of new objects of the | |
1447 | // correct type depending on the object type, a feature which may be very useful | |
1448 | // for containers when adding objects in case the container owns the objects. | |
1449 | // This feature allows e.g. AliJet to store either AliTrack objects or | |
1450 | // objects derived from AliTrack via the AddTrack memberfunction, provided | |
1451 | // these derived classes also have a proper Clone memberfunction. | |
1452 | ||
1453 | AliTrack* trk=new AliTrack(*this); | |
1454 | if (name) | |
1455 | { | |
1456 | if (strlen(name)) trk->SetName(name); | |
1457 | } | |
1458 | return trk; | |
1459 | } | |
1460 | /////////////////////////////////////////////////////////////////////////// |