]>
Commit | Line | Data |
---|---|---|
df9db588 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-2007, 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 | /* $Id$ */ | |
17 | ||
18 | //------------------------------------------------------------------------- | |
19 | // AOD track base class | |
20 | // Base class for Analysis Object Data | |
21 | // Generic version | |
22 | // Author: Markus Oldenburg, CERN | |
23 | //------------------------------------------------------------------------- | |
24 | ||
25 | #include "AliAODVertex.h" | |
26 | ||
27 | ClassImp(AliAODVertex) | |
28 | ||
29 | //______________________________________________________________________________ | |
30 | AliAODVertex::AliAODVertex() : | |
31 | TObject(), | |
df9db588 | 32 | fChi2(-999.), |
9f7c531f | 33 | fCovMatrix(NULL), |
df9db588 | 34 | fParent(0x0), |
9f7c531f | 35 | fDaughters(), |
36 | fType(kUndef) | |
37 | { | |
df9db588 | 38 | // default constructor |
39 | ||
40 | fPosition[0] = fPosition[1] = fPosition[2] = -999.; | |
41 | } | |
42 | ||
43 | //______________________________________________________________________________ | |
44 | AliAODVertex::AliAODVertex(const Double_t position[3], | |
31fd97b2 | 45 | const Double_t covMatrix[6], |
df9db588 | 46 | Double_t chi2, |
47 | TObject *parent, | |
48 | Char_t vtype) : | |
49 | TObject(), | |
df9db588 | 50 | fChi2(chi2), |
9f7c531f | 51 | fCovMatrix(NULL), |
df9db588 | 52 | fParent(parent), |
9f7c531f | 53 | fDaughters(), |
54 | fType(vtype) | |
df9db588 | 55 | { |
56 | // constructor | |
57 | ||
58 | SetPosition(position); | |
59 | if (covMatrix) SetCovMatrix(covMatrix); | |
60 | } | |
61 | ||
62 | //______________________________________________________________________________ | |
63 | AliAODVertex::AliAODVertex(const Float_t position[3], | |
64 | const Float_t covMatrix[6], | |
65 | Double_t chi2, | |
66 | TObject *parent, | |
67 | Char_t vtype) : | |
4d209fca | 68 | |
df9db588 | 69 | TObject(), |
df9db588 | 70 | fChi2(chi2), |
9f7c531f | 71 | fCovMatrix(NULL), |
df9db588 | 72 | fParent(parent), |
9f7c531f | 73 | fDaughters(), |
74 | fType(vtype) | |
df9db588 | 75 | { |
76 | // constructor | |
77 | ||
78 | SetPosition(position); | |
79 | if (covMatrix) SetCovMatrix(covMatrix); | |
80 | } | |
81 | ||
82 | //______________________________________________________________________________ | |
83 | AliAODVertex::AliAODVertex(const Double_t position[3], | |
84 | Double_t chi2, | |
85 | Char_t vtype) : | |
86 | TObject(), | |
df9db588 | 87 | fChi2(chi2), |
9f7c531f | 88 | fCovMatrix(NULL), |
df9db588 | 89 | fParent(0x0), |
9f7c531f | 90 | fDaughters(), |
91 | fType(vtype) | |
df9db588 | 92 | { |
93 | // constructor without covariance matrix | |
94 | ||
95 | SetPosition(position); | |
96 | } | |
97 | ||
98 | //______________________________________________________________________________ | |
99 | AliAODVertex::AliAODVertex(const Float_t position[3], | |
100 | Double_t chi2, | |
101 | Char_t vtype) : | |
102 | TObject(), | |
df9db588 | 103 | fChi2(chi2), |
9f7c531f | 104 | fCovMatrix(NULL), |
df9db588 | 105 | fParent(0x0), |
9f7c531f | 106 | fDaughters(), |
107 | fType(vtype) | |
df9db588 | 108 | { |
109 | // constructor without covariance matrix | |
110 | ||
111 | SetPosition(position); | |
112 | } | |
113 | ||
114 | //______________________________________________________________________________ | |
115 | AliAODVertex::~AliAODVertex() | |
116 | { | |
117 | // Destructor | |
118 | ||
119 | delete fCovMatrix; | |
120 | } | |
121 | ||
122 | //______________________________________________________________________________ | |
123 | AliAODVertex::AliAODVertex(const AliAODVertex& vtx) : | |
124 | TObject(vtx), | |
df9db588 | 125 | fChi2(vtx.fChi2), |
9f7c531f | 126 | fCovMatrix(NULL), |
df9db588 | 127 | fParent(vtx.fParent), |
9f7c531f | 128 | fDaughters(vtx.fDaughters), |
129 | fType(vtx.fType) | |
df9db588 | 130 | { |
131 | // Copy constructor. | |
132 | ||
133 | for (int i = 0; i < 3; i++) | |
134 | fPosition[i] = vtx.fPosition[i]; | |
135 | ||
5d62ce04 | 136 | if (vtx.fCovMatrix) fCovMatrix=new AliAODRedCov<3>(*vtx.fCovMatrix); |
df9db588 | 137 | } |
138 | ||
139 | //______________________________________________________________________________ | |
140 | AliAODVertex& AliAODVertex::operator=(const AliAODVertex& vtx) | |
141 | { | |
142 | // Assignment operator | |
143 | if (this != &vtx) { | |
144 | ||
145 | // name and type | |
146 | TObject::operator=(vtx); | |
147 | ||
148 | //momentum | |
149 | for (int i = 0; i < 3; i++) | |
150 | fPosition[i] = vtx.fPosition[i]; | |
151 | ||
9f7c531f | 152 | fChi2 = vtx.fChi2; |
153 | ||
df9db588 | 154 | //covariance matrix |
155 | delete fCovMatrix; | |
9f7c531f | 156 | fCovMatrix = NULL; |
5d62ce04 | 157 | if (vtx.fCovMatrix) fCovMatrix=new AliAODRedCov<3>(*vtx.fCovMatrix); |
df9db588 | 158 | |
159 | //other stuff | |
df9db588 | 160 | fParent = vtx.fParent; |
161 | fDaughters = vtx.fDaughters; | |
162 | fType = vtx.fType; | |
163 | } | |
164 | ||
165 | return *this; | |
166 | } | |
167 | ||
168 | //______________________________________________________________________________ | |
169 | template <class T> void AliAODVertex::GetSigmaXYZ(T sigma[3]) const | |
170 | { | |
171 | // Return errors on vertex position in thrust frame | |
172 | ||
173 | if(fCovMatrix) { | |
174 | sigma[0]=fCovMatrix[3]; //GetCovXZ | |
175 | sigma[1]=fCovMatrix[4]; //GetCovYZ | |
176 | sigma[2]=fCovMatrix[5]; //GetCovZZ | |
177 | } else | |
178 | sigma[0]=sigma[1]=sigma[2]=-999.; | |
179 | ||
180 | /* | |
181 | for (int i = 0, j = 6; i < 3; i++) { | |
182 | j -= i+1; | |
183 | sigma[2-i] = fCovMatrix ? TMath::Sqrt(fCovMatrix[j]) : -999.; | |
184 | } | |
185 | */ | |
186 | } | |
187 | ||
188 | //______________________________________________________________________________ | |
189 | Bool_t AliAODVertex::HasDaughter(TObject *daughter) const | |
190 | { | |
191 | // Checks if the given daughter (particle) is part of this vertex. | |
192 | ||
193 | TRefArrayIter iter(&fDaughters); | |
194 | while (TObject *daugh = iter.Next()) { | |
195 | if (daugh == daughter) return kTRUE; | |
196 | } | |
197 | return kFALSE; | |
198 | } | |
199 | ||
200 | //______________________________________________________________________________ | |
201 | Double_t AliAODVertex::RotatedCovMatrixXX(Double_t phi, Double_t theta) const | |
202 | { | |
203 | // XX term of covariance matrix after rotation by phi around z-axis | |
204 | // and, then, by theta around new y-axis | |
205 | ||
206 | if (!fCovMatrix) { | |
207 | //AliFatal("Covariance matrix not set"); | |
208 | return -999.; | |
209 | } | |
210 | ||
211 | Double_t covMatrix[6]; | |
212 | ||
213 | GetCovMatrix(covMatrix); | |
214 | ||
215 | Double_t cp = TMath::Cos(phi); | |
216 | Double_t sp = TMath::Sin(phi); | |
217 | Double_t ct = TMath::Cos(theta); | |
218 | Double_t st = TMath::Sin(theta); | |
219 | return | |
220 | covMatrix[0]*cp*cp*ct*ct // GetCovXX | |
221 | +covMatrix[1]*2.*cp*sp*ct*ct // GetCovXY | |
222 | +covMatrix[3]*2.*cp*ct*st // GetCovXZ | |
223 | +covMatrix[2]*sp*sp*ct*ct // GetCovYY | |
224 | +covMatrix[4]*2.*sp*ct*st // GetCovYZ | |
225 | +covMatrix[5]*st*st; // GetCovZZ | |
226 | } | |
227 | ||
228 | //______________________________________________________________________________ | |
229 | Double_t AliAODVertex::RotatedCovMatrixXY(Double_t phi, Double_t theta) const | |
230 | { | |
231 | // XY term of covariance matrix after rotation by phi around z-axis | |
232 | // and, then, by theta around new y-axis | |
233 | ||
234 | if (!fCovMatrix) { | |
235 | //AliFatal("Covariance matrix not set"); | |
236 | return -999.; | |
237 | } | |
238 | ||
239 | Double_t covMatrix[6]; | |
240 | ||
241 | GetCovMatrix(covMatrix); | |
242 | ||
243 | Double_t cp = TMath::Cos(phi); | |
244 | Double_t sp = TMath::Sin(phi); | |
245 | Double_t ct = TMath::Cos(theta); | |
246 | Double_t st = TMath::Sin(theta); | |
247 | return | |
248 | -covMatrix[0]*cp*sp*ct // GetCovXX | |
249 | +covMatrix[1]*ct*(cp*cp-sp*sp) // GetCovXY | |
250 | -covMatrix[3]*sp*st // GetCovXZ | |
251 | +covMatrix[2]*cp*sp*ct // GetCovYY | |
252 | +covMatrix[4]*cp*st; // GetCovYZ | |
253 | } | |
254 | ||
255 | //______________________________________________________________________________ | |
256 | Double_t AliAODVertex::RotatedCovMatrixXZ(Double_t phi, Double_t theta) const | |
257 | { | |
258 | // XZ term of covariance matrix after rotation by phi around z-axis | |
259 | // and, then, by theta around new y-axis | |
260 | ||
261 | if (!fCovMatrix) { | |
262 | //AliFatal("Covariance matrix not set"); | |
263 | return -999.; | |
264 | } | |
265 | ||
266 | Double_t covMatrix[6]; | |
267 | ||
268 | GetCovMatrix(covMatrix); | |
269 | ||
270 | Double_t cp = TMath::Cos(phi); | |
271 | Double_t sp = TMath::Sin(phi); | |
272 | Double_t ct = TMath::Cos(theta); | |
273 | Double_t st = TMath::Sin(theta); | |
274 | return | |
275 | -covMatrix[0]*cp*cp*ct*st // GetCovXX | |
276 | -covMatrix[1]*2.*cp*sp*ct*st // GetCovXY | |
277 | +covMatrix[3]*cp*(ct*ct-st*st) // GetCovXZ | |
278 | -covMatrix[2]*sp*sp*ct*st // GetCovYY | |
279 | +covMatrix[4]*sp*(ct*ct-st*st) // GetCovYZ | |
280 | +covMatrix[5]*ct*st; // GetCovZZ | |
281 | } | |
282 | ||
283 | //______________________________________________________________________________ | |
284 | Double_t AliAODVertex::RotatedCovMatrixYY(Double_t phi) const | |
285 | { | |
286 | // YY term of covariance matrix after rotation by phi around z-axis | |
287 | // and, then, by theta around new y-axis | |
288 | ||
289 | if (!fCovMatrix) { | |
290 | //AliFatal("Covariance matrix not set"); | |
291 | return -999.; | |
292 | } | |
293 | ||
294 | Double_t covMatrix[6]; | |
295 | ||
296 | GetCovMatrix(covMatrix); | |
297 | ||
298 | Double_t cp = TMath::Cos(phi); | |
299 | Double_t sp = TMath::Sin(phi); | |
300 | return | |
301 | covMatrix[0]*sp*sp // GetCovXX | |
302 | -covMatrix[1]*2.*cp*sp // GetCovXY | |
303 | +covMatrix[2]*cp*cp; // GetCovYY | |
304 | } | |
305 | ||
306 | //______________________________________________________________________________ | |
307 | Double_t AliAODVertex::RotatedCovMatrixYZ(Double_t phi, Double_t theta) const | |
308 | { | |
309 | // YZ term of covariance matrix after rotation by phi around z-axis | |
310 | // and, then, by theta around new y-axis | |
311 | ||
312 | if (!fCovMatrix) { | |
313 | //AliFatal("Covariance matrix not set"); | |
314 | return -999.; | |
315 | } | |
316 | ||
317 | Double_t covMatrix[6]; | |
318 | ||
319 | GetCovMatrix(covMatrix); | |
320 | ||
321 | Double_t cp = TMath::Cos(phi); | |
322 | Double_t sp = TMath::Sin(phi); | |
323 | Double_t ct = TMath::Cos(theta); | |
324 | Double_t st = TMath::Sin(theta); | |
325 | return | |
326 | covMatrix[0]*cp*sp*st // GetCovXX | |
327 | +covMatrix[1]*st*(sp*sp-cp*cp) // GetCovXY | |
328 | -covMatrix[3]*sp*ct // GetCovXZ | |
329 | -covMatrix[2]*cp*sp*st // GetCovYY | |
330 | +covMatrix[4]*cp*ct; // GetCovYZ | |
331 | } | |
332 | ||
333 | //______________________________________________________________________________ | |
334 | Double_t AliAODVertex::RotatedCovMatrixZZ(Double_t phi, Double_t theta) const | |
335 | { | |
336 | // ZZ term of covariance matrix after rotation by phi around z-axis | |
337 | // and, then, by theta around new y-axis | |
338 | ||
339 | if (!fCovMatrix) { | |
340 | //AliFatal("Covariance matrix not set"); | |
341 | return -999.; | |
342 | } | |
343 | ||
344 | Double_t covMatrix[6]; | |
345 | ||
346 | GetCovMatrix(covMatrix); | |
347 | ||
348 | Double_t cp = TMath::Cos(phi); | |
349 | Double_t sp = TMath::Sin(phi); | |
350 | Double_t ct = TMath::Cos(theta); | |
351 | Double_t st = TMath::Sin(theta); | |
352 | return | |
353 | covMatrix[0]*cp*cp*st*st // GetCovXX | |
354 | +covMatrix[1]*2.*cp*sp*st*st // GetCovXY | |
355 | -covMatrix[3]*2.*cp*ct*st // GetCovXZ | |
356 | +covMatrix[2]*sp*sp*st*st // GetCovYY | |
357 | -covMatrix[4]*2.*sp*sp*ct*st // GetCovYZ | |
358 | +covMatrix[5]*ct*ct; // GetCovZZ | |
359 | } | |
360 | ||
361 | //______________________________________________________________________________ | |
362 | Double_t AliAODVertex::DistanceToVertex(AliAODVertex *vtx) const | |
363 | { | |
364 | // distance in 3D to another AliAODVertex | |
365 | ||
366 | Double_t dx = GetX()-vtx->GetX(); | |
367 | Double_t dy = GetY()-vtx->GetY(); | |
368 | Double_t dz = GetZ()-vtx->GetZ(); | |
369 | ||
370 | return TMath::Sqrt(dx*dx+dy*dy+dz*dz); | |
371 | } | |
372 | ||
373 | //______________________________________________________________________________ | |
374 | Double_t AliAODVertex::DistanceXYToVertex(AliAODVertex *vtx) const | |
375 | { | |
376 | // distance in XY to another AliAODVertex | |
377 | ||
378 | Double_t dx = GetX()-vtx->GetX(); | |
379 | Double_t dy = GetY()-vtx->GetY(); | |
380 | ||
381 | return TMath::Sqrt(dx*dx+dy*dy); | |
382 | } | |
383 | ||
384 | //______________________________________________________________________________ | |
385 | Double_t AliAODVertex::ErrorDistanceToVertex(AliAODVertex *vtx) const | |
386 | { | |
387 | // error on the distance in 3D to another AliAODVertex | |
388 | ||
389 | Double_t phi,theta; | |
390 | PhiAndThetaToVertex(vtx,phi,theta); | |
391 | // error2 due to this vertex | |
392 | Double_t error2 = RotatedCovMatrixXX(phi,theta); | |
393 | // error2 due to vtx vertex | |
394 | Double_t error2vtx = vtx->RotatedCovMatrixXX(phi,theta); | |
395 | ||
396 | return TMath::Sqrt(error2+error2vtx); | |
397 | } | |
398 | ||
399 | //______________________________________________________________________________ | |
400 | Double_t AliAODVertex::ErrorDistanceXYToVertex(AliAODVertex *vtx) const | |
401 | { | |
402 | // error on the distance in XY to another AliAODVertex | |
403 | ||
404 | Double_t phi,theta; | |
405 | PhiAndThetaToVertex(vtx,phi,theta); | |
406 | // error2 due to this vertex | |
407 | Double_t error2 = RotatedCovMatrixXX(phi); | |
408 | // error2 due to vtx vertex | |
409 | Double_t error2vtx = vtx->RotatedCovMatrixXX(phi); | |
410 | ||
411 | return TMath::Sqrt(error2+error2vtx); | |
412 | } | |
413 | ||
414 | //______________________________________________________________________________ | |
415 | template <class T, class P> | |
416 | void AliAODVertex::PhiAndThetaToVertex(AliAODVertex *vtx, P &phi, T &theta) const | |
417 | { | |
418 | // rotation angles around z-axis (phi) and around new y-axis (theta) | |
419 | // with which vtx is seen (used by RotatedCovMatrix... methods) | |
420 | ||
421 | phi = TMath::ATan2(vtx->GetY()-GetY(),vtx->GetX()-GetX()); | |
422 | Double_t vtxxphi = vtx->GetX()*TMath::Cos(phi)+vtx->GetY()*TMath::Sin(phi); | |
423 | Double_t xphi = GetX()*TMath::Cos(phi)+GetY()*TMath::Sin(phi); | |
424 | theta = TMath::ATan2(vtx->GetZ()-GetZ(),vtxxphi-xphi); | |
425 | } | |
426 | ||
427 | //______________________________________________________________________________ | |
428 | void AliAODVertex::PrintIndices() const | |
429 | { | |
430 | // Print indices of particles originating form this vertex | |
431 | ||
432 | TRefArrayIter iter(&fDaughters); | |
433 | while (TObject *daugh = iter.Next()) { | |
434 | printf("Particle %p originates from this vertex.\n", daugh); | |
435 | } | |
436 | } | |
437 | ||
438 | //______________________________________________________________________________ | |
439 | void AliAODVertex::Print(Option_t* /*option*/) const | |
440 | { | |
441 | // Print information of all data members | |
442 | ||
443 | printf("Vertex position:\n"); | |
444 | printf(" x = %f\n", fPosition[0]); | |
445 | printf(" y = %f\n", fPosition[1]); | |
446 | printf(" z = %f\n", fPosition[2]); | |
447 | printf(" parent particle: %p\n", fParent.GetObject()); | |
448 | printf(" origin of %d particles\n", fDaughters.GetEntriesFast()); | |
449 | printf(" vertex type %d\n", fType); | |
450 | ||
451 | /* | |
452 | if (fCovMatrix) { | |
453 | printf("Covariance matrix:\n"); | |
454 | printf(" %12.10f %12.10f %12.10f\n %12.10f %12.10f %12.10f\n %12.10f %12.10f %12.10f\n", | |
455 | fCovMatrix[0], | |
456 | fCovMatrix[1], | |
457 | fCovMatrix[3], | |
458 | fCovMatrix[1], | |
459 | fCovMatrix[2], | |
460 | fCovMatrix[4], | |
461 | fCovMatrix[3], | |
462 | fCovMatrix[4], | |
463 | fCovMatrix[5]); | |
464 | } */ | |
465 | printf(" Chi^2 = %f\n", fChi2); | |
466 | } | |
467 |