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 | |
27 | ClassImp(AliVertex) |
28 | |
29 | //-------------------------------------------------------------------------- |
fe12e09c |
30 | AliVertex::AliVertex() : |
31 | TNamed(), |
32 | fSigma(0), |
c1b20d31 |
33 | fNContributors(0), |
34 | fNIndices(0) |
fe12e09c |
35 | { |
8a553be2 |
36 | // |
37 | // Default Constructor, set everything to 0 |
38 | // |
39 | for(Int_t k=0;k<3;k++) fPosition[k] = 0; |
c1b20d31 |
40 | fIndices = 0; |
8a553be2 |
41 | } |
42 | |
43 | //-------------------------------------------------------------------------- |
44 | AliVertex::AliVertex(Double_t position[3],Double_t dispersion, |
fe12e09c |
45 | Int_t nContributors): |
46 | TNamed(), |
47 | fSigma(dispersion), |
c1b20d31 |
48 | fNContributors(nContributors), |
49 | fNIndices(0) |
fe12e09c |
50 | { |
8a553be2 |
51 | // |
52 | // Standard Constructor |
53 | // |
54 | |
55 | for(Int_t k=0;k<3;k++) fPosition[k] = position[k]; |
c1b20d31 |
56 | fIndices = 0; |
8a553be2 |
57 | SetName("BaseVertex"); |
58 | |
59 | } |
60 | |
2d57349e |
61 | //-------------------------------------------------------------------------- |
fe12e09c |
62 | AliVertex::AliVertex(const AliVertex &source): |
63 | TNamed(source), |
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 | //-------------------------------------------------------------------------- |
80 | AliVertex &AliVertex::operator=(const AliVertex &source){ |
81 | // |
82 | // assignment operator |
83 | // |
84 | if(&source == this) return *this; |
85 | this->SetName(source.GetName()); |
86 | this->SetTitle(source.GetTitle()); |
87 | for(Int_t i=0;i<3;i++)fPosition[i] = source.fPosition[i]; |
88 | fSigma = source.GetDispersion(); |
89 | fNContributors = source.GetNContributors(); |
c1b20d31 |
90 | fNIndices = source.GetNIndices(); |
101dc7be |
91 | fIndices = 0x0; |
c1b20d31 |
92 | if(source.fNIndices>0) { |
93 | fIndices = new UShort_t[fNIndices]; |
94 | memcpy(fIndices,source.fIndices,fNIndices*sizeof(UShort_t)); |
95 | } |
2d57349e |
96 | return *this; |
97 | } |
98 | |
8a553be2 |
99 | |
100 | //-------------------------------------------------------------------------- |
101 | AliVertex::~AliVertex() { |
102 | // |
103 | // Default Destructor |
104 | // |
c1b20d31 |
105 | delete [] fIndices; |
8a553be2 |
106 | } |
107 | //-------------------------------------------------------------------------- |
108 | void AliVertex::GetXYZ(Double_t position[3]) const { |
109 | // |
110 | // Return position of the vertex in global frame |
111 | // |
112 | position[0] = fPosition[0]; |
113 | position[1] = fPosition[1]; |
114 | position[2] = fPosition[2]; |
115 | |
116 | return; |
117 | } |
118 | //-------------------------------------------------------------------------- |
c1b20d31 |
119 | void AliVertex::SetIndices(Int_t nindices,UShort_t *indices) { |
120 | // |
121 | // Set indices of tracks used for vertex determination |
122 | // |
123 | if(fNContributors<1) { printf("fNContributors<1"); return; } |
124 | fNIndices = nindices; |
101dc7be |
125 | delete [] fIndices; |
c1b20d31 |
126 | fIndices = new UShort_t[fNIndices]; |
127 | for(Int_t i=0;i<fNIndices;i++) fIndices[i] = indices[i]; |
128 | return; |
129 | } |
130 | //-------------------------------------------------------------------------- |
131 | Bool_t AliVertex::UsesTrack(Int_t index) const { |
132 | // |
133 | // checks if a track is used for the vertex |
134 | // |
135 | if(fNIndices<1) { printf("fNIndices<1"); return kFALSE; } |
136 | for(Int_t i=0;i<fNIndices;i++) { |
137 | if((Int_t)fIndices[i]==index) return kTRUE; |
138 | } |
139 | return kFALSE; |
140 | } |
141 | //-------------------------------------------------------------------------- |
8a553be2 |
142 | void AliVertex::Print(Option_t* /*option*/) const { |
143 | // |
144 | // Print out information on all data members |
145 | // |
146 | printf("Vertex position:\n"); |
147 | printf(" x = %f\n",fPosition[0]); |
148 | printf(" y = %f\n",fPosition[1]); |
149 | printf(" z = %f\n",fPosition[2]); |
150 | printf(" Dispersion = %f\n",fSigma); |
151 | printf(" # tracks = %d\n",fNContributors); |
152 | |
153 | return; |
154 | } |
155 | |
156 | |
157 | |
158 | |