changes for Vertex and Tracks classes
[u/mrichter/AliRoot.git] / STEER / ESD / AliCascadeVertexer.cxx
CommitLineData
c7bafca9 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//-------------------------------------------------------------------------
17// Implementation of the cascade vertexer class
18// Reads V0s and tracks, writes out cascade vertices
19// Fills the ESD with the cascades
20// Origin: Christian Kuhn, IReS, Strasbourg, christian.kuhn@ires.in2p3.fr
21//-------------------------------------------------------------------------
c028b974 22
23//modified by R. Vernet 30/6/2006 : daughter label
24//modified by R. Vernet 3/7/2006 : causality
5e4ff34d 25//modified by I. Belikov 24/11/2006 : static setter for the default cuts
c028b974 26
af885e0f 27#include "AliESDEvent.h"
c7bafca9 28#include "AliESDcascade.h"
29#include "AliCascadeVertexer.h"
30
31ClassImp(AliCascadeVertexer)
32
5e4ff34d 33//A set of loose cuts
34Double_t
9fbe5c5c 35 AliCascadeVertexer::fgChi2max=33.; //maximal allowed chi2
5e4ff34d 36Double_t
9fbe5c5c 37 AliCascadeVertexer::fgDV0min=0.01; //min V0 impact parameter
5e4ff34d 38Double_t
9fbe5c5c 39 AliCascadeVertexer::fgMassWin=0.008; //"window" around the Lambda mass
5e4ff34d 40Double_t
9fbe5c5c 41 AliCascadeVertexer::fgDBachMin=0.01; //min bachelor impact parameter
5e4ff34d 42Double_t
9fbe5c5c 43 AliCascadeVertexer::fgDCAmax=2.0; //max DCA between the V0 and the track
5e4ff34d 44Double_t
9fbe5c5c 45 AliCascadeVertexer::fgCPAmin=0.98; //min cosine of the cascade pointing angle
5e4ff34d 46Double_t
9fbe5c5c 47 AliCascadeVertexer::fgRmin=0.2; //min radius of the fiducial volume
5e4ff34d 48Double_t
9fbe5c5c 49 AliCascadeVertexer::fgRmax=100.; //max radius of the fiducial volume
5e4ff34d 50
51
af885e0f 52Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESDEvent *event) {
c7bafca9 53 //--------------------------------------------------------------------
54 // This function reconstructs cascade vertices
55 // Adapted to the ESD by I.Belikov (Jouri.Belikov@cern.ch)
56 //--------------------------------------------------------------------
81f174b6 57 const AliESDVertex *vtxT3D=event->GetPrimaryVertex();
58
e690d4d0 59 Double_t xPrimaryVertex=vtxT3D->GetX();
60 Double_t yPrimaryVertex=vtxT3D->GetY();
61 Double_t zPrimaryVertex=vtxT3D->GetZ();
5e4ff34d 62
c7bafca9 63 Double_t b=event->GetMagneticField();
64 Int_t nV0=(Int_t)event->GetNumberOfV0s();
c028b974 65
66 //stores relevant V0s in an array
c7bafca9 67 TObjArray vtcs(nV0);
68 Int_t i;
69 for (i=0; i<nV0; i++) {
70 AliESDv0 *v=event->GetV0(i);
d6a49f20 71 if (v->GetOnFlyStatus()) continue;
81f174b6 72 if (v->GetD(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex)<fDV0min) continue;
c7bafca9 73 vtcs.AddLast(v);
74 }
75 nV0=vtcs.GetEntriesFast();
76
c028b974 77 // stores relevant tracks in another array
c7bafca9 78 Int_t nentr=(Int_t)event->GetNumberOfTracks();
79 TArrayI trk(nentr); Int_t ntr=0;
80 for (i=0; i<nentr; i++) {
81 AliESDtrack *esdtr=event->GetTrack(i);
85f0f56e 82 ULong_t status=esdtr->GetStatus();
c7bafca9 83
84 if ((status&AliESDtrack::kITSrefit)==0)
85f0f56e 85 if ((status&AliESDtrack::kTPCrefit)==0) continue;
c7bafca9 86
81f174b6 87 if (TMath::Abs(esdtr->GetD(xPrimaryVertex,yPrimaryVertex,b))<fDBachMin) continue;
c7bafca9 88
89 trk[ntr++]=i;
90 }
91
92 Double_t massLambda=1.11568;
93 Int_t ncasc=0;
94
95 // Looking for the cascades...
c028b974 96
97 for (i=0; i<nV0; i++) { //loop on V0s
98
c7bafca9 99 AliESDv0 *v=(AliESDv0*)vtcs.UncheckedAt(i);
c71c41ac 100 AliESDv0 v0(*v);
101 v0.ChangeMassHypothesis(kLambda0); // the v0 must be Lambda
102 if (TMath::Abs(v0.GetEffMass()-massLambda)>fMassWin) continue;
c028b974 103
104 for (Int_t j=0; j<ntr; j++) {//loop on tracks
c7bafca9 105 Int_t bidx=trk[j];
b75d63a7 106 //Bo: if (bidx==v->GetNindex()) continue; //bachelor and v0's negative tracks must be different
c71c41ac 107 if (bidx==v0.GetIndex(0)) continue; //Bo: consistency 0 for neg
c7bafca9 108 AliESDtrack *btrk=event->GetTrack(bidx);
c7bafca9 109 if (btrk->GetSign()>0) continue; // bachelor's charge
110
c71c41ac 111 AliESDv0 *pv0=&v0;
c7bafca9 112 AliExternalTrackParam bt(*btrk), *pbt=&bt;
113
114 Double_t dca=PropagateToDCA(pv0,pbt,b);
115 if (dca > fDCAmax) continue;
116
c028b974 117 AliESDcascade cascade(*pv0,*pbt,bidx);//constucts a cascade candidate
f776b387 118 //PH if (cascade.GetChi2Xi() > fChi2max) continue;
c7bafca9 119
85f0f56e 120 Double_t x,y,z; cascade.GetXYZcascade(x,y,z); // Bo: bug correction
c7bafca9 121 Double_t r2=x*x + y*y;
122 if (r2 > fRmax*fRmax) continue; // condition on fiducial zone
123 if (r2 < fRmin*fRmin) continue;
124
c028b974 125 Double_t pxV0,pyV0,pzV0;
126 pv0->GetPxPyPz(pxV0,pyV0,pzV0);
127 if (x*pxV0+y*pyV0+z*pzV0 < 0) continue; //causality
128
c7bafca9 129 Double_t x1,y1,z1; pv0->GetXYZ(x1,y1,z1);
130 if (r2 > (x1*x1+y1*y1)) continue;
c7bafca9 131
81f174b6 132 if (cascade.GetCascadeCosineOfPointingAngle(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex) <fCPAmin) continue; //condition on the cascade pointing angle
c028b974 133
5c9c901e 134 cascade.SetDcaXiDaughters(dca);
c028b974 135 event->AddCascade(&cascade);
c7bafca9 136 ncasc++;
c028b974 137 } // end loop tracks
138 } // end loop V0s
c7bafca9 139
140 // Looking for the anti-cascades...
c028b974 141
142 for (i=0; i<nV0; i++) { //loop on V0s
c7bafca9 143 AliESDv0 *v=(AliESDv0*)vtcs.UncheckedAt(i);
c71c41ac 144 AliESDv0 v0(*v);
145 v0.ChangeMassHypothesis(kLambda0Bar); //the v0 must be anti-Lambda
146 if (TMath::Abs(v0.GetEffMass()-massLambda)>fMassWin) continue;
c028b974 147
148 for (Int_t j=0; j<ntr; j++) {//loop on tracks
c7bafca9 149 Int_t bidx=trk[j];
b75d63a7 150 //Bo: if (bidx==v->GetPindex()) continue; //bachelor and v0's positive tracks must be different
c71c41ac 151 if (bidx==v0.GetIndex(1)) continue; //Bo: consistency 1 for pos
c7bafca9 152 AliESDtrack *btrk=event->GetTrack(bidx);
c7bafca9 153 if (btrk->GetSign()<0) continue; // bachelor's charge
154
c71c41ac 155 AliESDv0 *pv0=&v0;
50be69d3 156 AliExternalTrackParam bt(*btrk), *pbt=&bt;
c7bafca9 157
158 Double_t dca=PropagateToDCA(pv0,pbt,b);
159 if (dca > fDCAmax) continue;
160
c028b974 161 AliESDcascade cascade(*pv0,*pbt,bidx); //constucts a cascade candidate
f776b387 162 //PH if (cascade.GetChi2Xi() > fChi2max) continue;
c7bafca9 163
85f0f56e 164 Double_t x,y,z; cascade.GetXYZcascade(x,y,z); // Bo: bug correction
c7bafca9 165 Double_t r2=x*x + y*y;
166 if (r2 > fRmax*fRmax) continue; // condition on fiducial zone
167 if (r2 < fRmin*fRmin) continue;
168
c028b974 169 Double_t pxV0,pyV0,pzV0;
170 pv0->GetPxPyPz(pxV0,pyV0,pzV0);
171 if (x*pxV0+y*pyV0+z*pzV0 < 0) continue; //causality
172
c7bafca9 173 Double_t x1,y1,z1; pv0->GetXYZ(x1,y1,z1);
174 if (r2 > (x1*x1+y1*y1)) continue;
c7bafca9 175
81f174b6 176 if (cascade.GetCascadeCosineOfPointingAngle(xPrimaryVertex,yPrimaryVertex,zPrimaryVertex) < fCPAmin) continue; //condition on the cascade pointing angle
5c9c901e 177
178 cascade.SetDcaXiDaughters(dca);
c028b974 179 event->AddCascade(&cascade);
c7bafca9 180 ncasc++;
181
c028b974 182 } // end loop tracks
183 } // end loop V0s
c7bafca9 184
185Info("V0sTracks2CascadeVertices","Number of reconstructed cascades: %d",ncasc);
186
187 return 0;
188}
189
190
97135b34 191Double_t AliCascadeVertexer::Det(Double_t a00, Double_t a01, Double_t a10, Double_t a11) const {
192 //--------------------------------------------------------------------
193 // This function calculates locally a 2x2 determinant
194 //--------------------------------------------------------------------
c7bafca9 195 return a00*a11 - a01*a10;
196}
197
97135b34 198Double_t AliCascadeVertexer::Det(Double_t a00,Double_t a01,Double_t a02,
199 Double_t a10,Double_t a11,Double_t a12,
200 Double_t a20,Double_t a21,Double_t a22) const {
201 //--------------------------------------------------------------------
202 // This function calculates locally a 3x3 determinant
203 //--------------------------------------------------------------------
204 return a00*Det(a11,a12,a21,a22)-a01*Det(a10,a12,a20,a22)+a02*Det(a10,a11,a20,a21);
c7bafca9 205}
206
207
208
209
97135b34 210Double_t AliCascadeVertexer::PropagateToDCA(AliESDv0 *v, AliExternalTrackParam *t, Double_t b) {
c7bafca9 211 //--------------------------------------------------------------------
212 // This function returns the DCA between the V0 and the track
213 //--------------------------------------------------------------------
214 Double_t alpha=t->GetAlpha(), cs1=TMath::Cos(alpha), sn1=TMath::Sin(alpha);
215 Double_t r[3]; t->GetXYZ(r);
216 Double_t x1=r[0], y1=r[1], z1=r[2];
217 Double_t p[3]; t->GetPxPyPz(p);
218 Double_t px1=p[0], py1=p[1], pz1=p[2];
219
220 Double_t x2,y2,z2; // position and momentum of V0
221 Double_t px2,py2,pz2;
222
223 v->GetXYZ(x2,y2,z2);
224 v->GetPxPyPz(px2,py2,pz2);
225
226// calculation dca
227
97135b34 228 Double_t dd= Det(x2-x1,y2-y1,z2-z1,px1,py1,pz1,px2,py2,pz2);
229 Double_t ax= Det(py1,pz1,py2,pz2);
230 Double_t ay=-Det(px1,pz1,px2,pz2);
231 Double_t az= Det(px1,py1,px2,py2);
c7bafca9 232
233 Double_t dca=TMath::Abs(dd)/TMath::Sqrt(ax*ax + ay*ay + az*az);
234
235//points of the DCA
97135b34 236 Double_t t1 = Det(x2-x1,y2-y1,z2-z1,px2,py2,pz2,ax,ay,az)/
237 Det(px1,py1,pz1,px2,py2,pz2,ax,ay,az);
c7bafca9 238
239 x1 += px1*t1; y1 += py1*t1; //z1 += pz1*t1;
240
241
242 //propagate track to the points of DCA
243
244 x1=x1*cs1 + y1*sn1;
245 if (!t->PropagateTo(x1,b)) {
246 Error("PropagateToDCA","Propagation failed !");
247 return 1.e+33;
248 }
249
250 return dca;
251}
252
253
254
255
256
257
258
259
260
261
262