]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDcascade.cxx
Classes for CTP time parameters added (Plamen)
[u/mrichter/AliRoot.git] / STEER / AliESDcascade.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          *
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 /* $Id$ */
17
18 //-------------------------------------------------------------------------
19 //               Implementation of the cascade vertex class
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
23 //    Origin: Christian Kuhn, IReS, Strasbourg, christian.kuhn@ires.in2p3.fr
24 //     Modified by: Antonin Maire,IPHC, Antonin.Maire@ires.in2p3.fr
25 //            and  Boris Hippolyte,IPHC, hippolyt@in2p3.fr 
26 //-------------------------------------------------------------------------
27
28 #include <TDatabasePDG.h>
29 #include <TMath.h>
30 #include <TVector3.h>
31
32 #include "AliESDcascade.h"
33 #include "AliLog.h"
34
35 ClassImp(AliESDcascade)
36
37 AliESDcascade::AliESDcascade() : 
38   AliESDv0(),
39   fEffMassXi(TDatabasePDG::Instance()->GetParticle(kXiMinus)->Mass()),
40   fChi2Xi(1024),
41   fDcaXiDaughters(1024),
42   fPdgCodeXi(kXiMinus),
43   fBachIdx(-1)
44 {
45   //--------------------------------------------------------------------
46   // Default constructor  (Xi-)
47   //--------------------------------------------------------------------
48   for (Int_t j=0; j<3; j++) {
49     fPosXi[j]=0.;
50     fBachMom[j]=0.;
51   }
52
53   fPosCovXi[0]=1024;
54   fPosCovXi[1]=fPosCovXi[2]=0.;
55   fPosCovXi[3]=1024;
56   fPosCovXi[4]=0.;
57   fPosCovXi[5]=1024;
58
59   fBachMomCov[0]=1024;
60   fBachMomCov[1]=fBachMomCov[2]=0.;
61   fBachMomCov[3]=1024;
62   fBachMomCov[4]=0.;
63   fBachMomCov[5]=1024;
64 }
65
66 AliESDcascade::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   }
85 }
86
87 AliESDcascade::AliESDcascade(const AliESDv0 &v,
88                              const AliExternalTrackParam &t, Int_t i) : 
89   AliESDv0(v),
90   fEffMassXi(TDatabasePDG::Instance()->GetParticle(kXiMinus)->Mass()),
91   fChi2Xi(1024),
92   fDcaXiDaughters(1024),
93   fPdgCodeXi(kXiMinus),
94   fBachIdx(i)
95 {
96   //--------------------------------------------------------------------
97   // Main constructor  (Xi-)
98   //--------------------------------------------------------------------
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   
118   fPosXi[0]=0.5*(x1+xm); fPosXi[1]=0.5*(y1+ym); fPosXi[2]=0.5*(z1+zm);
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   
126   fEffMassXi=TMath::Sqrt((e1+e2)*(e1+e2)-
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; 
133
134   // Setting pdg code and fixing charge
135   if (t.Charge()<0)
136     fPdgCodeXi = kXiMinus;
137   else
138     fPdgCodeXi = kXiPlusBar;
139
140   //PH Covariance matrices: to be calculated correctly in the future
141   fPosCovXi[0]=1024;
142   fPosCovXi[1]=fPosCovXi[2]=0.;
143   fPosCovXi[3]=1024;
144   fPosCovXi[4]=0.;
145   fPosCovXi[5]=1024;
146
147   fBachMomCov[0]=1024;
148   fBachMomCov[1]=fBachMomCov[2]=0.;
149   fBachMomCov[3]=1024;
150   fBachMomCov[4]=0.;
151   fBachMomCov[5]=1024;
152
153   fChi2Xi=1024.; 
154
155 }
156
157 AliESDcascade& AliESDcascade::operator=(const AliESDcascade& cas)
158 {
159   //--------------------------------------------------------------------
160   // The assignment operator
161   //--------------------------------------------------------------------
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
182 void 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;
192 }
193
194 AliESDcascade::~AliESDcascade() {
195   //--------------------------------------------------------------------
196   // Empty destructor
197   //--------------------------------------------------------------------
198 }
199
200 // Start with AliVParticle functions
201 Double_t AliESDcascade::E() const {
202   //--------------------------------------------------------------------
203   // This gives the energy assuming the ChangeMassHypothesis was called
204   //--------------------------------------------------------------------
205   return E(fPdgCodeXi);
206 }
207
208 Double_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
216 Double_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();
221   return TMath::Sqrt(mass*mass+P()*P());
222 }
223
224 Double_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
232 Double_t AliESDcascade::RapXi() const {
233   //--------------------------------------------------------------------
234   // This gives the pseudorapidity assuming a (Anti) Xi particle
235   //--------------------------------------------------------------------
236   return Y(kXiMinus);
237 }
238
239 Double_t AliESDcascade::RapOmega() const {
240   //--------------------------------------------------------------------
241   // This gives the pseudorapidity assuming a (Anti) Omega particle
242   //--------------------------------------------------------------------
243   return Y(kOmegaMinus);
244 }
245
246 Double_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
254   Double_t lQlBach = momBach.Dot(momTot)/momTot.Mag();
255   Double_t lQlV0 = momV0.Dot(momTot)/momTot.Mag();
256
257   return 1.-2./(1.+lQlBach/lQlV0);
258 }
259
260 Double_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
270 // Then the older functions
271 Double_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
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   }
286
287   switch (fPdgCodeXi) {
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:
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        }
309     break;
310   }
311
312   Double_t pxn=fNmom[0], pyn=fNmom[1], pzn=fNmom[2];
313   Double_t pxp=fPmom[0], pyp=fPmom[1], pzp=fPmom[2];
314
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   
338   fEffMassXi=TMath::Sqrt(((e0+eb)-pl)*((e0+eb)+pl));
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
352 void 
353 AliESDcascade::GetPxPyPz(Double_t &px, Double_t &py, Double_t &pz) const {
354   //--------------------------------------------------------------------
355   // This function returns the cascade momentum (global)
356   //--------------------------------------------------------------------
357   px=fNmom[0]+fPmom[0]+fBachMom[0];
358   py=fNmom[1]+fPmom[1]+fBachMom[1]; 
359   pz=fNmom[2]+fPmom[2]+fBachMom[2]; 
360 }
361
362 void AliESDcascade::GetXYZcascade(Double_t &x, Double_t &y, Double_t &z) const {
363   //--------------------------------------------------------------------
364   // This function returns cascade position (global)
365   //--------------------------------------------------------------------
366   x=fPosXi[0];
367   y=fPosXi[1];
368   z=fPosXi[2];
369 }
370
371 Double_t AliESDcascade::GetDcascade(Double_t x0, Double_t y0, Double_t z0) const {
372   //--------------------------------------------------------------------
373   // This function returns the cascade impact parameter
374   //--------------------------------------------------------------------
375
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];
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
389 Double_t AliESDcascade::GetCascadeCosineOfPointingAngle(Double_t refPointX, Double_t refPointY, Double_t refPointZ) const {
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 }
410
411 void AliESDcascade::GetPosCovXi(Double_t cov[6]) const {
412
413   for (Int_t i=0; i<6; ++i) cov[i] = fPosCovXi[i];
414 }