Bug corrected.
[u/mrichter/AliRoot.git] / STEER / AliESDcascade.cxx
CommitLineData
e23730c7 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
4f679a16 16/* $Id$ */
17
e23730c7 18//-------------------------------------------------------------------------
19// Implementation of the cascade vertex class
4f679a16 20// This is part of the Event Summary Data
21// which contains the result of the reconstruction
22// and is the main set of classes for analaysis
e23730c7 23// Origin: Christian Kuhn, IReS, Strasbourg, christian.kuhn@ires.in2p3.fr
3e27a419 24// Modified by: Antonin Maire,IPHC, Antonin.Maire@ires.in2p3.fr
25// and Boris Hippolyte,IPHC, hippolyt@in2p3.fr
e23730c7 26//-------------------------------------------------------------------------
4f679a16 27
90e48c0c 28#include <TDatabasePDG.h>
e23730c7 29#include <TMath.h>
3e27a419 30#include <TVector3.h>
e23730c7 31
32#include "AliESDcascade.h"
97135b34 33#include "AliLog.h"
e23730c7 34
35ClassImp(AliESDcascade)
36
90e48c0c 37AliESDcascade::AliESDcascade() :
c028b974 38 AliESDv0(),
8668c148 39 fEffMassXi(TDatabasePDG::Instance()->GetParticle(kXiMinus)->Mass()),
562dd0b4 40 fChi2Xi(1024),
41 fDcaXiDaughters(1024),
42 fPdgCodeXi(kXiMinus),
bfb36bff 43 fBachIdx(-1)
90e48c0c 44{
e23730c7 45 //--------------------------------------------------------------------
46 // Default constructor (Xi-)
47 //--------------------------------------------------------------------
bfb36bff 48 for (Int_t j=0; j<3; j++) {
c028b974 49 fPosXi[j]=0.;
bfb36bff 50 fBachMom[j]=0.;
51 }
52
562dd0b4 53 fPosCovXi[0]=1024;
c028b974 54 fPosCovXi[1]=fPosCovXi[2]=0.;
562dd0b4 55 fPosCovXi[3]=1024;
c028b974 56 fPosCovXi[4]=0.;
562dd0b4 57 fPosCovXi[5]=1024;
bfb36bff 58
562dd0b4 59 fBachMomCov[0]=1024;
bfb36bff 60 fBachMomCov[1]=fBachMomCov[2]=0.;
562dd0b4 61 fBachMomCov[3]=1024;
bfb36bff 62 fBachMomCov[4]=0.;
562dd0b4 63 fBachMomCov[5]=1024;
e23730c7 64}
65
3e27a419 66AliESDcascade::AliESDcascade(const AliESDcascade& cas) :
67 AliESDv0(cas),
68 fEffMassXi(cas.fEffMassXi),
69 fChi2Xi(cas.fChi2Xi),
70 fDcaXiDaughters(cas.fDcaXiDaughters),
71 fPdgCodeXi(cas.fPdgCodeXi),
72 fBachIdx(cas.fBachIdx)
73{
74 //--------------------------------------------------------------------
75 // The copy constructor
76 //--------------------------------------------------------------------
77 for (int i=0; i<3; i++) {
78 fPosXi[i] = cas.fPosXi[i];
79 fBachMom[i] = cas.fBachMom[i];
80 }
81 for (int i=0; i<6; i++) {
82 fPosCovXi[i] = cas.fPosCovXi[i];
83 fBachMomCov[i] = cas.fBachMomCov[i];
84 }
c028b974 85}
86
c7bafca9 87AliESDcascade::AliESDcascade(const AliESDv0 &v,
88 const AliExternalTrackParam &t, Int_t i) :
c028b974 89 AliESDv0(v),
562dd0b4 90 fEffMassXi(TDatabasePDG::Instance()->GetParticle(kXiMinus)->Mass()),
91 fChi2Xi(1024),
92 fDcaXiDaughters(1024),
8668c148 93 fPdgCodeXi(kXiMinus),
c7bafca9 94 fBachIdx(i)
95{
3e27a419 96 //--------------------------------------------------------------------
c7bafca9 97 // Main constructor (Xi-)
3e27a419 98 //--------------------------------------------------------------------
c7bafca9 99
100 Double_t r[3]; t.GetXYZ(r);
101 Double_t x1=r[0], y1=r[1], z1=r[2]; // position of the bachelor
102 Double_t p[3]; t.GetPxPyPz(p);
103 Double_t px1=p[0], py1=p[1], pz1=p[2];// momentum of the bachelor track
104
105 Double_t x2,y2,z2; // position of the V0
106 v.GetXYZ(x2,y2,z2);
107 Double_t px2,py2,pz2; // momentum of V0
108 v.GetPxPyPz(px2,py2,pz2);
109
110 Double_t a2=((x1-x2)*px2+(y1-y2)*py2+(z1-z2)*pz2)/(px2*px2+py2*py2+pz2*pz2);
111
112 Double_t xm=x2+a2*px2;
113 Double_t ym=y2+a2*py2;
114 Double_t zm=z2+a2*pz2;
115
116 // position of the cascade decay
117
c028b974 118 fPosXi[0]=0.5*(x1+xm); fPosXi[1]=0.5*(y1+ym); fPosXi[2]=0.5*(z1+zm);
c7bafca9 119
120
121 // invariant mass of the cascade (default is Ximinus)
122
123 Double_t e1=TMath::Sqrt(0.13957*0.13957 + px1*px1 + py1*py1 + pz1*pz1);
124 Double_t e2=TMath::Sqrt(1.11568*1.11568 + px2*px2 + py2*py2 + pz2*pz2);
125
8668c148 126 fEffMassXi=TMath::Sqrt((e1+e2)*(e1+e2)-
c7bafca9 127 (px1+px2)*(px1+px2)-(py1+py2)*(py1+py2)-(pz1+pz2)*(pz1+pz2));
128
129
130 // momenta of the bachelor and the V0
131
132 fBachMom[0]=px1; fBachMom[1]=py1; fBachMom[2]=pz1;
c7bafca9 133
d8e40f75 134 // Setting pdg code and fixing charge
135 if (t.Charge()<0)
136 fPdgCodeXi = kXiMinus;
137 else
138 fPdgCodeXi = kXiPlusBar;
139
bfb36bff 140 //PH Covariance matrices: to be calculated correctly in the future
562dd0b4 141 fPosCovXi[0]=1024;
c028b974 142 fPosCovXi[1]=fPosCovXi[2]=0.;
562dd0b4 143 fPosCovXi[3]=1024;
c028b974 144 fPosCovXi[4]=0.;
562dd0b4 145 fPosCovXi[5]=1024;
bfb36bff 146
562dd0b4 147 fBachMomCov[0]=1024;
bfb36bff 148 fBachMomCov[1]=fBachMomCov[2]=0.;
562dd0b4 149 fBachMomCov[3]=1024;
bfb36bff 150 fBachMomCov[4]=0.;
562dd0b4 151 fBachMomCov[5]=1024;
c7bafca9 152
d8e40f75 153 fChi2Xi=1024.;
c7bafca9 154
155}
156
3e27a419 157AliESDcascade& AliESDcascade::operator=(const AliESDcascade& cas)
c028b974 158{
3e27a419 159 //--------------------------------------------------------------------
160 // The assignment operator
161 //--------------------------------------------------------------------
732a24fe 162
163 if(this==&cas) return *this;
164 AliESDv0::operator=(cas);
165
166 fEffMassXi = cas.fEffMassXi;
167 fChi2Xi = cas.fChi2Xi;
168 fDcaXiDaughters = cas.fDcaXiDaughters;
169 fPdgCodeXi = cas.fPdgCodeXi;
170 fBachIdx = cas.fBachIdx;
171 for (int i=0; i<3; i++) {
172 fPosXi[i] = cas.fPosXi[i];
173 fBachMom[i] = cas.fBachMom[i];
174 }
175 for (int i=0; i<6; i++) {
176 fPosCovXi[i] = cas.fPosCovXi[i];
177 fBachMomCov[i] = cas.fBachMomCov[i];
178 }
179 return *this;
180}
181
182void AliESDcascade::Copy(TObject &obj) const {
183
184 // this overwrites the virtual TOBject::Copy()
185 // to allow run time copying without casting
186 // in AliESDEvent
187
188 if(this==&obj)return;
189 AliESDcascade *robj = dynamic_cast<AliESDcascade*>(&obj);
190 if(!robj)return; // not an AliESDcascade
191 *robj = *this;
3e27a419 192}
732a24fe 193
3e27a419 194AliESDcascade::~AliESDcascade() {
195 //--------------------------------------------------------------------
196 // Empty destructor
197 //--------------------------------------------------------------------
732a24fe 198}
199
646c9704 200// Start with AliVParticle functions
201Double_t AliESDcascade::E() const {
202 //--------------------------------------------------------------------
203 // This gives the energy assuming the ChangeMassHypothesis was called
204 //--------------------------------------------------------------------
3e27a419 205 return E(fPdgCodeXi);
206}
207
208Double_t AliESDcascade::Y() const {
209 //--------------------------------------------------------------------
210 // This gives the energy assuming the ChangeMassHypothesis was called
211 //--------------------------------------------------------------------
212 return Y(fPdgCodeXi);
213}
214
215// Then extend AliVParticle functions
216Double_t AliESDcascade::E(Int_t pdg) const {
217 //--------------------------------------------------------------------
218 // This gives the energy with the particle hypothesis as argument
219 //--------------------------------------------------------------------
220 Double_t mass = TDatabasePDG::Instance()->GetParticle(pdg)->Mass();
646c9704 221 return TMath::Sqrt(mass*mass+P()*P());
222}
223
3e27a419 224Double_t AliESDcascade::Y(Int_t pdg) const {
225 //--------------------------------------------------------------------
226 // This gives the rapidity with the particle hypothesis as argument
227 //--------------------------------------------------------------------
228 return 0.5*TMath::Log((E(pdg)+Pz())/(E(pdg)-Pz()+1.e-13));
229}
230
231// Now the functions for analysis consistency
232Double_t AliESDcascade::RapXi() const {
233 //--------------------------------------------------------------------
234 // This gives the pseudorapidity assuming a (Anti) Xi particle
235 //--------------------------------------------------------------------
236 return Y(kXiMinus);
237}
238
239Double_t AliESDcascade::RapOmega() const {
240 //--------------------------------------------------------------------
241 // This gives the pseudorapidity assuming a (Anti) Omega particle
242 //--------------------------------------------------------------------
243 return Y(kOmegaMinus);
244}
245
246Double_t AliESDcascade::AlphaXi() const {
247 //--------------------------------------------------------------------
248 // This gives the Armenteros-Podolanski alpha
249 //--------------------------------------------------------------------
250 TVector3 momBach(fBachMom[0],fBachMom[1],fBachMom[2]);
251 TVector3 momV0(fNmom[0]+fPmom[0],fNmom[1]+fPmom[1],fNmom[2]+fPmom[2]);
252 TVector3 momTot(Px(),Py(),Pz());
253
97135b34 254 Double_t lQlBach = momBach.Dot(momTot)/momTot.Mag();
255 Double_t lQlV0 = momV0.Dot(momTot)/momTot.Mag();
3e27a419 256
97135b34 257 return 1.-2./(1.+lQlBach/lQlV0);
3e27a419 258}
259
260Double_t AliESDcascade::PtArmXi() const {
261 //--------------------------------------------------------------------
262 // This gives the Armenteros-Podolanski ptarm
263 //--------------------------------------------------------------------
264 TVector3 momBach(fBachMom[0],fBachMom[1],fBachMom[2]);
265 TVector3 momTot(Px(),Py(),Pz());
266
267 return momBach.Perp(momTot);
268}
269
646c9704 270// Then the older functions
e23730c7 271Double_t AliESDcascade::ChangeMassHypothesis(Double_t &v0q, Int_t code) {
272 //--------------------------------------------------------------------
273 // This function changes the mass hypothesis for this cascade
274 // and returns the "kinematical quality" of this hypothesis
275 // together with the "quality" of associated V0 (argument v0q)
276 //--------------------------------------------------------------------
277 Double_t nmass=0.13957, pmass=0.93827, ps0=0.101;
278 Double_t bmass=0.13957, mass =1.3213, ps =0.139;
279
d8e40f75 280 if (Charge()*code<0)
281 fPdgCodeXi = code;
282 else {
283 AliWarning("Chosen PDG code does not match the sign of the bachelor... Corrected !!");
284 fPdgCodeXi = -code;
285 }
e23730c7 286
d8e40f75 287 switch (fPdgCodeXi) {
e23730c7 288 case kXiMinus:
289 break;
290 case kXiPlusBar:
291 nmass=0.93827; pmass=0.13957;
292 break;
293 case kOmegaMinus:
294 bmass=0.49368; mass=1.67245; ps=0.211;
295 break;
296 case kOmegaPlusBar:
297 nmass=0.93827; pmass=0.13957;
298 bmass=0.49368; mass=1.67245; ps=0.211;
299 break;
300 default:
d8e40f75 301 AliError("Invalide PDG code ! Assuming a Xi particle...");
302 if (Charge()<0) {
303 fPdgCodeXi=kXiMinus;
304 }
305 else {
306 fPdgCodeXi=kXiPlusBar;
307 nmass=0.93827; pmass=0.13957;
308 }
e23730c7 309 break;
310 }
311
c028b974 312 Double_t pxn=fNmom[0], pyn=fNmom[1], pzn=fNmom[2];
313 Double_t pxp=fPmom[0], pyp=fPmom[1], pzp=fPmom[2];
8668c148 314
e23730c7 315 Double_t px0=pxn+pxp, py0=pyn+pyp, pz0=pzn+pzp;
316 Double_t p0=TMath::Sqrt(px0*px0 + py0*py0 + pz0*pz0);
317
318 Double_t e0=TMath::Sqrt(1.11568*1.11568 + p0*p0);
319 Double_t beta0=p0/e0;
320 Double_t pln=(pxn*px0 + pyn*py0 + pzn*pz0)/p0;
321 Double_t plp=(pxp*px0 + pyp*py0 + pzp*pz0)/p0;
322 Double_t pt2=pxp*pxp + pyp*pyp + pzp*pzp - plp*plp;
323
324 Double_t a=(plp-pln)/(plp+pln);
325 a -= (pmass*pmass-nmass*nmass)/(1.11568*1.11568);
326 a = 0.25*beta0*beta0*1.11568*1.11568*a*a + pt2;
327
328
329 v0q=a - ps0*ps0;
330
331
332 Double_t pxb=fBachMom[0], pyb=fBachMom[1], pzb=fBachMom[2];
333
334 Double_t eb=TMath::Sqrt(bmass*bmass + pxb*pxb + pyb*pyb + pzb*pzb);
335 Double_t pxl=px0+pxb, pyl=py0+pyb, pzl=pz0+pzb;
336 Double_t pl=TMath::Sqrt(pxl*pxl + pyl*pyl + pzl*pzl);
337
60e55aee 338 fEffMassXi=TMath::Sqrt(((e0+eb)-pl)*((e0+eb)+pl));
e23730c7 339
340 Double_t beta=pl/(e0+eb);
341 Double_t pl0=(px0*pxl + py0*pyl + pz0*pzl)/pl;
342 Double_t plb=(pxb*pxl + pyb*pyl + pzb*pzl)/pl;
343 pt2=p0*p0 - pl0*pl0;
344
345 a=(pl0-plb)/(pl0+plb);
346 a -= (1.11568*1.11568-bmass*bmass)/(mass*mass);
347 a = 0.25*beta*beta*mass*mass*a*a + pt2;
348
349 return (a - ps*ps);
350}
351
352void
353AliESDcascade::GetPxPyPz(Double_t &px, Double_t &py, Double_t &pz) const {
354 //--------------------------------------------------------------------
355 // This function returns the cascade momentum (global)
356 //--------------------------------------------------------------------
8668c148 357 px=fNmom[0]+fPmom[0]+fBachMom[0];
c028b974 358 py=fNmom[1]+fPmom[1]+fBachMom[1];
359 pz=fNmom[2]+fPmom[2]+fBachMom[2];
e23730c7 360}
361
c028b974 362void AliESDcascade::GetXYZcascade(Double_t &x, Double_t &y, Double_t &z) const {
e23730c7 363 //--------------------------------------------------------------------
364 // This function returns cascade position (global)
365 //--------------------------------------------------------------------
c028b974 366 x=fPosXi[0];
367 y=fPosXi[1];
368 z=fPosXi[2];
e23730c7 369}
370
c028b974 371Double_t AliESDcascade::GetDcascade(Double_t x0, Double_t y0, Double_t z0) const {
e23730c7 372 //--------------------------------------------------------------------
373 // This function returns the cascade impact parameter
374 //--------------------------------------------------------------------
375
c028b974 376 Double_t x=fPosXi[0],y=fPosXi[1],z=fPosXi[2];
377 Double_t px=fNmom[0]+fPmom[0]+fBachMom[0];
378 Double_t py=fNmom[1]+fPmom[1]+fBachMom[1];
379 Double_t pz=fNmom[2]+fPmom[2]+fBachMom[2];
e23730c7 380
381 Double_t dx=(y0-y)*pz - (z0-z)*py;
382 Double_t dy=(x0-x)*pz - (z0-z)*px;
383 Double_t dz=(x0-x)*py - (y0-y)*px;
384 Double_t d=TMath::Sqrt((dx*dx+dy*dy+dz*dz)/(px*px+py*py+pz*pz));
385
386 return d;
387}
388
97135b34 389Double_t AliESDcascade::GetCascadeCosineOfPointingAngle(Double_t refPointX, Double_t refPointY, Double_t refPointZ) const {
c028b974 390 // calculates the pointing angle of the cascade wrt a reference point
391
392 Double_t momCas[3]; //momentum of the cascade
393 GetPxPyPz(momCas[0],momCas[1],momCas[2]);
394
395 Double_t deltaPos[3]; //vector between the reference point and the cascade vertex
396 deltaPos[0] = fPosXi[0] - refPointX;
397 deltaPos[1] = fPosXi[1] - refPointY;
398 deltaPos[2] = fPosXi[2] - refPointZ;
399
400 Double_t momCas2 = momCas[0]*momCas[0] + momCas[1]*momCas[1] + momCas[2]*momCas[2];
401 Double_t deltaPos2 = deltaPos[0]*deltaPos[0] + deltaPos[1]*deltaPos[1] + deltaPos[2]*deltaPos[2];
402
403 Double_t cosinePointingAngle = (deltaPos[0]*momCas[0] +
404 deltaPos[1]*momCas[1] +
405 deltaPos[2]*momCas[2] ) /
406 TMath::Sqrt(momCas2 * deltaPos2);
407
408 return cosinePointingAngle;
409}
074f017b 410
411void AliESDcascade::GetPosCovXi(Double_t cov[6]) const {
412
413 for (Int_t i=0; i<6; ++i) cov[i] = fPosCovXi[i];
414}