Line data Source code
1 : /**************************************************************************
2 : * Copyright(c) 1998-2003, 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 Primary Vertex class
18 : // for the Event Data Summary class
19 : // This class contains the Primary Vertex
20 : // of the event coming from reconstruction
21 : // Origin: A.Dainese, andrea.dainese@lnl.infn.it
22 : //-----------------------------------------------------------------
23 :
24 : //---- standard headers ----
25 : #include "Riostream.h"
26 : //---- Root headers --------
27 : #include <TMath.h>
28 : #include <TROOT.h>
29 : #include <TMatrixDSym.h>
30 : //---- AliRoot headers -----
31 : #include "AliESDVertex.h"
32 : #include "AliVTrack.h"
33 : #include "AliLog.h"
34 :
35 172 : ClassImp(AliESDVertex)
36 :
37 : //--------------------------------------------------------------------------
38 : AliESDVertex::AliESDVertex() :
39 265 : AliVertex(),
40 265 : fCovXX(0.005*0.005),
41 265 : fCovXY(0),
42 265 : fCovYY(0.005*0.005),
43 265 : fCovXZ(0),
44 265 : fCovYZ(0),
45 265 : fCovZZ(5.3*5.3),
46 265 : fChi2(0),
47 265 : fID(-1), // ID=-1 means the vertex with the biggest number of contributors
48 265 : fBCID(AliVTrack::kTOFBCNA)
49 1325 : {
50 : //
51 : // Default Constructor, set everything to 0
52 : //
53 265 : SetToZero();
54 530 : }
55 :
56 : //--------------------------------------------------------------------------
57 : AliESDVertex::AliESDVertex(Double_t positionZ,Double_t sigmaZ,
58 : Int_t nContributors,const Char_t *vtxName) :
59 0 : AliVertex(),
60 0 : fCovXX(0.005*0.005),
61 0 : fCovXY(0),
62 0 : fCovYY(0.005*0.005),
63 0 : fCovXZ(0),
64 0 : fCovYZ(0),
65 0 : fCovZZ(sigmaZ*sigmaZ),
66 0 : fChi2(0),
67 0 : fID(-1), // ID=-1 means the vertex with the biggest number of contributors
68 0 : fBCID(AliVTrack::kTOFBCNA)
69 0 : {
70 : //
71 : // Constructor for vertex Z from pixels
72 : //
73 :
74 0 : SetToZero();
75 :
76 0 : fPosition[2] = positionZ;
77 0 : SetName(vtxName);
78 0 : SetNContributors(nContributors);
79 :
80 0 : }
81 :
82 : //-------------------------------------------------------------------------
83 : AliESDVertex::AliESDVertex(const Double_t position[3],
84 : const Double_t covmatrix[6],
85 : Double_t chi2,Int_t nContributors,
86 : const Char_t *vtxName) :
87 106 : AliVertex(position,0.,nContributors),
88 106 : fCovXX(covmatrix[0]),
89 106 : fCovXY(covmatrix[1]),
90 106 : fCovYY(covmatrix[2]),
91 106 : fCovXZ(covmatrix[3]),
92 106 : fCovYZ(covmatrix[4]),
93 106 : fCovZZ(covmatrix[5]),
94 106 : fChi2(chi2),
95 106 : fID(-1), // ID=-1 means the vertex with the biggest number of contributors
96 106 : fBCID(AliVTrack::kTOFBCNA)
97 530 : {
98 : //
99 : // Constructor for vertex in 3D from tracks
100 : //
101 :
102 106 : SetToZero();
103 106 : SetName(vtxName);
104 :
105 212 : }
106 : //--------------------------------------------------------------------------
107 : AliESDVertex::AliESDVertex(Double_t position[3],Double_t sigma[3],
108 : const Char_t *vtxName) :
109 0 : AliVertex(position,0.,0),
110 0 : fCovXX(sigma[0]*sigma[0]),
111 0 : fCovXY(0),
112 0 : fCovYY(sigma[1]*sigma[1]),
113 0 : fCovXZ(0),
114 0 : fCovYZ(0),
115 0 : fCovZZ(sigma[2]*sigma[2]),
116 0 : fChi2(0),
117 0 : fID(-1), // ID=-1 means the vertex with the biggest number of contributors
118 0 : fBCID(AliVTrack::kTOFBCNA)
119 0 : {
120 : //
121 : // Constructor for smearing of true position
122 : //
123 :
124 0 : SetToZero();
125 0 : SetName(vtxName);
126 :
127 0 : }
128 : //--------------------------------------------------------------------------
129 : AliESDVertex::AliESDVertex(Double_t position[3],Double_t sigma[3],
130 : Double_t snr[3], const Char_t *vtxName) :
131 0 : AliVertex(position,0.,0),
132 0 : fCovXX(sigma[0]*sigma[0]),
133 0 : fCovXY(0),
134 0 : fCovYY(sigma[1]*sigma[1]),
135 0 : fCovXZ(0),
136 0 : fCovYZ(0),
137 0 : fCovZZ(sigma[2]*sigma[2]),
138 0 : fChi2(0),
139 0 : fID(-1), // ID=-1 means the vertex with the biggest number of contributors
140 0 : fBCID(AliVTrack::kTOFBCNA)
141 0 : {
142 : //
143 : // Constructor for Pb-Pb
144 : //
145 :
146 0 : SetToZero();
147 0 : SetName(vtxName);
148 :
149 0 : fSNR[0] = snr[0];
150 0 : fSNR[1] = snr[1];
151 0 : fSNR[2] = snr[2];
152 :
153 0 : }
154 : //--------------------------------------------------------------------------
155 : AliESDVertex::AliESDVertex(const AliESDVertex &source):
156 26 : AliVertex(source),
157 26 : fCovXX(source.fCovXX),
158 26 : fCovXY(source.fCovXY),
159 26 : fCovYY(source.fCovYY),
160 26 : fCovXZ(source.fCovXZ),
161 26 : fCovYZ(source.fCovYZ),
162 26 : fCovZZ(source.fCovZZ),
163 26 : fChi2(source.fChi2),
164 26 : fID(source.fID),
165 26 : fBCID(source.fBCID)
166 130 : {
167 : //
168 : // Copy constructor
169 : //
170 208 : for(Int_t i=0;i<3;i++) {
171 78 : fSNR[i] = source.fSNR[i];
172 : }
173 52 : }
174 : //--------------------------------------------------------------------------
175 : AliESDVertex &AliESDVertex::operator=(const AliESDVertex &source){
176 : //
177 : // assignment operator
178 : //
179 240 : if(&source != this){
180 120 : AliVertex::operator=(source);
181 960 : for(Int_t i=0;i<3;++i)fSNR[i] = source.fSNR[i];
182 120 : fCovXX = source.fCovXX;
183 120 : fCovXY = source.fCovXY;
184 120 : fCovYY = source.fCovYY;
185 120 : fCovXZ = source.fCovXZ;
186 120 : fCovYZ = source.fCovYZ;
187 120 : fCovZZ = source.fCovZZ;
188 120 : fChi2 = source.fChi2;
189 120 : fID = source.fID;
190 120 : fBCID = source.fBCID;
191 120 : }
192 120 : return *this;
193 : }
194 : //--------------------------------------------------------------------------
195 : void AliESDVertex::Copy(TObject &obj) const {
196 :
197 : // this overwrites the virtual TOBject::Copy()
198 : // to allow run time copying without casting
199 : // in AliESDEvent
200 :
201 12 : if(this==&obj)return;
202 18 : AliESDVertex *robj = dynamic_cast<AliESDVertex*>(&obj);
203 6 : if(!robj)return; // not an AliESDVertex
204 6 : *robj = *this;
205 :
206 12 : }
207 : //--------------------------------------------------------------------------
208 : void AliESDVertex::SetToZero() {
209 : //
210 : // Set the content of arrays to 0. Used by constructors
211 : //
212 3339 : for(Int_t i=0; i<3; i++){
213 1113 : fSNR[i] = 0.;
214 : }
215 371 : }
216 : //--------------------------------------------------------------------------
217 : void AliESDVertex::GetSigmaXYZ(Double_t sigma[3]) const {
218 : //
219 : // Return errors on vertex position in thrust frame
220 : //
221 272 : sigma[0] = TMath::Sqrt(fCovXX);
222 136 : sigma[1] = TMath::Sqrt(fCovYY);
223 136 : sigma[2] = TMath::Sqrt(fCovZZ);
224 :
225 136 : return;
226 : }
227 : //--------------------------------------------------------------------------
228 : void AliESDVertex::GetCovMatrix(Double_t covmatrix[6]) const {
229 : //
230 : // Return covariance matrix of the vertex
231 : //
232 2584 : covmatrix[0] = fCovXX;
233 1292 : covmatrix[1] = fCovXY;
234 1292 : covmatrix[2] = fCovYY;
235 1292 : covmatrix[3] = fCovXZ;
236 1292 : covmatrix[4] = fCovYZ;
237 1292 : covmatrix[5] = fCovZZ;
238 :
239 1292 : return;
240 : }
241 :
242 : //--------------------------------------------------------------------------
243 : void AliESDVertex::SetCovarianceMatrix(const Double_t *covmatrix) {
244 : //
245 : // Return covariance matrix of the vertex
246 : //
247 96 : fCovXX = covmatrix[0];
248 48 : fCovXY = covmatrix[1];
249 48 : fCovYY = covmatrix[2];
250 48 : fCovXZ = covmatrix[3];
251 48 : fCovYZ = covmatrix[4];
252 48 : fCovZZ = covmatrix[5];
253 :
254 48 : return;
255 : }
256 :
257 : //--------------------------------------------------------------------------
258 : void AliESDVertex::GetSNR(Double_t snr[3]) const {
259 : //
260 : // Return S/N ratios
261 : //
262 0 : for(Int_t i=0;i<3;i++) snr[i] = fSNR[i];
263 :
264 0 : return;
265 : }
266 : //--------------------------------------------------------------------------
267 : void AliESDVertex::Print(Option_t* /*option*/) const {
268 : //
269 : // Print out information on all data members
270 : //
271 0 : printf("ESD vertex position:\n");
272 0 : printf(" x = %f +- %f\n",fPosition[0], fCovXX>0 ? TMath::Sqrt(fCovXX) : 0.);
273 0 : printf(" y = %f +- %f\n",fPosition[1], fCovYY>0 ? TMath::Sqrt(fCovYY) : 0.);
274 0 : printf(" z = %f +- %f\n",fPosition[2], fCovZZ>0 ? TMath::Sqrt(fCovZZ) : 0.);
275 0 : printf(" Covariance matrix:\n");
276 0 : printf(" %12.10f %12.10f %12.10f\n %12.10f %12.10f %12.10f\n %12.10f %12.10f %12.10f\n",fCovXX,fCovXY,fCovXZ,fCovXY,fCovYY,fCovYZ,fCovXZ,fCovYZ,fCovZZ);
277 0 : printf(" S/N = (%f, %f, %f)\n",fSNR[0],fSNR[1],fSNR[2]);
278 0 : printf(" chi2 = %f\n",fChi2);
279 0 : printf(" # tracks (or tracklets) = %d BCID=%d\n",fNContributors,int(fBCID));
280 : //
281 0 : if (fCovXX<0 || fCovYY<0 || fCovZZ<0) {AliError("Attention: negative diagonal element");}
282 : //
283 0 : return;
284 : }
285 :
286 :
287 : //____________________________________________________________
288 : Double_t AliESDVertex::GetWDist(const AliESDVertex* v) const
289 : {
290 : // calculate sqrt of weighted distance to other vertex
291 10 : static TMatrixDSym vVb(3);
292 : double dist = -1;
293 2 : double dx = fPosition[0]-v->fPosition[0], dy = fPosition[1]-v->fPosition[1], dz = fPosition[2]-v->fPosition[2];
294 2 : vVb(0,0) = fCovXX + v->fCovXX;
295 2 : vVb(1,1) = fCovYY + v->fCovYY;
296 2 : vVb(2,2) = fCovZZ + v->fCovZZ;;
297 2 : vVb(1,0) = vVb(0,1) = fCovXY + v->fCovXY;
298 2 : vVb(0,2) = vVb(1,2) = vVb(2,0) = vVb(2,1) = 0.;
299 2 : vVb.InvertFast();
300 2 : if (!vVb.IsValid()) {AliError("Singular Matrix"); return dist;}
301 2 : dist = vVb(0,0)*dx*dx + vVb(1,1)*dy*dy + vVb(2,2)*dz*dz
302 2 : + 2*vVb(0,1)*dx*dy + 2*vVb(0,2)*dx*dz + 2*vVb(1,2)*dy*dz;
303 6 : return dist>0 ? TMath::Sqrt(dist) : -1;
304 2 : }
|