Fix effc++ warnings and most blatant coding-convention violations.
[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
24//-------------------------------------------------------------------------
4f679a16 25
90e48c0c 26#include <TDatabasePDG.h>
e23730c7 27#include <TMath.h>
28
5f7789fc 29#include "AliLog.h"
c7bafca9 30#include "AliExternalTrackParam.h"
31#include "AliESDv0.h"
e23730c7 32#include "AliESDcascade.h"
e23730c7 33
34ClassImp(AliESDcascade)
35
90e48c0c 36AliESDcascade::AliESDcascade() :
c028b974 37 AliESDv0(),
90e48c0c 38 fPdgCode(kXiMinus),
39 fEffMass(TDatabasePDG::Instance()->GetParticle(kXiMinus)->Mass()),
c028b974 40 fChi2Xi(1.e+33),
41 fDcaXiDaughters(999),
bfb36bff 42 fBachIdx(-1)
90e48c0c 43{
e23730c7 44 //--------------------------------------------------------------------
45 // Default constructor (Xi-)
46 //--------------------------------------------------------------------
bfb36bff 47 for (Int_t j=0; j<3; j++) {
c028b974 48 fPosXi[j]=0.;
bfb36bff 49 fBachMom[j]=0.;
50 }
51
c028b974 52 fPosCovXi[0]=1e10;
53 fPosCovXi[1]=fPosCovXi[2]=0.;
54 fPosCovXi[3]=1e10;
55 fPosCovXi[4]=0.;
56 fPosCovXi[5]=1e10;
bfb36bff 57
58 fBachMomCov[0]=1e10;
59 fBachMomCov[1]=fBachMomCov[2]=0.;
60 fBachMomCov[3]=1e10;
61 fBachMomCov[4]=0.;
62 fBachMomCov[5]=1e10;
e23730c7 63}
64
c028b974 65AliESDcascade::~AliESDcascade() {
66}
67
c7bafca9 68AliESDcascade::AliESDcascade(const AliESDv0 &v,
69 const AliExternalTrackParam &t, Int_t i) :
c028b974 70 AliESDv0(v),
c7bafca9 71 fPdgCode(kXiMinus),
c028b974 72 fChi2Xi(1.e+33),
c7bafca9 73 fBachIdx(i)
74{
c028b974 75 //---------------------------------------------------------------------------------------------
c7bafca9 76 // Main constructor (Xi-)
c028b974 77 //---------------------------------------------------------------------------------------------
c7bafca9 78
79 Double_t r[3]; t.GetXYZ(r);
80 Double_t x1=r[0], y1=r[1], z1=r[2]; // position of the bachelor
81 Double_t p[3]; t.GetPxPyPz(p);
82 Double_t px1=p[0], py1=p[1], pz1=p[2];// momentum of the bachelor track
83
84 Double_t x2,y2,z2; // position of the V0
85 v.GetXYZ(x2,y2,z2);
86 Double_t px2,py2,pz2; // momentum of V0
87 v.GetPxPyPz(px2,py2,pz2);
88
89 Double_t a2=((x1-x2)*px2+(y1-y2)*py2+(z1-z2)*pz2)/(px2*px2+py2*py2+pz2*pz2);
90
91 Double_t xm=x2+a2*px2;
92 Double_t ym=y2+a2*py2;
93 Double_t zm=z2+a2*pz2;
94
c028b974 95 //dca between V0 and bachelor
96
97 fDcaXiDaughters = TMath::Sqrt((x1-xm)*(x1-xm) + (y1-ym)*(y1-ym) + (z1-zm)*(z1-zm));
98
c7bafca9 99 // position of the cascade decay
100
c028b974 101 fPosXi[0]=0.5*(x1+xm); fPosXi[1]=0.5*(y1+ym); fPosXi[2]=0.5*(z1+zm);
c7bafca9 102
103
104 // invariant mass of the cascade (default is Ximinus)
105
106 Double_t e1=TMath::Sqrt(0.13957*0.13957 + px1*px1 + py1*py1 + pz1*pz1);
107 Double_t e2=TMath::Sqrt(1.11568*1.11568 + px2*px2 + py2*py2 + pz2*pz2);
108
109 fEffMass=TMath::Sqrt((e1+e2)*(e1+e2)-
110 (px1+px2)*(px1+px2)-(py1+py2)*(py1+py2)-(pz1+pz2)*(pz1+pz2));
111
112
113 // momenta of the bachelor and the V0
114
115 fBachMom[0]=px1; fBachMom[1]=py1; fBachMom[2]=pz1;
c7bafca9 116
bfb36bff 117 //PH Covariance matrices: to be calculated correctly in the future
c028b974 118 fPosCovXi[0]=1e10;
119 fPosCovXi[1]=fPosCovXi[2]=0.;
120 fPosCovXi[3]=1e10;
121 fPosCovXi[4]=0.;
122 fPosCovXi[5]=1e10;
bfb36bff 123
124 fBachMomCov[0]=1e10;
125 fBachMomCov[1]=fBachMomCov[2]=0.;
126 fBachMomCov[3]=1e10;
127 fBachMomCov[4]=0.;
128 fBachMomCov[5]=1e10;
c7bafca9 129
c028b974 130 fChi2Xi=7.;
c7bafca9 131
132}
133
c028b974 134AliESDcascade::AliESDcascade(const AliESDcascade& cas) :
135 AliESDv0(cas)
136{
137 //copy constructor
138 fPdgCode = cas.fPdgCode;
139 fEffMass = cas.fEffMass;
140 fChi2Xi = cas.fChi2Xi;
141 fDcaXiDaughters = cas.fDcaXiDaughters;
142 fBachIdx = cas.fBachIdx;
143 for (int i=0; i<3; i++) {
144 fPosXi[i] = cas.fPosXi[i];
145 fBachMom[i] = cas.fBachMom[i];
146 }
147 for (int i=0; i<6; i++) {
148 fPosCovXi[i] = cas.fPosCovXi[i];
149 fBachMomCov[i] = cas.fBachMomCov[i];
150 }
151}
152
153AliESDcascade& AliESDcascade::operator=(const AliESDcascade& cas) {
154 //assignment operator
155 if (this != &cas) {
156 AliESDv0::operator=(cas);
157 fPdgCode = cas.fPdgCode;
158 fEffMass = cas.fEffMass;
159 fChi2Xi = cas.fChi2Xi;
160 fDcaXiDaughters = cas.fDcaXiDaughters;
161 fBachIdx = cas.fBachIdx;
162 for (int i=0; i<3; i++) {
163 fPosXi[i] = cas.fPosXi[i];
164 fBachMom[i] = cas.fBachMom[i];
165 }
166 for (int i=0; i<6; i++) {
167 fPosCovXi[i] = cas.fPosCovXi[i];
168 fBachMomCov[i] = cas.fBachMomCov[i];
169 }
170 }
171 return *this;
172}
173
e23730c7 174Double_t AliESDcascade::ChangeMassHypothesis(Double_t &v0q, Int_t code) {
175 //--------------------------------------------------------------------
176 // This function changes the mass hypothesis for this cascade
177 // and returns the "kinematical quality" of this hypothesis
178 // together with the "quality" of associated V0 (argument v0q)
179 //--------------------------------------------------------------------
180 Double_t nmass=0.13957, pmass=0.93827, ps0=0.101;
181 Double_t bmass=0.13957, mass =1.3213, ps =0.139;
182
183 fPdgCode=code;
184
185 switch (code) {
186 case 213:
187 bmass=0.93827;
188 break;
189 case kXiMinus:
190 break;
191 case kXiPlusBar:
192 nmass=0.93827; pmass=0.13957;
193 break;
194 case kOmegaMinus:
195 bmass=0.49368; mass=1.67245; ps=0.211;
196 break;
197 case kOmegaPlusBar:
198 nmass=0.93827; pmass=0.13957;
199 bmass=0.49368; mass=1.67245; ps=0.211;
200 break;
201 default:
5f7789fc 202 AliError("Invalide PDG code ! Assuming XiMinus's...");
e23730c7 203 fPdgCode=kXiMinus;
204 break;
205 }
206
c028b974 207 Double_t pxn=fNmom[0], pyn=fNmom[1], pzn=fNmom[2];
208 Double_t pxp=fPmom[0], pyp=fPmom[1], pzp=fPmom[2];
e23730c7 209 Double_t px0=pxn+pxp, py0=pyn+pyp, pz0=pzn+pzp;
210 Double_t p0=TMath::Sqrt(px0*px0 + py0*py0 + pz0*pz0);
211
212 Double_t e0=TMath::Sqrt(1.11568*1.11568 + p0*p0);
213 Double_t beta0=p0/e0;
214 Double_t pln=(pxn*px0 + pyn*py0 + pzn*pz0)/p0;
215 Double_t plp=(pxp*px0 + pyp*py0 + pzp*pz0)/p0;
216 Double_t pt2=pxp*pxp + pyp*pyp + pzp*pzp - plp*plp;
217
218 Double_t a=(plp-pln)/(plp+pln);
219 a -= (pmass*pmass-nmass*nmass)/(1.11568*1.11568);
220 a = 0.25*beta0*beta0*1.11568*1.11568*a*a + pt2;
221
222
223 v0q=a - ps0*ps0;
224
225
226 Double_t pxb=fBachMom[0], pyb=fBachMom[1], pzb=fBachMom[2];
227
228 Double_t eb=TMath::Sqrt(bmass*bmass + pxb*pxb + pyb*pyb + pzb*pzb);
229 Double_t pxl=px0+pxb, pyl=py0+pyb, pzl=pz0+pzb;
230 Double_t pl=TMath::Sqrt(pxl*pxl + pyl*pyl + pzl*pzl);
231
232 fEffMass=TMath::Sqrt((e0+eb)*(e0+eb) - pl*pl);
233
234 Double_t beta=pl/(e0+eb);
235 Double_t pl0=(px0*pxl + py0*pyl + pz0*pzl)/pl;
236 Double_t plb=(pxb*pxl + pyb*pyl + pzb*pzl)/pl;
237 pt2=p0*p0 - pl0*pl0;
238
239 a=(pl0-plb)/(pl0+plb);
240 a -= (1.11568*1.11568-bmass*bmass)/(mass*mass);
241 a = 0.25*beta*beta*mass*mass*a*a + pt2;
242
243 return (a - ps*ps);
244}
245
246void
247AliESDcascade::GetPxPyPz(Double_t &px, Double_t &py, Double_t &pz) const {
248 //--------------------------------------------------------------------
249 // This function returns the cascade momentum (global)
250 //--------------------------------------------------------------------
c028b974 251 px=fNmom[0]+fPmom[0]+fBachMom[0];
252 py=fNmom[1]+fPmom[1]+fBachMom[1];
253 pz=fNmom[2]+fPmom[2]+fBachMom[2];
e23730c7 254}
255
c028b974 256void AliESDcascade::GetXYZcascade(Double_t &x, Double_t &y, Double_t &z) const {
e23730c7 257 //--------------------------------------------------------------------
258 // This function returns cascade position (global)
259 //--------------------------------------------------------------------
c028b974 260 x=fPosXi[0];
261 y=fPosXi[1];
262 z=fPosXi[2];
e23730c7 263}
264
c028b974 265Double_t AliESDcascade::GetDcascade(Double_t x0, Double_t y0, Double_t z0) const {
e23730c7 266 //--------------------------------------------------------------------
267 // This function returns the cascade impact parameter
268 //--------------------------------------------------------------------
269
c028b974 270 Double_t x=fPosXi[0],y=fPosXi[1],z=fPosXi[2];
271 Double_t px=fNmom[0]+fPmom[0]+fBachMom[0];
272 Double_t py=fNmom[1]+fPmom[1]+fBachMom[1];
273 Double_t pz=fNmom[2]+fPmom[2]+fBachMom[2];
e23730c7 274
275 Double_t dx=(y0-y)*pz - (z0-z)*py;
276 Double_t dy=(x0-x)*pz - (z0-z)*px;
277 Double_t dz=(x0-x)*py - (y0-y)*px;
278 Double_t d=TMath::Sqrt((dx*dx+dy*dy+dz*dz)/(px*px+py*py+pz*pz));
279
280 return d;
281}
282
c028b974 283Double_t AliESDcascade::GetCascadeCosineOfPointingAngle(Double_t& refPointX, Double_t& refPointY, Double_t& refPointZ) const {
284 // calculates the pointing angle of the cascade wrt a reference point
285
286 Double_t momCas[3]; //momentum of the cascade
287 GetPxPyPz(momCas[0],momCas[1],momCas[2]);
288
289 Double_t deltaPos[3]; //vector between the reference point and the cascade vertex
290 deltaPos[0] = fPosXi[0] - refPointX;
291 deltaPos[1] = fPosXi[1] - refPointY;
292 deltaPos[2] = fPosXi[2] - refPointZ;
293
294 Double_t momCas2 = momCas[0]*momCas[0] + momCas[1]*momCas[1] + momCas[2]*momCas[2];
295 Double_t deltaPos2 = deltaPos[0]*deltaPos[0] + deltaPos[1]*deltaPos[1] + deltaPos[2]*deltaPos[2];
296
297 Double_t cosinePointingAngle = (deltaPos[0]*momCas[0] +
298 deltaPos[1]*momCas[1] +
299 deltaPos[2]*momCas[2] ) /
300 TMath::Sqrt(momCas2 * deltaPos2);
301
302 return cosinePointingAngle;
303}