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