]> git.uio.no Git - u/mrichter/AliRoot.git/blob - STEER/AliESDVertex.cxx
patch for GCC < 4.3
[u/mrichter/AliRoot.git] / STEER / AliESDVertex.cxx
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 //---- AliRoot headers -----
30 #include "AliESDVertex.h"
31
32
33 ClassImp(AliESDVertex)
34
35 //--------------------------------------------------------------------------
36 AliESDVertex::AliESDVertex() :
37   AliVertex(),
38   fCovXX(0.005*0.005),
39   fCovXY(0),
40   fCovYY(0.005*0.005),
41   fCovXZ(0),
42   fCovYZ(0),
43   fCovZZ(5.3*5.3),
44   fChi2(0),
45   fID(-1)   // ID=-1 means the vertex with the biggest number of contributors 
46 {
47   //
48   // Default Constructor, set everything to 0
49   //
50   SetToZero();
51 }
52
53 //--------------------------------------------------------------------------
54 AliESDVertex::AliESDVertex(Double_t positionZ,Double_t sigmaZ,
55                            Int_t nContributors,const Char_t *vtxName) :
56   AliVertex(),
57   fCovXX(0.005*0.005),
58   fCovXY(0),
59   fCovYY(0.005*0.005),
60   fCovXZ(0),
61   fCovYZ(0),
62   fCovZZ(sigmaZ*sigmaZ),
63   fChi2(0),
64   fID(-1)   // ID=-1 means the vertex with the biggest number of contributors 
65 {
66   //
67   // Constructor for vertex Z from pixels
68   //
69
70   SetToZero();
71
72   fPosition[2]   = positionZ;
73   SetName(vtxName);
74   SetNContributors(nContributors);
75
76 }
77
78 //------------------------------------------------------------------------- 
79 AliESDVertex::AliESDVertex(Double_t position[3],Double_t covmatrix[6],
80                            Double_t chi2,Int_t nContributors,
81                            const Char_t *vtxName) :
82   AliVertex(position,0.,nContributors),
83   fCovXX(covmatrix[0]),
84   fCovXY(covmatrix[1]),
85   fCovYY(covmatrix[2]),
86   fCovXZ(covmatrix[3]),
87   fCovYZ(covmatrix[4]),
88   fCovZZ(covmatrix[5]),
89   fChi2(chi2),
90   fID(-1)   // ID=-1 means the vertex with the biggest number of contributors 
91 {
92   //
93   // Constructor for vertex in 3D from tracks
94   //
95
96   SetToZero();
97   SetName(vtxName);
98
99 }
100 //--------------------------------------------------------------------------
101 AliESDVertex::AliESDVertex(Double_t position[3],Double_t sigma[3],
102                            const Char_t *vtxName) :
103   AliVertex(position,0.,0),
104   fCovXX(sigma[0]*sigma[0]),
105   fCovXY(0),
106   fCovYY(sigma[1]*sigma[1]),
107   fCovXZ(0),
108   fCovYZ(0),
109   fCovZZ(sigma[2]*sigma[2]),
110   fChi2(0),
111   fID(-1)   // ID=-1 means the vertex with the biggest number of contributors 
112 {
113   //
114   // Constructor for smearing of true position
115   //
116
117   SetToZero();
118   SetName(vtxName);
119
120 }
121 //--------------------------------------------------------------------------
122 AliESDVertex::AliESDVertex(Double_t position[3],Double_t sigma[3],
123                            Double_t snr[3], const Char_t *vtxName) :
124   AliVertex(position,0.,0),
125   fCovXX(sigma[0]*sigma[0]),
126   fCovXY(0),
127   fCovYY(sigma[1]*sigma[1]),
128   fCovXZ(0),
129   fCovYZ(0),
130   fCovZZ(sigma[2]*sigma[2]),
131   fChi2(0),
132   fID(-1)   // ID=-1 means the vertex with the biggest number of contributors 
133 {
134   //
135   // Constructor for Pb-Pb
136   //
137
138   SetToZero();
139   SetName(vtxName);
140
141   fSNR[0]        = snr[0];
142   fSNR[1]        = snr[1];
143   fSNR[2]        = snr[2];
144
145 }
146 //--------------------------------------------------------------------------
147 AliESDVertex::AliESDVertex(const AliESDVertex &source):
148   AliVertex(source),
149   fCovXX(source.fCovXX),
150   fCovXY(source.fCovXY),
151   fCovYY(source.fCovYY),
152   fCovXZ(source.fCovXZ),
153   fCovYZ(source.fCovYZ),
154   fCovZZ(source.fCovZZ),
155   fChi2(source.fChi2),
156   fID(source.fID)
157 {
158   //
159   // Copy constructor
160   //
161   for(Int_t i=0;i<3;i++) {
162     fSNR[i] = source.fSNR[i];
163   }
164 }
165 //--------------------------------------------------------------------------
166 AliESDVertex &AliESDVertex::operator=(const AliESDVertex &source){
167   //
168   // assignment operator
169   //
170   if(&source != this){
171     AliVertex::operator=(source);
172     for(Int_t i=0;i<3;++i)fSNR[i] = source.fSNR[i];
173     fCovXX = source.fCovXX;
174     fCovXY = source.fCovXY;
175     fCovYY = source.fCovYY;
176     fCovXZ = source.fCovXZ;
177     fCovYZ = source.fCovYZ;
178     fCovZZ = source.fCovZZ;
179     fChi2 = source.fChi2;
180     fID = source.fID;
181   }
182   return *this;
183 }
184 //--------------------------------------------------------------------------
185 void AliESDVertex::Copy(TObject &obj) const {
186   
187   // this overwrites the virtual TOBject::Copy()
188   // to allow run time copying without casting
189   // in AliESDEvent
190
191   if(this==&obj)return;
192   AliESDVertex *robj = dynamic_cast<AliESDVertex*>(&obj);
193   if(!robj)return; // not an AliESDVertex
194   *robj = *this;
195
196 }
197 //--------------------------------------------------------------------------
198 void AliESDVertex::SetToZero() {
199   //
200   // Set the content of arrays to 0. Used by constructors
201   //
202   for(Int_t i=0; i<3; i++){
203     fSNR[i] = 0.;
204   }
205 }
206 //--------------------------------------------------------------------------
207 void AliESDVertex::GetSigmaXYZ(Double_t sigma[3]) const {
208   //
209   // Return errors on vertex position in thrust frame
210   //
211   sigma[0] = TMath::Sqrt(fCovXX);
212   sigma[1] = TMath::Sqrt(fCovYY);
213   sigma[2] = TMath::Sqrt(fCovZZ);
214
215   return;
216 }
217 //--------------------------------------------------------------------------
218 void AliESDVertex::GetCovMatrix(Double_t covmatrix[6]) const {
219   //
220   // Return covariance matrix of the vertex
221   //
222   covmatrix[0] = fCovXX;
223   covmatrix[1] = fCovXY;
224   covmatrix[2] = fCovYY;
225   covmatrix[3] = fCovXZ;
226   covmatrix[4] = fCovYZ;
227   covmatrix[5] = fCovZZ;
228
229   return;
230 }
231
232 //--------------------------------------------------------------------------
233 void AliESDVertex::GetSNR(Double_t snr[3]) const {
234   //
235   // Return S/N ratios
236   //
237   for(Int_t i=0;i<3;i++) snr[i] = fSNR[i];
238
239   return;
240 }
241 //--------------------------------------------------------------------------
242 void AliESDVertex::Print(Option_t* /*option*/) const {
243   //
244   // Print out information on all data members
245   //
246   printf("ESD vertex position:\n");
247   printf("   x = %f +- %f\n",fPosition[0],TMath::Sqrt(fCovXX));
248   printf("   y = %f +- %f\n",fPosition[1],TMath::Sqrt(fCovYY));
249   printf("   z = %f +- %f\n",fPosition[2],TMath::Sqrt(fCovZZ));
250   printf(" Covariance matrix:\n");
251   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);
252   printf(" S/N = (%f, %f, %f)\n",fSNR[0],fSNR[1],fSNR[2]);
253   printf(" chi2 = %f\n",fChi2);
254   printf(" # tracks (or tracklets) = %d\n",fNContributors);
255
256   return;
257 }
258
259
260
261