]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliCascadeVertexer.cxx
Updated version of the V0 and cascade classes (Boris, Renaud)
[u/mrichter/AliRoot.git] / STEER / AliCascadeVertexer.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 //-------------------------------------------------------------------------
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 //-------------------------------------------------------------------------
22
23 //modified by R. Vernet 30/6/2006 : daughter label
24 //modified by R. Vernet  3/7/2006 : causality
25
26
27 #include <TObjArray.h>
28 #include <TTree.h>
29
30 #include "AliESD.h"
31 #include "AliESDv0.h"
32 #include "AliESDcascade.h"
33 #include "AliCascadeVertexer.h"
34
35 ClassImp(AliCascadeVertexer)
36
37 Int_t AliCascadeVertexer::V0sTracks2CascadeVertices(AliESD *event) {
38   //--------------------------------------------------------------------
39   // This function reconstructs cascade vertices
40   //      Adapted to the ESD by I.Belikov (Jouri.Belikov@cern.ch)
41   //--------------------------------------------------------------------
42    Double_t b=event->GetMagneticField();
43    Int_t nV0=(Int_t)event->GetNumberOfV0s();
44
45    //stores relevant V0s in an array
46    TObjArray vtcs(nV0);
47    Int_t i;
48    for (i=0; i<nV0; i++) {
49        AliESDv0 *v=event->GetV0(i);
50        if (v->GetD(fX,fY,fZ)<fDV0min) continue;
51        vtcs.AddLast(v);
52    }
53    nV0=vtcs.GetEntriesFast();
54
55    // stores relevant tracks in another array
56    Int_t nentr=(Int_t)event->GetNumberOfTracks();
57    TArrayI trk(nentr); Int_t ntr=0;
58    for (i=0; i<nentr; i++) {
59        AliESDtrack *esdtr=event->GetTrack(i);
60        UInt_t status=esdtr->GetStatus();
61        UInt_t flags=AliESDtrack::kITSin|AliESDtrack::kTPCin|
62                     AliESDtrack::kTPCpid|AliESDtrack::kESDpid;
63
64        if ((status&AliESDtrack::kITSrefit)==0)
65           if (flags!=status) continue;
66
67        if (TMath::Abs(esdtr->GetD(fX,fY,b))<fDBachMin) continue;
68
69        trk[ntr++]=i;
70    }   
71
72    Double_t massLambda=1.11568;
73    Int_t ncasc=0;
74
75    // Looking for the cascades...
76
77    for (i=0; i<nV0; i++) { //loop on V0s
78
79       AliESDv0 *v=(AliESDv0*)vtcs.UncheckedAt(i);
80       v->ChangeMassHypothesis(kLambda0); // the v0 must be Lambda 
81       if (TMath::Abs(v->GetEffMass()-massLambda)>fMassWin) continue; 
82
83       for (Int_t j=0; j<ntr; j++) {//loop on tracks
84          Int_t bidx=trk[j];
85          if (bidx==v->GetNindex()) continue; //bachelor and v0's negative tracks must be different
86          AliESDtrack *btrk=event->GetTrack(bidx);
87          if (btrk->GetSign()>0) continue;  // bachelor's charge 
88           
89          AliESDv0 v0(*v), *pv0=&v0;
90          AliExternalTrackParam bt(*btrk), *pbt=&bt;
91
92          Double_t dca=PropagateToDCA(pv0,pbt,b);
93          if (dca > fDCAmax) continue;
94
95          AliESDcascade cascade(*pv0,*pbt,bidx);//constucts a cascade candidate
96          if (cascade.GetChi2Xi() > fChi2max) continue;
97
98          Double_t x,y,z; cascade.GetXYZ(x,y,z); 
99          Double_t r2=x*x + y*y; 
100          if (r2 > fRmax*fRmax) continue;   // condition on fiducial zone
101          if (r2 < fRmin*fRmin) continue;
102
103          Double_t pxV0,pyV0,pzV0;
104          pv0->GetPxPyPz(pxV0,pyV0,pzV0);
105          if (x*pxV0+y*pyV0+z*pzV0 < 0) continue; //causality
106
107          Double_t x1,y1,z1; pv0->GetXYZ(x1,y1,z1);
108          if (r2 > (x1*x1+y1*y1)) continue;
109
110          if (cascade.GetCascadeCosineOfPointingAngle(fX,fY,fZ) <fCPAmax) continue; //condition on the cascade pointing angle 
111          
112          event->AddCascade(&cascade);
113          ncasc++;
114       } // end loop tracks
115    } // end loop V0s
116
117    // Looking for the anti-cascades...
118
119    for (i=0; i<nV0; i++) { //loop on V0s
120       AliESDv0 *v=(AliESDv0*)vtcs.UncheckedAt(i);
121       v->ChangeMassHypothesis(kLambda0Bar); //the v0 must be anti-Lambda 
122       if (TMath::Abs(v->GetEffMass()-massLambda)>fMassWin) continue; 
123
124       for (Int_t j=0; j<ntr; j++) {//loop on tracks
125          Int_t bidx=trk[j];
126          if (bidx==v->GetPindex()) continue; //bachelor and v0's positive tracks must be different
127          AliESDtrack *btrk=event->GetTrack(bidx);
128          if (btrk->GetSign()<0) continue;  // bachelor's charge 
129           
130          AliESDv0 v0(*v), *pv0=&v0;
131          AliESDtrack bt(*btrk), *pbt=&bt;
132
133          Double_t dca=PropagateToDCA(pv0,pbt,b);
134          if (dca > fDCAmax) continue;
135
136          AliESDcascade cascade(*pv0,*pbt,bidx); //constucts a cascade candidate
137          if (cascade.GetChi2Xi() > fChi2max) continue;
138
139          Double_t x,y,z; cascade.GetXYZ(x,y,z); 
140          Double_t r2=x*x + y*y; 
141          if (r2 > fRmax*fRmax) continue;   // condition on fiducial zone
142          if (r2 < fRmin*fRmin) continue;
143
144          Double_t pxV0,pyV0,pzV0;
145          pv0->GetPxPyPz(pxV0,pyV0,pzV0);
146          if (x*pxV0+y*pyV0+z*pzV0 < 0) continue; //causality
147
148          Double_t x1,y1,z1; pv0->GetXYZ(x1,y1,z1);
149          if (r2 > (x1*x1+y1*y1)) continue;
150          if (z*z > z1*z1) continue;
151
152          if (cascade.GetCascadeCosineOfPointingAngle(fX,fY,fZ) < fCPAmax) continue; //condition on the cascade pointing angle 
153          event->AddCascade(&cascade);
154          ncasc++;
155
156       } // end loop tracks
157    } // end loop V0s
158
159 Info("V0sTracks2CascadeVertices","Number of reconstructed cascades: %d",ncasc);
160
161    return 0;
162 }
163
164
165 inline Double_t det(Double_t a00, Double_t a01, Double_t a10, Double_t a11){
166   // determinant 2x2
167   return a00*a11 - a01*a10;
168 }
169
170 inline Double_t det (Double_t a00,Double_t a01,Double_t a02,
171                      Double_t a10,Double_t a11,Double_t a12,
172                      Double_t a20,Double_t a21,Double_t a22) {
173   // determinant 3x3
174   return 
175   a00*det(a11,a12,a21,a22)-a01*det(a10,a12,a20,a22)+a02*det(a10,a11,a20,a21);
176 }
177
178
179
180
181 Double_t AliCascadeVertexer::
182 PropagateToDCA(AliESDv0 *v, AliExternalTrackParam *t, Double_t b) {
183   //--------------------------------------------------------------------
184   // This function returns the DCA between the V0 and the track
185   //--------------------------------------------------------------------
186   Double_t alpha=t->GetAlpha(), cs1=TMath::Cos(alpha), sn1=TMath::Sin(alpha);
187   Double_t r[3]; t->GetXYZ(r);
188   Double_t x1=r[0], y1=r[1], z1=r[2];
189   Double_t p[3]; t->GetPxPyPz(p);
190   Double_t px1=p[0], py1=p[1], pz1=p[2];
191   
192   Double_t x2,y2,z2;     // position and momentum of V0
193   Double_t px2,py2,pz2;
194   
195   v->GetXYZ(x2,y2,z2);
196   v->GetPxPyPz(px2,py2,pz2);
197  
198 // calculation dca
199    
200   Double_t dd= det(x2-x1,y2-y1,z2-z1,px1,py1,pz1,px2,py2,pz2);
201   Double_t ax= det(py1,pz1,py2,pz2);
202   Double_t ay=-det(px1,pz1,px2,pz2);
203   Double_t az= det(px1,py1,px2,py2);
204
205   Double_t dca=TMath::Abs(dd)/TMath::Sqrt(ax*ax + ay*ay + az*az);
206
207 //points of the DCA
208   Double_t t1 = det(x2-x1,y2-y1,z2-z1,px2,py2,pz2,ax,ay,az)/
209                 det(px1,py1,pz1,px2,py2,pz2,ax,ay,az);
210   
211   x1 += px1*t1; y1 += py1*t1; //z1 += pz1*t1;
212   
213
214   //propagate track to the points of DCA
215
216   x1=x1*cs1 + y1*sn1;
217   if (!t->PropagateTo(x1,b)) {
218     Error("PropagateToDCA","Propagation failed !");
219     return 1.e+33;
220   }  
221
222   return dca;
223 }
224
225
226
227
228
229
230
231
232
233
234