- Three classes by MinJung Kweon AliHFEpriVtx, AliHFEsecVtx and AliHFEmcQA for primar...
[u/mrichter/AliRoot.git] / STEER / AliVertex.cxx
CommitLineData
8a553be2 1/**************************************************************************
2 * Copyright(c) 2006-2008, 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 base Vertex class
18// This class contains the Secondary Vertex
19// of a set of tracks
20// And it is the base class for primary vertices
21// Origin: F.Prino, Torino, prino@to.infn.it
22//-----------------------------------------------------------------
23
24#include "AliVertex.h"
25
26
27ClassImp(AliVertex)
28
29//--------------------------------------------------------------------------
fe12e09c 30AliVertex::AliVertex() :
bdd011d6 31 AliVVertex(),
fe12e09c 32 fSigma(0),
c1b20d31 33 fNContributors(0),
0cd61c1d 34 fNIndices(0),
35 fIndices(0)
fe12e09c 36{
8a553be2 37//
38// Default Constructor, set everything to 0
39//
40 for(Int_t k=0;k<3;k++) fPosition[k] = 0;
8a553be2 41}
42
43//--------------------------------------------------------------------------
44AliVertex::AliVertex(Double_t position[3],Double_t dispersion,
fe12e09c 45 Int_t nContributors):
bdd011d6 46 AliVVertex(),
fe12e09c 47 fSigma(dispersion),
c1b20d31 48 fNContributors(nContributors),
0cd61c1d 49 fNIndices(0),
50 fIndices(0)
fe12e09c 51{
8a553be2 52 //
53 // Standard Constructor
54 //
55
56 for(Int_t k=0;k<3;k++) fPosition[k] = position[k];
8a553be2 57 SetName("BaseVertex");
58
59}
60
2d57349e 61//--------------------------------------------------------------------------
fe12e09c 62AliVertex::AliVertex(const AliVertex &source):
bdd011d6 63 AliVVertex(source),
fe12e09c 64 fSigma(source.GetDispersion()),
c1b20d31 65 fNContributors(source.GetNContributors()),
101dc7be 66 fNIndices(source.GetNIndices()),
67 fIndices(0x0)
fe12e09c 68{
2d57349e 69 //
70 // Copy constructor
71 //
72 for(Int_t i=0;i<3;i++)fPosition[i] = source.fPosition[i];
c1b20d31 73 if(source.fNIndices>0) {
74 fIndices = new UShort_t[fNIndices];
75 memcpy(fIndices,source.fIndices,fNIndices*sizeof(UShort_t));
76 }
2d57349e 77}
78
79//--------------------------------------------------------------------------
80AliVertex &AliVertex::operator=(const AliVertex &source){
81 //
82 // assignment operator
83 //
316c6cd9 84 if(&source != this){
bdd011d6 85 AliVVertex::operator=(source);
316c6cd9 86 for(Int_t i=0;i<3;i++)fPosition[i] = source.fPosition[i];
87 fSigma = source.GetDispersion();
88 fNContributors = source.GetNContributors();
89 fNIndices = source.GetNIndices();
90 if(fIndices)delete [] fIndices;
91 fIndices = 0;
92 if(fNIndices>0) {
93 fIndices = new UShort_t[fNIndices];
94 memcpy(fIndices,source.fIndices,fNIndices*sizeof(UShort_t));
95 }
c1b20d31 96 }
2d57349e 97 return *this;
98}
99
8a553be2 100
101//--------------------------------------------------------------------------
102AliVertex::~AliVertex() {
103//
104// Default Destructor
105//
c1b20d31 106 delete [] fIndices;
316c6cd9 107 fIndices = 0;
8a553be2 108}
74c2962e 109
110void AliVertex::Clear(Option_t* option)
111{
112 // Delete allocated memory
113 delete [] fIndices;
114 fIndices = 0;
bdd011d6 115 AliVVertex::Clear(option);
74c2962e 116}
117
8a553be2 118//--------------------------------------------------------------------------
119void AliVertex::GetXYZ(Double_t position[3]) const {
120//
121// Return position of the vertex in global frame
122//
123 position[0] = fPosition[0];
124 position[1] = fPosition[1];
125 position[2] = fPosition[2];
126
127 return;
128}
129//--------------------------------------------------------------------------
bdd011d6 130void AliVertex::GetCovarianceMatrix(Double_t covmatrix[6]) const {
131//
132// Fake method (is implmented in AliESDVertex)
133//
134 for(Int_t i=0;i<6;i++) covmatrix[i] = -999.;
135
136 return;
137}
138//--------------------------------------------------------------------------
c1b20d31 139void AliVertex::SetIndices(Int_t nindices,UShort_t *indices) {
140//
141// Set indices of tracks used for vertex determination
142//
143 if(fNContributors<1) { printf("fNContributors<1"); return; }
144 fNIndices = nindices;
101dc7be 145 delete [] fIndices;
c1b20d31 146 fIndices = new UShort_t[fNIndices];
147 for(Int_t i=0;i<fNIndices;i++) fIndices[i] = indices[i];
148 return;
149}
150//--------------------------------------------------------------------------
151Bool_t AliVertex::UsesTrack(Int_t index) const {
152//
153// checks if a track is used for the vertex
154//
958fd90b 155 if(fNIndices<1) {/* printf("fNIndices<1"); */return kFALSE; }
c1b20d31 156 for(Int_t i=0;i<fNIndices;i++) {
157 if((Int_t)fIndices[i]==index) return kTRUE;
158 }
159 return kFALSE;
160}
161//--------------------------------------------------------------------------
8a553be2 162void AliVertex::Print(Option_t* /*option*/) const {
163//
164// Print out information on all data members
165//
166 printf("Vertex position:\n");
167 printf(" x = %f\n",fPosition[0]);
168 printf(" y = %f\n",fPosition[1]);
169 printf(" z = %f\n",fPosition[2]);
170 printf(" Dispersion = %f\n",fSigma);
171 printf(" # tracks = %d\n",fNContributors);
172
173 return;
174}
175
176
177
178