]> git.uio.no Git - u/mrichter/AliRoot.git/blame - STEER/AliCascadeVertexer.cxx
Memory leak corrected (Ch. Klein-Boesing)
[u/mrichter/AliRoot.git] / STEER / 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
27
c7bafca9 28#include <TObjArray.h>
29#include <TTree.h>
30
af885e0f 31#include "AliESDEvent.h"
c7bafca9 32#include "AliESDv0.h"
33#include "AliESDcascade.h"
34#include "AliCascadeVertexer.h"
faffd83e 35#include "AliESDtrack.h"
36#include "AliESDVertex.h"
c7bafca9 37
38ClassImp(AliCascadeVertexer)
39
5e4ff34d 40//A set of loose cuts
41Double_t
e82eee7e 42 AliCascadeVertexer::fgChi2max=33.; //maximal allowed chi2
5e4ff34d 43Double_t
e82eee7e 44 AliCascadeVertexer::fgDV0min=0.05; //min V0 impact parameter
5e4ff34d 45Double_t
e82eee7e 46 AliCascadeVertexer::fgMassWin=0.01; //"window" around the Lambda mass
5e4ff34d 47Double_t
e82eee7e 48 AliCascadeVertexer::fgDBachMin=0.035; //min bachelor impact parameter
5e4ff34d 49Double_t
e82eee7e 50 AliCascadeVertexer::fgDCAmax=0.10; //max DCA between the V0 and the track
5e4ff34d 51Double_t
e82eee7e 52 AliCascadeVertexer::fgCPAmax=0.9985; //max cosine of the cascade pointing angle
5e4ff34d 53Double_t
e82eee7e 54 AliCascadeVertexer::fgRmin=0.2; //min radius of the fiducial volume
5e4ff34d 55Double_t
e82eee7e 56 AliCascadeVertexer::fgRmax=100.; //max radius of the fiducial volume
5e4ff34d 57
58
af885e0f 59Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESDEvent *event) {
c7bafca9 60 //--------------------------------------------------------------------
61 // This function reconstructs cascade vertices
62 // Adapted to the ESD by I.Belikov (Jouri.Belikov@cern.ch)
63 //--------------------------------------------------------------------
5e4ff34d 64 const AliESDVertex *vtx=event->GetVertex();
65 Double_t xv=vtx->GetXv(), yv=vtx->GetYv(), zv=vtx->GetZv();
66
c7bafca9 67 Double_t b=event->GetMagneticField();
68 Int_t nV0=(Int_t)event->GetNumberOfV0s();
c028b974 69
70 //stores relevant V0s in an array
c7bafca9 71 TObjArray vtcs(nV0);
72 Int_t i;
73 for (i=0; i<nV0; i++) {
74 AliESDv0 *v=event->GetV0(i);
d6a49f20 75 if (v->GetOnFlyStatus()) continue;
5e4ff34d 76 if (v->GetD(xv,yv,zv)<fDV0min) continue;
c7bafca9 77 vtcs.AddLast(v);
78 }
79 nV0=vtcs.GetEntriesFast();
80
c028b974 81 // stores relevant tracks in another array
c7bafca9 82 Int_t nentr=(Int_t)event->GetNumberOfTracks();
83 TArrayI trk(nentr); Int_t ntr=0;
84 for (i=0; i<nentr; i++) {
85 AliESDtrack *esdtr=event->GetTrack(i);
86 UInt_t status=esdtr->GetStatus();
87 UInt_t flags=AliESDtrack::kITSin|AliESDtrack::kTPCin|
88 AliESDtrack::kTPCpid|AliESDtrack::kESDpid;
89
90 if ((status&AliESDtrack::kITSrefit)==0)
91 if (flags!=status) continue;
92
5e4ff34d 93 if (TMath::Abs(esdtr->GetD(xv,yv,b))<fDBachMin) continue;
c7bafca9 94
95 trk[ntr++]=i;
96 }
97
98 Double_t massLambda=1.11568;
99 Int_t ncasc=0;
100
101 // Looking for the cascades...
c028b974 102
103 for (i=0; i<nV0; i++) { //loop on V0s
104
c7bafca9 105 AliESDv0 *v=(AliESDv0*)vtcs.UncheckedAt(i);
106 v->ChangeMassHypothesis(kLambda0); // the v0 must be Lambda
107 if (TMath::Abs(v->GetEffMass()-massLambda)>fMassWin) continue;
c028b974 108
109 for (Int_t j=0; j<ntr; j++) {//loop on tracks
c7bafca9 110 Int_t bidx=trk[j];
b75d63a7 111 //Bo: if (bidx==v->GetNindex()) continue; //bachelor and v0's negative tracks must be different
112 if (bidx==v->GetIndex(0)) continue; //Bo: consistency 0 for neg
c7bafca9 113 AliESDtrack *btrk=event->GetTrack(bidx);
c7bafca9 114 if (btrk->GetSign()>0) continue; // bachelor's charge
115
c028b974 116 AliESDv0 v0(*v), *pv0=&v0;
c7bafca9 117 AliExternalTrackParam bt(*btrk), *pbt=&bt;
118
119 Double_t dca=PropagateToDCA(pv0,pbt,b);
120 if (dca > fDCAmax) continue;
121
c028b974 122 AliESDcascade cascade(*pv0,*pbt,bidx);//constucts a cascade candidate
123 if (cascade.GetChi2Xi() > fChi2max) continue;
c7bafca9 124
125 Double_t x,y,z; cascade.GetXYZ(x,y,z);
126 Double_t r2=x*x + y*y;
127 if (r2 > fRmax*fRmax) continue; // condition on fiducial zone
128 if (r2 < fRmin*fRmin) continue;
129
c028b974 130 Double_t pxV0,pyV0,pzV0;
131 pv0->GetPxPyPz(pxV0,pyV0,pzV0);
132 if (x*pxV0+y*pyV0+z*pzV0 < 0) continue; //causality
133
c7bafca9 134 Double_t x1,y1,z1; pv0->GetXYZ(x1,y1,z1);
135 if (r2 > (x1*x1+y1*y1)) continue;
c7bafca9 136
5e4ff34d 137 if (cascade.GetCascadeCosineOfPointingAngle(xv,yv,zv) <fCPAmax) continue; //condition on the cascade pointing angle
c028b974 138
139 event->AddCascade(&cascade);
c7bafca9 140 ncasc++;
c028b974 141 } // end loop tracks
142 } // end loop V0s
c7bafca9 143
144 // Looking for the anti-cascades...
c028b974 145
146 for (i=0; i<nV0; i++) { //loop on V0s
c7bafca9 147 AliESDv0 *v=(AliESDv0*)vtcs.UncheckedAt(i);
148 v->ChangeMassHypothesis(kLambda0Bar); //the v0 must be anti-Lambda
149 if (TMath::Abs(v->GetEffMass()-massLambda)>fMassWin) continue;
c028b974 150
151 for (Int_t j=0; j<ntr; j++) {//loop on tracks
c7bafca9 152 Int_t bidx=trk[j];
b75d63a7 153 //Bo: if (bidx==v->GetPindex()) continue; //bachelor and v0's positive tracks must be different
154 if (bidx==v->GetIndex(1)) continue; //Bo: consistency 1 for pos
c7bafca9 155 AliESDtrack *btrk=event->GetTrack(bidx);
c7bafca9 156 if (btrk->GetSign()<0) continue; // bachelor's charge
157
158 AliESDv0 v0(*v), *pv0=&v0;
159 AliESDtrack bt(*btrk), *pbt=&bt;
160
161 Double_t dca=PropagateToDCA(pv0,pbt,b);
162 if (dca > fDCAmax) continue;
163
c028b974 164 AliESDcascade cascade(*pv0,*pbt,bidx); //constucts a cascade candidate
165 if (cascade.GetChi2Xi() > fChi2max) continue;
c7bafca9 166
167 Double_t x,y,z; cascade.GetXYZ(x,y,z);
168 Double_t r2=x*x + y*y;
169 if (r2 > fRmax*fRmax) continue; // condition on fiducial zone
170 if (r2 < fRmin*fRmin) continue;
171
c028b974 172 Double_t pxV0,pyV0,pzV0;
173 pv0->GetPxPyPz(pxV0,pyV0,pzV0);
174 if (x*pxV0+y*pyV0+z*pzV0 < 0) continue; //causality
175
c7bafca9 176 Double_t x1,y1,z1; pv0->GetXYZ(x1,y1,z1);
177 if (r2 > (x1*x1+y1*y1)) continue;
178 if (z*z > z1*z1) continue;
c7bafca9 179
5e4ff34d 180 if (cascade.GetCascadeCosineOfPointingAngle(xv,yv,zv) < fCPAmax) continue; //condition on the cascade pointing angle
c028b974 181 event->AddCascade(&cascade);
c7bafca9 182 ncasc++;
183
c028b974 184 } // end loop tracks
185 } // end loop V0s
c7bafca9 186
187Info("V0sTracks2CascadeVertices","Number of reconstructed cascades: %d",ncasc);
188
189 return 0;
190}
191
192
df53c9d5 193Double_t det(Double_t a00, Double_t a01, Double_t a10, Double_t a11){
c7bafca9 194 // determinant 2x2
195 return a00*a11 - a01*a10;
196}
197
df53c9d5 198Double_t det (Double_t a00,Double_t a01,Double_t a02,
c7bafca9 199 Double_t a10,Double_t a11,Double_t a12,
200 Double_t a20,Double_t a21,Double_t a22) {
201 // determinant 3x3
202 return
203 a00*det(a11,a12,a21,a22)-a01*det(a10,a12,a20,a22)+a02*det(a10,a11,a20,a21);
204}
205
206
207
208
209Double_t AliCascadeVertexer::
210PropagateToDCA(AliESDv0 *v, AliExternalTrackParam *t, Double_t b) {
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
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);
232
233 Double_t dca=TMath::Abs(dd)/TMath::Sqrt(ax*ax + ay*ay + az*az);
234
235//points of the DCA
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);
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