]>
Commit | Line | Data |
---|---|---|
4c039060 | 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 | $Log$ | |
959fbac5 | 18 | Revision 1.3 1999/09/29 09:24:28 fca |
19 | Introduction of the Copyright and cvs Log | |
20 | ||
4c039060 | 21 | */ |
22 | ||
959fbac5 | 23 | /////////////////////////////////////////////////////////////////////////// |
24 | // Class AliVertex | |
25 | // Creation and investigation of an AliVertex. | |
26 | // An AliVertex can be constructed by adding AliTracks and/or AliJets. | |
27 | // | |
28 | // Note : Also (secondary) vertices can be added to a vertex. | |
29 | // | |
30 | // Coding example to make 3 vertices v1, v2 and v3. | |
31 | // ------------------------------------------------ | |
32 | // v1 contains the tracks 1,2,3 and 4 | |
33 | // v2 contains the tracks 5,6 and 7 | |
34 | // v3 contains the jets 1 and 2 | |
35 | // | |
36 | // AliTrack t1,t2,t3,t4,t5,t6,t7; | |
37 | // ... | |
38 | // ... // code to fill the track data | |
39 | // ... | |
40 | // | |
41 | // AliJet j1,j2; | |
42 | // ... | |
43 | // ... // code to fill the jet data | |
44 | // ... | |
45 | // | |
46 | // AliVertex v1(5); | |
47 | // | |
48 | // v1.Add(t1); | |
49 | // v1.Add(t2); | |
50 | // v1.Add(t3); | |
51 | // v1.Add(t4); | |
52 | // | |
53 | // Float_t r1[3]={2.4,0.1,-8.5}; | |
54 | // v1.SetPosition(r1,"car"); | |
55 | // | |
56 | // AliVertex v2(2); | |
57 | // v2.Add(t5); | |
58 | // v2.Add(t6); | |
59 | // v2.Add(t7); | |
60 | // | |
61 | // Float_t r2[3]={1.6,-3.2,5.7}; | |
62 | // v2.SetPosition(r2,"car"); | |
63 | // | |
64 | // AliVertex v3; | |
65 | // | |
66 | // v3.Add(j1); | |
67 | // v3.Add(j2); | |
68 | // | |
69 | // Float_t r3[3]={6.2,4.8,1.3}; | |
70 | // v3.SetPosition(r3,"car"); | |
71 | // | |
72 | // v1.Info("sph"); | |
73 | // v2.ListAll(); | |
74 | // v3.List("cyl"); | |
75 | // | |
76 | // Float_t e1=v1.GetEnergy(); | |
77 | // Ali3Vector p1=v1.Get3Momentum(); | |
78 | // Float_t loc[3]; | |
79 | // v1.GetPosition(loc,"sph"); | |
80 | // AliPosition r=v2.GetPosition(); | |
81 | // r.Info(); | |
82 | // Int_t nt=v2.GetNtracks(); | |
83 | // AliTrack* tv=v2.GetTrack(1); // Access track number 1 of Vertex v2 | |
84 | // | |
85 | // Specify the vertices v2 and v3 as secondary vertices of v1 | |
86 | // | |
87 | // v1.Add(v2); | |
88 | // v1.Add(v3); | |
89 | // | |
90 | // v1.List(); | |
91 | // | |
92 | // Int_t nv=v1.GetNvtx(); | |
93 | // AliVertex* vx=v1.GetVertex(1); // Access 1st secondary vertex of v1 | |
94 | // Float_t e=vx->GetEnergy(); | |
95 | // | |
96 | // Float_t M=v1.GetInvmass(); | |
97 | // | |
98 | // Reconstruct Vertex v1 from scratch | |
99 | // | |
100 | // v1.Reset(); | |
101 | // v1.SetNvmax(25); // Increase initial no. of sec. vertices | |
102 | // v1.Add(t3); | |
103 | // v1.Add(t7); | |
104 | // v1.Add(j2); | |
105 | // Float_t pos[3]={7,9,4}; | |
106 | // v1.SetPosition(pos,"car"); | |
107 | // | |
108 | // Note : All quantities are in GeV, GeV/c or GeV/c**2 | |
109 | // | |
110 | //--- Author: Nick van Eijndhoven 04-apr-1998 UU-SAP Utrecht | |
111 | //- Modified: NvE 08-apr-1999 UU-SAP Utrecht to inherit from AliJet | |
112 | /////////////////////////////////////////////////////////////////////////// | |
113 | ||
d88f97cc | 114 | #include "AliVertex.h" |
115 | ||
116 | ClassImp(AliVertex) // Class implementation to enable ROOT I/O | |
117 | ||
118 | AliVertex::AliVertex() | |
119 | { | |
959fbac5 | 120 | // Default constructor. |
121 | // All variables initialised to 0. | |
122 | // Initial maximum number of tracks is set to the default value. | |
123 | // Initial maximum number of sec. vertices is set to the default value. | |
d88f97cc | 124 | fNvmax=0; |
125 | fVertices=0; | |
126 | Reset(); | |
127 | SetNtinit(); | |
128 | SetNvmax(); | |
129 | } | |
130 | /////////////////////////////////////////////////////////////////////////// | |
131 | AliVertex::AliVertex(Int_t n) | |
132 | { | |
133 | // Create a vertex to hold initially a maximum of n tracks | |
134 | // All variables initialised to 0 | |
135 | fNvmax=0; | |
136 | fVertices=0; | |
137 | Reset(); | |
138 | if (n > 0) | |
139 | { | |
140 | SetNtinit(n); | |
141 | } | |
142 | else | |
143 | { | |
144 | cout << endl; | |
145 | cout << " *AliVertex* Initial max. number of tracks entered : " << n << endl; | |
146 | cout << " This is invalid. Default initial maximum will be used." << endl; | |
147 | cout << endl; | |
148 | SetNtinit(); | |
149 | } | |
150 | SetNvmax(); | |
151 | } | |
152 | /////////////////////////////////////////////////////////////////////////// | |
153 | AliVertex::~AliVertex() | |
154 | { | |
155 | // Default destructor | |
156 | if (fVertices) delete fVertices; | |
157 | fVertices=0; | |
158 | } | |
159 | /////////////////////////////////////////////////////////////////////////// | |
160 | void AliVertex::SetNvmax(Int_t n) | |
161 | { | |
162 | // Set the initial maximum number of (secondary) vertices | |
163 | if (n > 0) | |
164 | { | |
165 | fNvmax=n; | |
166 | } | |
167 | else | |
168 | { | |
169 | fNvmax=1; | |
170 | } | |
171 | if (fVertices) delete fVertices; | |
172 | fVertices=new TObjArray(fNvmax); | |
173 | } | |
174 | /////////////////////////////////////////////////////////////////////////// | |
175 | void AliVertex::Reset() | |
176 | { | |
177 | // Reset all variables to 0 | |
178 | // The max. number of tracks is set to the initial value again | |
179 | // The max. number of vertices is set to the default value again | |
180 | ||
181 | AliJet::Reset(); | |
182 | ||
183 | fNvtx=0; | |
184 | if (fNvmax>0) SetNvmax(fNvmax); | |
185 | } | |
186 | /////////////////////////////////////////////////////////////////////////// | |
187 | void AliVertex::Add(AliJet& j) | |
188 | { | |
189 | // Add the tracks of a jet to the vertex | |
190 | AliTrack* tj; | |
191 | for (Int_t i=1; i<=j.GetNtracks(); i++) | |
192 | { | |
193 | tj=j.GetTrack(i); | |
194 | AliJet::Add(tj); | |
195 | } | |
196 | } | |
197 | /////////////////////////////////////////////////////////////////////////// | |
198 | void AliVertex::Add(AliVertex& v) | |
199 | { | |
200 | // Add a (secondary) vertex to the current vertex. | |
201 | // In case the maximum number of (secondary) vertices has been reached, | |
202 | // the array space will be extended automatically | |
203 | // | |
204 | // Note : The 4-momentum of the current (primary) vertex | |
205 | // is updated automatically, but the track connecting | |
206 | // both vertices has to be entered separately by the user. | |
207 | // | |
208 | if (fNvtx == fNvmax) // Check if maximum vertex number is reached | |
209 | { | |
210 | fNvmax++; | |
211 | fVertices->Expand(fNvmax); | |
212 | } | |
213 | ||
214 | // Update 4-momentum for current vertex | |
215 | fNvtx++; | |
216 | fVertices->Add(&v); | |
959fbac5 | 217 | (Ali4Vector)(*this)+=v; |
d88f97cc | 218 | } |
219 | /////////////////////////////////////////////////////////////////////////// | |
220 | void AliVertex::Info(TString f) | |
221 | { | |
222 | // Provide vertex information within the coordinate frame f | |
223 | cout << " *AliVertex::Info* Invmass : " << GetInvmass() | |
224 | << " Charge : " << GetCharge() << " Momentum : " << GetMomentum() | |
225 | << " Ntracks : " << GetNtracks() << " Nvertices : " << fNvtx << endl; | |
226 | cout << " "; | |
227 | Ali4Vector::Info(f); | |
228 | cout << " Position"; | |
229 | AliPosition::Info(f); | |
230 | } | |
231 | /////////////////////////////////////////////////////////////////////////// | |
232 | void AliVertex::List(TString f) | |
233 | { | |
234 | // Provide primary track and sec. vertex information within the coordinate frame f | |
235 | ||
236 | Info(f); // Information of the current vertex | |
237 | ||
238 | // The tracks of this vertex | |
239 | AliTrack* t; | |
240 | for (Int_t it=1; it<=GetNtracks(); it++) | |
241 | { | |
242 | t=GetTrack(it); | |
243 | if (t) | |
244 | { | |
245 | cout << " ---Track no. " << it << endl; | |
246 | cout << " "; | |
247 | t->Info(f); | |
248 | } | |
249 | else | |
250 | { | |
251 | cout << " *AliVertex::List* Error : No track present." << endl; | |
252 | } | |
253 | } | |
254 | ||
255 | // The secondary vertices of this vertex | |
256 | AliVertex* v; | |
257 | for (Int_t iv=1; iv<=GetNvertices(); iv++) | |
258 | { | |
259 | v=GetVertex(iv); | |
260 | if (v) | |
261 | { | |
262 | cout << " ---Level 1 sec. vertex no. " << iv << endl; | |
263 | cout << " "; | |
264 | v->Info(f); | |
265 | } | |
266 | else | |
267 | { | |
268 | cout << " *AliVertex::List* Error : No sec. vertex present." << endl; | |
269 | } | |
270 | } | |
271 | } | |
272 | /////////////////////////////////////////////////////////////////////////// | |
273 | void AliVertex::ListAll(TString f) | |
274 | { | |
275 | // Provide complete (sec) vertex and (decay) track info within the coordinate frame f | |
276 | ||
277 | Info(f); // Information of the current vertex | |
278 | ||
279 | // The tracks of this vertex | |
280 | AliTrack* t; | |
281 | for (Int_t it=1; it<=GetNtracks(); it++) | |
282 | { | |
283 | t=GetTrack(it); | |
284 | if (t) | |
285 | { | |
286 | cout << " ---Track no. " << it << endl; | |
287 | cout << " "; | |
288 | t->ListAll(f); | |
289 | } | |
290 | else | |
291 | { | |
292 | cout << " *AliVertex::ListAll* Error : No track present." << endl; | |
293 | } | |
294 | } | |
295 | ||
296 | AliVertex* v=this; | |
297 | Dump(v,1,f); // Information of all sec. vertices | |
298 | } | |
299 | ////////////////////////////////////////////////////////////////////////// | |
300 | void AliVertex::Dump(AliVertex* v,Int_t n,TString f) | |
301 | { | |
302 | // Recursively provide the info of all secondary vertices of this vertex | |
303 | AliVertex* vs; | |
304 | for (Int_t iv=1; iv<=v->GetNvertices(); iv++) | |
305 | { | |
306 | vs=v->GetVertex(iv); | |
307 | if (vs) | |
308 | { | |
309 | cout << " ---Level " << n << " sec. vertex no. " << iv << endl; | |
310 | cout << " "; | |
311 | vs->Info(f); | |
312 | ||
313 | // The tracks of this vertex | |
314 | AliTrack* t; | |
315 | for (Int_t it=1; it<=vs->GetNtracks(); it++) | |
316 | { | |
317 | t=vs->GetTrack(it); | |
318 | if (t) | |
319 | { | |
320 | cout << " ---Track no. " << it << endl; | |
321 | cout << " "; | |
322 | t->ListAll(f); | |
323 | } | |
324 | else | |
325 | { | |
326 | cout << " *AliVertex::Dump* Error : No track present." << endl; | |
327 | } | |
328 | } | |
329 | ||
330 | // Go for next sec. vertex level of this sec. vertex recursively | |
331 | Dump(vs,n+1,f); | |
332 | } | |
333 | else | |
334 | { | |
335 | cout << " *AliVertex::Dump* Error : No sec. vertex present." << endl; | |
336 | } | |
337 | } | |
338 | } | |
339 | ////////////////////////////////////////////////////////////////////////// | |
340 | Int_t AliVertex::GetNvertices() | |
341 | { | |
342 | // Return the current number of (secondary) vertices | |
343 | return fNvtx; | |
344 | } | |
345 | /////////////////////////////////////////////////////////////////////////// | |
346 | AliVertex* AliVertex::GetVertex(Int_t i) | |
347 | { | |
348 | // Return the i-th (secondary) vertex of the current vertex | |
349 | return (AliVertex*)fVertices->At(i-1); | |
350 | } | |
351 | /////////////////////////////////////////////////////////////////////////// |